Finalization of the user management by profile (UI to manage the accounts), and some unrelated changes:

- Using class labels in the UI
- Data model: you may specify a set of allowed values from a query (see caller_id in bizIncident class), still not 100% used in the UI but does not generate any error
- Data model: you may specify a password field (AttributePassword replacing AttributeString)
- Setup: calling UserRight::Setup() right after calling UserRight::CreateAdministrator()
- Setup: administrator account created with "my organization" and a dedicated contact
- Menus: optimized the load of std menus (queries written in OQL to get the benefit of the query cache)
- Menus: admin tools, seen only by people having the "admin" profile
- Object edition: fixed bug with the display of N-N links in the form

SVN:code[110]
This commit is contained in:
Romain Quetiez
2009-09-04 15:22:40 +00:00
parent a096d46a59
commit 6c286bf952
36 changed files with 3112 additions and 2524 deletions

View File

@@ -96,7 +96,7 @@ EOF;
$bChildItem = utils::ReadPostedParam('child_item', false);
$oMenuNode->Set('label', $sDescription);
$oMenuNode->Set('name', $sLabel);
$oMenuNode->Set('icon_path', '/images/std_view.gif');
$oMenuNode->Set('icon_path', '../images/std_view.gif');
$oMenuNode->Set('template', $sMenuNodeContent);
$oMenuNode->Set('hyperlink', 'UI.php');
$oMenuNode->Set('type', 'user');

View File

@@ -84,6 +84,8 @@ switch($operation)
}
foreach($oWizardHelper->GetFieldsForAllowedValues() as $sAttCode)
{
// MetaModel::GetAllowedValues_att() => array(id => value)
// Improvement: what if the list is too long?
$oWizardHelper->SetAllowedValuesHtml($sAttCode, "Possible values ($sAttCode)");
}
$oPage->add($oWizardHelper->ToJSON());
@@ -192,7 +194,9 @@ switch($operation)
$sClass = utils::ReadParam('sclass', 'bizContact');
$sJSONSet = stripslashes(utils::ReadParam('sset', ''));
$sExtKeyToMe = utils::ReadParam('sextkeytome', '');
UILinksWidget::RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe);
$sExtKeyToRemote = utils::ReadParam('sextkeytoremote', '');
$iObjectId = utils::ReadParam('id', -1);
UILinksWidget::RenderSet($oPage, $sClass, $sJSONSet, $sExtKeyToMe, $sExtKeyToRemote, $iObjectId);
break;
case 'autocomplete':
@@ -208,6 +212,7 @@ switch($operation)
if ($oThis = MetaModel::GetObject($sClass, $key))
{
$aArgs['*this*'] = $oThis;
$aArgs['this'] = $oThis;
}
}
$aAllowedValues = MetaModel::GetAllowedValues_att($sClass, $sAttCode, $aArgs, $sName);

View File

@@ -87,7 +87,7 @@ function DisplayDetails(web_page $oPage, $sClassName, $sKey)
global $oContext;
//$oObj = MetaModel::GetObject($sClassName, $sKey);
$oObj = $oContext->GetObject($sClassName, $sKey);
$oPage->p("Details of ".get_class($oObj)." - $sKey");
$oPage->p("Details of ".MetaModel::GetName($sClassName)." - $sKey");
$oObj->DisplayDetails($oPage);
@@ -140,7 +140,7 @@ function DisplayChangesLog(web_page $oPage, $sClassName, $sKey)
global $oContext;
//$oObj = MetaModel::GetObject($sClassName, $sKey);
$oObj = $oContext->GetObject($sClassName, $sKey);
$oPage->p("Changes log for ".get_class($oObj)." - $sKey");
$oPage->p("Changes log for ".MetaModel::GetName($sClassName)." - $sKey");
$oObj->DisplayChangesLog($oPage);
@@ -219,7 +219,7 @@ function DisplayEditForm(web_page $oPage, $sClassName, $sKey)
$oPage->p("You are not allowed to edit this object.");
return;
}
$oPage->p("Edition of ".get_class($oObj)." - $sKey\n");
$oPage->p("Edition of ".MetaModel::GetName($sClassName)." - $sKey\n");
$aDetails = array();
$oPage->add("<form method=\"post\">\n");
@@ -332,7 +332,7 @@ function UpdateObject(web_page $oPage, $sClassName, $sKey, $aAttributes)
$iChangeId = $oMyChange->DBInsert();
$oObj->DBUpdateTracked($oMyChange);
$oPage->p(get_class($oObj)." updated\n");
$oPage->p(MetaModel::GetName($sClassName)." updated\n");
}
else
{
@@ -342,13 +342,14 @@ function UpdateObject(web_page $oPage, $sClassName, $sKey, $aAttributes)
// By Rom
// $oObj->DisplayDetails($oPage);
// replaced by...
DisplayDetails($oPage, get_class($oObj), $oObj->GetKey());
DisplayDetails($oPage, $sClassName, $sKey);
$oPage->p("<a href=\"\">Return to main page</a>");
}
function DeleteObject(web_page $oPage, $sClassName, $sKey)
{
global $oContext;
$sClassLabel = MetaModel::GetName($sClassName);
//$oObj = MetaModel::GetObject($sClassName, $sKey);
$oObj = $oContext->GetObject($sClassName, $sKey);
if ($oObj == null)
@@ -356,7 +357,7 @@ function DeleteObject(web_page $oPage, $sClassName, $sKey)
$oPage->p("You are not allowed to delete this object.");
return;
}
$oPage->p("Deletion of $sClassName - $sKey");
$oPage->p("Deletion of $sClassLabel - $sKey");
if ($oObj->CheckToDelete())
{
@@ -368,13 +369,13 @@ function DeleteObject(web_page $oPage, $sClassName, $sKey)
$iChangeId = $oMyChange->DBInsert();
$oObj->DBDeleteTracked($oMyChange);
$oPage->p("$sClassName deleted\n");
$oPage->p("$sClassLabel deleted\n");
}
else
{
$oPage->p("<strong>Error: object can not be deleted!</strong>\n");
// By Rom
DisplayDetails($oPage, get_class($oObj), $oObj->GetKey());
DisplayDetails($oPage, $sClassName, $sKey);
}
$oPage->p("<a href=\"\">Return to main page</a>");
}
@@ -382,7 +383,8 @@ function DeleteObject(web_page $oPage, $sClassName, $sKey)
function CreateObject(web_page $oPage, $sClassName, $aAttributes)
{
$oObj = MetaModel::NewObject($sClassName);
$oPage->p("Creation of ".get_class($oObj)." object.");
$sClassLabel = MetaModel::GetName(get_class($oObj));
$oPage->p("Creation of $sClassLabel object.");
foreach(MetaModel::ListAttributeDefs(get_class($oObj)) as $sAttCode=>$oAttDef)
{
@@ -401,7 +403,7 @@ function CreateObject(web_page $oPage, $sClassName, $aAttributes)
$iChangeId = $oMyChange->DBInsert();
$oObj->DBInsertTracked($oMyChange);
$oPage->p(get_class($oObj)." created\n");
$oPage->p($sClassLabel." created\n");
// By Rom
// $oObj->DisplayDetails($oPage);
@@ -419,6 +421,7 @@ function CreateObject(web_page $oPage, $sClassName, $aAttributes)
function AddLinks($oPage, $sClassName, $sKey, $sLinkClass, $sExtKeyToMe, $sExtKeyToPartner, $sFilter)
{
global $oContext;
$sClassLabel = MetaModel::GetName($sClassName);
//$oObj = MetaModel::GetObject($sClassName, $sKey);
$oObj = $oContext->GetObject($sClassName, $sKey);
if ($oObj == null)
@@ -426,7 +429,7 @@ function AddLinks($oPage, $sClassName, $sKey, $sLinkClass, $sExtKeyToMe, $sExtKe
$oPage->p("You are not allowed to modify (create links on) this object.");
return;
}
$oPage->p("Creating links for $sClassName - $sKey");
$oPage->p("Creating links for $sClassLabel - $sKey");
$oFilter = CMDBSearchFilter::unserialize($sFilter);
$oPage->p("Linking to ".$oFilter->__DescribeHTML());
@@ -447,7 +450,7 @@ function AddLinks($oPage, $sClassName, $sKey, $sLinkClass, $sExtKeyToMe, $sExtKe
$iChangeId = $oMyChange->DBInsert();
$oNewLink->DBInsertTracked($oMyChange);
$oPage->p(get_class($oNewLink)." created\n");
$oPage->p(MetaModel::GetName($sLinkClass)." created\n");
}
else
{
@@ -595,19 +598,21 @@ switch($operation)
$oPage->add("</ul>\n");
foreach( $aTopLevelClasses as $sClassName)
{
$sClassLabel = MetaModel::GetName($sClassName);
$oPage->add("<div id=\"tab_$sClassName\">");
if (count(MetaModel::GetSubclasses($sClassName)) > 0)
{
$sActiveSubclass = ReadParam('subclassname', '');
foreach(MetaModel::GetSubclasses($sClassName) as $sSubclassName)
{
$sSubclassLabel = MetaModel::GetName($sSubclassName);
//$oSearchFilter = new CMDBSearchFilter($sSubclassName);
$oSearchFilter = $oContext->NewFilter($sSubclassName);
$oSearchFilter ->AddCondition('org_id', $sCurrentOrganization, '=');
$oPage->add("<div style=\"border:1px solid #97a5b0; margin-top:0.5em;\">\n");
$oPage->add("<div style=\"padding:0.25em;background-color:#f0f0f0\">\n");
$oPage->p("<strong>$sSubclassName</strong> - ".MetaModel::GetClassDescription($sSubclassName));
$oPage->p("<strong>$sSubclassLabel</strong> - ".MetaModel::GetClassDescription($sSubclassName));
$oPage->add("<form method=\"get\">\n");
$oPage->add("<input type=\"hidden\" name=\"classname\" value=\"$sClassName\">\n");
$oPage->add("<input type=\"hidden\" name=\"subclassname\" value=\"$sSubclassName\">\n");
@@ -634,7 +639,7 @@ switch($operation)
$iMatchesCount = $oSet->Count();
if ($iMatchesCount == 0)
{
$oPage->p("No $sSubclassName matches these criteria.");
$oPage->p("No $sSubclassLabel matches these criteria.");
$oPage->small_p("(".$oSearchFilter->__DescribeHTML().")");
}
else
@@ -642,7 +647,7 @@ switch($operation)
$oPage->p("$iMatchesCount item(s) found.");
cmdbAbstractObject::DisplaySet($oPage, $oSet);
}
$oPage->p("<a href=\"?operation=new&class=$sSubclassName\">Create a new $sSubclassName</a>\n");
$oPage->p("<a href=\"?operation=new&class=$sSubclassName\">Create a new $sSubclassLabel</a>\n");
$oPage->add("</div>\n");
}
}
@@ -655,7 +660,7 @@ switch($operation)
$oPage->add("<div style=\"border:1px solid #97a5b0; margin-top:0.5em;\">\n");
$oPage->add("<div style=\"padding:0.25em;background-color:#f0f0f0\">\n");
$oPage->p("<strong>$sClassName</strong> - ".MetaModel::GetClassDescription($sClassName));
$oPage->p("<strong>$sClassLabel</strong> - ".MetaModel::GetClassDescription($sClassName));
$oPage->add("<form method=\"get\">\n");
$oPage->add("<input type=\"hidden\" name=\"classname\" value=\"$sClassName\">\n");
$oPage->add("<input type=\"hidden\" name=\"org\" value=\"$sCurrentOrganization\">\n");
@@ -681,7 +686,7 @@ switch($operation)
$iMatchesCount = $oSet->Count();
if ($iMatchesCount == 0)
{
$oPage->p("No $sClassName matches these criteria.");
$oPage->p("No $sClassLabel matches these criteria.");
$oPage->small_p("(".$oSearchFilter->__DescribeHTML().")");
}
else
@@ -690,7 +695,7 @@ switch($operation)
cmdbAbstractObject::DisplaySet($oPage, $oSet);
$oPage->small_p("(".$oSearchFilter->__DescribeHTML().")");
}
$oPage->p("<a href=\"?operation=new&ctx=$iContext&class=$sClassName\">Create a new $sClassName</a>\n");
$oPage->p("<a href=\"?operation=new&ctx=$iContext&class=$sClassName\">Create a new $sClassLabel</a>\n");
$oPage->add("</div>\n");
$oPage->add("</div>\n");
}

View File

@@ -333,8 +333,8 @@ function DisplayClassDetails($oPage, $sClass)
{
$sValue = $oAttDef->GetDescription();
}
$sType = $oAttDef->GetType().' ('.$oAttDef->GetTypeDesc().')';
$sOrigin = MetaModel::GetAttributeOrigin($sClass, $sAttCode);
$sType = $oAttDef->GetType().' ('.$oAttDef->GetTypeDesc().')';
$sOrigin = MetaModel::GetAttributeOrigin($sClass, $sAttCode);
$sAllowedValues = "";
$oAllowedValuesDef = $oAttDef->GetValuesDef();
$sMoreInfo = "";

View File

@@ -263,6 +263,23 @@ if ($iUser == -1)
}
else
{
$oPage->p('<h2>How is it computing the user rights?</h2>');
$oPage->p('<h3>1st, find the profiles that apply</h3>');
$oPage->p('<p>Project the current object in every existing dimension</p>');
$oPage->p('<p>Project the observed profile in every existing dimension (might depend on the user)</p>');
$oPage->p('<p>If an overlap is found in any dimension, then the profile applies</p>');
$oPage->p('<h3>2nd, interpret the profiles</h3>');
$oPage->p('<p>Note: granting rights for specific attributes is not fully implemented. It is still not taking into account the inheritance of rights AND the UI will not take that information into account!</p>');
$oPage->p('<p>Actions: looks into URP_ActionGrant for a permission (yes or no) and goes up into the class hierarchy until an answer is found, defaults to <em>no</em></p>');
$oPage->p('<p>Stimuli: looks into URP_StimulusGrant for a permission (yes or no), defaults to <em>no</em></p>');
$oPage->p('<h3>3rd, keep the most permissive one</h3>');
$oPage->p('<p>If one profile says YES, then the answer is YES</p>');
$oUser = MetaModel::GetObject('URP_Users', $iUser);
$oPage->p('<h2>Projections for user '.$oUser->GetName().'</h2>');