/** * isValid Checks if a campaign exists in db using Campaign model's * campaignExists function. * * @param $value string group name * @return boolean */ public function isValid($value) { $value = (string) $value; $this->_setValue($value); $campaignModel = new Default_Model_Campaigns(); if ($campaignModel->campaignExists($value)) { $this->_error(self::NOT_MATCH); return false; // if the group exists, the form is not valid } else { return true; // if the group doesn't exist, the form is valid } }
/** * adminunlinkAction * * Shows contents which are linket to campaign. Campaign(group) admin can select and remove link. * * @author Mikko Korpinen */ public function adminunlinkAction() { // Get authentication $auth = Zend_Auth::getInstance(); // If user has identity if ($auth->hasIdentity()) { // Get requests $params = $this->getRequest()->getParams(); $relatestoid = $params['relatestoid']; $groupId = $params['groupid']; if (!isset($relatestoid) && !isset($groupId)) { $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true); $this->_redirector->gotoUrl($redirectUrl); } $groupAdminsModel = new Default_Model_GroupAdmins(); $groupAdmins = $groupAdminsModel->getGroupAdmins($groupId); $user = $auth->getIdentity(); if (!$groupAdminsModel->userIsAdmin($groupId, $user->user_id)) { $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true); $this->_redirector->gotoUrl($redirectUrl); } $campaignModel = new Default_Model_Campaigns(); $campaignexists = $campaignModel->campaignExists($relatestoid); if ($campaignexists) { $relatesToCampaign = $campaignModel->getCampaignById($relatestoid); $this->view->relatesToCampaignName = $relatesToCampaign['name_cmp']; $campaignContents = $campaignModel->getAllContentsInCampaign($relatestoid); $campaignFlagContents = array(); $campaignNormalContents = array(); $contentflagmodel = new Default_Model_ContentFlags(); // Check if content is flaged foreach ($campaignContents as $content) { $cfl_ids = $contentflagmodel->getFlagsByContentId($content['id_cnt']); if (!empty($cfl_ids)) { $campaignFlagContents[] = $content; } else { $campaignNormalContents[] = $content; } } } $this->view->campaignexists = $campaignexists; $this->view->relatesToId = $relatestoid; $this->view->contents = $campaignNormalContents; $this->view->flagcontents = $campaignFlagContents; $this->view->userIsGroupAdmin = $this->checkIfArrayHasKeyWithValue($groupAdmins, 'id_usr', $user->user_id); } else { // If not logged, redirecting to system message page $message = 'content-link-not-logged'; $url = $this->_urlHelper->url(array('controller' => 'msg', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true); $this->flash($message, $url); } }