- Enhancement (Trac#189) first version of a (simple) End-Users portal.

- Fix for the appUserPreferences class

SVN:trunk[806]
This commit is contained in:
Denis Flaven
2010-09-10 10:10:57 +00:00
parent 7312d977f3
commit 463e7b5413
11 changed files with 79 additions and 7 deletions

View File

@@ -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', ''); $operation = utils::ReadParam('loginop', '');
session_start(); session_start();
@@ -392,6 +399,11 @@ EOF
$oP->output(); $oP->output();
exit; exit;
} }
elseif ( (!$bIsAllowedToPortalUsers) && (UserRights::IsPortalUser()))
{
// No rights to be here, redirect to the portal
header('Location: ../portal/index.php');
}
} }
} // End of class } // End of class

View File

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

View File

@@ -529,6 +529,8 @@ class UserRights
if (!self::CheckLogin()) return true; if (!self::CheckLogin()) return true;
if (self::IsAdministrator()) 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 // this module is forbidden for non admins.... BUT I NEED IT HERE TO DETERMINE USER RIGHTS
if (MetaModel::HasCategory($sClass, 'addon/userrights')) return true; if (MetaModel::HasCategory($sClass, 'addon/userrights')) return true;

View File

@@ -39,7 +39,7 @@
// //
Dict::Add('EN US', 'English', 'English', array( Dict::Add('EN US', 'English', 'English', array(
'Class:AuditCategory' => 'AuditCategory', 'Class:AuditCategory' => 'Audit Category',
'Class:AuditCategory+' => 'A section inside the overall audit', 'Class:AuditCategory+' => 'A section inside the overall audit',
'Class:AuditCategory/Attribute:name' => 'Category Name', 'Class:AuditCategory/Attribute:name' => 'Category Name',
'Class:AuditCategory/Attribute:name+' => 'Short name for this category', '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:description+' => 'Long description for this audit category',
'Class:AuditCategory/Attribute:definition_set' => 'Definition Set', 'Class:AuditCategory/Attribute:definition_set' => 'Definition Set',
'Class:AuditCategory/Attribute:definition_set+' => 'OQL expression defining the set of objects to audit', '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( 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+' => 'A rule to check for a given Audit category',
'Class:AuditRule/Attribute:name' => 'Rule Name', 'Class:AuditRule/Attribute:name' => 'Rule Name',
'Class:AuditRule/Attribute:name+' => 'Short name for this rule', '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:Actions' => 'Actions',
'UI:NotificationsMenu:AvailableActions' => 'Available 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 Queries',
'Menu:RunQueriesMenu+' => 'Run any query', '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:PasswordConfirm' => '(Confirm)',
'UI:BeforeAdding_Class_ObjectsSaveThisObject' => 'Before adding more %1$s objects, save this object.', 'UI:BeforeAdding_Class_ObjectsSaveThisObject' => 'Before adding more %1$s objects, save this object.',
'UI:DisplayThisMessageAtStartup' => 'Display this message at startup', '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.',
)); ));

View File

@@ -47,6 +47,8 @@ Dict::Add('FR FR', 'French', 'Français', array(
'Class:AuditCategory/Attribute:description+' => 'Description', 'Class:AuditCategory/Attribute:description+' => 'Description',
'Class:AuditCategory/Attribute:definition_set' => 'Ensemble de définition', '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: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:Actions' => 'Actions',
'UI:NotificationsMenu:AvailableActions' => 'Actions existantes', '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' => 'Requêtes OQL',
'Menu:RunQueriesMenu+' => 'Executer une requête 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:PasswordConfirm' => '(Confirmer)',
'UI:BeforeAdding_Class_ObjectsSaveThisObject' => 'Enregistrez l\'objet courant avant de créer de nouveaux éléments de type %1$s.', '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', '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
images/back.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.6 KiB

BIN
images/logoff.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
images/password.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

BIN
images/refresh.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@@ -33,7 +33,7 @@ require_once('../application/startup.inc.php');
require_once('../application/user.preferences.class.inc.php'); require_once('../application/user.preferences.class.inc.php');
require_once('../application/loginwebpage.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 = new ajax_page("");
$oPage->no_cache(); $oPage->no_cache();

View File

@@ -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-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("<div id=\"login\">\n");
$oPage->add("<h1>".Dict::S('UI:LogOff:ThankYou')."</h1>\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->add("</div>\n");
$oPage->output(); $oPage->output();
?> ?>