Beispiel #1
0
 /**
  * campaignsAction
  *
  * @author Mikko Korpinen
  */
 public function campaignsAction()
 {
     // User identity, group header and group menu:
     // Group id
     $grpId = $this->_request->getParam('groupid');
     $grpModel = new Default_Model_Groups();
     // Check if group exists
     if (!isset($grpId) || !$grpModel->groupExistsById($grpId)) {
         $target = $this->_urlHelper->url(array('controller' => 'group', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
         $this->_redirector->gotoUrl($target);
     }
     // Group data
     $grpData = $this->getGroupData($grpId);
     // Menudata
     $menuData['id_grp'] = $grpId;
     $menuData['grp_action'] = 'campaigns';
     $menuData['group_name_grp'] = $grpData['group_name_grp'];
     $menuData['grp_admins'] = $grpData['grp_admins'];
     // Set $this->view->...
     $this->view->grpData = $grpData;
     $this->view->menuData = $menuData;
     // Group campaignAction special stuff:
     // Get campaigns
     $campaignModel = new Default_Model_Campaigns();
     // Set $this->view->...
     $this->view->openCampaigns = $campaignModel->getOpenCampaignsByGroup($grpId);
     $this->view->notstartedCampaigns = $campaignModel->getNotstartedCampaignsByGroup($grpId);
     $this->view->endedCampaigns = $campaignModel->getEndedCampaignsByGroup($grpId);
 }
Beispiel #2
0
 /**
  * viewAction - shows an individual group's page
  *
  * @author Mikko Aatola
  */
 function viewAction()
 {
     // Get authentication
     $auth = Zend_Auth::getInstance();
     // If user has identity
     if ($auth->hasIdentity()) {
         $this->view->identity = true;
     } else {
         $this->view->identity = false;
     }
     // Get data for this specific group.
     $grpId = $this->_request->getParam('groupid');
     $grpModel = new Default_Model_Groups();
     $usrHasGrpModel = new Default_Model_UserHasGroup();
     $usrHasGrpWaitingModel = new Default_Model_UserHasGroupWaiting();
     $grpAdminsModel = new Default_Model_GroupAdmins();
     $campaignModel = new Default_Model_Campaigns();
     $grpAdmins = $grpAdminsModel->getGroupAdmins($grpId);
     $user = $auth->getIdentity();
     $grpData = $grpModel->getGroupData($grpId);
     $grpData['description_grp'] = str_replace("\n", '<br>', $grpData['description_grp']);
     $grpData['body_grp'] = str_replace("\n", '<br>', $grpData['body_grp']);
     // Group type
     $grpTypeId = $grpModel->getGroupTypeId($grpId);
     $grpTypeModel = new Default_Model_GroupTypes();
     $isClosed = $grpTypeModel->isClosed($grpTypeId);
     // Waiting list count
     $usrWaitingCount = $usrHasGrpWaitingModel->getUserCountByGroup($grpId);
     // Group weblinks
     $groupWeblinksModel = new Default_Model_GroupWeblinks();
     $grpData['groupWeblinks'] = $groupWeblinksModel->getGroupWeblinks($grpId);
     $i = 0;
     foreach ($grpData['groupWeblinks'] as $weblink) {
         if (strlen($weblink['name_gwl']) == 0 || strlen($weblink['url_gwl']) == 0) {
             unset($grpData['groupWeblinks'][$i]);
         }
         $i++;
     }
     // Get group groups
     $grpHasGrpModel = new Default_Model_GroupHasGroup();
     $linkedgroups = $grpHasGrpModel->getGroupGroups($grpId);
     $linkedgroups = array_merge($linkedgroups['parents'], $linkedgroups['childs']);
     $comments = new Oibs_Controller_Plugin_Comments("group", $grpId);
     if ($this->view->identity) {
         $comments->allowComments(true);
     }
     $this->view->jsmetabox->append('commentUrls', $comments->getUrls());
     $comments->loadComments();
     $this->view->comments = $comments;
     $this->view->hasFeeds = Oibs_Controller_Plugin_RssReader::hasFeeds($grpId, "group");
     // Add data to the view.
     $this->view->grpId = $grpId;
     $this->view->grpData = $grpData;
     $this->view->grpUsers = $usrHasGrpModel->getAllUsersInGroup($grpId);
     $this->view->grpAdmins = $grpAdmins;
     $this->view->userHasGroup = $usrHasGrpModel;
     $this->view->userHasGroupWaiting = $usrHasGrpWaitingModel;
     //$this->view->campaigns = $campaignModel->getCampaignsByGroup($grpId);
     $this->view->openCampaigns = $campaignModel->getOpenCampaignsByGroup($grpId);
     $this->view->notstartedCampaigns = $campaignModel->getNotstartedCampaignsByGroup($grpId);
     $this->view->endedCampaigns = $campaignModel->getEndedCampaignsByGroup($grpId);
     $this->view->userIsGroupAdmin = isset($user->user_id) ? $this->checkIfArrayHasKeyWithValue($grpAdmins, 'id_usr', $user->user_id) : false;
     $this->view->linkedgroups = $linkedgroups;
     $this->view->isClosed = $isClosed;
     $this->view->usrWaitingCount = $usrWaitingCount;
 }