Beispiel #1
0
 /**
  * Display module contents
  *
  * @return  void
  */
 public function run()
 {
     $database = \App::get('db');
     $uid = User::get('id');
     //get the params
     $this->cls = $this->params->get('moduleclass_sfx');
     $this->limit = $this->params->get('limit', 5);
     $this->charlimit = $this->params->get('charlimit', 100);
     $this->feedlink = $this->params->get('feedlink', 'yes');
     $this->morelink = $this->params->get('morelink', '');
     // Get popular groups
     $popularGroups = Group\Helper::getPopularGroups();
     $counter = 0;
     $groupsToDisplay = array();
     foreach ($popularGroups as $g) {
         // Get the group
         $group = Group::getInstance($g->gidNumber);
         // Check join policy
         $joinPolicy = $group->get('join_policy');
         // If group is invite only or closed check if th user is a member of the group
         if ($joinPolicy > 1) {
             // if not a member do not display the group
             if (!$group->isMember($uid)) {
                 continue;
             }
         }
         $groupsToDisplay[] = $g;
         $counter++;
         if ($counter == $this->limit) {
             break;
         }
     }
     //set groups to view
     $this->groups = $groupsToDisplay;
     require $this->getLayoutPath();
 }
Beispiel #2
0
 /**
  * Intro Page
  *
  * @return  void
  */
 public function displayTask()
 {
     // set the neeced layout
     $this->view->setLayout('display');
     // build the title
     $this->_buildTitle();
     // build pathway
     $this->_buildPathway();
     //vars
     $mytags = '';
     $this->view->mygroups = array('members' => null, 'invitees' => null, 'applicants' => null);
     $this->view->populargroups = array();
     $this->view->interestinggroups = array();
     //get the users profile
     $profile = \Hubzero\User\Profile::getInstance(User::get("id"));
     //if we have a users profile load their groups and groups matching their tags
     if (is_object($profile)) {
         //get users tags
         include_once PATH_CORE . DS . 'components' . DS . 'com_members' . DS . 'models' . DS . 'tags.php';
         $mt = new \Components\Members\Models\Tags($profile->get("uidNumber"));
         $mytags = $mt->render('string');
         //get users groups
         $this->view->mygroups['members'] = \Hubzero\User\Helper::getGroups($profile->get("uidNumber"), 'members', 1);
         $this->view->mygroups['invitees'] = \Hubzero\User\Helper::getGroups($profile->get("uidNumber"), 'invitees', 1);
         $this->view->mygroups['applicants'] = \Hubzero\User\Helper::getGroups($profile->get("uidNumber"), 'applicants', 1);
         $this->view->mygroups = array_filter($this->view->mygroups);
         //get groups user may be interested in
         $this->view->interestinggroups = Group\Helper::getGroupsMatchingTagString($mytags, \Hubzero\User\Helper::getGroups($profile->get("uidNumber")));
     }
     //get the popular groups
     $this->view->populargroups = Group\Helper::getPopularGroups(3);
     //get featured groups
     $this->view->featuredgroups = Group\Helper::getFeaturedGroups($this->config->get('intro_featuredgroups_list', ''));
     //set some vars for view
     $this->view->config = $this->config;
     $this->view->title = $this->_title;
     // get view notifications
     $this->view->notifications = $this->getNotifications() ? $this->getNotifications() : array();
     //display view
     $this->view->display();
 }