diff --git a/e107_admin/prefs.php b/e107_admin/prefs.php index 9d6596035..0a8033a65 100644 --- a/e107_admin/prefs.php +++ b/e107_admin/prefs.php @@ -2,16 +2,14 @@ /* * e107 website system * - * Copyright (C) 2008-2009 e107 Inc (e107.org) + * Copyright (C) 2008-2010 e107 Inc (e107.org) * Released under the terms and conditions of the * GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * * Administration - Site Preferences * - * $Source: /cvs_backup/e107_0.8/e107_admin/prefs.php,v $ - * $Revision$ - * $Date$ - * $Author$ + * $URL$ + * $Id$ * */ require_once ("../class2.php"); @@ -29,31 +27,33 @@ if(! getperms("1")) } include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); - $e_sub_cat = 'prefs'; -require_once (e_HANDLER."userclass_class.php"); -require_once (e_HANDLER."user_extended_class.php"); -$e_userclass = new user_class(); -$ue = new e107_user_extended(); +require_once (e_ADMIN."auth.php"); -if(! $pref['timezone']) +$e_userclass = e107::getUserClass(); +require_once (e_HANDLER."user_extended_class.php"); +$ue = new e107_user_extended(); +$core_pref = e107::getConfig(); + +if(!$core_pref->get('timezone')) { - $pref['timezone'] = "GMT"; + $core_pref->set('timezone', 'GMT'); } -require_once (e_HANDLER."form_handler.php"); -require_once (e_HANDLER."message_handler.php"); -$rs = new form(); -$frm = new e_form(true); //enable inner tabindex counter -$emessage = &eMessage::getInstance(); +$frm = e107::getForm(false, true); //enable inner tabindex counter +$emessage = e107::getMessage(); +$tp = e107::getParser(); /* RESET DISPLAY NAMES */ if(isset($_POST['submit_resetdisplaynames'])) { - $e107->sql->db_Update('user', 'user_name=user_loginname'); + e107::getDb()->db_Update('user', 'user_name=user_loginname'); $emessage->add(PRFLAN_157); } +//echo '
';
+//var_dump($core_pref->getPref());
+//echo '
'; /* UPDATE PREFERENCES */ if(isset($_POST['updateprefs'])) { @@ -83,6 +83,7 @@ if(isset($_POST['updateprefs'])) $_POST['membersonly_exceptions'] = explode("\n",$_POST['membersonly_exceptions']); + // FIXME - automate - pref model & validation handler $prefChanges = array(); foreach($_POST as $key => $value) { @@ -111,14 +112,15 @@ if(isset($_POST['updateprefs'])) { $newValue = $tp->toDB($value); } - if($newValue != $pref[$key]) + $core_pref->update($key, $newValue); + /*if($newValue != $core_pref->get($key)) { // Changed value - $pref[$key] = $newValue; + $core_pref->set($key, $newValue); $prefChanges[$key] = $newValue; - } + }*/ } - - if(count($prefChanges)) + $core_pref->save(false); + /*if(count($prefChanges)) { // Values have changed $e107cache->clear('', TRUE); $saved = save_prefs(); @@ -127,21 +129,21 @@ if(isset($_POST['updateprefs'])) { $logStr .= "[!br!]{$k} => {$v}"; } - $admin_log->log_event('PREFS_01', PRFLAN_195.$logStr, ''); + $admin_log->log_event('PREFS_01', PRFLAN_195.$logStr); $e107->sql->db_Select_gen("TRUNCATE ".MPREFIX."online"); - } - if($saved) + }*/ + //if($saved) { /*$emessage->addSession(PRFLAN_106, E_MESSAGE_SUCCESS); header("location:".e_ADMIN."prefs.php?u"); exit();*/ //no redirect, smarter form (remember last used tab - $emessage->add(PRFLAN_106, E_MESSAGE_SUCCESS); + //$emessage->add(PRFLAN_106, E_MESSAGE_SUCCESS); } - else + //else { // done in class2: include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_admin.php'); - $emessage->add(LAN_NO_CHANGE); + //$emessage->add(LAN_NO_CHANGE); } } @@ -158,9 +160,6 @@ if (plugInstalled('alt_auth')) } } - - -require_once (e_ADMIN."auth.php"); /* if(isset($message)) { diff --git a/e107_handlers/admin_log_class.php b/e107_handlers/admin_log_class.php index 0aec79986..f8f947299 100644 --- a/e107_handlers/admin_log_class.php +++ b/e107_handlers/admin_log_class.php @@ -354,7 +354,7 @@ class e_admin_log // Returns true if changes, false otherwise. // Only makes log entry if changes detected. // The $old array is updated with changes, but not saved anywhere - function logArrayDiffs(&$new, &$old, $event) + function logArrayDiffs(&$new, &$old, $event, $logNow = true) { $changes = array(); foreach ($new as $k=>$v) @@ -368,7 +368,8 @@ class e_admin_log } if (count($changes)) { - $this->log_event($event, implode('[!br!]', $changes), E_LOG_INFORMATIVE, ''); + if($logNow) $this->log_event($event, implode('[!br!]', $changes), E_LOG_INFORMATIVE, ''); + else $this->logMessage(implode('[!br!]', $changes), LOG_MESSAGE_NODISPLAY, E_MESSAGE_INFO); return TRUE; } return FALSE; @@ -475,7 +476,7 @@ class e_admin_log { $logString .= $separator; if ($m['loglevel'] == LOG_MESSAGE_NODISPLAY) { $logString .= ' '; } // Indent supplementary messages - $logString .= $m['message']; + $logString .= strip_tags(str_replace(array('
', '
', '
'), '[!br!]', $m['message'])); if (isset($resultTypes[$m['loglevel']])) { $logString .= ' - '.$resultTypes[$m['loglevel']]; diff --git a/e107_handlers/pref_class.php b/e107_handlers/pref_class.php index ad8fa14f3..b895e905d 100644 --- a/e107_handlers/pref_class.php +++ b/e107_handlers/pref_class.php @@ -525,21 +525,21 @@ class e_pref extends e_admin_model if($this->set_backup === true && !empty($this->pref_cache)) { + $old = e107::getArrayStorage()->ReadArray($this->pref_cache); if($this->serial_bc) { - $old = e107::getArrayStorage()->ReadArray($this->pref_cache); $dbdata = serialize($old); } else { - $old = $dbdata = $this->pref_cache; + $dbdata = $this->pref_cache; } - + // auto admin log if(is_array($old)) // fix install problems - no old prefs available { - $new = $this->getPref(); - $admin_log->logArrayDiffs($new, $old, 'LAN_FIXME'); + $new = $this->getPref(); + $admin_log->logArrayDiffs($new, $old, 'LAN_FIXME', false); unset($new, $old); } if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('".$this->prefid."_Backup', '".addslashes($dbdata)."') ")) @@ -550,7 +550,7 @@ class e_pref extends e_admin_model } $this->setPrefCache($this->toString(false), true); //reset pref cache - runtime & file - $admin_log->logSuccess('Settings successfully saved.', true, $session_messages); + $admin_log->logSuccess('Settings successfully saved.', true, $session_messages)->flushMessages('LAN_FIXME'); //BC if($this->alias === 'core') {