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

- Fixed a typo
- New type of attributes that determines automatically the available languages (i.e. loaded dictionaries) for the application

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@446 a333f486-631f-4898-b8df-5754b55c2be0

dflaven пре 15 година
родитељ
комит
a62c8fabf1
2 измењених фајлова са 34 додато и 2 уклоњено
  1. 3 2
      addons/userrights/userrightsprofile.class.inc.php
  2. 31 0
      core/attributedef.class.inc.php

+ 3 - 2
addons/userrights/userrightsprofile.class.inc.php

@@ -78,7 +78,8 @@ class URP_Users extends UserRightsBaseClass
 		MetaModel::Init_AddAttribute(new AttributeString("login", array("allowed_values"=>null, "sql"=>"login", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
 		MetaModel::Init_AddAttribute(new AttributePassword("password", array("allowed_values"=>null, "sql"=>"pwd", "default_value"=>null, "is_null_allowed"=>false, "depends_on"=>array())));
 
-		MetaModel::Init_AddAttribute(new AttributeEnum("language", array("allowed_values"=>new ValueSetEnum('EN US,FR FR'), "sql"=>"language", "default_value"=>"EN US", "is_null_allowed"=>false, "depends_on"=>array())));
+		//MetaModel::Init_AddAttribute(new AttributeString("language", array("allowed_values"=>array('EN US,FR FR'), "sql"=>"language", "default_value"=>"EN US", "is_null_allowed"=>false, "depends_on"=>array())));
+		MetaModel::Init_AddAttribute(new AttributeApplicationLanguage("language", array("sql"=>"language", "default_value"=>"EN US", "is_null_allowed"=>false, "depends_on"=>array())));
 
 		MetaModel::Init_AddAttribute(new AttributeLinkedSetIndirect("profiles", array("linked_class"=>"URP_UserProfile", "ext_key_to_me"=>"userid", "ext_key_to_remote"=>"profileid", "allowed_values"=>null, "count_min"=>1, "count_max"=>0, "depends_on"=>array())));
 
@@ -438,7 +439,7 @@ class URP_UserProfile extends UserRightsBaseClass
 
 	public function GetName()
 	{
-		return Dict::Format('UI:USerManagement:LinkBetween_User_And_Profile');
+		return Dict::Format('UI:UserManagement:LinkBetween_User_And_Profile');
 	}
 }
 

+ 31 - 0
core/attributedef.class.inc.php

@@ -681,6 +681,37 @@ class AttributeClass extends AttributeString
 }
 
 /**
+ * An attibute that matches one of the language codes availables in the dictionnary 
+ *
+ * @package     iTopORM
+ */
+class AttributeApplicationLanguage extends AttributeString
+{
+	static protected function ListExpectedParams()
+	{
+		return parent::ListExpectedParams();
+	}
+
+	public function __construct($sCode, $aParams)
+	{
+		$this->m_sCode = $sCode;
+		$aAvailableLanguages = Dict::GetLanguages();
+		$aLanguageCodes = array();
+		foreach($aAvailableLanguages as $sLangCode => $aInfo)
+		{
+			$aLanguageCodes[$sLangCode] = $aInfo['description'].' ('.$aInfo['localized_description'].')';
+		}
+		$aParams["allowed_values"] = new ValueSetEnum($aLanguageCodes);
+		parent::__construct($sCode, $aParams);
+	}
+
+	public function RequiresIndex()
+	{
+		return true;
+	}
+}
+
+/**
  * The attribute dedicated to the finalclass automatic attribute 
  *
  * @package     iTopORM