portaldispatcher.class.inc.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. <?php
  2. class PortalDispatcher
  3. {
  4. protected $sPortalid;
  5. protected $aData;
  6. public function __construct($sPortalId)
  7. {
  8. $this->sPortalid = $sPortalId;
  9. $this->aData = PortalDispatcherData::GetData($sPortalId);
  10. }
  11. public function IsUserAllowed()
  12. {
  13. if (array_key_exists('profile_list', $_SESSION))
  14. {
  15. $aProfiles = $_SESSION['profile_list'];
  16. }
  17. else
  18. {
  19. $oUser = UserRights::GetUserObject();
  20. $oSet = $oUser->Get('profile_list');
  21. while(($oLnkUserProfile = $oSet->Fetch()) !== null)
  22. {
  23. $aProfiles[] = $oLnkUserProfile->Get('profileid_friendlyname');
  24. }
  25. $_SESSION['profile_list'] = $aProfiles;
  26. }
  27. foreach($this->aData['deny'] as $sDeniedProfile)
  28. {
  29. // If one denied profile is present, it's enough => return false
  30. if (in_array($sDeniedProfile, $aProfiles))
  31. {
  32. return false;
  33. }
  34. }
  35. foreach($this->aData['allow'] as $sAllowProfile)
  36. {
  37. // if one required profile is missing, it's enough => return false
  38. if (!in_array($sAllowProfile, $aProfiles))
  39. {
  40. return false;
  41. }
  42. }
  43. return true;
  44. }
  45. public function GetURL()
  46. {
  47. return utils::GetAbsoluteUrlAppRoot().$this->aData['url'];
  48. }
  49. public function GetLabel()
  50. {
  51. return Dict::S('portal:'.$this->sPortalid);
  52. }
  53. public function GetRank()
  54. {
  55. return $this->aData['rank'];
  56. }
  57. }