portaldispatcher.class.inc.php 1.4 KB

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