mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-18 06:48:50 +02:00
User management by profile moving forward: pages to check the projection of objects/users in user defined dimensions
Introduced parameters in OQL (:myvar) Added the verb MetaModel::IsValidObject($oMyObj) SVN:code[88]
This commit is contained in:
@@ -75,7 +75,7 @@ class TestOQLParser extends TestFunction
|
||||
$oOql = new OqlInterpreter($sQuery);
|
||||
try
|
||||
{
|
||||
$oTrash = $oOql->ParseQuery();
|
||||
$oTrash = $oOql->Parse(); // Not expecting a given format, otherwise use ParseExpression/ParseObjectQuery/ParseValueSetQuery
|
||||
MyHelpers::var_dump_html($oTrash, true);
|
||||
}
|
||||
catch (OQLException $OqlException)
|
||||
@@ -687,7 +687,7 @@ class TestQueriesOnFarm extends TestBizModel
|
||||
try
|
||||
{
|
||||
//$oOql = new OqlInterpreter($sQuery);
|
||||
//$oTrash = $oOql->ParseQuery();
|
||||
//$oTrash = $oOql->ParseObjectQuery();
|
||||
//MyHelpers::var_dump_html($oTrash, true);
|
||||
$oMyFilter = DBObjectSearch::FromOQL($sQuery);
|
||||
}
|
||||
|
||||
90
trunk/pages/usermanagement_classproj.php
Normal file
90
trunk/pages/usermanagement_classproj.php
Normal file
@@ -0,0 +1,90 @@
|
||||
<?php
|
||||
require_once('../application/application.inc.php');
|
||||
require_once('../application/itopwebpage.class.inc.php');
|
||||
|
||||
require_once('../application/startup.inc.php');
|
||||
|
||||
|
||||
function ComputeProjections($oPage, $sScope)
|
||||
{
|
||||
// Load the classes for a further usage
|
||||
//
|
||||
$aClasses = MetaModel::GetClasses();
|
||||
|
||||
// Load the dimensions for a further usage
|
||||
//
|
||||
$aDimensions = array();
|
||||
$oDimensionSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Dimensions"));
|
||||
while ($oDimension = $oDimensionSet->Fetch())
|
||||
{
|
||||
$aDimensions[$oDimension->GetKey()] = $oDimension;
|
||||
}
|
||||
|
||||
// Load the class projections for a further usage
|
||||
//
|
||||
$aClassProj = array();
|
||||
$oClassProjSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_ClassProjection"));
|
||||
while ($oClassProj = $oClassProjSet->Fetch())
|
||||
{
|
||||
$aClassProjs[$oClassProj->Get('class')][$oClassProj->Get('dimensionid')] = $oClassProj;
|
||||
}
|
||||
|
||||
// Setup display structure
|
||||
//
|
||||
$aDisplayConfig = array();
|
||||
$aDisplayConfig['class'] = array('label' => 'Class', 'description' => 'Class');
|
||||
$aDisplayConfig['object'] = array('label' => 'Object', 'description' => 'Projected object');
|
||||
foreach ($aDimensions as $iDimension => $oDimension)
|
||||
{
|
||||
$aDisplayConfig['dim'.$oDimension->GetKey()] = array('label' => $oDimension->GetName(), 'description' => $oDimension->Get('description'));
|
||||
}
|
||||
|
||||
// Load objects
|
||||
//
|
||||
$aDisplayData = array();
|
||||
$oObjectSet = new DBObjectSet(DBObjectSearch::FromOQL($sScope));
|
||||
$sClass = $oObjectSet->GetClass();
|
||||
while ($oObject = $oObjectSet->Fetch())
|
||||
{
|
||||
$aObjectProj = array();
|
||||
$oObjectProj['class'] = $sClass;
|
||||
$oObjectProj['object'] = $oObject->GetName();
|
||||
foreach ($aDimensions as $iDimension => $oDimension)
|
||||
{
|
||||
// #@# to be moved, may be time consuming
|
||||
$oDimension->CheckProjectionSpec($aClassProjs[$sClass][$iDimension]);
|
||||
|
||||
$aValues = $aClassProjs[$sClass][$iDimension]->ProjectObject($oObject);
|
||||
$sValues = implode(', ', $aValues);
|
||||
$oObjectProj['dim'.$oDimension->GetKey()] = htmlentities($sValues);
|
||||
}
|
||||
|
||||
$aDisplayData[] = $oObjectProj;
|
||||
}
|
||||
|
||||
$oPage->table($aDisplayConfig, $aDisplayData);
|
||||
|
||||
//$oPage->SetCurrentTab('Attributes');
|
||||
//$oPage->p("[<a href=\"?operation='list'\">All classes</a>]");
|
||||
//$oPage->add("</ul>\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
require_once('../application/loginwebpage.class.inc.php');
|
||||
login_web_page::DoLogin(); // Check user rights and prompt if needed
|
||||
|
||||
// Display the menu on the left
|
||||
$oContext = new UserContext();
|
||||
$oAppContext = new ApplicationContext();
|
||||
$iActiveNodeId = utils::ReadParam('menu', -1);
|
||||
$currentOrganization = utils::ReadParam('org_id', 1);
|
||||
$sScope = utils::ReadParam('scope', 'SELECT bizDevice');
|
||||
|
||||
$oPage = new iTopWebPage("iTop user management - class projections", $currentOrganization);
|
||||
$oPage->no_cache();
|
||||
|
||||
ComputeProjections($oPage, $sScope);
|
||||
$oPage->output();
|
||||
|
||||
?>
|
||||
100
trunk/pages/usermanagement_profileproj.php
Normal file
100
trunk/pages/usermanagement_profileproj.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
require_once('../application/application.inc.php');
|
||||
require_once('../application/itopwebpage.class.inc.php');
|
||||
|
||||
require_once('../application/startup.inc.php');
|
||||
|
||||
|
||||
function ComputeProjections($oPage)
|
||||
{
|
||||
// Load the profiles for a further usage
|
||||
//
|
||||
$aProfiles = array();
|
||||
$oProfileSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Profiles"));
|
||||
while ($oProfile = $oProfileSet->Fetch())
|
||||
{
|
||||
$aProfiles[$oProfile->GetKey()] = $oProfile;
|
||||
}
|
||||
|
||||
// Load the dimensions for a further usage
|
||||
//
|
||||
$aDimensions = array();
|
||||
$oDimensionSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Dimensions"));
|
||||
while ($oDimension = $oDimensionSet->Fetch())
|
||||
{
|
||||
$aDimensions[$oDimension->GetKey()] = $oDimension;
|
||||
}
|
||||
|
||||
// Load the profile projections for a further usage
|
||||
//
|
||||
$aProPro = array();
|
||||
$oProProSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_ProfileProjection"));
|
||||
while ($oProPro = $oProProSet->Fetch())
|
||||
{
|
||||
$aProPros[$oProPro->Get('profileid')][$oProPro->Get('dimensionid')] = $oProPro;
|
||||
}
|
||||
|
||||
// Setup display structure
|
||||
//
|
||||
$aDisplayConfig = array();
|
||||
$aDisplayConfig['user'] = array('label' => 'User', 'description' => 'User concerned by the projection');
|
||||
$aDisplayConfig['profile'] = array('label' => 'Profile', 'description' => 'Profile in which the projection is specified');
|
||||
foreach ($aDimensions as $iDimension => $oDimension)
|
||||
{
|
||||
$aDisplayConfig['dim'.$oDimension->GetKey()] = array('label' => $oDimension->GetName(), 'description' => $oDimension->Get('description'));
|
||||
}
|
||||
|
||||
// Load users, and create a record per couple user/profile
|
||||
//
|
||||
$aDisplayData = array();
|
||||
$oUserSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Users"));
|
||||
while ($oUser = $oUserSet->Fetch())
|
||||
{
|
||||
$oUserProfileSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_UserProfile WHERE userid = :user->id"), array(), array('user' => $oUser));
|
||||
while ($oUserProfile = $oUserProfileSet->Fetch())
|
||||
{
|
||||
$iProfile = $oUserProfile->Get('profileid');
|
||||
$oProfile = $aProfiles[$iProfile];
|
||||
|
||||
$aUserProfileProj = array();
|
||||
$aUserProfileProj['user'] = $oUser->GetName();
|
||||
$aUserProfileProj['profile'] = $oProfile->GetName();
|
||||
foreach ($aDimensions as $iDimension => $oDimension)
|
||||
{
|
||||
// #@# to be moved, may be time consuming
|
||||
$oDimension->CheckProjectionSpec($aProPros[$iProfile][$iDimension]);
|
||||
|
||||
$aValues = $aProPros[$iProfile][$iDimension]->ProjectUser($oUser);
|
||||
$sValues = implode(', ', $aValues);
|
||||
$aUserProfileProj['dim'.$oDimension->GetKey()] = htmlentities($sValues);
|
||||
}
|
||||
|
||||
$aDisplayData[] = $aUserProfileProj;
|
||||
}
|
||||
}
|
||||
|
||||
$oPage->table($aDisplayConfig, $aDisplayData);
|
||||
|
||||
//$oPage->SetCurrentTab('Attributes');
|
||||
//$oPage->p("[<a href=\"?operation='list'\">All classes</a>]");
|
||||
//$oPage->add("</ul>\n");
|
||||
|
||||
}
|
||||
|
||||
|
||||
require_once('../application/loginwebpage.class.inc.php');
|
||||
login_web_page::DoLogin(); // Check user rights and prompt if needed
|
||||
|
||||
// Display the menu on the left
|
||||
$oContext = new UserContext();
|
||||
$oAppContext = new ApplicationContext();
|
||||
$iActiveNodeId = utils::ReadParam('menu', -1);
|
||||
$currentOrganization = utils::ReadParam('org_id', 1);
|
||||
|
||||
$oPage = new iTopWebPage("iTop user management - profile projections", $currentOrganization);
|
||||
$oPage->no_cache();
|
||||
|
||||
ComputeProjections($oPage);
|
||||
$oPage->output();
|
||||
|
||||
?>
|
||||
Reference in New Issue
Block a user