/** * linkedgroupsAction * * @author Mikko Korpinen */ public function linkedgroupsAction() { // 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'] = 'linkedgroups'; $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 membersAction special stuff: // Get linked groups $grpHasGrpModel = new Default_Model_GroupHasGroup(); $linkedgroups = $grpHasGrpModel->getGroupGroups($grpId); $linkedgroups = array_merge($linkedgroups['parents'], $linkedgroups['childs']); $usrHasGrpModel = new Default_Model_UserHasGroup(); $cmpModel = new Default_Model_Campaigns(); $linkedgroups_new = array(); foreach ($linkedgroups as $grp) { $grp['campaign_count'] = count($cmpModel->getCampaignsByGroup($grp['id_grp'])); $grp['member_count'] = count($usrHasGrpModel->getAllUsersInGroup($grp['id_grp'])); $linkedgroups_new[] = $grp; } // Set $this->view->... $this->view->linkedgroups = $linkedgroups_new; }
function getrecentgroupsAction() { $offset = isset($this->params['offset']) ? $this->params['offset'] : 0; $grpmodel = new Default_Model_Groups(); $grpadm = new Default_Model_GroupAdmins(); $usrHasGrp = new Default_Model_UserHasGroup(); $cmpmodel = new Default_Model_Campaigns(); $grps = $grpmodel->getRecentFromOffset($offset, 10); $grps_new = array(); foreach ($grps as $grp) { $adm = $grpadm->getGroupAdmins($grp['id_grp']); $grp['id_admin'] = $adm[0]['id_usr']; $grp['login_name_admin'] = $adm[0]['login_name_usr']; $grp['campaign_count'] = count($cmpmodel->getCampaignsByGroup($grp['id_grp'])); $grp['member_count'] = count($usrHasGrp->getAllUsersInGroup($grp['id_grp'])); $grps_new[] = $grp; } $this->view->recentgroups = $grps_new; }
/** * 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()) { // Get data for this specific group. $grpId = $this->_request->getParam('groupid'); $grpModel = new Default_Model_Groups(); $usrHasGrpModel = new Default_Model_UserHasGroup(); $grpAdminsModel = new Default_Model_GroupAdmins(); $campaignModel = new Default_Model_Campaigns(); $grpAdmins = $grpAdminsModel->getGroupAdmins($grpId); $user = $auth->getIdentity(); // Add data to the view. $this->view->grpId = $grpId; $this->view->grpData = $grpModel->getGroupData($grpId); $this->view->grpUsers = $usrHasGrpModel->getAllUsersInGroup($grpId); $this->view->grpAdmins = $grpAdmins; $this->view->userHasGroup = $usrHasGrpModel; $this->view->campaigns = $campaignModel->getCampaignsByGroup($grpId); $this->view->userIsGroupAdmin = $this->checkIfArrayHasKeyWithValue($grpAdmins, 'id_usr', $user->user_id); } else { // Groups are only visible to registered users. $target = $this->_urlHelper->url(array('controller' => 'index', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true); $this->_redirector->gotoUrl($target); } }