mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-13 07:24:13 +01:00
New configuration setting (and new class of Log objects) to keep track of the application's usage: an entry in the log is added each time a user connects to the application. (This feature is disabled by default)
SVN:trunk[1073]
This commit is contained in:
@@ -326,6 +326,16 @@ EOF
|
|||||||
{
|
{
|
||||||
// User is Ok, let's save it in the session and proceed with normal login
|
// User is Ok, let's save it in the session and proceed with normal login
|
||||||
UserRights::Login($sAuthUser, $sAuthentication); // Login & set the user's language
|
UserRights::Login($sAuthUser, $sAuthentication); // Login & set the user's language
|
||||||
|
|
||||||
|
if (MetaModel::GetConfig()->Get('log_usage'))
|
||||||
|
{
|
||||||
|
$oLog = new EventLoginUsage();
|
||||||
|
$oLog->Set('userinfo', UserRights::GetUser());
|
||||||
|
$oLog->Set('user_id', UserRights::GetUserObject()->GetKey());
|
||||||
|
$oLog->Set('message', 'Successful login');
|
||||||
|
$oLog->DBInsertNoReload();
|
||||||
|
}
|
||||||
|
|
||||||
$_SESSION['auth_user'] = $sAuthUser;
|
$_SESSION['auth_user'] = $sAuthUser;
|
||||||
$_SESSION['login_mode'] = $sLoginMode;
|
$_SESSION['login_mode'] = $sLoginMode;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -205,6 +205,14 @@ class Config
|
|||||||
'source_of_value' => '',
|
'source_of_value' => '',
|
||||||
'show_in_conf_sample' => true,
|
'show_in_conf_sample' => true,
|
||||||
),
|
),
|
||||||
|
'log_usage' => array(
|
||||||
|
'type' => 'bool',
|
||||||
|
'description' => 'Log the usage of the application (i.e. the date/time and the user name of each login)',
|
||||||
|
'default' => false,
|
||||||
|
'value' => false,
|
||||||
|
'source_of_value' => '',
|
||||||
|
'show_in_conf_sample' => false,
|
||||||
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
public function IsProperty($sPropCode)
|
public function IsProperty($sPropCode)
|
||||||
|
|||||||
@@ -258,4 +258,35 @@ class EventWebService extends Event
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class EventLoginUsage extends Event
|
||||||
|
{
|
||||||
|
public static function Init()
|
||||||
|
{
|
||||||
|
$aParams = array
|
||||||
|
(
|
||||||
|
"category" => "core/cmdb,view_in_gui",
|
||||||
|
"key_type" => "autoincrement",
|
||||||
|
"name_attcode" => "",
|
||||||
|
"state_attcode" => "",
|
||||||
|
"reconc_keys" => array(),
|
||||||
|
"db_table" => "priv_event_loginusage",
|
||||||
|
"db_key_field" => "id",
|
||||||
|
"db_finalclass_field" => "",
|
||||||
|
);
|
||||||
|
MetaModel::Init_Params($aParams);
|
||||||
|
MetaModel::Init_InheritAttributes();
|
||||||
|
|
||||||
|
MetaModel::Init_AddAttribute(new AttributeExternalKey("user_id", array("targetclass"=>"User", "jointype"=> "", "allowed_values"=>null, "sql"=>"user_id", "is_null_allowed"=>false, "on_target_delete"=>DEL_MANUAL, "depends_on"=>array())));
|
||||||
|
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_name", array("allowed_values"=>null, "extkey_attcode"=>"user_id", "target_attcode"=>"contactid", "is_null_allowed"=>true, "depends_on"=>array())));
|
||||||
|
MetaModel::Init_AddAttribute(new AttributeExternalField("contact_email", array("allowed_values"=>null, "extkey_attcode"=>"user_id", "target_attcode"=>"email", "is_null_allowed"=>true, "depends_on"=>array())));
|
||||||
|
|
||||||
|
// Display lists
|
||||||
|
MetaModel::Init_SetZListItems('details', array('date', 'user_id', 'contact_name', 'contact_email', 'userinfo', 'message')); // Attributes to be displayed for the complete details
|
||||||
|
MetaModel::Init_SetZListItems('list', array('date', 'user_id', 'contact_name', 'contact_email', 'userinfo')); // Attributes to be displayed for a list
|
||||||
|
// Search criteria
|
||||||
|
MetaModel::Init_SetZListItems('standard_search', array('date', 'user_id', 'contact_name', 'contact_email')); // Criteria of the std search form
|
||||||
|
// MetaModel::Init_SetZListItems('advanced_search', array('name')); // Criteria of the advanced search form
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user