Explorar o código

- Enhancement (Trac#189) first version of a (simple) End-Users portal.
- Fix for the appUserPreferences class

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

dflaven %!s(int64=14) %!d(string=hai) anos
pai
achega
a22878ab1e

+ 13 - 1
application/loginwebpage.class.inc.php

@@ -329,7 +329,14 @@ EOF
 		}
 	}
 	
-	static function DoLogin($bMustBeAdmin = false)
+	/**
+	 * Check if the user is already authentified, if yes, then performs some additional validations:
+	 * - if $bMustBeAdmin is true, then the user must be an administrator, otherwise an error is displayed
+	 * - if $bIsAllowedToPortalUsers is false and the user has only access to the portal, then the user is redirected to the portal
+	 * @param bool $bMustBeAdmin Whether or not the user must be an admin to access the current page
+	 * @param bool $bIsAllowedToPortalUsers Whether or not the current page is considered as part of the portal
+	 */
+	static function DoLogin($bMustBeAdmin = false, $bIsAllowedToPortalUsers = false)
 	{
 		$operation = utils::ReadParam('loginop', '');
 		session_start();
@@ -392,6 +399,11 @@ EOF
 			$oP->output();
 			exit;
 		}
+		elseif ( (!$bIsAllowedToPortalUsers) && (UserRights::IsPortalUser()))
+		{
+			// No rights to be here, redirect to the portal
+			header('Location: ../portal/index.php');
+		}
 	}
 
 } // End of class

+ 2 - 2
application/user.preferences.class.inc.php

@@ -125,14 +125,14 @@ class appUserPreferences extends DBObject
 	{
 		if (self::$oUserPrefs != null) return;
 		$oSearch = new DBObjectSearch('appUserPreferences');
-		$oSearch->AddCondition('userid', UserRights::GetUser(), '=');
+		$oSearch->AddCondition('userid', UserRights::GetUserId(), '=');
 		$oSet = new DBObjectSet($oSearch);
 		$oObj = $oSet->Fetch();
 		if ($oObj == null)
 		{
 			// No prefs (yet) for this user, create the object
 			$oObj = new appUserPreferences();
-			$oObj->Set('userid', UserRights::GetUser());
+			$oObj->Set('userid', UserRights::GetUserId());
 			$oObj->Set('preferences', array()); // Default preferences: an empty array
 			$oObj->DBInsert();
 		}

+ 2 - 0
core/userrights.class.inc.php

@@ -529,6 +529,8 @@ class UserRights
 		if (!self::CheckLogin()) return true;
 
 		if (self::IsAdministrator()) return true;
+		// Portal users actions are limited by the portal page...
+		if (self::IsPortalUser()) return true;
 
 		// this module is forbidden for non admins.... BUT I NEED IT HERE TO DETERMINE USER RIGHTS
 		if (MetaModel::HasCategory($sClass, 'addon/userrights')) return true;

+ 27 - 2
dictionaries/dictionary.itop.ui.php

@@ -39,7 +39,7 @@
 //
 
 Dict::Add('EN US', 'English', 'English', array(
-	'Class:AuditCategory' => 'AuditCategory',
+	'Class:AuditCategory' => 'Audit Category',
 	'Class:AuditCategory+' => 'A section inside the overall audit',
 	'Class:AuditCategory/Attribute:name' => 'Category Name',
 	'Class:AuditCategory/Attribute:name+' => 'Short name for this category',
@@ -47,6 +47,8 @@ Dict::Add('EN US', 'English', 'English', array(
 	'Class:AuditCategory/Attribute:description+' => 'Long description for this audit category',
 	'Class:AuditCategory/Attribute:definition_set' => 'Definition Set',
 	'Class:AuditCategory/Attribute:definition_set+' => 'OQL expression defining the set of objects to audit',
+	'Class:AuditCategory/Attribute:rules_list' => 'Audit Rules',
+	'Class:AuditCategory/Attribute:rules_list+' => 'Audit rules for this category',
 ));
 
 //
@@ -54,7 +56,7 @@ Dict::Add('EN US', 'English', 'English', array(
 //
 
 Dict::Add('EN US', 'English', 'English', array(
-	'Class:AuditRule' => 'AuditRule',
+	'Class:AuditRule' => 'Audit Rule',
 	'Class:AuditRule+' => 'A rule to check for a given Audit category',
 	'Class:AuditRule/Attribute:name' => 'Rule Name',
 	'Class:AuditRule/Attribute:name+' => 'Short name for this rule',
@@ -788,6 +790,10 @@ When associated with a trigger, each action is given an "order" number, specifyi
 	'UI:NotificationsMenu:Actions' => 'Actions',
 	'UI:NotificationsMenu:AvailableActions' => 'Available actions',
 	
+	'Menu:AuditCategories' => 'Audit Categories',
+	'Menu:AuditCategories+' => 'Audit Categories',
+	'Menu:Notifications:Title' => 'Audit Categories',
+	
 	'Menu:RunQueriesMenu' => 'Run Queries',
 	'Menu:RunQueriesMenu+' => 'Run any query',
 	
@@ -829,6 +835,25 @@ When associated with a trigger, each action is given an "order" number, specifyi
 	'UI:PasswordConfirm' => '(Confirm)',
 	'UI:BeforeAdding_Class_ObjectsSaveThisObject' => 'Before adding more %1$s objects, save this object.',
 	'UI:DisplayThisMessageAtStartup' => 'Display this message at startup',
+
+	'Portal:Title' => 'iTop user portal',
+	'Portal:Refresh' => 'Refresh',
+	'Portal:Back' => 'Back',
+	'Portal:CreateNewRequest' => 'Create a new request',
+	'Portal:ChangeMyPassword' => 'Change my password',
+	'Portal:Disconnect' => 'Disconnect',
+	'Portal:OpenRequests' => 'My open requests',
+	'Portal:ResolvedRequests'  => 'My resolved requests',
+	'Portal:SelectService' => 'Select a service from the catalog:',
+	'Portal:PleaseSelectOneService' => 'Please select one service',
+	'Portal:SelectSubcategoryFrom_Service' => 'Select a sub-category for the service %1$s:',
+	'Portal:PleaseSelectAServiceSubCategory' => 'Please select one sub-category',
+	'Portal:DescriptionOfTheRequest' => 'Enter the description of your request:',
+	'Portal:TitleRequestDetailsFor_Request' => 'Details for request %1$s:',
+	'Portal:NoOpenRequest' => 'No request in this category.',
+	'Portal:Button:CloseTicket' => 'Close this ticket',
+	'Portal:EnterYourCommentsOnTicket' => 'Enter your comments about the resolution of this ticket:',
+	'Portal:ErrorNoContactForThisUser' => 'Error: the current user is not associated with a Contact/Person. Please contact your administrator.',
 ));
 
 

+ 24 - 0
dictionaries/fr.dictionary.itop.ui.php

@@ -47,6 +47,8 @@ Dict::Add('FR FR', 'French', 'Français', array(
 	'Class:AuditCategory/Attribute:description+' => 'Description',
 	'Class:AuditCategory/Attribute:definition_set' => 'Ensemble de définition',
 	'Class:AuditCategory/Attribute:definition_set+' => 'Expression OQL qui défini le périmètre d\'application de l\'audit',
+	'Class:AuditCategory/Attribute:rules_list' => 'Règles d\'audit',
+	'Class:AuditCategory/Attribute:rules_list+' => 'Règles d\'audit pour cette catégorie',
 ));
 
 //
@@ -802,6 +804,9 @@ Lors de l\'association à un déclencheur, on attribue à chaque action un numé
 	'UI:NotificationsMenu:Actions' => 'Actions',
 	'UI:NotificationsMenu:AvailableActions' => 'Actions existantes',
 
+	'Menu:AuditCategories' => 'Catégories d\'audit',
+	'Menu:AuditCategories+' => 'Catégories d\'audit',
+	'Menu:Notifications:Title' => 'Catégories d\'audit',
 	
 	'Menu:RunQueriesMenu' => 'Requêtes OQL',
 	'Menu:RunQueriesMenu+' => 'Executer une requête OQL',
@@ -840,6 +845,25 @@ Lors de l\'association à un déclencheur, on attribue à chaque action un numé
 	'UI:PasswordConfirm' => '(Confirmer)',
 	'UI:BeforeAdding_Class_ObjectsSaveThisObject' => 'Enregistrez l\'objet courant avant de créer de nouveaux éléments de type %1$s.',
 	'UI:DisplayThisMessageAtStartup' => 'Afficher ce message au démarrage',
+
+	'Portal:Title' => 'Portail utilisateur iTop',
+	'Portal:Refresh' => 'Rafraîchir',
+	'Portal:Back' => 'Retour',
+	'Portal:CreateNewRequest' => 'Créer une nouvelle requête',
+	'Portal:ChangeMyPassword' => 'Changer mon mot de passe',
+	'Portal:Disconnect' => 'Déconnexion',
+	'Portal:OpenRequests' => 'Mes requêtes en cours',
+	'Portal:ResolvedRequests'  => 'Mes requêtes résolues',
+	'Portal:SelectService' => 'Choisissez un service dans le catalogue:',
+	'Portal:PleaseSelectOneService' => 'Veuillez choisir un service',
+	'Portal:SelectSubcategoryFrom_Service' => 'Choisissez une sous-catégorie du service %1$s:',
+	'Portal:PleaseSelectAServiceSubCategory' => 'Veuillez choisir une sous-catégorie', 
+	'Portal:DescriptionOfTheRequest' => 'Entrez la description de votre requête:',
+	'Portal:TitleRequestDetailsFor_Request' => 'Détails de votre requête %1$s:',
+	'Portal:NoOpenRequest' => 'Aucune requête.',
+	'Portal:Button:CloseTicket' => 'Clôre cette requête',
+	'Portal:EnterYourCommentsOnTicket' => 'Vos commentaires à propos du traitement de cette requête:',
+	'Portal:ErrorNoContactForThisUser' => 'Erreur: l\'utilisateur courant n\'est pas associé à une Personne/Contact. Contactez votre administrateur.',
 ));
 
 ?>

BIN=BIN
images/back.png


BIN=BIN
images/logoff.png


BIN=BIN
images/password.png


BIN=BIN
images/refresh.png


+ 1 - 1
pages/ajax.render.php

@@ -33,7 +33,7 @@ require_once('../application/startup.inc.php');
 require_once('../application/user.preferences.class.inc.php');
 
 require_once('../application/loginwebpage.class.inc.php');
-LoginWebPage::DoLogin(); // Check user rights and prompt if needed
+LoginWebPage::DoLogin(false /* bMustBeAdmin */, true /* IsAllowedToPortalUsers */); // Check user rights and prompt if needed
 
 $oPage = new ajax_page("");
 $oPage->no_cache();

+ 10 - 1
pages/logoff.php

@@ -31,7 +31,16 @@ $sVersionShort = Dict::Format('UI:iTopVersion:Short', ITOP_VERSION);
 $oPage->add("<div id=\"login-logo\"><a href=\"http://www.combodo.com/itop\"><img title=\"$sVersionShort\" src=\"../images/itop-logo.png\"></a></div>\n");
 $oPage->add("<div id=\"login\">\n");
 $oPage->add("<h1>".Dict::S('UI:LogOff:ThankYou')."</h1>\n");
-$oPage->add("<p><a href=\"../pages/UI.php\">".Dict::S('UI:LogOff:ClickHereToLoginAgain')."</a></p>");
+$bPortal = utils::ReadParam('portal', false);
+if ($bPortal)
+{
+	$sUrl = '../portal/';
+}
+else
+{
+	$sUrl = '../pages/UI.php';
+}
+$oPage->add("<p><a href=\"$sUrl\">".Dict::S('UI:LogOff:ClickHereToLoginAgain')."</a></p>");
 $oPage->add("</div>\n");
 $oPage->output();
 ?>