/** * linkAction * * Get user contents which are related to particular content type * * @author ??? * @author 2010 Mikko Korpinen * */ public function linkAction() { // Get authentication $auth = Zend_Auth::getInstance(); // If user has identity if ($auth->hasIdentity()) { // Get requests $params = $this->getRequest()->getParams(); // Get content type $contenttype = isset($params['contenttype']) ? $params['contenttype'] : ''; $relatestoid = isset($params['relatestoid']) ? $params['relatestoid'] : ''; if ($this->validateLinking($contenttype, $relatestoid, -1)) { $model_content_types = new Default_Model_ContentTypes(); $model_cnt_has_cnt = new Default_Model_ContentHasContent(); $id_usr = $auth->getIdentity()->user_id; $id_cty = $model_content_types->getIdByType($contenttype); $userModel = new Default_Model_User(); $userContents = $userModel->getUserContent($id_usr); $contents = array(); // If user have not this types content then set false $hasUserContents = true; if (!$this->checkIfArrayHasKeyWithValue($userContents, "id_cty_cnt", $id_cty)) { $this->view->linkingContentType = $contenttype; $hasUserContents = false; } else { foreach ($userContents as $content) { if (!$model_cnt_has_cnt->checkIfContentHasContent($relatestoid, $content['id_cnt']) && !$model_cnt_has_cnt->checkIfContentHasContent($content['id_cnt'], $relatestoid)) { if ($content['id_cty_cnt'] == $id_cty && $content['id_cnt'] != $relatestoid) { $contents[] = $content; } } } $this->view->relatesToId = $relatestoid; $this->view->linkingContentType = $contenttype; $this->view->contents = $contents; $this->view->hasUserContents = $hasUserContents; } } } 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); } }