/** * removelinkAction * * Remove link to content from campaign * * @author Mikko Korpinen */ public function removelinksAction() { // Get authentication $auth = Zend_Auth::getInstance(); // If user has identity if ($auth->hasIdentity()) { $cmpId = $this->_request->getParam('cmpid'); $this->view->cmpid = $cmpId; $cntId = $this->_request->getParam('cntid'); $this->view->cntid = $cntId; if (!(isset($cmpId) && isset($cntId))) { $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true); $this->_redirector->gotoUrl($redirectUrl); } $cntHasUsrModel = new Default_Model_ContentHasUser(); $usrId = $auth->getIdentity()->user_id; if (!$cntHasUsrModel->contentHasOwner($usrId, $cntId)) { $redirectUrl = $this->_urlHelper->url(array('controller' => 'account', 'action' => 'view', 'user' => $auth->getIdentity()->username, 'language' => $this->language), 'lang_default', true); $this->_redirector->gotoUrl($redirectUrl); } $cmphascntmodel = new Default_Model_CampaignHasContent(); $cmphascntmodel->removeContentFromCampaign($cmpId, $cntId); // TODO: // Tell the user that the unlink was created. // Redirect back to the user page $redirectUrl = $this->_urlHelper->url(array('controller' => 'account', 'action' => 'view', 'user' => $auth->getIdentity()->username, 'language' => $this->language), 'lang_default', true); $this->_redirector->gotoUrl($redirectUrl); } 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); } }
/** * publishAction * * Set a content to published by id * * @param id integer ID of content to be published */ public function publishAction() { $params = $this->getRequest()->getParams(); $contentId = (int) $params['content_id']; $auth = Zend_Auth::getInstance(); $username = null; $message = ''; if ($auth->hasIdentity()) { $userId = $auth->getIdentity()->user_id; $username = $auth->getIdentity()->username; $content = new Default_Model_Content(); $url = $this->_urlHelper->url(array('controller' => 'msg', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true); if ($content->checkIfContentExists($contentId)) { //$contentUrl = $this->baseUrl ."/". $this->view->language ."/view/".$contentId; $contentUrl = $this->_urlHelper->url(array('controller' => 'view', 'action' => $contentId, 'language' => $this->view->language), 'lang_default', true); $cntHasUsr = new Default_Model_ContentHasUser(); $userIsOwner = $cntHasUsr->contentHasOwner($userId, $contentId); if ($userIsOwner) { if ($content->publishContent($contentId)) { $message = $this->view->translate('content-publish-successful'); $message .= " " . $this->view->translate('content-publish-click'); $message .= " <a href=\"" . $contentUrl . "\">"; $message .= " " . $this->view->translate('content-publish-here'); $message .= "</a> "; $message .= " " . $this->view->translate('content-publish-view-content'); //$this->flash($message, $url); } else { $message = 'content-publish-not-successful'; //$this->flash($message, $url); } } else { $message = 'content-publish-not-owner'; //$this->flash($message, $url); } } else { $message = 'content-publish-invalid-content-id'; //$this->flash($message, $url); } } else { $message = 'content-publish-not-authed'; //$this->flash($message, $url); } // Add login to log $logger = Zend_Registry::get('logs'); if (isset($logger['contentpublish'])) { $logMessage = sprintf('Publish attempt FROM: %s USER: %s. MESSAGE: %s. CONTENT ID: %s.', $_SERVER['REMOTE_ADDR'], $username, $this->view->translate($message, 'en'), $contentId); $logger['contentpublish']->notice($logMessage); } $this->flash($message, $url); }
/** * removeAction - Remove specified comment by content owner or comment owner * * @author Mikko Korpinen */ public function removeAction() { $auth = Zend_Auth::getInstance(); if ($auth->hasIdentity()) { // Get requests $params = $this->getRequest()->getParams(); $cmtid = $params['cmtid']; $cntid = $params['cntid']; $usrid = $auth->getIdentity()->user_id; $cntHasUsrModel = new Default_Model_ContentHasUser(); $user_is_content_owner = $cntHasUsrModel->contentHasOwner($usrid, $cntid); $commentmodel = new Default_Model_Comments(); $user_is_comment_owner = $commentmodel->userIsOwner($usrid, $cmtid); if ($user_is_content_owner || $user_is_comment_owner) { $flagmodel = new Default_Model_CommentFlags(); $flags = $flagmodel->getFlagsByCommentId($cmtid); $commentExists = $commentmodel->commentExists($cmtid); if ($commentExists) { if (count($flags) > 0) { $flagmodel->removeFlagsByCommentId($cmtid); } $commentmodel->removeCommentText($cmtid); } } $redirectUrl = $this->_urlHelper->url(array('content_id' => $cntid, 'language' => $this->view->language), 'content_shortview', true); $this->_redirector->gotoUrl($redirectUrl); } else { $redirectUrl = $this->_urlHelper->url(array('language' => $this->view->language), 'index', true); $this->_redirector->gotoUrl($redirectUrl); } }