Example #1
0
 /**
  * View Group
  *
  * @return     array
  */
 public function viewTask()
 {
     // set the needed layout
     $this->view->setLayout('view');
     // validate the incoming cname
     if (!$this->_validCn($this->cn, true)) {
         $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
     }
     // Load the group object
     $this->view->group = Group::getInstance($this->cn);
     // check to make sure we were able to load group
     if (!is_object($this->view->group) || !$this->view->group->get('gidNumber') || !$this->view->group->get('cn')) {
         $this->suggestNonExistingGroupTask();
         return;
     }
     // Ensure it's an allowable group type to display
     if (!in_array($this->view->group->get('type'), array(1, 3))) {
         $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
     }
     // ensure the group is published
     if ($this->view->group->get('published') != 1) {
         $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
     }
     // Ensure the group has been published or has been approved
     if ($this->view->group->get('approved') != 1) {
         //get list of members & managers & invitees
         $managers = $this->view->group->get('managers');
         $members = $this->view->group->get('members');
         $invitees = $this->view->group->get('invitees');
         $members_invitees = array_merge($members, $invitees);
         $managers_members_invitees = array_merge($managers, $members, $invitees);
         //if user is not member, manager, or invitee deny access
         if (!in_array(User::get('id'), $managers_members_invitees)) {
             $this->_errorHandler(404, Lang::txt('COM_GROUPS_ERROR_NOT_FOUND'));
         }
         //if user is NOT manager but member or invitee
         if (!in_array(User::get('id'), $managers) && in_array(User::get('id'), $members_invitees)) {
             $this->unapprovedGroupTask();
             return;
         }
         //set notification and clear after
         $this->setNotification(Lang::txt('COM_GROUPS_PENDING_APPROVAL_WARNING'), 'warning');
     }
     // Get the group params
     $this->view->gparams = new \Hubzero\Config\Registry($this->view->group->get('params'));
     // Check authorization
     $this->view->authorized = Helpers\View::authorize($this->view->group);
     // get active tab
     $this->view->tab = Helpers\View::getTab($this->view->group);
     $this->view->trueTab = strtolower(Request::getVar('active', 'overview'));
     // get group pages if any
     $pageArchive = Page\Archive::getInstance();
     $pages = $pageArchive->pages('list', array('gidNumber' => $this->view->group->get('gidNumber'), 'state' => array(0, 1), 'orderby' => 'lft ASC'));
     // custom error handling for super groups
     Helpers\View::attachCustomErrorHandler($this->view->group);
     // add the overview content
     $overviewContent = '';
     $activePage = null;
     if ($this->view->tab == 'overview') {
         // add home page to pages list
         $pages = Helpers\Pages::addHomePage($this->view->group, $pages);
         // fetch the active page
         $activePage = Helpers\Pages::getActivePage($this->view->group, $pages);
         // are we on the login
         if ($this->view->trueTab == 'login') {
             $overviewContent = Helpers\View::superGroupLogin($this->view->group);
         }
         // check to see if we have super group component or php page
         if ($overviewContent == null && $this->config->get('super_components', 0)) {
             $overviewContent = Helpers\View::superGroupComponents($this->view->group, $this->view->trueTab);
         }
         // do we have group php pages
         if ($overviewContent == null) {
             $overviewContent = Helpers\View::superGroupPhpPages($this->view->group);
         }
         //set overview content
         if ($overviewContent == null) {
             $overviewContent = Helpers\Pages::displayPage($this->view->group, $activePage);
         }
     }
     // build the title
     $this->_buildTitle($pages);
     // build pathway
     $this->_buildPathway($pages);
     //set some vars for view
     $this->view->title = $this->_title;
     $this->view->content = Helpers\View::displaySectionsContent($this->view->group, $overviewContent);
     $this->view->activePage = $activePage;
     $this->view->notifications = $this->getNotifications() ? $this->getNotifications() : array();
     //is this a super group?
     if ($this->view->group->isSuperGroup()) {
         //use group template file if we have it
         Request::setVar('tmpl', 'group');
         // must call here cause otherwise doesnt load template
         $this->view->css()->js();
         // load super group template
         // parse & render
         $superGroupTemplate = new Helpers\Template();
         $superGroupTemplate->set('group', $this->view->group)->set('tab', $this->view->trueTab)->set('content', $this->view->content)->set('page', $this->view->activePage)->parse()->render();
         // echo content & stop execution
         return $superGroupTemplate->output(true);
     }
     //display view
     $this->view->display();
 }
Example #2
0
 /**
  * Display Active Tab Title, next to group name
  *
  * @param    $group    \Hubzero\User\Group Object
  * @return   string
  */
 public static function displayTab($group)
 {
     //get group categories
     $sections = self::getSections();
     //get active tab
     $tab = self::getTab($group);
     // If a sub-page of the overview tab
     $active = strtolower(Request::getVar('active', 'overview'));
     if ($tab == 'overview' && $tab != $active) {
         $pageArchive = Archive::getInstance();
         $pages = $pageArchive->pages('list', array('gidNumber' => $group->get('gidNumber'), 'state' => array(0, 1), 'orderby' => 'lft ASC'));
         // fetch the active page
         $activePage = Pages::getActivePage($group, $pages);
         if ($activePage) {
             return $activePage->get('title');
         }
     }
     //return title of active tab
     foreach ($sections as $section) {
         if ($tab == $section['name']) {
             return $section['title'];
         }
     }
 }