/** * The place to check if the data set in the snippet is valid * to generate the snippet. * * When invalid data should result in an error, you can throw it * here but you can also perform the check in the * checkRegistryRequestsAnswers() function from the * {@see \MUtil_Registry_TargetInterface}. * * @return boolean */ public function hasHtmlOutput() { $model = $this->getModel(); $data = $model->loadFirst(); $roles = $this->currentUser->getAllowedRoles(); //\MUtil_Echo::track($data); // Perform access check here, before anything has happened!!! if (isset($data['ggp_role']) && !isset($roles[$data['ggp_role']])) { $this->addMessage($this->_('You do not have sufficient privilege to edit this group.')); $this->afterSaveRouteUrl = array($this->request->getActionKey() => 'show'); $this->resetRoute = false; return false; } $this->menu->getParameterSource()->offsetSet('ggp_role', $data['ggp_role']); return parent::hasHtmlOutput(); }
/** * Set the footer of the browse table. * * Overrule this function to set the header differently, without * having to recode the core table building code. * * @param \MUtil_Model_Bridge_VerticalTableBridge $bridge * @param \MUtil_Model_ModelAbstract $model * @return void */ protected function setShowTableFooter(\MUtil_Model_Bridge_VerticalTableBridge $bridge, \MUtil_Model_ModelAbstract $model) { if ($model instanceof RoundModel) { $this->useCount = $model->getStartCount($this->roundId); if ($this->useCount) { $this->addMessage(sprintf($this->plural('This round has been completed %s time.', 'This round has been completed %s times.', $this->useCount), $this->useCount)); $this->addMessage($this->_('This round cannot be deleted, only deactivated.')); $this->deleteQuestion = $this->_('Do you want to deactivate this round?'); $this->displayTitle = $this->_('Deactivate round'); } } parent::setShowTableFooter($bridge, $model); }