getRestParams(); if (1 === count($params) && is_numeric($params[0]) && ($committee = CommitteeObj::getCommitteeData($params[0])) ) { $this->_getDataObj()->setCommitteeId($committee['id']); $this->_doc->setHeader('"' . $committee['title'] . '" ' . $this->_doc->getTitle()); } else { $this->_do404(); } if (!$this->_checkUserAccess()) { $this->_do404(); } return parent::exec(); } protected function _checkUserAccess() { $auth = App_User_Auth::getInstance(); if ($auth->isLoggedIn()) { $userId = $auth->getData('id'); $leadershipsId = CommitteeObj::getCommitteeLeadershipIds($this->_getDataObj()->getCommitteeId()); return in_array($userId, $leadershipsId); } return false; } public static function buildUrl($committeeId, array $params = null) { if (($url = static::getPage('url'))) { $url .= '/' . $committeeId . ($params ? '?' . http_build_query($params) : ''); } return $url; } protected function _doEdit() { $this->_doc->setHeader('Edit ' . $this->getConfig('itemName')); return parent::_doEdit(); } protected function _doUpdate() { $this->_doc->setHeader('Edit ' . $this->getConfig('itemName')); return parent::_doUpdate(); } protected function _doNew() { $this->_doc->setHeader('Add New ' . $this->getConfig('itemName')); return parent::_doNew(); } protected function _doInsert() { $this->_doc->setHeader('Add New ' . $this->getConfig('itemName')); return parent::_doInsert(); } protected function _postInsert() { $this->_sendAdminNotification(self::SETTINGS_MAIL_PREFIX, 'EventAdded', $this->_getNotificationData()); return parent::_postInsert(); } protected function _postDelete() { $this->_sendAdminNotification(self::SETTINGS_MAIL_PREFIX, 'EventDeleted', $this->_getNotificationData()); return parent::_postDelete(); } protected function _getNotificationData() { $data = $this->_getDataObj()->getData(); $committeeData = CommitteeObj::getCommitteeData($data['committeeId'])->toArray(); $eventLink = EventAdminView::getPage('url'); $userData = \App_User_Auth::getInstance()->getData(); return array( 'eventName' => htmlspecialchars($data['title']), 'eventLink' => $eventLink . '?action=edit&id=' . $this->_getDataObj()->getPrimaryKey(), 'linkToCommitteeEvents' => $eventLink . '?committeeId=' . $data['committeeId'], 'committeeName' => htmlspecialchars($committeeData['title']), 'memberLink' => \App_User_Admin_View::getEditUrl($userData['id']), 'memberFirstName' => htmlspecialchars($userData['firstName']), 'memberLastName' => htmlspecialchars($userData['lastName']), ); } }