* @author Romain Quetiez * @author Denis Flaven * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL */ class UserLocal extends UserInternal { public static function Init() { $aParams = array ( "category" => "addon/authentication", "key_type" => "autoincrement", "name_attcode" => "login", "state_attcode" => "", "reconc_keys" => array(), "db_table" => "priv_user_local", "db_key_field" => "id", "db_finalclass_field" => "", "display_template" => "", ); MetaModel::Init_Params($aParams); MetaModel::Init_InheritAttributes(); MetaModel::Init_AddAttribute(new AttributeOneWayPassword("password", array("allowed_values"=>null, "sql"=>"pwd", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array()))); // Display lists MetaModel::Init_SetZListItems('details', array('contactid', 'first_name', 'email', 'login', 'password', 'language', 'profile_list', 'allowed_org_list')); // Attributes to be displayed for the complete details MetaModel::Init_SetZListItems('list', array('first_name', 'last_name', 'login')); // Attributes to be displayed for a list // Search criteria MetaModel::Init_SetZListItems('standard_search', array('login', 'contactid')); // Criteria of the std search form MetaModel::Init_SetZListItems('advanced_search', array('login', 'contactid')); // Criteria of the advanced search form } public function CheckCredentials($sPassword) { $oPassword = $this->Get('password'); // ormPassword object // Cannot compare directly the values since they are hashed, so // Let's ask the password to compare the hashed values if ($oPassword->CheckPassword($sPassword)) { return true; } return false; } public function TrustWebServerContext() { return true; } public function CanChangePassword() { // For now everyone can change their password.. return true; } public function CanLogOff() { // Internal authentication allows everybody to log off return true; } public function ChangePassword($sOldPassword, $sNewPassword) { $oPassword = $this->Get('password'); // ormPassword object // Cannot compare directly the values since they are hashed, so // Let's ask the password to compare the hashed values if ($oPassword->CheckPassword($sOldPassword)) { $this->Set('password', $sNewPassword); $oChange = MetaModel::NewObject("CMDBChange"); $oChange->Set("date", time()); $sUserString = CMDBChange::GetCurrentUserName(); $oChange->Set("userinfo", $sUserString); $oChange->DBInsert(); $this->DBUpdateTracked($oChange, true); return true; } return false; } } ?>