From 14039f85e02d217c86ed76b9df0bcd5e701e36ce Mon Sep 17 00:00:00 2001 From: CaMer0n Date: Sat, 4 Jul 2009 13:36:15 +0000 Subject: [PATCH] save_pref('user') updated to store as array (like core prefs). should be backwards compatible - but expecting a few things to break. Infopanel now stores customization settings in user-pref. Newspost table-listing customization now also saves in user-pref. Some admin icon array clean-up. user-theme saving doesn't work at time of testing. Rolled back class2 and problem existed before. (see note in class2.php line 1489) --- class2.php | 46 ++++++++++++++++++------------- e107_admin/admin.php | 42 +++++++++++++++++++--------- e107_admin/includes/infopanel.php | 45 ++++++++++++++++++++---------- e107_admin/newspost.php | 42 +++++++++++++++------------- e107_handlers/form_handler.php | 14 +++++----- e107_themes/jayya/style.css | 2 +- 6 files changed, 117 insertions(+), 74 deletions(-) diff --git a/class2.php b/class2.php index 2f2b04c59..00188d055 100644 --- a/class2.php +++ b/class2.php @@ -9,9 +9,9 @@ * General purpose file * * $Source: /cvs_backup/e107_0.8/class2.php,v $ -* $Revision: 1.95 $ -* $Date: 2009-05-26 20:17:57 $ -* $Author: e107steved $ +* $Revision: 1.96 $ +* $Date: 2009-07-04 13:36:14 $ +* $Author: e107coders $ * */ // @@ -1323,8 +1323,10 @@ function save_prefs($table = 'core', $uid = USERID, $row_val = '') } else { - $_user_pref = $tp -> toDB($user_pref); - $tmp=addslashes(serialize($_user_pref)); + // $_user_pref = $tp -> toDB($user_pref); + // $tmp=addslashes(serialize($_user_pref)); + $_user_pref = $tp->toDB($user_pref, true, true); + $tmp = $eArrayStorage->WriteArray($_user_pref); $sql->db_Update('user', "user_prefs='$tmp' WHERE user_id=".intval($uid)); return $tmp; } @@ -1383,7 +1385,7 @@ function init_session() # - return boolean # - scope public */ - global $sql, $pref, $user_pref, $tp, $currentUser, $e107, $_E107; + global $sql, $pref, $user_pref, $tp, $currentUser, $e107, $_E107, $eArrayStorage; define('USERIP', $e107->getip()); @@ -1476,20 +1478,26 @@ function init_session() exit; } - $user_pref = ($result['user_prefs'] ? unserialize($result['user_prefs']) : ''); - - if (check_class(varset($pref['allow_theme_select'],FALSE))) - { // User can set own theme - if (isset($_POST['settheme'])) + if($result['user_prefs']) { + $user_pref = (substr($result['user_prefs'],0,5) == "array") ? $eArrayStorage->ReadArray($result['user_prefs']) : unserialize($result['user_prefs']); + } + + + + + 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 + if (isset($_POST['settheme'])) + { $user_pref['sitetheme'] = ($pref['sitetheme'] == $_POST['sitetheme'] ? "" : $_POST['sitetheme']); - save_prefs('user'); - } - } - elseif (isset($user_pref['sitetheme'])) - { // User obviously no longer allowed his own theme - clear it - unset($user_pref['sitetheme']); - save_prefs('user'); + save_prefs('user'); + } + } + elseif (isset($user_pref['sitetheme'])) + { // User obviously no longer allowed his own theme - clear it + unset($user_pref['sitetheme']); + save_prefs('user'); } @@ -1520,7 +1528,7 @@ function init_session() } } - define('USERCLASS_LIST', class_list()); + define('USERCLASS_LIST', class_list()); define('e_CLASS_REGEXP', '(^|,)('.str_replace(',', '|', USERCLASS_LIST).')(,|$)'); define('e_NOBODY_REGEXP', '(^|,)'.e_UC_NOBODY.'(,|$)'); } diff --git a/e107_admin/admin.php b/e107_admin/admin.php index b9bab6e35..e6bf074b2 100644 --- a/e107_admin/admin.php +++ b/e107_admin/admin.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/admin.php,v $ -| $Revision: 1.10 $ -| $Date: 2009-07-04 03:08:03 $ +| $Revision: 1.11 $ +| $Date: 2009-07-04 13:36:15 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -223,6 +223,26 @@ function render_clean() $newarray = asortbyindex($array_functions, 1); +$array_functions_assoc = convert_core_icons($newarray); + + + +function convert_core_icons($newarray) // Put core button array in the same format as plugin button array. +{ + foreach($newarray as $val) + { + $key = "e-".basename($val[0],".php"); + $val['icon'] = $val[5]; + $val['icon_32'] = $val[6]; + $val['title'] = $val[1]; + $val['link'] = $val[0]; + $val['caption'] = $val['2']; + $val['perms'] = $val['4']; + $array_functions_assoc[$key] = $val; + } + return $array_functions_assoc; +} + require_once(e_ADMIN.'includes/'.$pref['adminstyle'].'.php'); @@ -335,21 +355,16 @@ function getPluginLinks($iconSize = E_16_PLUGMANAGER, $linkStyle = 'adminb') if ($eplug_conffile) { $eplug_name = $tp->toHTML($eplug_name,FALSE,"defs, emotes_off"); - if ($iconSize == E_16_PLUGMANAGER) - { - $plugin_icon = $eplug_icon_small ? "" : E_16_PLUGIN; - } - else - { - $plugin_icon = $eplug_icon ? "" : E_32_PLUGIN; - } - $plugin_array[$plugin_path] = array('link' => e_PLUGIN.$plugin_path."/".$eplug_conffile, 'title' => $eplug_name, 'caption' => $eplug_caption, 'perms' => "P".$plugin_id, 'icon' => $plugin_icon); + $plugin_icon = $eplug_icon_small ? "" : E_16_PLUGIN; + $plugin_icon_32 = $eplug_icon ? "" : E_32_PLUGIN; + + $plugin_array['p-'.$plugin_path] = array('link' => e_PLUGIN.$plugin_path."/".$eplug_conffile, 'title' => $eplug_name, 'caption' => $eplug_caption, 'perms' => "P".$plugin_id, 'icon' => $plugin_icon, 'icon_32' => $plugin_icon_32); } unset($eplug_conffile, $eplug_name, $eplug_caption, $eplug_icon_small); } } - ksort($plugin_array, SORT_STRING); + ksort($plugin_array, SORT_STRING); // To FIX, without changing the current key format, sort by 'title' if($linkStyle == "array") { @@ -358,7 +373,8 @@ function getPluginLinks($iconSize = E_16_PLUGMANAGER, $linkStyle = 'adminb') foreach ($plugin_array as $plug_key => $plug_value) { - $text .= render_links($plug_value['link'], $plug_value['title'], $plug_value['caption'], $plug_value['perms'], $plug_value['icon'], $linkStyle); + $the_icon = ($iconSize == E_16_PLUGMANAGER) ? $plug_value['icon'] : $plug_value['icon_32']; + $text .= render_links($plug_value['link'], $plug_value['title'], $plug_value['caption'], $plug_value['perms'], $the_icon, $linkStyle); } return $text; } diff --git a/e107_admin/includes/infopanel.php b/e107_admin/includes/infopanel.php index c385881e3..d3b4fc1a0 100644 --- a/e107_admin/includes/infopanel.php +++ b/e107_admin/includes/infopanel.php @@ -11,8 +11,8 @@ | GNU General Public License (http://gnu.org). | | $Source: /cvs_backup/e107_0.8/e107_admin/includes/infopanel.php,v $ -| $Revision: 1.1 $ -| $Date: 2009-07-04 03:08:03 $ +| $Revision: 1.2 $ +| $Date: 2009-07-04 13:36:15 $ | $Author: e107coders $ +----------------------------------------------------------------------------+ */ @@ -24,6 +24,13 @@ $emessage = &eMessage::getInstance(); require_once(e_HANDLER."form_handler.php"); $frm = new e_form(true); //enable inner tabindex counter +if(isset($_POST['submit-mye107'])) +{ + $user_pref['core-infopanel-mye107'] = $_POST['e-mye107']; + save_prefs('user'); +} + + $text = "
    @@ -54,16 +61,16 @@ attribute 5 = category attribute 6 = 16 x 16 image attribute 7 = 32 x 32 image */ - $buts = ""; + /* $buts = ""; - while (list($key, $funcinfo) = each($newarray)) + while (list($key, $funcinfo) = each($array_functions_assoc)) { - $iconlist[] = array("title"=>$funcinfo[1],"icon"=>$funcinfo[5]); // , $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[6], "classis"); + $iconlist[$key] = array("title"=>$funcinfo[1],"icon"=>$funcinfo[5]); // , $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[6], "classis"); $buts .= render_links($funcinfo[0], $funcinfo[1], $funcinfo[2], $funcinfo[3], $funcinfo[6], "classis"); - } + }*/ + $iconlist = array_merge($array_functions_assoc,getPluginLinks(E_16_PLUGMANAGER, "array")); - $pluglist = getPluginLinks(E_16_PLUGMANAGER, "array"); $text .= " @@ -80,7 +87,15 @@ attribute 7 = 32 x 32 image
    "; - $text .= getPluginLinks(E_32_PLUGMANAGER, "div"); + // Rendering the saved configuration. + + foreach($iconlist as $key=>$val) + { + if(in_array($key,$user_pref['core-infopanel-mye107'])) + { + $text .= render_links($val['link'], $val['title'], $val['caption'], $val['perms'], $val['icon_32'], "div"); + } + } $text .="
     
    @@ -182,24 +197,24 @@ $text .= " // Customizer ------------------------------------------ $text .= " -
    +
    Customize your Admin Panel
    "; + foreach($iconlist as $key=>$icon) { - $checked = (in_array($key,$columnsDefault)) ? TRUE : FALSE; + $checked = (in_array($key,$user_pref['core-infopanel-mye107'])) ? TRUE : FALSE; $text .= "
    - ".$icon['icon'].$frm->checkbox('e-columns[]', $key, $checked). $icon['title']."
    "; + ".$icon['icon'].$frm->checkbox('e-mye107[]',$key, $checked). $icon['title']."
    "; } foreach($pluglist as $key=>$icon) { - $checked = (in_array($key,$columnsDefault)) ? TRUE : FALSE; + $checked = (in_array('p-'.$key,$user_pref['core-infopanel-mye107'])) ? TRUE : FALSE; $text .= "
    - ".$icon['icon'].$frm->checkbox('e-columns[]', $key, $checked). $icon['title']."
    "; - + ".$icon['icon'].$frm->checkbox('e-mye107[]', $key, $checked). $icon['title']."
    "; } @@ -208,7 +223,7 @@ $text .= "
    "; $text .= "
    "; // has issues with the checkboxes. $text .= $frm->admin_button('submit-mye107','Save','Save'); - $text .= " (TO-DO)
    + $text .= "
diff --git a/e107_admin/newspost.php b/e107_admin/newspost.php index b8dd375e5..f22188e26 100644 --- a/e107_admin/newspost.php +++ b/e107_admin/newspost.php @@ -9,8 +9,8 @@ * News Administration * * $Source: /cvs_backup/e107_0.8/e107_admin/newspost.php,v $ - * $Revision: 1.41 $ - * $Date: 2009-07-03 06:48:43 $ + * $Revision: 1.42 $ + * $Date: 2009-07-04 13:36:15 $ * $Author: e107coders $ */ require_once("../class2.php"); @@ -580,14 +580,14 @@ class admin_newspost function _observe_saveColumns() { - global $pref,$admin_log; - $pref['admin_news_columns'] = $_POST['e-columns']; - save_prefs(); + global $user_pref,$admin_log; + $user_pref['admin_news_columns'] = $_POST['e-columns']; + save_prefs('user'); } function show_existing_items() { - global $pref,$gen; + global $user_pref,$gen; require_once(e_HANDLER."form_handler.php"); $frm = new e_form(true); //enable inner tabindex counter @@ -597,6 +597,10 @@ class admin_newspost $sort_link = $sort_order == 'asc' ? 'desc' : 'asc'; // Effectively toggle setting for headings $amount = 10;//TODO - pref + if(!is_array($user_pref['admin_news_columns'])) + { + $user_pref['admin_news_columns'] = array("news_id","news_title","news_author","news_render_type"); + } $field_columns = $this->_fields; @@ -659,9 +663,9 @@ class admin_newspost
".NWSLAN_4." - ".$frm->colGroup($field_columns,"admin_news_columns")." + ".$frm->colGroup($this->_fields,$user_pref['admin_news_columns'])." - ".$frm->thead($field_columns,"admin_news_columns")." + ".$frm->thead($this->_fields,$user_pref['admin_news_columns'])." "; @@ -679,17 +683,17 @@ class admin_newspost // Below must be in the same order as the field_columns above. - $text .= (in_array("news_id",$pref['admin_news_columns'])) ? "\n" : ""; - $text .= (in_array("news_title",$pref['admin_news_columns'])) ? " \n" : ""; - $text .= (in_array("news_author",$pref['admin_news_columns'])) ? "\n" : ""; - $text .= (in_array("news_datestamp",$pref['admin_news_columns'])) ? "\n" : ""; - $text .= (in_array("news_category",$pref['admin_news_columns'])) ? "\n" : ""; - $text .= (in_array("news_class",$pref['admin_news_columns'])) ? "\n" : ""; - $text .= (in_array("news_render_type",$pref['admin_news_columns'])) ? "\n" : ""; - $text .= (in_array("news_thumbnail",$pref['admin_news_columns'])) ? "\n" : ""; - $text .= (in_array("news_sticky",$pref['admin_news_columns'])) ? "\n" : ""; - $text .= (in_array("news_allow_comments",$pref['admin_news_columns'])) ? "\n" : ""; - $text .= (in_array("news_comment_total",$pref['admin_news_columns'])) ? "\n" : ""; + $text .= (in_array("news_id",$user_pref['admin_news_columns'])) ? "\n" : ""; + $text .= (in_array("news_title",$user_pref['admin_news_columns'])) ? " \n" : ""; + $text .= (in_array("news_author",$user_pref['admin_news_columns'])) ? "\n" : ""; + $text .= (in_array("news_datestamp",$user_pref['admin_news_columns'])) ? "\n" : ""; + $text .= (in_array("news_category",$user_pref['admin_news_columns'])) ? "\n" : ""; + $text .= (in_array("news_class",$user_pref['admin_news_columns'])) ? "\n" : ""; + $text .= (in_array("news_render_type",$user_pref['admin_news_columns'])) ? "\n" : ""; + $text .= (in_array("news_thumbnail",$user_pref['admin_news_columns'])) ? "\n" : ""; + $text .= (in_array("news_sticky",$user_pref['admin_news_columns'])) ? "\n" : ""; + $text .= (in_array("news_allow_comments",$user_pref['admin_news_columns'])) ? "\n" : ""; + $text .= (in_array("news_comment_total",$user_pref['admin_news_columns'])) ? "\n" : ""; $text .= " "; } @@ -610,16 +610,16 @@ class e_form function thead($fieldarray,$columnPref='') { - global $pref; + foreach($fieldarray as $key=>$val) { - if(in_array($key,$pref[$columnPref]) || $key == "options") + if(in_array($key,$columnPref) || $key == "options") { $cl = ($val['thclass']) ? "class='".$val['thclass']."'" : ""; $text .= "\n\t"; diff --git a/e107_themes/jayya/style.css b/e107_themes/jayya/style.css index 0d4aeb766..47dd23439 100644 --- a/e107_themes/jayya/style.css +++ b/e107_themes/jayya/style.css @@ -731,7 +731,7 @@ ul.plugin-navigation ul.plugin-navigation-sub a.link-active {font-weight: bold;} /***** Admin Main Panel Buttons **/ -.core-mainpanel-block { text-align:center; width:100px; float:left; height:48px; display:block } +.core-mainpanel-block { text-align:center; width:100px; float:left; height:48px; display:block;margin:15px; } .core-mainpanel-link-text { font-weight:bold; text-decoration: none; padding:3px }
".$row['news_id']."".($row['news_title'] ? $e107->tp->toHTML($row['news_title'], false,"TITLE") : "[".NWSLAN_42."]")."".$author['user_name']."".$gen->convert_date($row['news_datestamp'],'short')." ".$news_category[$row['news_category']]." ".r_userclass_name($row['news_class'])." ".$ren_type[$row['news_render_type']]."".$thumbnail."".$sticky."".$comments."".$row['news_comment_total']."".$row['news_id']."".($row['news_title'] ? $e107->tp->toHTML($row['news_title'], false,"TITLE") : "[".NWSLAN_42."]")."".$author['user_name']."".$gen->convert_date($row['news_datestamp'],'short')." ".$news_category[$row['news_category']]." ".r_userclass_name($row['news_class'])." ".$ren_type[$row['news_render_type']]."".$thumbnail."".$sticky."".$comments."".$row['news_comment_total']." diff --git a/e107_handlers/form_handler.php b/e107_handlers/form_handler.php index d08118b10..9973c3e75 100644 --- a/e107_handlers/form_handler.php +++ b/e107_handlers/form_handler.php @@ -9,8 +9,8 @@ * Form Handler * * $Source: /cvs_backup/e107_0.8/e107_handlers/form_handler.php,v $ - * $Revision: 1.26 $ - * $Date: 2009-07-03 06:48:43 $ + * $Revision: 1.27 $ + * $Date: 2009-07-04 13:36:15 $ * $Author: e107coders $ * */ @@ -597,10 +597,10 @@ class e_form function colGroup($fieldarray,$columnPref='') { - global $pref; + foreach($fieldarray as $key=>$val) { - if(in_array($key,$pref[$columnPref])) + if(in_array($key,$columnPref)) { $text .= "\n
"; $text .= ($val['url']) ? "" : ""; $text .= $val['title']; - $text .= ($key == "options") ? $this->columnSelector($fieldarray,$pref[$columnPref]) : ""; + $text .= ($key == "options") ? $this->columnSelector($fieldarray,$columnPref) : ""; $text .= ($val['url']) ? "" : ""; $text .= "