1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-17 20:01:47 +02:00

EONE-79 (issue): LogArray fixes; Admin settings page - work in progress

This commit is contained in:
secretr
2010-04-19 13:31:47 +00:00
parent 71f81fbea2
commit 3c3486f806
3 changed files with 41 additions and 41 deletions

View File

@@ -2,16 +2,14 @@
/* /*
* e107 website system * 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 * Released under the terms and conditions of the
* GNU General Public License (http://www.gnu.org/licenses/gpl.txt) * GNU General Public License (http://www.gnu.org/licenses/gpl.txt)
* *
* Administration - Site Preferences * Administration - Site Preferences
* *
* $Source: /cvs_backup/e107_0.8/e107_admin/prefs.php,v $ * $URL$
* $Revision$ * $Id$
* $Date$
* $Author$
* *
*/ */
require_once ("../class2.php"); require_once ("../class2.php");
@@ -29,31 +27,33 @@ if(! getperms("1"))
} }
include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE); include_lan(e_LANGUAGEDIR.e_LANGUAGE.'/admin/lan_'.e_PAGE);
$e_sub_cat = 'prefs'; $e_sub_cat = 'prefs';
require_once (e_HANDLER."userclass_class.php"); require_once (e_ADMIN."auth.php");
require_once (e_HANDLER."user_extended_class.php");
$e_userclass = new user_class();
$ue = new e107_user_extended();
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"); $frm = e107::getForm(false, true); //enable inner tabindex counter
require_once (e_HANDLER."message_handler.php"); $emessage = e107::getMessage();
$rs = new form(); $tp = e107::getParser();
$frm = new e_form(true); //enable inner tabindex counter
$emessage = &eMessage::getInstance();
/* RESET DISPLAY NAMES */ /* RESET DISPLAY NAMES */
if(isset($_POST['submit_resetdisplaynames'])) 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); $emessage->add(PRFLAN_157);
} }
//echo '<pre>';
//var_dump($core_pref->getPref());
//echo '</pre>';
/* UPDATE PREFERENCES */ /* UPDATE PREFERENCES */
if(isset($_POST['updateprefs'])) if(isset($_POST['updateprefs']))
{ {
@@ -83,6 +83,7 @@ if(isset($_POST['updateprefs']))
$_POST['membersonly_exceptions'] = explode("\n",$_POST['membersonly_exceptions']); $_POST['membersonly_exceptions'] = explode("\n",$_POST['membersonly_exceptions']);
// FIXME - automate - pref model & validation handler
$prefChanges = array(); $prefChanges = array();
foreach($_POST as $key => $value) foreach($_POST as $key => $value)
{ {
@@ -111,14 +112,15 @@ if(isset($_POST['updateprefs']))
{ {
$newValue = $tp->toDB($value); $newValue = $tp->toDB($value);
} }
if($newValue != $pref[$key]) $core_pref->update($key, $newValue);
/*if($newValue != $core_pref->get($key))
{ // Changed value { // Changed value
$pref[$key] = $newValue; $core_pref->set($key, $newValue);
$prefChanges[$key] = $newValue; $prefChanges[$key] = $newValue;
} }*/
} }
$core_pref->save(false);
if(count($prefChanges)) /*if(count($prefChanges))
{ // Values have changed { // Values have changed
$e107cache->clear('', TRUE); $e107cache->clear('', TRUE);
$saved = save_prefs(); $saved = save_prefs();
@@ -127,21 +129,21 @@ if(isset($_POST['updateprefs']))
{ {
$logStr .= "[!br!]{$k} => {$v}"; $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"); $e107->sql->db_Select_gen("TRUNCATE ".MPREFIX."online");
} }*/
if($saved) //if($saved)
{ {
/*$emessage->addSession(PRFLAN_106, E_MESSAGE_SUCCESS); /*$emessage->addSession(PRFLAN_106, E_MESSAGE_SUCCESS);
header("location:".e_ADMIN."prefs.php?u"); header("location:".e_ADMIN."prefs.php?u");
exit();*/ exit();*/
//no redirect, smarter form (remember last used tab //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'); // 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)) if(isset($message))
{ {

View File

@@ -354,7 +354,7 @@ class e_admin_log
// Returns true if changes, false otherwise. // Returns true if changes, false otherwise.
// Only makes log entry if changes detected. // Only makes log entry if changes detected.
// The $old array is updated with changes, but not saved anywhere // 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(); $changes = array();
foreach ($new as $k=>$v) foreach ($new as $k=>$v)
@@ -368,7 +368,8 @@ class e_admin_log
} }
if (count($changes)) 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 TRUE;
} }
return FALSE; return FALSE;
@@ -475,7 +476,7 @@ class e_admin_log
{ {
$logString .= $separator; $logString .= $separator;
if ($m['loglevel'] == LOG_MESSAGE_NODISPLAY) { $logString .= ' '; } // Indent supplementary messages if ($m['loglevel'] == LOG_MESSAGE_NODISPLAY) { $logString .= ' '; } // Indent supplementary messages
$logString .= $m['message']; $logString .= strip_tags(str_replace(array('<br>', '<br/>', '<br />'), '[!br!]', $m['message']));
if (isset($resultTypes[$m['loglevel']])) if (isset($resultTypes[$m['loglevel']]))
{ {
$logString .= ' - '.$resultTypes[$m['loglevel']]; $logString .= ' - '.$resultTypes[$m['loglevel']];

View File

@@ -525,21 +525,21 @@ class e_pref extends e_admin_model
if($this->set_backup === true && !empty($this->pref_cache)) if($this->set_backup === true && !empty($this->pref_cache))
{ {
$old = e107::getArrayStorage()->ReadArray($this->pref_cache);
if($this->serial_bc) if($this->serial_bc)
{ {
$old = e107::getArrayStorage()->ReadArray($this->pref_cache);
$dbdata = serialize($old); $dbdata = serialize($old);
} }
else else
{ {
$old = $dbdata = $this->pref_cache; $dbdata = $this->pref_cache;
} }
// auto admin log // auto admin log
if(is_array($old)) // fix install problems - no old prefs available if(is_array($old)) // fix install problems - no old prefs available
{ {
$new = $this->getPref(); $new = $this->getPref();
$admin_log->logArrayDiffs($new, $old, 'LAN_FIXME'); $admin_log->logArrayDiffs($new, $old, 'LAN_FIXME', false);
unset($new, $old); unset($new, $old);
} }
if(e107::getDb()->db_Select_gen("REPLACE INTO `#core` (e107_name,e107_value) values ('".$this->prefid."_Backup', '".addslashes($dbdata)."') ")) 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 $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 //BC
if($this->alias === 'core') if($this->alias === 'core')
{ {