allows() public method

Returns if the page allows a mode. Access rights and user state are taken into consideration.
public allows ( integer $mode ) : boolean
$mode integer The mode to check for.
return boolean True if the mode is allowed.
Esempio n. 1
0
 /**
  * Returns if the page allows a mode. Access rights and user state
  * are taken into consideration.
  *
  * @see $supportedModes
  *
  * @param integer $mode  The mode to check for.
  *
  * @return boolean  True if the mode is allowed.
  */
 public function allows($mode)
 {
     if ($mode == Wicked::MODE_EDIT) {
         $page = Wicked_Page::getPage($this->referrer());
         if ($page->isLocked(Wicked::lockUser())) {
             return false;
         }
     }
     return parent::allows($mode);
 }
Esempio n. 2
0
 /**
  * Returns if the page allows a mode. Access rights and user state
  * are taken into consideration.
  *
  * @see $supportedModes
  *
  * @param integer $mode  The mode to check for.
  *
  * @return boolean  True if the mode is allowed.
  */
 public function allows($mode)
 {
     switch ($mode) {
         case Wicked::MODE_EDIT:
             if ($this->isLocked()) {
                 return Wicked::lockUser() == $this->_lock['lock_owner'];
             }
             break;
         case Wicked::MODE_LOCKING:
             if ($GLOBALS['browser']->isRobot()) {
                 return false;
             }
             if ($GLOBALS['registry']->isAdmin()) {
                 return true;
             }
             if (($this->getPermissions() & Horde_Perms::EDIT) == 0) {
                 return false;
             }
             break;
         case Wicked::MODE_UNLOCKING:
             if ($GLOBALS['registry']->isAdmin()) {
                 return true;
             }
             if ($this->_lock) {
                 return Wicked::lockUser() == $this->_lock['lock_owner'];
             }
             return false;
     }
     return parent::allows($mode);
 }