X-Git-Url: https://git.mxchange.org/?p=mailer.git;a=blobdiff_plain;f=inc%2Flibs%2Ftheme_functions.php;h=eb85579a286784abf03ecd8802fac91a85a2cb96;hp=3a7c791673e67d66ba9a50b5ff863991ad2c29f5;hb=af71686cb6c6e59eee9c206b36342f7dd7164c1f;hpb=a090e351c49fe021fb3064325694da03402332e0 diff --git a/inc/libs/theme_functions.php b/inc/libs/theme_functions.php index 3a7c791673..eb85579a28 100644 --- a/inc/libs/theme_functions.php +++ b/inc/libs/theme_functions.php @@ -38,16 +38,22 @@ // Some security stuff... if (!defined('__SECURITY')) { - $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), "/inc") + 4) . "/security.php"; + $INC = substr(dirname(__FILE__), 0, strpos(dirname(__FILE__), '/inc') + 4) . '/security.php'; require($INC); } -// Create a selection box with installed and activated themes -function THEME_SELECTION_BOX ($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,26 +61,37 @@ function THEME_SELECTION_BOX ($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'])); - if (INCLUDE_READABLE($INC)) { + + // Load it's theme.php file if found + if (isIncludeReadable($INC)) { // And save all data in array - LOAD_INC($INC); + loadInclude($INC); $themesArray['theme_unix'][] = $content['theme_path']; $themesArray['theme_name'][] = $GLOBALS['theme_data']['name']; } // 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 = ''; foreach ($themesArray['theme_unix'] as $key => $theme) { $OUT .= "