/** * If an app is not enabled for an actor then don't let the viewer to see it. * * @param string $action Action name * * @return bool */ public function canExecute($action) { if ($this->isOwnable() && $this->actor && $this->actor->authorize('access') === false) { return false; } return parent::canExecute($action); }
/** * If the viewer has been blocked by an actor then don't bring up the actor * * @param string $action The action * * @return boolean */ public function canExecute($action) { if ($this->getItem() && $this->getItem()->blocking(get_viewer())) { return false; } //if the action is an admin action then check if the viewer is an admin if ($this->isAdministrable()) { $methods = $this->getBehavior('administrable')->getMethods(); if (in_array('_action' . ucfirst($action), $methods) && $this->canAdminister() === false) { return false; } } return parent::canExecute($action); }
/** * Initializes the default configuration for the object. * * Called from {@link __construct()} as a first step of object instantiation. * * @param KConfig $config An optional KConfig object with configuration options. */ protected function _initialize(KConfig $config) { parent::_initialize($config); $this->_viewer = get_viewer(); }