usermanagement_classproj.php 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. <?php
  2. // Copyright (C) 2010 Combodo SARL
  3. //
  4. // This program is free software; you can redistribute it and/or modify
  5. // it under the terms of the GNU General Public License as published by
  6. // the Free Software Foundation; version 3 of the License.
  7. //
  8. // This program is distributed in the hope that it will be useful,
  9. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. // GNU General Public License for more details.
  12. //
  13. // You should have received a copy of the GNU General Public License
  14. // along with this program; if not, write to the Free Software
  15. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  16. /**
  17. * Specific to the addon 'user management by profile'
  18. * Was developed for testing purposes only
  19. *
  20. * @author Erwan Taloc <erwan.taloc@combodo.com>
  21. * @author Romain Quetiez <romain.quetiez@combodo.com>
  22. * @author Denis Flaven <denis.flaven@combodo.com>
  23. * @license http://www.opensource.org/licenses/gpl-3.0.html LGPL
  24. */
  25. require_once('../application/application.inc.php');
  26. require_once('../application/itopwebpage.class.inc.php');
  27. require_once('../application/startup.inc.php');
  28. function ComputeProjections($oPage, $sScope)
  29. {
  30. // Load the classes for a further usage
  31. //
  32. $aClasses = MetaModel::GetClasses();
  33. // Load the dimensions for a further usage
  34. //
  35. $aDimensions = array();
  36. $oDimensionSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_Dimensions"));
  37. while ($oDimension = $oDimensionSet->Fetch())
  38. {
  39. $aDimensions[$oDimension->GetKey()] = $oDimension;
  40. }
  41. // Load the class projections for a further usage
  42. //
  43. $aClassProj = array();
  44. $oClassProjSet = new DBObjectSet(DBObjectSearch::FromOQL("SELECT URP_ClassProjection"));
  45. while ($oClassProj = $oClassProjSet->Fetch())
  46. {
  47. $aClassProjs[$oClassProj->Get('class')][$oClassProj->Get('dimensionid')] = $oClassProj;
  48. }
  49. // Setup display structure
  50. //
  51. $aDisplayConfig = array();
  52. $aDisplayConfig['class'] = array('label' => Dict::S('UI:UserManagement:Class'), 'description' => Dict::S('UI:UserManagement:Class+'));
  53. $aDisplayConfig['object'] = array('label' => Dict::S('UI:UserManagement:ProjectedObject'), 'description' => Dict::S('UI:UserManagement:ProjectedObject+'));
  54. foreach ($aDimensions as $iDimension => $oDimension)
  55. {
  56. $aDisplayConfig['dim'.$oDimension->GetKey()] = array('label' => $oDimension->GetName(), 'description' => $oDimension->Get('description'));
  57. }
  58. // Load objects
  59. //
  60. $aDisplayData = array();
  61. $oObjectSet = new DBObjectSet(DBObjectSearch::FromOQL($sScope));
  62. $sClass = $oObjectSet->GetClass();
  63. while ($oObject = $oObjectSet->Fetch())
  64. {
  65. $aObjectProj = array();
  66. $oObjectProj['class'] = $sClass;
  67. $oObjectProj['object'] = $oObject->GetName();
  68. foreach ($aDimensions as $iDimension => $oDimension)
  69. {
  70. // #@# to be moved, may be time consuming
  71. $oDimension->CheckProjectionSpec($aClassProjs[$sClass][$iDimension], $sClass);
  72. $aValues = $aClassProjs[$sClass][$iDimension]->ProjectObject($oObject);
  73. if (is_null($aValues))
  74. {
  75. $sValues = htmlentities(Dict::S('UI:UserManagement:AnyObject'));
  76. }
  77. else
  78. {
  79. $sValues = implode(', ', $aValues);
  80. }
  81. $oObjectProj['dim'.$oDimension->GetKey()] = $sValues;
  82. }
  83. $aDisplayData[] = $oObjectProj;
  84. }
  85. $oPage->table($aDisplayConfig, $aDisplayData);
  86. //$oPage->SetCurrentTab('Attributes');
  87. //$oPage->p("[<a href=\"?operation='list'\">All classes</a>]");
  88. //$oPage->add("</ul>\n");
  89. }
  90. require_once('../application/loginwebpage.class.inc.php');
  91. LoginWebPage::DoLogin(); // Check user rights and prompt if needed
  92. // Display the menu on the left
  93. $oContext = new UserContext();
  94. $oAppContext = new ApplicationContext();
  95. $iActiveNodeId = utils::ReadParam('menu', -1);
  96. $currentOrganization = utils::ReadParam('org_id', 1);
  97. $sScope = utils::ReadParam('scope', 'SELECT bizDevice');
  98. $oPage = new iTopWebPage(Dict::S('UI:PageTitle:ClassProjections'), $currentOrganization);
  99. $oPage->no_cache();
  100. ComputeProjections($oPage, $sScope);
  101. $oPage->output();
  102. ?>