Ejemplo n.º 1
0
 /**
  * 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;
 }
Ejemplo n.º 2
0
 /**
  * removegrouplinkAction - Remove group link
  */
 public function removegrouplinkAction()
 {
     $parentGrpId = $this->_request->getParam('parentgrpid');
     $this->view->parentgrpid = $parentGrpId;
     $childGrpId = $this->_request->getParam('childgrpid');
     $this->view->childgrpid = $childGrpId;
     if (!(isset($parentGrpId) && isset($childGrpId))) {
         $redirectUrl = $this->_urlHelper->url(array('controller' => 'group', 'action' => 'index', 'language' => $this->view->language), 'lang_default', true);
         $this->_redirector->gotoUrl($redirectUrl);
     }
     $grphasgrpmodel = new Default_Model_GroupHasGroup();
     $grphasgrpmodel->removeGroupFromGroup($parentGrpId, $childGrpId);
     $grphasgrpmodel->removeGroupFromGroup($childGrpId, $parentGrpId);
     // TODO:
     // Tell the user that the unlink was created.
     // Redirect back to the current campaign's page.
     $target = $this->_urlHelper->url(array('groupid' => $parentGrpId, 'language' => $this->view->language), 'group_shortview', true);
     $this->_redirector->gotoUrl($target);
 }