Example #1
0
 /**
  * Retrieves the group template
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return	
  */
 public function getGroupTemplate()
 {
     $ids = $this->input->get('groups', array(), 'array');
     if (!$ids) {
         return $this->ajax->reject();
     }
     $groups = array();
     foreach ($ids as $id) {
         $group = ES::group($id);
         $groups[] = $group;
     }
     $theme = ES::themes();
     $theme->set('groups', $groups);
     $html = $theme->output('admin/profiles/form.groups.item');
     return $this->ajax->resolve($html);
 }
Example #2
0
 /**
  * Retrieves a list of default groups
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return	
  */
 public function getDefaultGroups()
 {
     $params = $this->getParams();
     $items = $params->get('default_groups');
     $groups = array();
     if (!$items) {
         return $groups;
     }
     foreach ($items as $id) {
         $group = ES::group($id);
         $groups[] = $group;
     }
     return $groups;
 }
Example #3
0
 /**
  * Allows user to join a group
  *
  * @since	1.2
  * @access	public
  */
 public function joinGroup()
 {
     // Check for request forgeries
     ES::checkToken();
     // Only registered members allowed
     ES::requireLogin();
     // Get the group id
     $id = $this->input->get('id', 0, 'int');
     $group = ES::group($id);
     if (!$group->id || !$id) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_GROUPS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $this->view->call(__FUNCTION__);
     }
     // Get the user's access as we want to limit the number of groups they can join
     $access = $this->my->getAccess();
     $total = $this->my->getTotalGroups();
     if ($access->exceeded('groups.join', $total)) {
         return $this->view->call('exceededJoin');
     }
     // Create a member record for the group
     $group->createMember($this->my->id);
     return $this->view->call(__FUNCTION__, $group);
 }
Example #4
0
 /**
  * Displays the join group dialog
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function joinGroup()
 {
     // Only logged in users are allowed here.
     FD::requireLogin();
     // Get the group id from request
     $id = $this->input->get('id', 0, 'int');
     // Determines if this is an api request
     $api = $this->input->get('api', false, 'bool');
     // Load up the group
     $group = ES::group($id);
     if (!$id || !$group) {
         return $this->ajax->reject();
     }
     // Try to load the member object
     $member = ES::table('GroupMember');
     $member->load(array('uid' => $this->my->id, 'type' => SOCIAL_TYPE_USER, 'cluster_id' => $group->id));
     // Determines which namespace we should be using
     $namespace = 'site/groups/dialog.join.open';
     // Check if the group is open or closed
     if ($group->isClosed()) {
         if ($member->state == SOCIAL_GROUPS_MEMBER_PUBLISHED) {
             $namespace = 'site/groups/dialog.join.invited';
         } else {
             $namespace = 'site/groups/dialog.join.closed';
         }
     }
     $theme = ES::themes();
     $theme->set('group', $group);
     $contents = $theme->output($namespace);
     return $this->ajax->resolve($contents);
 }