Fixed issues with themes
[mailer.git] / inc / modules / guest / action-themes.php
index 6b3118598508712cdb521df6d5c0ee6fe75069dd..28c50740610b686d6fcb250e4c547149ec44b1c1 100644 (file)
@@ -17,7 +17,7 @@
  * Needs to be in all Files and every File needs "svn propset           *
  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
- * Copyright (c) 2003 - 2008 by Roland Haeder                           *
+ * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
 
 // Some security stuff...
 if (!defined('__SECURITY')) {
-       $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php';
-       require($INC);
-} elseif ((!EXT_IS_ACTIVE('theme')) && (!IS_ADMIN())) {
-       addFatalMessage(__FILE__, __LINE__, generateExtensionInactiveMessage('theme'));
+       die();
+} elseif (!isBlockModeEnabled()) {
+       // Non-block mode detected
        return;
 }
 
-// Load all active designs (or all if admin)
-$whereStatement = ''; $OUT = '';
-if (!IS_ADMIN()) $whereStatement = " WHERE theme_active='Y'";
-$result_themes = SQL_QUERY("SELECT theme_path FROM `{!_MYSQL_PREFIX!}_themes`".$whereStatement, __FILE__, __LINE__);
-$num_themes = SQL_NUMROWS($result_themes);
+if ((!isExtensionActive('theme')) && (!isAdmin())) {
+       loadTemplate('admin_settings_saved', false, generateExtensionInactiveNotInstalledMessage('theme'));
+       return;
+} // END - if
+
+// Get total num
+if (isAdmin()) {
+       // Load all themes for admin
+       $num_themes = countSumTotalData('', 'themes', 'id', '', true);
+} else {
+       // Load only active designs for user
+       $num_themes = countSumTotalData('Y', 'themes', 'id', 'theme_active', true);
+}
 
+$OUT = '';
 if ($num_themes > 1) {
        // If more than 1 is installed output selection box
-       $act = '';
-       if (!empty($GLOBALS['action'])) $act = SQL_ESCAPE($GLOBALS['action']);
-       $OUT = generateThemeSelectionBox('index', $act, $GLOBALS['what'], $result_themes);
-} elseif (($num_themes == 1) || ((!IS_ADMIN()) && ($num_themes == 0))) {
-       // If there's only one just print it's name
-       define('__THEME_NAME', getCurrentThemeName());
-       $OUT = LOAD_TEMPLATE("theme_one", true);
-} elseif (IS_ADMIN()) {
+       $OUT = generateThemeSelectionBox();
+} elseif (($num_themes == 1) || ((!isAdmin()) && ($num_themes == 0))) {
+       // If there's only one just output it's name
+       $OUT = loadTemplate('theme_one', true, getCurrentThemeName());
+} elseif (isAdmin()) {
        // If there is no theme installed and there's an admin notify him!
-       $OUT = LOAD_TEMPLATE('admin_settings_saved', true, "<div class=\"admin_note\">{--ADMIN_NO_THEME_INSTALLED_WARNING--}</div>");
+       $OUT = '{--ADMIN_NO_THEME_INSTALLED_WARNING--}';
 }
 
-// Free memory
-SQL_FREERESULT($result_themes);
-
 // Load final box template
-LOAD_TEMPLATE("theme_select_box", false, $OUT);
+$GLOBALS['rows'] .= loadTemplate('theme_select_box', true, $OUT);
 
-//
+// [EOF]
 ?>