mirror of
https://github.com/e107inc/e107.git
synced 2025-01-17 12:48:24 +01:00
Allow rolling-log to be set using the add() method. Use: e107::getLog()->add(); Upgraded the callMethod() function to allow for using existing objects as well as class name.
This commit is contained in:
parent
280f100190
commit
d248a5d2ff
@ -479,6 +479,13 @@ class admin_log_form_ui extends e_admin_form_ui
|
||||
// Custom Method/Function
|
||||
function dblog_type($curVal,$mode)
|
||||
{
|
||||
/*
|
||||
define("E_LOG_INFORMATIVE", 0); // Minimal Log Level, including really minor stuff
|
||||
define("E_LOG_NOTICE", 1); // More important than informative, but less important than notice
|
||||
define("E_LOG_WARNING", 2); // Not anything serious, but important information
|
||||
define("E_LOG_FATAL", 3); // An event so bad your site ceased execution.
|
||||
define("E_LOG_PLUGIN", 4); // Plugin information
|
||||
*/
|
||||
|
||||
$array = array(
|
||||
' ', // Minimal Log Level, including really minor stuff
|
||||
@ -494,12 +501,12 @@ class admin_log_form_ui extends e_admin_form_ui
|
||||
switch($mode)
|
||||
{
|
||||
case 'read': // List Page
|
||||
return varset($array[$curVal], $curval);
|
||||
return varset($array[$curVal], $curVal);
|
||||
break;
|
||||
|
||||
case 'filter':
|
||||
case 'batch':
|
||||
return $array;
|
||||
return array('Informative','Notice','Warning','Fatal');
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -688,21 +695,21 @@ class dblog_ui extends e_admin_ui
|
||||
protected $fields = array (
|
||||
// 'checkboxes' => array ( 'title' => '', 'type' => null, 'data' => null, 'width' => '5%', 'thclass' => 'center', 'forced' => '1', 'class' => 'center', 'toggle' => 'e-multiselect', ),
|
||||
'dblog_id' => array ( 'title' => LAN_ID, 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'dblog_datestamp' => array ( 'title' => LAN_DATESTAMP, 'type' => 'method', 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'dblog_datestamp' => array ( 'title' => LAN_DATESTAMP, 'type' => 'datestamp', 'data' => 'int', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'dblog_microtime' => array ( 'title' => 'Microtime', 'type' => 'method', 'data' => 'int', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'dblog_type' => array ( 'title' => LAN_TYPE, 'type' => 'method', 'data' => 'int', 'width' => 'auto', 'batch' => true, 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'dblog_eventcode' => array ( 'title' => 'Eventcode', 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'dblog_user_id' => array ( 'title' => LAN_ID, 'type' => 'user', 'data' => 'int', 'width' => '5%', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'dblog_user_name' => array ( 'title' => LAN_USER, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'filter' => true, 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'dblog_ip' => array ( 'title' => LAN_IP, 'type' => 'text', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'dblog_ip' => array ( 'title' => LAN_IP, 'type' => 'ip', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'dblog_caller' => array ( 'title' => 'Caller', 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'dblog_title' => array ( 'title' => LAN_TITLE, 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'dblog_remarks' => array ( 'title' => 'Remarks', 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'center', 'thclass' => 'center', ),
|
||||
'dblog_remarks' => array ( 'title' => 'Remarks', 'type' => 'method', 'data' => 'str', 'width' => 'auto', 'help' => '', 'readParms' => '', 'writeParms' => '', 'class' => 'left', 'thclass' => 'left', ),
|
||||
'options' => array ( 'title' => 'Options', 'type' => null, 'nolist'=>true, 'data' => null, 'width' => '10%', 'thclass' => 'center last', 'class' => 'center last', 'forced' => '1', ),
|
||||
);
|
||||
|
||||
);
|
||||
|
||||
protected $fieldpref = array('dblog_id', 'dblog_datestamp', 'dblog_microtime', 'dblog_type', 'dblog_eventcode', 'dblog_user_id', 'dblog_user_name', 'dblog_ip', 'dblog_caller', 'dblog_title', 'dblog_remarks');
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -136,7 +136,7 @@ class e_admin_log
|
||||
|
||||
|
||||
/**
|
||||
* Add a Save an event into the admin log.
|
||||
* Add a Save an event into the admin, rolloing or user log.
|
||||
*
|
||||
* Alternative admin log entry point - compatible with legacy calls, and a bit simpler to use than the generic entry point.
|
||||
* ($eventcode has been added - give it a reference to identify the source module, such as 'NEWS_12' or 'ECAL_03')
|
||||
@ -150,11 +150,12 @@ class e_admin_log
|
||||
*
|
||||
* @param string $event_title
|
||||
* @param mixed $event_details
|
||||
* @param integer $event_type [optional] Log level
|
||||
* @param unknown $event_code [optional]
|
||||
* @param integer $event_type [optional] Log level eg. E_LOG_INFORMATIVE, E_LOG_NOTICE, E_LOG_WARNING, E_LOG_FATAL
|
||||
* @param string $event_code [optional] - eg. 'BOUNCE'
|
||||
* @param integer $target [optional] LOG_TO_ADMIN, LOG_TO_AUDIT, LOG_TO_ROLLING
|
||||
* @return e_admin_log
|
||||
*/
|
||||
public function add($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE , $event_code = '')
|
||||
public function add($event_title, $event_detail, $event_type = E_LOG_INFORMATIVE , $event_code = '', $target = LOG_TO_ADMIN )
|
||||
{
|
||||
if ($event_code == '')
|
||||
{
|
||||
@ -200,7 +201,7 @@ class e_admin_log
|
||||
}
|
||||
|
||||
|
||||
$this->e_log_event($event_type, -1, $event_code, $event_title, $event_detail, FALSE, LOG_TO_ADMIN);
|
||||
$this->e_log_event($event_type, -1, $event_code, $event_title, $event_detail, FALSE, $target);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -1260,7 +1260,7 @@ class e107
|
||||
|
||||
/**
|
||||
* Retrieve admin log singleton object
|
||||
*
|
||||
* @Deprecated - use e107::getLog();
|
||||
* @return e_admin_log
|
||||
*/
|
||||
public static function getAdminLog()
|
||||
@ -1268,6 +1268,16 @@ class e107
|
||||
return self::getSingleton('e_admin_log', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve admin log singleton object
|
||||
*
|
||||
* @return e_admin_log
|
||||
*/
|
||||
public static function getLog()
|
||||
{
|
||||
return self::getSingleton('e_admin_log', true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve date handler singleton object
|
||||
*
|
||||
@ -1842,9 +1852,10 @@ class e107
|
||||
return $new_addon;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Safe way to call user methods.
|
||||
* @param string $class_name
|
||||
* @param string|object $class_name
|
||||
* @param string $method_name
|
||||
* @return boolean FALSE
|
||||
*/
|
||||
@ -1852,9 +1863,19 @@ class e107
|
||||
{
|
||||
$mes = e107::getMessage();
|
||||
|
||||
if(class_exists($class_name))
|
||||
if(is_object($class_name) || class_exists($class_name))
|
||||
{
|
||||
$obj = new $class_name;
|
||||
|
||||
if(is_object($class_name))
|
||||
{
|
||||
$obj = $class_name;
|
||||
$class_name = get_class($obj);
|
||||
}
|
||||
else
|
||||
{
|
||||
$obj = new $class_name;
|
||||
}
|
||||
|
||||
if(method_exists($obj, $method_name))
|
||||
{
|
||||
if(E107_DBG_INCLUDES)
|
||||
@ -1871,6 +1892,7 @@ class e107
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get theme name or path.
|
||||
*
|
||||
|
Loading…
x
Reference in New Issue
Block a user