Exemplo n.º 1
0
 /**
  * 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);
     }
 }
Exemplo n.º 2
0
 /**
  * linkAction
  *
  * Link content to campaign.
  */
 public function linkAction()
 {
     $auth = Zend_Auth::getInstance();
     if ($auth->hasIdentity()) {
         $usrId = $auth->getIdentity()->user_id;
         $cmpId = $this->_request->getParam('cmpid');
         if (!isset($cmpId)) {
             $redirectUrl = $this->_urlHelper->url(array('controller' => 'campaign', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
             $this->_redirector->gotoUrl($redirectUrl);
         }
         $this->view->cmpid = $cmpId;
         $cmpmodel = new Default_Model_Campaigns();
         $cmp = $cmpmodel->getCampaignById($cmpId);
         $usrmodel = new Default_Model_User();
         $usrcnt = $usrmodel->getUserContent($usrId);
         if (!empty($usrcnt)) {
             $cmpcnt = $cmpmodel->getAllContentsInCampaign($cmpId);
             $cnt = array();
             foreach ($usrcnt as $usercontent) {
                 if (!$this->checkIfArrayHasKeyWithValue($cmpcnt, 'id_cnt', $usercontent['id_cnt'])) {
                     $cnt[] = $usercontent;
                 }
             }
             $hasUserContents = true;
         } else {
             $hasUserContents = false;
         }
         $this->view->cmp = $cmp;
         $this->view->usrcnt = $cnt;
         $this->view->hasUserContents = $hasUserContents;
     } else {
         // If not logged, redirecting to system message page
         $message = 'campaign-link-not-logged';
         $url = $this->_urlHelper->url(array('controller' => 'msg', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
         $this->flash($message, $url);
     }
 }