public function indexAction() { $params = $this->_getAllParams(); $mode_list = $mode_grid = $mode_map = 1; $mode_enabled = array(); $view_mode = 'list'; if (isset($params['mode_list'])) { $mode_list = $params['mode_list']; } if ($mode_list) { $mode_enabled[] = 'list'; } if (isset($params['mode_grid'])) { $mode_grid = $params['mode_grid']; } if ($mode_grid) { $mode_enabled[] = 'grid'; } if (isset($params['mode_map'])) { $mode_map = $params['mode_map']; } if ($mode_map) { $mode_enabled[] = 'map'; } if (isset($params['view_mode'])) { $view_mode = $params['view_mode']; } if ($mode_enabled && !in_array($view_mode, $mode_enabled)) { $view_mode = $mode_enabled[0]; } $this->view->mode_enabled = $mode_enabled; $class_mode = "advgroup_list-view"; switch ($view_mode) { case 'grid': $class_mode = "advgroup_grid-view"; break; case 'map': $class_mode = "advgroup_map-view"; break; default: $class_mode = "advgroup_list-view"; break; } $this->view->class_mode = $class_mode; $this->view->view_mode = $view_mode; //Get fields for filtering group search. $request = Zend_Controller_Front::getInstance()->getRequest(); $form = new Advgroup_Form_Search(); $form->isValid($request->getParams()); $this->view->formValues = $params = $form->getValues(); $params['search'] = '1'; // Viewer 's friends field. $viewer = Engine_Api::_()->user()->getViewer(); if ($viewer->getIdentity() && $params['view']) { $params['users'] = array(); foreach ($viewer->membership()->getMembersInfo(true) as $memberinfo) { $params['users'][] = $memberinfo->user_id; } if (empty($params['users'])) { $params['users'][] = 0; } } $this->view->paginator = $paginator = Engine_Api::_()->getItemTable('group')->getGroupPaginator($params); //Set curent page $itemsPerPage = Engine_Api::_()->getApi('settings', 'core')->getSetting('advgroup.page', 9); $paginator->setItemCountPerPage($itemsPerPage); $paginator->setCurrentPageNumber($params['page']); }
public function manageAction() { $this->_helper->content->setEnabled(); //Require User if (!$this->_helper->requireUser->isValid()) { return; } //Get Main and Quick Navigation $this->view->navigation = $navigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('advgroup_main'); $this->view->quickNavigation = $quickNavigation = Engine_Api::_()->getApi('menus', 'core')->getNavigation('advgroup_quick'); //Create & modify search form. $this->view->form = $search_form = new Advgroup_Form_Search(); $search_form->removeElement('view'); $search_form->addElement('Select', 'view', array('label' => 'View:', 'multiOptions' => array('0' => 'All My Clubs', '2' => 'Only Clubs I Lead'), 'onchange' => '$(this).getParent("form").submit();')); $request = Zend_Controller_Front::getInstance()->getRequest(); $search_form->isValid($request->getParams()); $params = $search_form->getValues(); //Get form values $this->view->formValues = $params = $search_form->getValues(); //Get viewer $viewer = Engine_Api::_()->user()->getViewer(); //Filter parameters if ($params['view'] != "2") { $memTable = Engine_Api::_()->getDbtable('membership', 'advgroup'); $select = $memTable->select()->where('user_id = ?', $viewer->getIdentity())->where('active = 1'); $memberships = $memTable->fetchAll($select); $group_ids = array(0); foreach ($memberships as $membership) { $group_ids[] = $membership->resource_id; } $params['group_ids'] = $group_ids; } else { $params['user_id'] = $viewer->getIdentity(); } //Get data $this->view->paginator = $paginator = Engine_Api::_()->getItemTable('group')->getGroupPaginator($params); $paginator->setCurrentPageNumber($this->_getParam('page')); $itemsPerPage = Engine_Api::_()->getApi('settings', 'core')->getSetting('advgroup.page', 10); $paginator->setItemCountPerPage($itemsPerPage); // Check create $this->view->canCreate = Engine_Api::_()->authorization()->isAllowed('group', null, 'create'); }