]> git.mxchange.org Git - mailer.git/blobdiff - inc/libs/theme_functions.php
Fixed for loading themes, no longer needed parameters removed
[mailer.git] / inc / libs / theme_functions.php
index 44363a8c7cc42d1f8ebb72afc8e975ae7d4d5f09..eb85579a286784abf03ecd8802fac91a85a2cb96 100644 (file)
@@ -42,12 +42,18 @@ if (!defined('__SECURITY')) {
        require($INC);
 }
 
-// Create a selection box with installed and activated themes
-function generateThemeSelectionBox ($mod, $act, $wht, $result) {
+// Create a selection box with installed and activated themes or all if admin
+function generateThemeSelectionBox () {
+       // Init variables and fill them if set
+       $what = '';
+       $mod = getModule();
+       if (isWhatSet()) {
+               $what = getWhat();
+       } // END - if
+
        // Construction URL
-       $formAction = "{!URL!}/modules.php?module=".$mod;
-       if (!empty($act)) $formAction .= "&action=".$act;
-       if (!empty($wht)) $formAction .= "&what=".$wht;
+       $formAction = "{!URL!}/modules.php?module=" . $mod;
+       if (!empty($what)) $formAction .= "&what=" . $what;
 
        // Initialize array
        $themesArray = array(
@@ -55,10 +61,21 @@ function generateThemeSelectionBox ($mod, $act, $wht, $result) {
                'theme_name'   => array()  // Title
        );
 
+       // Only activated themes for the user
+       $add = " WHERE `theme_active`='Y'";
+
+       // Do we have admin?
+       if (IS_ADMIN()) $add = '';
+
+       // Select all themes we want
+       $result = SQL_QUERY("SELECT `theme_path`, `theme_name` FROM `{!_MYSQL_PREFIX!}_themes`".$add." ORDER BY `theme_name` ASC", __FILE__, __LINE__);
+
        // Load all themes
        while ($content = SQL_FETCHARRAY($result)) {
-               // Load it's theme.php file
+               // Construct relative include file name
                $INC = sprintf("theme/%s/theme.php", SQL_ESCAPE($content['theme_path']));
+
+               // Load it's theme.php file if found
                if (isIncludeReadable($INC)) {
                        // And save all data in array
                        loadInclude($INC);
@@ -67,8 +84,8 @@ function generateThemeSelectionBox ($mod, $act, $wht, $result) {
                } // END - if
        } // END - while
 
-       // Sort whole array by title
-       array_pk_sort($themesArray, array('theme_name'));
+       // Free the result
+       SQL_FREERESULT($result);
 
        // Construct selection form for the box template
        $OUT = '';