function generateAction() { //Copy&Paste from RssController \o/ :D // Set an empty layout for view $this->_helper->layout()->setLayout('empty'); // Make baseurl absolute URL $absoluteBaseUrl = strtolower(trim(array_shift(explode('/', $_SERVER['SERVER_PROTOCOL'])))) . '://' . $_SERVER['HTTP_HOST'] . Zend_Controller_Front::getInstance()->getBaseUrl(); $this->view->absoluteBaseUrl = $absoluteBaseUrl; // Get parameters $params = $this->getRequest()->getParams(); // Get content type $cty = isset($params['type']) ? $params['type'] : 'all'; // Get number of items $count = isset($params['count']) ? $params['count'] : 10; //$lang = ($this->view->language == "en" || $this->view->language == "fi") ? $this->view->language : "en"; //$lang = $this->view->language; // Set array for content data $data = array(); // Get recent content by type $content = new Default_Model_Content(); $data = $content->getRecentByLangAndType($this->view->language, $cty, $count); // Get tags for contents $tags_model = new Default_Model_ContentHasTag(); $usersid_model = new Default_Model_ContentHasUser(); $users_model = new Default_Model_User(); $i = 0; foreach ($data as $dataRow) { $tags = $tags_model->getContentTags($dataRow['id_cnt']); $user = $users_model->getContentOwner($dataRow['id_cnt']); $data[$i]['author'] = $user['login_name_usr']; $tagNames = array(); foreach ($tags as $tag) { $tagNames[] = $tag['name_tag']; } $data[$i]['tags'] = join(", ", $tagNames); $i++; } // Set to view $this->view->contentData = $data; }
/** * makelinksAction * * Make content link to content. * */ public function makelinksAction() { // Get authentication $auth = Zend_Auth::getInstance(); $absoluteBaseUrl = strtolower(trim(array_shift(explode('/', $_SERVER['SERVER_PROTOCOL'])))) . '://' . $_SERVER['HTTP_HOST'] . Zend_Controller_Front::getInstance()->getBaseUrl(); // 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['parentid']) ? $params['parentid'] : ''; $linkedcontentid = isset($params['childid']) ? $params['childid'] : ''; if ($this->validateLinking($contenttype, $relatestoid, $linkedcontentid)) { $model_cnt_has_cnt = new Default_Model_ContentHasContent(); $model_cnt_has_cnt->addContentToContent($relatestoid, $linkedcontentid); // Send email to owner of content about a new link // if user allows linking notifications $userModel = new Default_Model_User(); $owner = $userModel->getContentOwner($relatestoid); $notificationsModel = new Default_Model_Notifications(); $notifications = $notificationsModel->getNotificationsById($owner['id_usr']); if (in_array('link', $notifications)) { $cntModel = new Default_Model_Content(); $originalHeader = $cntModel->getContentHeaderByContentId($relatestoid); $linkedHeader = $cntModel->getContentHeaderByContentId($linkedcontentid); $senderId = $auth->getIdentity()->user_id; $senderName = $auth->getIdentity()->username; $emailNotification = new Oibs_Controller_Plugin_Email(); $emailNotification->setNotificationType('link')->setSenderId($auth->getIdentity()->user_id)->setReceiverId($owner['id_usr'])->setParameter('URL', $absoluteBaseUrl . "/en")->setParameter('SENDER-NAME', $senderName)->setParameter('LINKED-ID', $linkedcontentid)->setParameter('LINKED-TITLE', $linkedHeader)->setParameter('ORIGINAL-ID', $relatestoid)->setParameter('ORIGINAL-TITLE', $originalHeader); if ($emailNotification->isValid()) { $emailNotification->send(); } else { //echo $emailNotification->getErrorMessage(); die; } } $url = $this->_urlHelper->url(array('controller' => 'view', 'action' => $relatestoid, 'language' => $this->view->language), 'lang_default', true); $message = "content-linked-successfully"; $this->flash($message, $url); } } 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); } }