usermanagement_classproj.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. <?php
  2. require_once('../application/application.inc.php');
  3. require_once('../application/itopwebpage.class.inc.php');
  4. require_once('../application/startup.inc.php');
  5. function ComputeProjections($oPage, $sScope)
  6. {
  7. // Load the classes for a further usage
  8. //
  9. $aClasses = MetaModel::GetClasses();
  10. // Load the dimensions for a further usage
  11. //
  12. $aDimensions = array();
  13. $oDimensionSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Dimensions"));
  14. while ($oDimension = $oDimensionSet->Fetch())
  15. {
  16. $aDimensions[$oDimension->GetKey()] = $oDimension;
  17. }
  18. // Load the class projections for a further usage
  19. //
  20. $aClassProj = array();
  21. $oClassProjSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_ClassProjection"));
  22. while ($oClassProj = $oClassProjSet->Fetch())
  23. {
  24. $aClassProjs[$oClassProj->Get('class')][$oClassProj->Get('dimensionid')] = $oClassProj;
  25. }
  26. // Setup display structure
  27. //
  28. $aDisplayConfig = array();
  29. $aDisplayConfig['class'] = array('label' => 'Class', 'description' => 'Class');
  30. $aDisplayConfig['object'] = array('label' => 'Object', 'description' => 'Projected object');
  31. foreach ($aDimensions as $iDimension => $oDimension)
  32. {
  33. $aDisplayConfig['dim'.$oDimension->GetKey()] = array('label' => $oDimension->GetName(), 'description' => $oDimension->Get('description'));
  34. }
  35. // Load objects
  36. //
  37. $aDisplayData = array();
  38. $oObjectSet = new DBObjectSet(DBObjectSearch::FromOQL($sScope));
  39. $sClass = $oObjectSet->GetClass();
  40. while ($oObject = $oObjectSet->Fetch())
  41. {
  42. $aObjectProj = array();
  43. $oObjectProj['class'] = $sClass;
  44. $oObjectProj['object'] = $oObject->GetName();
  45. foreach ($aDimensions as $iDimension => $oDimension)
  46. {
  47. // #@# to be moved, may be time consuming
  48. $oDimension->CheckProjectionSpec($aClassProjs[$sClass][$iDimension]);
  49. $aValues = $aClassProjs[$sClass][$iDimension]->ProjectObject($oObject);
  50. if (is_null($aValues))
  51. {
  52. $sValues = '<any>';
  53. }
  54. else
  55. {
  56. $sValues = implode(', ', $aValues);
  57. }
  58. $oObjectProj['dim'.$oDimension->GetKey()] = htmlentities($sValues);
  59. }
  60. $aDisplayData[] = $oObjectProj;
  61. }
  62. $oPage->table($aDisplayConfig, $aDisplayData);
  63. //$oPage->SetCurrentTab('Attributes');
  64. //$oPage->p("[<a href=\"?operation='list'\">All classes</a>]");
  65. //$oPage->add("</ul>\n");
  66. }
  67. require_once('../application/loginwebpage.class.inc.php');
  68. login_web_page::DoLogin(); // Check user rights and prompt if needed
  69. // Display the menu on the left
  70. $oContext = new UserContext();
  71. $oAppContext = new ApplicationContext();
  72. $iActiveNodeId = utils::ReadParam('menu', -1);
  73. $currentOrganization = utils::ReadParam('org_id', 1);
  74. $sScope = utils::ReadParam('scope', 'SELECT bizDevice');
  75. $oPage = new iTopWebPage("iTop user management - class projections", $currentOrganization);
  76. $oPage->no_cache();
  77. ComputeProjections($oPage, $sScope);
  78. $oPage->output();
  79. ?>