1
0
mirror of https://github.com/e107inc/e107.git synced 2025-03-14 09:29:45 +01:00

Fix for user-theme menu.

This commit is contained in:
CaMer0n 2009-07-07 22:56:13 +00:00
parent c5c7af80e9
commit 9edec709e8
5 changed files with 66 additions and 35 deletions

View File

@ -9,9 +9,9 @@
* General purpose file * General purpose file
* *
* $Source: /cvs_backup/e107_0.8/class2.php,v $ * $Source: /cvs_backup/e107_0.8/class2.php,v $
* $Revision: 1.101 $ * $Revision: 1.102 $
* $Date: 2009-07-07 21:39:18 $ * $Date: 2009-07-07 22:56:10 $
* $Author: e107steved $ * $Author: e107coders $
* *
*/ */
// //
@ -930,16 +930,17 @@ define('TIMEOFFSET', $e_deltaTime);
if(!defined("THEME_LAYOUT")) if(!defined("THEME_LAYOUT"))
{ {
$def = ""; // no custom pages found yet. $def = ""; // no custom pages found yet.
$cusPagePref = (is_array($user_pref['sitetheme_custompages'])) ? $user_pref['sitetheme_custompages'] : $pref['sitetheme_custompages'];
if(is_array($pref['sitetheme_custompages'])) // check if we match a page in layout custompages. if(is_array($cusPagePref)) // check if we match a page in layout custompages.
{ {
foreach($pref['sitetheme_custompages'] as $layout=>$cusPageArray) foreach($cusPagePref as $lyout=>$cusPageArray)
{ {
foreach($cusPageArray as $kpage) foreach($cusPageArray as $kpage)
{ {
if ($kpage && (strstr(e_SELF, $kpage) || strstr(e_SELF."?".e_QUERY,$kpage))) if ($kpage && (strstr(e_SELF, $kpage) || strstr(e_SELF."?".e_QUERY,$kpage)))
{ {
$def = ($layout) ? $layout : "no_array"; $def = ($lyout) ? $lyout : "no_array";
break; break;
} }
} }
@ -952,9 +953,11 @@ if(!defined("THEME_LAYOUT"))
} }
else // default layout. else // default layout.
{ {
define("THEME_LAYOUT",varset($pref['sitetheme_deflayout'])); // default layout. $deflayout = (!isset($user_pref['sitetheme_deflayout'])) ? varset($pref['sitetheme_deflayout']) : $user_pref['sitetheme_deflayout'];
define("THEME_LAYOUT",$deflayout); // default layout.
} }
unset($def); unset($def,$lyout,$cusPagePref);
} }
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
@ -1516,19 +1519,32 @@ function init_session()
} }
if (check_class(varset($pref['allow_theme_select'],FALSE))) // This check doesn't work, because it relies on the definitions for USER, ADMIN, USERCLASS_LIST etc that haven't been defined yet.. if (check_class(varset($pref['allow_theme_select'],FALSE))) // This check doesn't work, because it relies on the definitions for USER, ADMIN, USERCLASS_LIST etc that haven't been defined yet..
{ // User can set own theme { // User can set own theme
if (isset($_POST['settheme'])) if (isset($_POST['settheme']))
{ {
$user_pref['sitetheme'] = ($pref['sitetheme'] == $_POST['sitetheme'] ? "" : $_POST['sitetheme']); if($pref['sitetheme'] != $_POST['sitetheme'])
{
require_once(e_HANDLER."theme_handler.php");
$utheme = new themeHandler;
$ut = $utheme->themeArray[$_POST['sitetheme']];
$user_pref['sitetheme'] = $_POST['sitetheme'];
$user_pref['sitetheme_custompages'] = $ut['custompages'];
$user_pref['sitetheme_deflayout'] = $utheme->findDefault($_POST['sitetheme']);
}
else
{
unset($user_pref['sitetheme'],$user_pref['sitetheme_custompages'],$user_pref['sitetheme_deflayout']);
}
save_prefs('user'); save_prefs('user');
unset($ut);
} }
} }
elseif (isset($user_pref['sitetheme'])) elseif (isset($user_pref['sitetheme']))
{ // User obviously no longer allowed his own theme - clear it { // User obviously no longer allowed his own theme - clear it
unset($user_pref['sitetheme']); unset($user_pref['sitetheme'],$user_pref['sitetheme_custompages'],$user_pref['sitetheme_deflayout']);
save_prefs('user'); save_prefs('user');
} }

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $ | $Source: /cvs_backup/e107_0.8/e107_admin/menus.php,v $
| $Revision: 1.18 $ | $Revision: 1.19 $
| $Date: 2009-07-07 16:04:42 $ | $Date: 2009-07-07 22:56:11 $
| $Author: e107coders $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@ -247,20 +247,18 @@ if(isset($_POST['menuUsePreset']) && $_POST['curLayout'])
{ {
$row=$sql->db_Fetch(); $row=$sql->db_Fetch();
if(!$sql->db_Update('menus', "menu_order='{$val['menu_order']}', menu_location = ".$val['menu_location'].", menu_class= ".$val['menu_class']." WHERE menu_name='".$val['menu_name']."' AND menu_layout = '$layout' LIMIT 1 ",TRUE)) if(!$sql->db_Update('menus', "menu_order='{$val['menu_order']}', menu_location = ".$val['menu_location'].", menu_class= ".$val['menu_class']." WHERE menu_name='".$val['menu_name']."' AND menu_layout = '$layout' LIMIT 1 "))
{ {
$qry = " $qry = "
INSERT into #menus INSERT into #menus
(`menu_name`, `menu_location`, `menu_order`, `menu_pages`,`menu_class`, `menu_path`, `menu_layout`) (`menu_name`, `menu_location`, `menu_order`, `menu_pages`,`menu_class`, `menu_path`, `menu_layout`)
VALUES ('{$val['menu_name']}', {$val['menu_location']}, {$val['menu_order']}, '', '{$val['menu_class']}', '{$row['menu_path']}', '{$layout}') VALUES ('{$val['menu_name']}', {$val['menu_location']}, {$val['menu_order']}, '', '{$val['menu_class']}', '{$row['menu_path']}', '{$layout}')
"; ";
$sql->db_Select_gen($qry,TRUE); $sql->db_Select_gen($qry);
$admin_log->log_event('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,''); $admin_log->log_event('MENU_01',$row['menu_name'].'[!br!]'.$location.'[!br!]'.$menu_count.'[!br!]'.$row['menu_path'],E_LOG_INFORMATIVE,'');
} }
} }
} }

View File

@ -11,8 +11,8 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $ | $Source: /cvs_backup/e107_0.8/e107_handlers/theme_handler.php,v $
| $Revision: 1.25 $ | $Revision: 1.26 $
| $Date: 2009-07-07 16:04:45 $ | $Date: 2009-07-07 22:56:12 $
| $Author: e107coders $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
@ -726,7 +726,6 @@ class themeHandler{
function findDefault($theme) function findDefault($theme)
{ {
if(varset($_POST['layout_default'])) if(varset($_POST['layout_default']))
{ {
return $_POST['layout_default']; return $_POST['layout_default'];

View File

@ -11,9 +11,9 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/user_menu/config.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/user_menu/config.php,v $
| $Revision: 1.1 $ | $Revision: 1.2 $
| $Date: 2008-10-02 21:10:02 $ | $Date: 2009-07-07 22:56:13 $
| $Author: e107steved $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
$eplug_admin = TRUE; $eplug_admin = TRUE;
@ -78,15 +78,21 @@ if (isset($pref['allowed_themes']))
$themeeditclass = varset($pref['allow_theme_select'],e_UC_NOBODY); $themeeditclass = varset($pref['allow_theme_select'],e_UC_NOBODY);
$text = " $text = "
<form method='post' action='".e_SELF."' name='menu_conf_form'> <form method='post' action='".e_SELF."' id='menu_conf_form'>
<table style='".ADMIN_WIDTH."' class='fborder' > <fieldset id='core-user_menu-usertheme'>
<colgroup> <legend class='e-hideme'>".LAN_UMENU_THEME_6."</legend>
<table cellpadding='0' cellspacing='0' class='adminlist'>
<colgroup span='2'>
<col style='width: 50%' /> <col style='width: 50%' />
<col style='width: 50%' /> <col style='width: 50%' />
</colgroup> </colgroup>
<thead>
<tr> <tr>
<td colspan='2' class='forumheader2'>".LAN_UMENU_THEME_4."</td> <th colspan='2' class='forumheader2'>".LAN_UMENU_THEME_4."</th>
</tr>"; </tr>
</thead>
<tbody>";
foreach ($themeOptions as $th) foreach ($themeOptions as $th)
{ {
@ -108,11 +114,20 @@ $text .= "
<tr> <tr>
<td colspan='2' class='forumheader' style='text-align:center'><input class='button' type='submit' name='update_theme' value='".LAN_UMENU_THEME_5."' /></td> <td colspan='2' class='forumheader' style='text-align:center'><input class='button' type='submit' name='update_theme' value='".LAN_UMENU_THEME_5."' /></td>
</tr> </tr>
</table> </tbody>
</table>
</fieldset>
</form> </form>
</div>"; ";
$ns->tablerender(LAN_UMENU_THEME_6, $text); $ns->tablerender(LAN_UMENU_THEME_6, $text);
require_once(e_ADMIN."footer.php"); require_once(e_ADMIN."footer.php");
function headerjs()
{
return "<script type='text/javascript' src='".e_FILE_ABS."jslib/core/admin.js'></script>";
}
?> ?>

View File

@ -11,16 +11,18 @@
| GNU General Public License (http://gnu.org). | GNU General Public License (http://gnu.org).
| |
| $Source: /cvs_backup/e107_0.8/e107_plugins/user_menu/usertheme_menu.php,v $ | $Source: /cvs_backup/e107_0.8/e107_plugins/user_menu/usertheme_menu.php,v $
| $Revision: 1.2 $ | $Revision: 1.3 $
| $Date: 2008-10-02 21:10:02 $ | $Date: 2009-07-07 22:56:13 $
| $Author: e107steved $ | $Author: e107coders $
+----------------------------------------------------------------------------+ +----------------------------------------------------------------------------+
*/ */
if (!defined('e107_INIT')) { exit; } if (!defined('e107_INIT')) { exit; }
global $pref, $eArrayStorage;
if ((USER == TRUE) && check_class(varset($pref['allow_theme_select'],FALSE))) if ((USER == TRUE) && check_class(varset($pref['allow_theme_select'],FALSE)))
{ {
$allThemes = TRUE; $allThemes = TRUE;
if (isset($pref['allowed_themes'])) if (isset($pref['allowed_themes']))
{ {
@ -50,7 +52,8 @@ if ((USER == TRUE) && check_class(varset($pref['allow_theme_select'],FALSE)))
while ($row = $sql->db_Fetch()) while ($row = $sql->db_Fetch())
{ {
$up = unserialize($row['user_prefs']); $up = (substr($row['user_prefs'],0,5) == "array") ? $eArrayStorage->ReadArray($row['user_prefs']) : unserialize($row['user_prefs']);
if (isset($themecount[$up['sitetheme']])) { $themecount[$up['sitetheme']]++; } if (isset($themecount[$up['sitetheme']])) { $themecount[$up['sitetheme']]++; }
} }