portaldispatcher.class.inc.php 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. $bRet = true;
  14. if (array_key_exists('profile_list', $_SESSION))
  15. {
  16. $aProfiles = $_SESSION['profile_list'];
  17. }
  18. else
  19. {
  20. $oUser = UserRights::GetUserObject();
  21. $oSet = $oUser->Get('profile_list');
  22. while(($oLnkUserProfile = $oSet->Fetch()) !== null)
  23. {
  24. $aProfiles[] = $oLnkUserProfile->Get('profileid_friendlyname');
  25. }
  26. $_SESSION['profile_list'] = $aProfiles;
  27. }
  28. foreach($this->aData['deny'] as $sDeniedProfile)
  29. {
  30. // If one denied profile is present, it's enough => return false
  31. if (in_array($sDeniedProfile, $aProfiles))
  32. {
  33. return false;
  34. }
  35. }
  36. // If there are some "allow" profiles, then by default the result is false
  37. // since the user must have at least one of the profiles to be allowed
  38. if (count($this->aData['allow']) > 0)
  39. {
  40. $bRet = false;
  41. }
  42. foreach($this->aData['allow'] as $sAllowProfile)
  43. {
  44. // If one "allow" profile is present, it's enough => return true
  45. if (in_array($sAllowProfile, $aProfiles))
  46. {
  47. return true;
  48. }
  49. }
  50. return $bRet;
  51. }
  52. public function GetURL()
  53. {
  54. return utils::GetAbsoluteUrlAppRoot().$this->aData['url'];
  55. }
  56. public function GetLabel()
  57. {
  58. return Dict::S('portal:'.$this->sPortalid);
  59. }
  60. public function GetRank()
  61. {
  62. return $this->aData['rank'];
  63. }
  64. }