usermanagement_profileproj.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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)
  6. {
  7. // Load the profiles for a further usage
  8. //
  9. $aProfiles = array();
  10. $oProfileSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Profiles"));
  11. while ($oProfile = $oProfileSet->Fetch())
  12. {
  13. $aProfiles[$oProfile->GetKey()] = $oProfile;
  14. }
  15. // Load the dimensions for a further usage
  16. //
  17. $aDimensions = array();
  18. $oDimensionSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Dimensions"));
  19. while ($oDimension = $oDimensionSet->Fetch())
  20. {
  21. $aDimensions[$oDimension->GetKey()] = $oDimension;
  22. }
  23. // Load the profile projections for a further usage
  24. //
  25. $aProPro = array();
  26. $oProProSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_ProfileProjection"));
  27. while ($oProPro = $oProProSet->Fetch())
  28. {
  29. $aProPros[$oProPro->Get('profileid')][$oProPro->Get('dimensionid')] = $oProPro;
  30. }
  31. // Setup display structure
  32. //
  33. $aDisplayConfig = array();
  34. $aDisplayConfig['user'] = array('label' => 'User', 'description' => 'User concerned by the projection');
  35. $aDisplayConfig['profile'] = array('label' => 'Profile', 'description' => 'Profile in which the projection is specified');
  36. foreach ($aDimensions as $iDimension => $oDimension)
  37. {
  38. $aDisplayConfig['dim'.$oDimension->GetKey()] = array('label' => $oDimension->GetName(), 'description' => $oDimension->Get('description'));
  39. }
  40. // Load users, and create a record per couple user/profile
  41. //
  42. $aDisplayData = array();
  43. $oUserSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Users"));
  44. while ($oUser = $oUserSet->Fetch())
  45. {
  46. $oUserProfileSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_UserProfile WHERE userid = :user->id"), array(), array('user' => $oUser));
  47. while ($oUserProfile = $oUserProfileSet->Fetch())
  48. {
  49. $iProfile = $oUserProfile->Get('profileid');
  50. $oProfile = $aProfiles[$iProfile];
  51. $aUserProfileProj = array();
  52. $aUserProfileProj['user'] = $oUser->GetName();
  53. $aUserProfileProj['profile'] = $oProfile->GetName();
  54. foreach ($aDimensions as $iDimension => $oDimension)
  55. {
  56. // #@# to be moved, may be time consuming
  57. $oDimension->CheckProjectionSpec($aProPros[$iProfile][$iDimension], get_class($oUser));
  58. $aValues = $aProPros[$iProfile][$iDimension]->ProjectUser($oUser);
  59. if (is_null($aValues))
  60. {
  61. $sValues = htmlentities('<any>');
  62. }
  63. else
  64. {
  65. $sValues = implode(', ', $aValues);
  66. }
  67. $aUserProfileProj['dim'.$oDimension->GetKey()] = $sValues;
  68. }
  69. $aDisplayData[] = $aUserProfileProj;
  70. }
  71. }
  72. $oPage->table($aDisplayConfig, $aDisplayData);
  73. //$oPage->SetCurrentTab('Attributes');
  74. //$oPage->p("[<a href=\"?operation='list'\">All classes</a>]");
  75. //$oPage->add("</ul>\n");
  76. }
  77. require_once('../application/loginwebpage.class.inc.php');
  78. LoginWebPage::DoLogin(); // Check user rights and prompt if needed
  79. // Display the menu on the left
  80. $oContext = new UserContext();
  81. $oAppContext = new ApplicationContext();
  82. $iActiveNodeId = utils::ReadParam('menu', -1);
  83. $currentOrganization = utils::ReadParam('org_id', 1);
  84. $oPage = new iTopWebPage("iTop user management - profile projections", $currentOrganization);
  85. $oPage->no_cache();
  86. ComputeProjections($oPage);
  87. $oPage->output();
  88. ?>