$theme[0]['PATH'] = SM_PATH . 'themes/default_theme.php';
$theme[0]['NAME'] = 'Default';
$aTemplateSet = array();
-$aTemplateSet[0]['PATH'] = SM_PATH . 'templates/default/';
-$aTemplateSet[0]['NAME'] = 'Default template';
+$aTemplateSet[0]['ID'] = 'default';
+$aTemplateSet[0]['NAME'] = 'Default';
/* load site configuration */
require(SM_PATH . 'config/config.php');
/* load local configuration overrides */
session_set_cookie_params (0, $base_uri);
sqsession_is_active();
+include_once(SM_PATH . 'plugins/multilogin/functions.php');
+multilogin_sqoverride_config_do();
+
/**
* DISABLED.
* Remove globalized session data in rg=on setups
case 'style':
// need to get the right template set up
- sqGetGlobalVar('templatedir', $templatedir, SQ_GET);
+ //
+ sqGetGlobalVar('templateid', $templateid, SQ_GET);
// sanitize just in case...
- $templatedir = preg_replace('/(\.\.\/){1,}/', '', $templatedir);
-
- // could also conceivably make sure given templatedir is in $aTemplateSet
+ //
+ $templateid = preg_replace('/(\.\.\/){1,}/', '', $templateid);
+
+ // make sure given template actually is available
+ //
+ $aTemplateSet = (!isset($aTemplateSet) || !is_array($aTemplateSet)
+ ? array() : $aTemplateSet);
+ $templateset_default = (!isset($templateset_default) ? 0 : $templateset_default);
+ $found_templateset = false;
+ for ($i = 0; $i < count($aTemplateSet); ++$i) {
+ if ($aTemplateSet[$i]['ID'] == $templateid) {
+ $found_templateset = true;
+ break;
+ }
+ }
- // set template directory only if what was given is valid
- if (is_dir(SM_PATH . 'templates/' . $templatedir . '/')) {
- $sTplDir = SM_PATH . 'templates/' . $templatedir . '/';
+// FIXME: do we need/want to check here for actual presence of template sets?
+ // selected template not available, fall back to default template
+ //
+ if (!$found_templateset) {
+ $sTemplateID = (!isset($aTemplateSet[$templateset_default]['ID'])
+ ? 'default' : $aTemplateSet[$templateset_default]['ID']);
+ } else {
+ $sTemplateID = $templateid;
}
session_write_close();
/**
* Initialize the template object (logout_error uses it)
*/
- require(SM_PATH . 'class/template/template.class.php');
+ require(SM_PATH . 'class/template/Template.class.php');
/*
- * $sTplDir is not initialized when a user is not logged in, so we will use
- * the config file defaults here. If the neccesary variables are net set,
- * force a default value.
+ * $sTemplateID is not initialized when a user is not logged in, so we
+ * will use the config file defaults here. If the neccesary variables
+ * are net set, force a default value.
*/
- $aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet );
+ $aTemplateSet = (!isset($aTemplateSet) || !is_array($aTemplateSet)
+ ? array() : $aTemplateSet);
$templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default );
- $sTplDir = ( !isset($aTemplateSet[$templateset_default]['PATH']) ?
- SM_PATH . 'templates/default/' :
- $aTemplateSet[$templateset_default]['PATH'] );
- $oTemplate = new Template($sTplDir);
+ $sTemplateID = ( !isset($aTemplateSet[$templateset_default]['ID']) ?
+ 'default' : $aTemplateSet[$templateset_default]['ID'] );
+ $oTemplate = Template::construct_template($sTemplateID);
set_up_language($squirrelmail_language, true);
logout_error( _("You must be logged in to access this page.") );
/**
* Initialize the template object
*/
-require(SM_PATH . 'class/template/template.class.php');
+require(SM_PATH . 'class/template/Template.class.php');
/*
- * $sTplDir is not initialized when a user is not logged in, so we will use
- * the config file defaults here. If the neccesary variables are not set,
- * force a default value.
+ * $sTemplateID is not initialized when a user is not logged in, so we
+ * will use the config file defaults here. If the neccesary variables
+ * are not set, force a default value.
*
- * If the user is logged in, $sTplDir will be set in load_prefs.php, so we
- * shouldn't change it here.
+ * If the user is logged in, $sTemplateID will be set in load_prefs.php,
+ * so we shouldn't change it here.
*/
-if (!isset($sTplDir)) {
- $aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet );
+if (!isset($sTemplateID)) {
+ $aTemplateSet = (!isset($aTemplateSet) || !is_array($aTemplateSet)
+ ? array() : $aTemplateSet);
$templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default );
- $sTplDir = !isset($aTemplateSet[$templateset_default]['PATH']) ? SM_PATH . 'templates/default/' : $aTemplateSet[$templateset_default]['PATH'];
- $icon_theme_path = !$use_icons ? NULL : $sTplDir . 'images/';
+ $sTemplateID = !isset($aTemplateSet[$templateset_default]['ID']) ? 'default' : $aTemplateSet[$templateset_default]['ID'];
+ $icon_theme_path = !$use_icons ? NULL : Template::calculate_template_images_directory($sTemplateID);
}
-$oTemplate = new Template($sTplDir);
+$oTemplate = Template::construct_template($sTemplateID);
// We want some variables to always be available to the template
-$always_include = array('sTplDir', 'icon_theme_path');
+$always_include = array('sTemplateID', 'icon_theme_path');
foreach ($always_include as $var) {
$oTemplate->assign($var, (isset($$var) ? $$var : NULL));
}
// TODO Get rid of "none" strings when NULL or false should be used, i hate them i hate them i hate them!!!.
$custom_css = getPref($data_dir, $username, 'custom_css', 'none' );
-$theme = ( !isset($theme) ? array() : $theme );
-$color = ( !isset($color) ? array() : $color );
-$aTemplateSet = ( !isset($aTemplateSet) ? array() : $aTemplateSet );
+$aTemplateSet = (!isset($aTemplateSet) || !is_array($aTemplateSet)
+ ? array() : $aTemplateSet);
$templateset_default = ( !isset($templateset_default) ? 0 : $templateset_default );
-$chosen_theme = getPref($data_dir, $username, 'chosen_theme');
-$sTplDir = getPref($data_dir, $username, 'sTplDir', SM_PATH . 'templates/default/');
-$found_templateset = false;
-
-/* need to adjust $chosen_template path with SM_PATH */
-$sTplDir = preg_replace("/(\.\.\/){1,}/", SM_PATH, $sTplDir);
+$sTemplateID = getPref($data_dir, $username, 'sTemplateID', 'default');
+// check user prefs template selection against templates actually available
+//
+$found_templateset = false;
for ($i = 0; $i < count($aTemplateSet); ++$i){
- if ($aTemplateSet[$i]['PATH'] == $sTplDir) {
+ if ($aTemplateSet[$i]['ID'] == $sTemplateID) {
$found_templateset = true;
break;
}
}
-$sTplDir = ($found_templateset ? $sTplDir : '');
+
+// FIXME: do we need/want to check here for actual presence of template sets?
+// selected template not available, fall back to default template
+//
if (!$found_templateset) {
- if (isset($aTemplateSet) && isset($aTemplateSet[$templateset_default]) && file_exists($aTemplateSet[$templateset_default]['PATH'])) {
- $sTplDir = $aTemplateSet[$templateset_default]['PATH'];
- } else {
- $sTplDir = SM_PATH.'templates/default/';
- }
-} else if (!file_exists($sTplDir)) {
- $sTplDir = SM_PATH.'templates/default/';
+ $sTemplateID = ( !isset($aTemplateSet[$templateset_default]['ID']) ?
+ 'default' : $aTemplateSet[$templateset_default]['ID'] );
}
+$theme = ( !isset($theme) ? array() : $theme );
+$color = ( !isset($color) ? array() : $color );
+
+$chosen_theme = getPref($data_dir, $username, 'chosen_theme');
$found_theme = false;
/* need to adjust $chosen_theme path with SM_PATH */
* theme to use. If the admin has disabled icons, or the user has
* set the icon theme to "None," no icons will be used.
*/
-$icon_theme_path = (!$use_icons || $icon_theme=='none') ? NULL : ($icon_theme == 'template' ? $sTplDir . 'images/' : $icon_theme);
+$icon_theme_path = (!$use_icons || $icon_theme=='none') ? NULL : ($icon_theme == 'template' ? Template::calculate_template_images_directory($sTemplateID) : $icon_theme);
// show (or not) flag and unflag buttons on mailbox list screen
$show_flag_buttons = getPref($data_dir, $username, 'show_flag_buttons', SMPREF_ON );
function load_optpage_data_display() {
global $theme, $fontsets, $language, $languages,$aTemplateSet,
$default_use_mdn, $squirrelmail_language, $allow_thread_sort,
- $show_alternative_names, $use_icons, $use_iframe, $sTplDir;
+ $show_alternative_names, $use_icons, $use_iframe, $sTemplateID;
/* Build a simple array into which we will build options. */
$optgrps = array();
$templateset_values = array();
foreach ($aTemplateSet as $sKey => $aTemplateSetAttributes) {
- $templateset_values[$aTemplateSetAttributes['NAME']] = $aTemplateSetAttributes['PATH'];
+ $templateset_values[$aTemplateSetAttributes['NAME']] = $aTemplateSetAttributes['ID'];
}
ksort($templateset_values);
$templateset_values = array_flip($templateset_values);
// display template options only when there is more than one template
if (count($templateset_values)>1) {
$optvals[SMOPT_GRP_GENERAL][] = array(
- 'name' => 'sTplDir',
- 'caption' => _("Template"),
+ 'name' => 'sTemplateID',
+ 'caption' => _("Skin"),
'type' => SMOPT_TYPE_STRLIST,
'refresh' => SMOPT_REFRESH_ALL,
'posvals' => $templateset_values,
'size' => SMOPT_SIZE_TINY
);
/*
+FIXME!
disabled because the template doesn't support it (yet?)
$optvals[SMOPT_GRP_MAILBOX][] = array(
'name' => 'show_recipient_instead',
/* Do checking to make sure $new_theme is in the array. */
$templateset_in_array = false;
for ($i = 0; $i < count($aTemplateSet); ++$i) {
- if ($aTemplateSet[$i]['PATH'] == $option->new_value) {
+ if ($aTemplateSet[$i]['ID'] == $option->new_value) {
$templateset_in_array = true;
break;
}