public function flagAction() { // Set an empty layout for view $this->_helper->layout()->setLayout('empty'); // Get requests $params = $this->getRequest()->getParams(); $flaggedId = $params['flaggedid']; // Models for the job $auth = Zend_Auth::getInstance()->getIdentity(); $userId = $auth->user_id; $flagmodel = new Default_Model_ContentFlags(); $flagExists = $flagmodel->flagExists($flaggedId, $userId); $contentmodel = new Default_Model_Content(); $contentExists = $contentmodel->checkIfContentExists($flaggedId); if ($contentExists == true) { if ($flagExists == true) { $success = 0; } elseif ($flagExists == false) { $success = 1; $flagmodel->addFlag($flaggedId, $userId); } } elseif ($contentExists == false) { $success = 0; } $this->view->success = $success; }
/** * unlinkAction * * Shows user contents which are linket to campaign. User can select and remove link. * * @author Mikko Korpinen */ public function unlinkAction() { // Get authentication $auth = Zend_Auth::getInstance(); // If user has identity if ($auth->hasIdentity()) { // Get requests $params = $this->getRequest()->getParams(); $relatestoid = $params['relatestoid']; if (!isset($relatestoid)) { $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true); $this->_redirector->gotoUrl($redirectUrl); } $contenttype = ''; $campaigns = array(); $model_content = new Default_Model_Content(); $contentexists = $model_content->checkIfContentExists($relatestoid); if ($contentexists) { $relatesToContent = $model_content->getDataAsSimpleArray($relatestoid); $this->view->relatesToContentTitle = $relatesToContent['title_cnt']; $model_content_types = new Default_Model_ContentTypes(); $model_cmp_has_cnt = new Default_Model_CampaignHasContent(); $contenttype = $model_content_types->getTypeById($relatesToContent['id_cty_cnt']); $contentCampaigns = $model_cmp_has_cnt->getContentCampaigns($relatestoid); } $this->view->contentexists = $contentexists; $this->view->relatesToId = $relatestoid; $this->view->linkingContentType = $contenttype; $this->view->campaigns = $contentCampaigns; } 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); } }