Преглед изворни кода

Aligned the authentication module with the one of 2.x, to enable the feature "Forgot password" for legacy data models

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3111 a333f486-631f-4898-b8df-5754b55c2be0
romainq пре 11 година
родитељ
комит
ec46295a9d

+ 4 - 23
datamodels/1.x/authent-local/de.dict.authent-local.php

@@ -16,36 +16,17 @@
 //   You should have received a copy of the GNU Affero General Public License
 //   along with iTop. If not, see <http://www.gnu.org/licenses/>
 
-
 /**
- * Localized data
- *
- * @author      Stephan Rosenke <stephan.rosenke@itomig.de>
+ * @author	Stephan Rosenke <stephan.rosenke@itomig.de>
+ * @author 	David M. Gümbel <david.guembel@itomig.de>
  * @copyright   Copyright (C) 2010-2012 Combodo SARL
- * @license     http://opensource.org/licenses/AGPL-3.0
+ * @licence	http://opensource.org/licenses/AGPL-3.0
  */
 
-// Dictionnay conventions
-// Class:<class_name>
-// Class:<class_name>+
-// Class:<class_name>/Attribute:<attribute_code>
-// Class:<class_name>/Attribute:<attribute_code>+
-// Class:<class_name>/Attribute:<attribute_code>/Value:<value>
-// Class:<class_name>/Attribute:<attribute_code>/Value:<value>+
-// Class:<class_name>/Stimulus:<stimulus_code>
-// Class:<class_name>/Stimulus:<stimulus_code>+
-
-//
-// Class: UserLocal
-//
-
 Dict::Add('DE DE', 'German', 'Deutsch', array(
 	'Class:UserLocal' => 'iTop-Benutzer',
 	'Class:UserLocal+' => 'Benutzer von iTop authentifiziert',
 	'Class:UserLocal/Attribute:password' => 'Passwort',
 	'Class:UserLocal/Attribute:password+' => 'Benutzerpasswort',
 ));
-
-
-
-?>
+?>

+ 51 - 0
datamodels/1.x/authent-local/es_cr.dict.authent-local.php

@@ -0,0 +1,51 @@
+<?php
+// Copyright (C) 2010-2013 Combodo SARL
+//
+//   This file is part of iTop.
+//
+//   iTop is free software; you can redistribute it and/or modify	
+//   it under the terms of the GNU Affero General Public License as published by
+//   the Free Software Foundation, either version 3 of the License, or
+//   (at your option) any later version.
+//
+//   iTop is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//   GNU Affero General Public License for more details.
+//
+//   You should have received a copy of the GNU Affero General Public License
+//   along with iTop. If not, see <http://www.gnu.org/licenses/>
+
+
+/**
+ * Localized data
+ *
+ * @copyright   Copyright (C) 2010-2013 Combodo SARL
+ * @license     http://opensource.org/licenses/AGPL-3.0
+ * @traductor   Miguel Turrubiates <miguel_tf@yahoo.com> 
+ */
+
+// Dictionnay conventions
+// Class:<class_name>
+// Class:<class_name>+
+// Class:<class_name>/Attribute:<attribute_code>
+// Class:<class_name>/Attribute:<attribute_code>+
+// Class:<class_name>/Attribute:<attribute_code>/Value:<value>
+// Class:<class_name>/Attribute:<attribute_code>/Value:<value>+
+// Class:<class_name>/Stimulus:<stimulus_code>
+// Class:<class_name>/Stimulus:<stimulus_code>+
+
+//
+// Class: UserLocal
+//
+
+Dict::Add('ES CR', 'Spanish', 'Español, Castellano', array(
+	'Class:UserLocal' => 'Usuario de iTop',
+	'Class:UserLocal+' => 'Usuario Autenticado vía iTop',
+	'Class:UserLocal/Attribute:password' => 'Contrase&ntilde;a',
+	'Class:UserLocal/Attribute:password+' => 'Contrase&ntilde;a',
+));
+
+
+
+?>

+ 32 - 51
datamodels/1.x/authent-local/ja.dict.authent-local.php

@@ -1,51 +1,32 @@
-<?php
-// Copyright (C) 2010-2012 Combodo SARL
-//
-//   This file is part of iTop.
-//
-//   iTop is free software; you can redistribute it and/or modify	
-//   it under the terms of the GNU Affero General Public License as published by
-//   the Free Software Foundation, either version 3 of the License, or
-//   (at your option) any later version.
-//
-//   iTop is distributed in the hope that it will be useful,
-//   but WITHOUT ANY WARRANTY; without even the implied warranty of
-//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-//   GNU Affero General Public License for more details.
-//
-//   You should have received a copy of the GNU Affero General Public License
-//   along with iTop. If not, see <http://www.gnu.org/licenses/>
-
-
-/**
- * Localized data
- *
- * @author      Hirofumi Kosaka <kosaka@rworks.jp>
- * @copyright   Copyright (C) 2010-2012 Combodo SARL
- * @license     http://opensource.org/licenses/AGPL-3.0
- */
-
-// Dictionnay conventions
-// Class:<class_name>
-// Class:<class_name>+
-// Class:<class_name>/Attribute:<attribute_code>
-// Class:<class_name>/Attribute:<attribute_code>+
-// Class:<class_name>/Attribute:<attribute_code>/Value:<value>
-// Class:<class_name>/Attribute:<attribute_code>/Value:<value>+
-// Class:<class_name>/Stimulus:<stimulus_code>
-// Class:<class_name>/Stimulus:<stimulus_code>+
-
-//
-// Class: UserLocal
-//
-
-Dict::Add('JA JP', 'Japanese', '日本語', array(
-	'Class:UserLocal' => 'iTopユーザー',		 // 'iTop user',
-	'Class:UserLocal+' => 'iTopローカル認証ユーザー',	 // 'User authentified by iTop',
-	'Class:UserLocal/Attribute:password' => 'パスワード',   //  'Password',
-	'Class:UserLocal/Attribute:password+' => '認証文字列', // 'user authentication string',
-));
-
-
-
-?>
+<?php
+// Copyright (C) 2010-2012 Combodo SARL
+//
+//   This file is part of iTop.
+//
+//   iTop is free software; you can redistribute it and/or modify	
+//   it under the terms of the GNU Affero General Public License as published by
+//   the Free Software Foundation, either version 3 of the License, or
+//   (at your option) any later version.
+//
+//   iTop is distributed in the hope that it will be useful,
+//   but WITHOUT ANY WARRANTY; without even the implied warranty of
+//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+//   GNU Affero General Public License for more details.
+//
+//   You should have received a copy of the GNU Affero General Public License
+//   along with iTop. If not, see <http://www.gnu.org/licenses/>
+
+/**
+ * @author	Hirofumi Kosaka <kosaka@rworks.jp>
+
+ * @copyright   Copyright (C) 2010-2012 Combodo SARL
+ * @licence	http://opensource.org/licenses/AGPL-3.0
+ */
+
+Dict::Add('JA JP', 'Japanese', '日本語', array(
+	'Class:UserLocal' => 'iTopユーザー',
+	'Class:UserLocal+' => 'iTopローカル認証ユーザー',
+	'Class:UserLocal/Attribute:password' => 'パスワード',
+	'Class:UserLocal/Attribute:password+' => '認証文字列',
+));
+?>

+ 42 - 10
datamodels/1.x/authent-local/model.authent-local.php

@@ -74,7 +74,10 @@ class UserLocal extends UserInternal
 
 	public function CanChangePassword()
 	{
-		// For now everyone can change their password..
+		if (MetaModel::GetConfig()->Get('demo_mode'))
+		{
+			return false;
+		}
 		return true;
 	}
 
@@ -85,18 +88,47 @@ class UserLocal extends UserInternal
 		// 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);
+			$this->SetPassword($sNewPassword);
 			return true;
 		}
 		return false;
 	}
-}
 
+	/**
+	 * Use with care!
+	 */	 	
+	public function SetPassword($sNewPassword)
+	{
+		$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);
+	}
+
+	/**
+	 * Returns the set of flags (OPT_ATT_HIDDEN, OPT_ATT_READONLY, OPT_ATT_MANDATORY...)
+	 * for the given attribute in the current state of the object
+	 * @param $sAttCode string $sAttCode The code of the attribute
+	 * @param $aReasons array To store the reasons why the attribute is read-only (info about the synchro replicas)
+	 * @param $sTargetState string The target state in which to evalutate the flags, if empty the current state will be used
+	 * @return integer Flags: the binary combination of the flags applicable to this attribute
+	 */	 	  	 	
+	public function GetAttributeFlags($sAttCode, &$aReasons = array(), $sTargetState = '')
+	{
+		$iFlags = parent::GetAttributeFlags($sAttCode, $aReasons, $sTargetState);
+		if (MetaModel::GetConfig()->Get('demo_mode'))
+		{
+			if (strpos('contactid,login,language,password,profile_list,allowed_org_list', $sAttCode) !== false)
+			{
+				// contactid and allowed_org_list are disabled to make sure the portal remains accessible 
+				$aReasons[] = 'Sorry, this attribute is read-only in the demonstration mode!';
+				$iFlags |= OPT_ATT_READONLY;
+			}
+		}
+		return $iFlags;
+	}
+}
 
-?>

+ 4 - 20
datamodels/1.x/authent-local/ru.dict.authent-local.php

@@ -17,32 +17,16 @@
 //   along with iTop. If not, see <http://www.gnu.org/licenses/>
 
 /**
- * Localized data
- *
- * @author      Vladimir Shilov <shilow@ukr.net>
+ * @author	Vladimir Shilov <shilow@ukr.net>
+
  * @copyright   Copyright (C) 2010-2012 Combodo SARL
- * @license     http://opensource.org/licenses/AGPL-3.0
+ * @licence	http://opensource.org/licenses/AGPL-3.0
  */
 
-// Dictionnay conventions
-// Class:<class_name>
-// Class:<class_name>+
-// Class:<class_name>/Attribute:<attribute_code>
-// Class:<class_name>/Attribute:<attribute_code>+
-// Class:<class_name>/Attribute:<attribute_code>/Value:<value>
-// Class:<class_name>/Attribute:<attribute_code>/Value:<value>+
-// Class:<class_name>/Stimulus:<stimulus_code>
-// Class:<class_name>/Stimulus:<stimulus_code>+
-
-//
-// Class: UserLocal
-//
-
 Dict::Add('RU RU', 'Russian', 'Русский', array(
 	'Class:UserLocal' => 'Пользователь iTop',
 	'Class:UserLocal+' => 'Пользователь аутентифицированный iTop',
 	'Class:UserLocal/Attribute:password' => 'Пароль',
 	'Class:UserLocal/Attribute:password+' => 'строка аутентификации пользователя',
 ));
-
-?>
+?>