コード例 #1
0
ファイル: helper.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * Display module contents
  *
  * @return  void
  */
 public function display()
 {
     // Get the module parameters
     $this->moduleclass = $this->params->get('moduleclass');
     $this->limit = intval($this->params->get('limit', 100));
     $this->recentgroups = array();
     // Get the user's groups
     $this->allgroups = $this->_getGroups(User::get('id'), 'all');
     include_once \Component::path('com_groups') . DS . 'models' . DS . 'recent.php';
     $recents = Recent::all()->whereEquals('user_id', User::get('id'))->order('created', 'desc')->limit(5)->rows();
     foreach ($this->allgroups as $group) {
         foreach ($recents as $recent) {
             if ($recent->get('group_id') == $group->gidNumber) {
                 $this->recentgroups[] = $group;
             }
         }
     }
     if (!User::authorise('core.create', 'com_groups')) {
         $this->params->set('button_show_add', 0);
     }
     require $this->getLayoutPath();
 }
コード例 #2
0
ファイル: groups.php プロジェクト: kevinwojo/hubzero-cms
 /**
  * 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'));
     if ($this->view->group->get('approved') != 1 && $this->view->trueTab != 'overview') {
         return $this->unapprovedGroupTask();
     }
     // Record the user
     if (!User::isGuest() && in_array(User::get('id'), $this->view->group->get('members'))) {
         include_once dirname(dirname(__DIR__)) . DS . 'models' . DS . 'recent.php';
         Recent::hit(User::get('id'), $this->view->group->get('gidNumber'));
     }
     // 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();
 }