Browse Source

- Create the admin account with the default language selected during the setup

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@566 a333f486-631f-4898-b8df-5754b55c2be0
dflaven 15 years ago
parent
commit
7abb5601b1

+ 1 - 1
addons/userrights/userrightsmatrix.class.inc.php

@@ -140,7 +140,7 @@ class UserRightsMatrix extends UserRightsAddOnAPI
 	);
 	);
 
 
 	// Installation: create the very first user
 	// Installation: create the very first user
-	public function CreateAdministrator($sAdminUser, $sAdminPwd)
+	public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage)
 	{
 	{
 		// Maybe we should check that no other user with userid == 0 exists
 		// Maybe we should check that no other user with userid == 0 exists
 		$oUser = new UserRightsMatrixUsers();
 		$oUser = new UserRightsMatrixUsers();

+ 1 - 1
addons/userrights/userrightsnull.class.inc.php

@@ -27,7 +27,7 @@
 class UserRightsNull extends UserRightsAddOnAPI
 class UserRightsNull extends UserRightsAddOnAPI
 {
 {
 	// Installation: create the very first user
 	// Installation: create the very first user
-	public function CreateAdministrator($sAdminUser, $sAdminPwd)
+	public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US')
 	{
 	{
 		return true;
 		return true;
 	}
 	}

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

@@ -707,7 +707,7 @@ class UserRightsProfile extends UserRightsAddOnAPI
 	);
 	);
 
 
 	// Installation: create the very first user
 	// Installation: create the very first user
-	public function CreateAdministrator($sAdminUser, $sAdminPwd)
+	public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US')
 	{
 	{
 		// Create a change to record the history of the User object
 		// Create a change to record the history of the User object
 		$oChange = MetaModel::NewObject("CMDBChange");
 		$oChange = MetaModel::NewObject("CMDBChange");
@@ -748,7 +748,7 @@ class UserRightsProfile extends UserRightsAddOnAPI
 		$oUser->Set('login', $sAdminUser);
 		$oUser->Set('login', $sAdminUser);
 		$oUser->Set('password', $sAdminPwd);
 		$oUser->Set('password', $sAdminPwd);
 		$oUser->Set('userid', $iContactId);
 		$oUser->Set('userid', $iContactId);
-		$oUser->Set('language', utils::GetConfig()->GetDefaultLanguage()); // Default language was chosen during the installation
+		$oUser->Set('language', $sLanguage); // Language was chosen during the installation
 		$iUserId = $oUser->DBInsertTrackedNoReload($oChange);
 		$iUserId = $oUser->DBInsertTrackedNoReload($oChange);
 		
 		
 		// Add this user to the very specific 'admin' profile
 		// Add this user to the very specific 'admin' profile

+ 3 - 3
core/userrights.class.inc.php

@@ -51,7 +51,7 @@ define('UR_ACTION_APPLICATION_DEFINED', 10000); // Application specific actions
 abstract class UserRightsAddOnAPI
 abstract class UserRightsAddOnAPI
 {
 {
 	abstract public function Setup(); // initial installation
 	abstract public function Setup(); // initial installation
-	abstract public function CreateAdministrator($sAdminUser, $sAdminPwd); // could be used during initial installation
+	abstract public function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US'); // could be used during initial installation
 
 
 	abstract public function Init(); // loads data (possible optimizations)
 	abstract public function Init(); // loads data (possible optimizations)
 	abstract public function CheckCredentials($sLogin, $sPassword); // returns the id of the user or false
 	abstract public function CheckCredentials($sLogin, $sPassword); // returns the id of the user or false
@@ -111,9 +111,9 @@ class UserRights
 	}
 	}
 
 
 	// Installation: create the very first user
 	// Installation: create the very first user
-	public static function CreateAdministrator($sAdminUser, $sAdminPwd)
+	public static function CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage = 'EN US')
 	{
 	{
-		return self::$m_oAddOn->CreateAdministrator($sAdminUser, $sAdminPwd);
+		return self::$m_oAddOn->CreateAdministrator($sAdminUser, $sAdminPwd, $sLanguage);
 	}
 	}
 	
 	
 	// Installation (e.g: give default values for users)
 	// Installation (e.g: give default values for users)

+ 3 - 2
setup/index.php

@@ -400,7 +400,7 @@ function CreateDatabaseStructure(SetupWebPage $oP, Config $oConfig, $sDBName, $s
  * Helper function to create and administrator account for iTop
  * Helper function to create and administrator account for iTop
  * @return boolean true on success, false otherwise 
  * @return boolean true on success, false otherwise 
  */
  */
-function CreateAdminAccount(SetupWebPage $oP, Config $oConfig, $sAdminUser, $sAdminPwd)
+function CreateAdminAccount(SetupWebPage $oP, Config $oConfig, $sAdminUser, $sAdminPwd, $sLanguage)
 {
 {
 	$oP->log('Info - CreateAdminAccount');
 	$oP->log('Info - CreateAdminAccount');
 	InitDataModel($oP, TMP_CONFIG_FILE, true);  // allow missing DB
 	InitDataModel($oP, TMP_CONFIG_FILE, true);  // allow missing DB
@@ -877,6 +877,7 @@ function SampleDataSelection(SetupWebPage $oP, $aParamValues, $iCurrentStep, Con
 	$oP->set_title("Application Initialization");
 	$oP->set_title("Application Initialization");
 	$sAdminUser = $aParamValues['auth_user'];
 	$sAdminUser = $aParamValues['auth_user'];
 	$sAdminPwd = $aParamValues['auth_pwd'];
 	$sAdminPwd = $aParamValues['auth_pwd'];
+	$sLanguage = $aParamValues['language'];
 	$oConfig->SetDefaultLanguage($aParamValues['language']);
 	$oConfig->SetDefaultLanguage($aParamValues['language']);
 	$oConfig->WriteToFile(TMP_CONFIG_FILE);
 	$oConfig->WriteToFile(TMP_CONFIG_FILE);
 
 
@@ -884,7 +885,7 @@ function SampleDataSelection(SetupWebPage $oP, $aParamValues, $iCurrentStep, Con
 	$oP->add("<input type=\"hidden\" name=\"operation\" value=\"$sNextOperation\">\n");
 	$oP->add("<input type=\"hidden\" name=\"operation\" value=\"$sNextOperation\">\n");
 	AddParamsToForm($oP, $aParamValues, array('sample_data'));
 	AddParamsToForm($oP, $aParamValues, array('sample_data'));
 	
 	
-	if (CreateAdminAccount($oP, $oConfig, $sAdminUser, $sAdminPwd) && UserRights::Setup())
+	if (CreateAdminAccount($oP, $oConfig, $sAdminUser, $sAdminPwd, $sLanguage) && UserRights::Setup())
 	{
 	{
 		$oP->add("<h2>Loading of sample data</h2>\n");
 		$oP->add("<h2>Loading of sample data</h2>\n");
 		$oP->p("<fieldset><legend> Do you want to load sample data into the database ? </legend>\n");
 		$oP->p("<fieldset><legend> Do you want to load sample data into the database ? </legend>\n");