Пример #1
0
 /**
  * Method to get the field input markup.
  *
  * @return  string	The field input markup.
  * @since   1.2
  */
 protected function getInput()
 {
     // Load the language file.
     FD::language()->loadAdmin();
     FD::language()->loadSite();
     // Render the headers
     FD::page()->start();
     // Attach dialog's css file.
     JFactory::getDocument()->addStylesheet(rtrim(JURI::root(), '/') . '/administrator/components/com_easysocial/themes/default/styles/style.css');
     $theme = FD::themes();
     $label = (string) $this->element['label'];
     $name = (string) $this->name;
     $title = JText::_('COM_EASYSOCIAL_JFIELD_SELECT_GROUP');
     if ($this->value) {
         $id = explode(':', $this->value);
         $id = $id[0];
         $group = FD::group($id);
         $title = $group->getName();
     }
     $theme->set('name', $name);
     $theme->set('id', $this->id);
     $theme->set('value', $this->value);
     $theme->set('label', $label);
     $theme->set('title', $title);
     $output = $theme->output('admin/jfields/group');
     // We do not want to process stylesheets on Joomla 2.5 and below.
     $options = array();
     if (FD::version()->getVersion() < 3) {
         $options['processStylesheets'] = false;
     }
     FD::page()->end($options);
     return $output;
 }
Пример #2
0
 /**
  * Processes likes notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(&$item)
 {
     // For rejection, we know that there's always only 1 target
     if ($item->cmd == 'groups.promoted') {
         // Get the group
         $group = FD::group($item->uid);
         $item->title = JText::sprintf('APP_GROUP_GROUPS_YOU_HAVE_BEEN_PROMOTED_AS_THE_GROUP_ADMIN', $group->getName());
         $item->image = $group->getAvatar();
         return;
     }
     // For rejection, we know that there's always only 1 target
     if ($item->cmd == 'groups.user.rejected') {
         // Get the group
         $group = FD::group($item->uid);
         $item->title = JText::sprintf('APP_GROUP_GROUPS_YOUR_APPLICATION_HAS_BEEN_REJECTED', $group->getName());
         return;
     }
     // For user removal, we know that there's always only 1 target
     if ($item->cmd == 'groups.user.removed') {
         // Get the group
         $group = FD::group($item->uid);
         $item->title = JText::sprintf('APP_GROUP_GROUPS_YOU_HAVE_BEEN_REMOVED_FROM_GROUP', $group->getName());
         return;
     }
 }
Пример #3
0
 /**
  * Filters the output of members
  *
  * @since	1.2
  * @access	public
  * @return
  */
 public function filterMembers()
 {
     // Check for request forgeriess
     FD::checkToken();
     // Ensure that the user is logged in.
     FD::requireLogin();
     // Load up ajax lib
     $ajax = FD::ajax();
     // Get the group
     $id = JRequest::getInt('id');
     $group = FD::group($id);
     // @TODO: Check whether the viewer can really view the contents
     // Get the current filter
     $filter = JRequest::getWord('filter');
     $options = array();
     if ($filter == 'admin') {
         $options['admin'] = true;
     }
     if ($filter == 'pending') {
         $options['state'] = SOCIAL_GROUPS_MEMBER_PENDING;
     }
     $model = FD::model('Groups');
     $users = $model->getMembers($group->id, $options);
     $pagination = $model->getPagination();
     // Load the contents
     $theme = FD::themes();
     $theme->set('pagination', $pagination);
     $theme->set('group', $group);
     $theme->set('users', $users);
     $contents = $theme->output('apps/group/members/groups/default.list');
     return $ajax->resolve($contents);
 }
Пример #4
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $group = FD::group($uid);
     $editor = JFactory::getEditor();
     // Only allow group admin to create or edit news
     if (!$group->isAdmin() && !$this->my->isSiteAdmin()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_GROUPS_ONLY_MEMBER_ARE_ALLOWED'), SOCIAL_MSG_ERROR);
         return $this->redirect($group->getPermalink(false));
     }
     $id = JRequest::getInt('newsId');
     $news = FD::table('GroupNews');
     $news->load($id);
     FD::page()->title(JText::_('APP_GROUP_NEWS_FORM_UPDATE_PAGE_TITLE'));
     // Determine if this is a new record or not
     if (!$id) {
         $news->comments = true;
         FD::page()->title(JText::_('APP_GROUP_NEWS_FORM_CREATE_PAGE_TITLE'));
     }
     // Get app params
     $params = $this->app->getParams();
     $this->set('params', $params);
     $this->set('news', $news);
     $this->set('editor', $editor);
     $this->set('group', $group);
     echo parent::display('canvas/form');
 }
Пример #5
0
 /**
  * Validates the username.
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	JSON	A jsong encoded string.
  *
  * @author	Jason Rey <*****@*****.**>
  */
 public function isValid()
 {
     // Render the ajax lib.
     $ajax = FD::ajax();
     // Get the group id
     $groupId = JRequest::getInt('groupid', 0);
     // Set the current username
     $current = '';
     if (!empty($groupId)) {
         $group = FD::group($groupId);
         $current = $group->alias;
     }
     // Get the provided permalink
     $permalink = JRequest::getVar('permalink', '');
     // Check if the field is required
     if (!$this->field->isRequired() && empty($permalink)) {
         return true;
     }
     // Check if the permalink provided is valid
     if (!SocialFieldsGroupPermalinkHelper::valid($permalink, $this->params)) {
         return $ajax->reject(JText::_('PLG_FIELDS_GROUP_PERMALINK_INVALID_PERMALINK'));
     }
     // Test if permalink exists
     if (SocialFieldsGroupPermalinkHelper::exists($permalink) && $permalink != $current) {
         return $ajax->reject(JText::_('PLG_FIELDS_GROUP_PERMALINK_NOT_AVAILABLE'));
     }
     $text = JText::_('PLG_FIELDS_GROUP_PERMALINK_AVAILABLE');
     return $ajax->resolve($text);
 }
Пример #6
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($groupId = null, $docType = null)
 {
     $group = FD::group($groupId);
     // Render the rss model
     $model = FD::model('RSS');
     $result = $model->getItems($group->id, SOCIAL_TYPE_GROUP);
     // If there are tasks, we need to bind them with the table.
     $feeds = array();
     if ($result) {
         foreach ($result as $row) {
             // Bind the result back to the note object.
             $rss = FD::table('Rss');
             $rss->bind($row);
             // Initialize the parser.
             $parser = @JFactory::getFeedParser($rss->url);
             $rss->parser = $parser;
             $rss->total = @$parser->get_item_quantity();
             $rss->items = @$parser->get_items();
             $feeds[] = $rss;
         }
     }
     // Get the app params
     $params = $this->app->getParams();
     $limit = $params->get('total', 5);
     $this->set('totalDisplayed', $limit);
     $this->set('appId', $this->app->id);
     $this->set('group', $group);
     $this->set('feeds', $feeds);
     echo parent::display('views/default');
 }
Пример #7
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.2
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($groupId = null, $docType = null)
 {
     $group = FD::group($groupId);
     // Check if the viewer is allowed here.
     if (!$group->canViewItem()) {
         return $this->redirect($group->getPermalink(false));
     }
     // Get app params
     $params = $this->app->getParams();
     // Load the milestone
     $id = JRequest::getInt('milestoneId');
     $milestone = FD::table('Milestone');
     $milestone->load($id);
     FD::page()->title(JText::_('APP_GROUP_TASKS_TITLE_CREATE_MILESTONE'));
     if ($id && $milestone->id) {
         FD::page()->title(JText::_('APP_GROUP_TASKS_TITLE_EDITING_MILESTONE'));
     }
     // Get a list of members from the group
     $groupModel = FD::model('Groups');
     $members = $groupModel->getMembers($group->id);
     $this->set('members', $members);
     $this->set('milestone', $milestone);
     $this->set('params', $params);
     $this->set('group', $group);
     echo parent::display('views/form');
 }
Пример #8
0
 public function createStream($verb)
 {
     // Create a new stream item for this discussion
     $stream = FD::stream();
     // Get the stream template
     $tpl = $stream->getTemplate();
     // Someone just joined the group
     $tpl->setActor($this->created_by, SOCIAL_TYPE_USER);
     // Set the params to cache the group data
     $registry = FD::registry();
     $registry->set('news', $this);
     // Set the context
     $tpl->setContext($this->id, 'news');
     $group = FD::group($this->cluster_id);
     // Set the cluster
     $tpl->setCluster($this->cluster_id, SOCIAL_TYPE_GROUP, $group->type);
     // Set the verb
     $tpl->setVerb($verb);
     // Set the params
     $tpl->setParams($registry);
     if ($this->_stream_date) {
         $tpl->setDate($this->_stream_date);
     }
     $tpl->setAccess('core.view');
     // Add the stream
     $stream->add($tpl);
 }
Пример #9
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($groupId = null, $docType = null)
 {
     // Load up the group
     $group = FD::group($groupId);
     // Check if the viewer is really allowed to view news
     if ($group->isInviteOnly() && $group->isClosed() && !$group->isMember() && !$this->my->isSiteAdmin()) {
         return $this->redirect($group->getPermalink(false));
     }
     $params = $this->app->getParams();
     // Set the max length of the item
     $options = array('limit' => (int) $params->get('total', 10));
     $model = FD::model('Groups');
     $items = $model->getNews($group->id, $options);
     $pagination = $model->getPagination();
     // Format the item's content.
     $this->format($items, $params);
     $pagination->setVar('option', 'com_easysocial');
     $pagination->setVar('view', 'groups');
     $pagination->setVar('layout', 'item');
     $pagination->setVar('id', $group->getAlias());
     $pagination->setVar('appId', $this->app->getAlias());
     $this->set('params', $params);
     $this->set('pagination', $pagination);
     $this->set('group', $group);
     $this->set('items', $items);
     echo parent::display('canvas/default');
 }
Пример #10
0
 public function sidebarBottom($groupId)
 {
     $params = $this->getParams();
     if (!$params->get('widget', true)) {
         return;
     }
     $group = FD::group($groupId);
     if (!$group->getAccess()->get('events.groupevent', true)) {
         return;
     }
     $my = FD::user();
     $days = $params->get('widget_days', 14);
     $total = $params->get('widget_total', 5);
     $date = FD::date();
     $now = $date->toSql();
     $future = FD::date($date->toUnix() + $days * 24 * 60 * 60)->toSql();
     $options = array();
     $options['start-after'] = $now;
     $options['start-before'] = $future;
     $options['limit'] = $total;
     $options['state'] = SOCIAL_STATE_PUBLISHED;
     $options['ordering'] = 'start';
     $options['group_id'] = $groupId;
     $events = FD::model('Events')->getEvents($options);
     if (empty($events)) {
         return;
     }
     $theme = FD::themes();
     $theme->set('events', $events);
     $theme->set('app', $this->app);
     echo $theme->output('themes:/apps/user/events/widgets/dashboard/upcoming');
 }
Пример #11
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $group = FD::group($uid);
     // Get the article item
     $news = FD::table('GroupNews');
     $news->load(JRequest::getInt('newsId'));
     // Check if the user is really allowed to view this item
     if (!$group->canViewItem()) {
         return $this->redirect($group->getPermalink(false));
     }
     // Get the author of the article
     $author = FD::user($news->created_by);
     // Get the url for the article
     $url = FRoute::apps(array('layout' => 'canvas', 'customView' => 'item', 'uid' => $group->getAlias(), 'type' => SOCIAL_TYPE_GROUP, 'id' => $this->app->getAlias(), 'articleId' => $news->id), false);
     // Apply comments for the article
     $comments = FD::comments($news->id, 'news', 'create', SOCIAL_APPS_GROUP_GROUP, array('url' => $url));
     // Apply likes for the article
     $likes = FD::likes()->get($news->id, 'news', 'create', SOCIAL_APPS_GROUP_GROUP);
     // Set the page title
     FD::page()->title($news->get('title'));
     // Get a list of other news
     $model = FD::model('Groups');
     // Retrieve the params
     $params = $this->app->getParams();
     $this->set('params', $params);
     $this->set('group', $group);
     $this->set('likes', $likes);
     $this->set('comments', $comments);
     $this->set('author', $author);
     $this->set('news', $news);
     echo parent::display('canvas/item');
 }
Пример #12
0
 function getSearch()
 {
     //init variable
     $app = JFactory::getApplication();
     $log_user = JFactory::getUser($this->plugin->get('user')->id);
     $nxt_lim = 20;
     $search = $app->input->get('search', '', 'STRING');
     $nxt_lim = $app->input->get('next_limit', 0, 'INT');
     $mapp = new EasySocialApiMappingHelper();
     $res = new stdClass();
     if (empty($search)) {
         $res->status = 0;
         $res->message = 'Empty searchtext';
         return $res;
     }
     $userid = $log_user->id;
     $serch_obj = new EasySocialModelSearch();
     $db = JFactory::getDbo();
     $query = $db->getQuery(true);
     $frnd_obj = new EasySocialModelFriends();
     $query->select($db->quoteName(array('su.user_id')));
     $query->from($db->quoteName('#__social_users', 'su'));
     $query->join('LEFT', $db->quoteName('#__users', 'u') . ' ON (' . $db->quoteName('su.user_id') . ' = ' . $db->quoteName('u.id') . ')');
     //->where(($db->quoteName('u.username') . ' LIKE '. $db->quote('\'% '.$search.'%\'') ).'OR' .( $db->quoteName('u.name') . ' LIKE '. $db->quote('\'%'.$search.'%\'') ).'OR'.( $db->quoteName('u.email') . ' LIKE '. $db->quote('\'%'.$search.'%\'')))
     if (!empty($search)) {
         $query->where("(u.username LIKE '%" . $search . "%' ) OR ( u.name LIKE '%" . $search . "%') OR ( u.email LIKE '%" . $search . "%')");
     }
     $query->order($db->quoteName('u.id') . 'ASC');
     $db->setQuery($query);
     $tdata = $db->loadObjectList();
     $susers = array();
     foreach ($tdata as $ky => $val) {
         $susers[] = FD::user($val->user_id);
     }
     $base_obj = $mapp->mapItem($susers, 'user', $log_user->id);
     $list['user'] = $this->createSearchObj($base_obj);
     //for group
     $query1 = $db->getQuery(true);
     $query1->select($db->quoteName(array('cl.id')));
     $query1->from($db->quoteName('#__social_clusters', 'cl'));
     if (!empty($search)) {
         $query1->where("(cl.title LIKE '%" . $search . "%' )");
     }
     $query1->order($db->quoteName('cl.id') . 'ASC');
     $db->setQuery($query1);
     $gdata = $db->loadObjectList();
     $grp_model = FD::model('Groups');
     $group = array();
     foreach ($gdata as $grp) {
         $group[] = FD::group($grp->id);
     }
     $list['group'] = $mapp->mapItem($group, 'group', $log_user->id);
     if (empty($list['group'])) {
         $ret_arr = new stdClass();
         $ret_arr->status = false;
         $ret_arr->message = "No group found in search";
         $list['group'] = $ret_arr;
     }
     return $list;
 }
Пример #13
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $group = FD::group($uid);
     $editor = JFactory::getEditor();
     $this->set('editor', $editor);
     $this->set('group', $group);
     echo parent::display('canvas/form');
 }
Пример #14
0
 public function __construct($id)
 {
     parent::__construct($id, 'group');
     if (!EB::easysocial()->exists()) {
         return;
     }
     $this->group = FD::group($id);
 }
Пример #15
0
 /**
  * Allows caller to update a stream
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function update()
 {
     // Check for request forgeries
     FD::checkToken();
     // Check for valid users
     FD::requireLogin();
     // Get the current view
     $view = $this->getCurrentView();
     // Get the stream id
     $id = JRequest::getInt('id');
     $stream = FD::table('Stream');
     $stream->load($id);
     // Check for valid stream id's.
     if (!$id || !$stream->id) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // @TODO: Check for permissions
     $my = FD::user();
     if ($stream->cluster_id) {
         $group = FD::group($stream->cluster_id);
         if (!$my->isSiteAdmin() && $stream->actor_id != $my->id && !$group->isAdmin()) {
             $view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_NO_PERMISSIONS_TO_EDIT'), SOCIAL_MSG_ERROR);
             return $view->call(__FUNCTION__);
         }
     } else {
         if (!$my->isSiteAdmin() && $stream->actor_id != $my->id) {
             $view->setMessage(JText::_('COM_EASYSOCIAL_STREAM_NO_PERMISSIONS_TO_EDIT'), SOCIAL_MSG_ERROR);
             return $view->call(__FUNCTION__);
         }
     }
     $content = JRequest::getVar('content', '', 'post', 'string', JREQUEST_ALLOWRAW);
     $mentions = JRequest::getVar('mentions');
     // Format the json string to array
     if (!empty($mentions)) {
         foreach ($mentions as &$mention) {
             $mention = FD::json()->decode($mention);
         }
     }
     // Process the content
     $stream->content = $content;
     // Set the last edited date
     $stream->edited = FD::date()->toSql();
     // Get the stream model and remove mentions
     $model = FD::model('Stream');
     $model->removeMentions($stream->id);
     // Now we need to add new mentions
     if ($mentions) {
         $model->addMentions($stream->id, $mentions);
     }
     // Save the stream
     $stream->store();
     // Because we know that story posts only has 1 item, we may safely assume that the first index.
     $items = $stream->getItems();
     $item = $items[0];
     return $view->call(__FUNCTION__, $item);
 }
Пример #16
0
 /**
  * Displays the application output in the canvas.
  *
  * @since	1.0
  * @access	public
  * @param	int		The user id that is currently being viewed.
  */
 public function display($groupId = null, $docType = null)
 {
     $group = FD::group($groupId);
     $model = FD::model('Groups');
     $users = $model->getMembers($group->id);
     $pagination = $model->getPagination();
     $this->set('group', $group);
     $this->set('users', $users);
     echo parent::display('groups/default');
 }
Пример #17
0
 /**
  * Display user photos on the side bar
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function sidebarBottom($groupId)
 {
     // Get the group
     $group = FD::group($groupId);
     $params = $this->app->getParams();
     if ($params->get('show_online', true)) {
         echo $this->getOnlineUsers($group);
     }
     if ($params->get('show_friends', true)) {
         echo $this->getFriends($group);
     }
 }
Пример #18
0
function getGroupAlias($id)
{
    static $groups = array();
    // Ensure that the id is purely an integer
    if (!isset($groups[$id])) {
        $group = FD::group($id);
        // We need to replace : with - since SH404 correctly processes it.
        $alias = $group->getAlias();
        $alias = str_ireplace(':', '-', $alias);
        $groups[$id] = $alias;
    }
    return $groups[$id];
}
Пример #19
0
 /**
  * Display user photos on the side bar
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function sidebarBottom($groupId)
 {
     // Get the group
     $group = FD::group($groupId);
     $params = $this->app->getParams();
     // Determines if we should display the online group members
     if ($params->get('show_online')) {
         echo $this->getOnlineUsers($group);
     }
     // Determines if we should display friends in this group
     if ($params->get('show_friends')) {
         echo $this->getFriends($group);
     }
 }
Пример #20
0
 /**
  * Displays the restricted page
  *
  * @since	4.0
  * @access	public
  * @param	string
  * @return
  */
 public function restricted($uid = null, $type = SOCIAL_TYPE_USER)
 {
     $ajax = FD::ajax();
     if ($type == SOCIAL_TYPE_USER) {
         $node = FD::user($uid);
     }
     if ($type == SOCIAL_TYPE_GROUP) {
         $node = FD::group($uid);
     }
     $this->set('showProfileHeader', true);
     $this->set('uid', $uid);
     $this->set('type', $type);
     $this->set('node', $node);
     $html = $theme->output('site/albums/restricted');
     $ajax->resolve($html);
 }
Пример #21
0
 /**
  * Display user photos on the side bar
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function sidebarBottom($groupId)
 {
     // Get the params of the group
     $params = $this->app->getParams();
     if (!$params->get('widget')) {
         return;
     }
     $group = FD::group($groupId);
     $theme = FD::themes();
     $limit = $params->get('widget_total', 5);
     $model = FD::model('Files');
     $options = array('limit' => $limit);
     $files = $model->getFiles($group->id, SOCIAL_TYPE_GROUP, $options);
     $theme->set('files', $files);
     echo $theme->output('themes:/apps/group/files/widgets/widget.files');
 }
Пример #22
0
 /**
  * Processes comment notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(SocialTableNotification &$item)
 {
     // Get the group item
     $group = FD::group($item->uid);
     // Get the actor
     $actor = FD::user($item->actor_id);
     // Set the title of the notification
     $item->title = JText::sprintf('APP_GROUP_NEWS_USER_POSTED_NEW_NEWS', $actor->getName(), $group->getName());
     if (!$item->context_ids) {
         return;
     }
     // Set the news item
     $news = FD::table('ClusterNews');
     $news->load($item->context_ids);
     $item->content = $news->title;
     return $item;
 }
Пример #23
0
 private function loadAccess($id = null, $type = SOCIAL_TYPE_USER)
 {
     // This is to prevent unnecessary multiple loading per user id
     static $loadedAccess = array();
     $uid = null;
     // Perform data standardization
     // If type is profile, then we just directly use it as profile id
     if ($type === SOCIAL_TYPE_PROFILES) {
         $uid = $id;
     }
     // If type is user then we deduce the profile id from the user
     if ($type === SOCIAL_TYPE_USER) {
         // Get the user object
         $my = FD::user($id);
         $uid = $my->profile_id;
         $type = SOCIAL_TYPE_PROFILES;
     }
     // clusters is the profiles equivalent
     // If type is groups category, then use the id directly
     if ($type === SOCIAL_TYPE_CLUSTERS) {
         $uid = $id;
     }
     // If the type is group, then get the group category id from the group
     if ($type === SOCIAL_TYPE_GROUP) {
         // @TODO: Get the group category id
         $group = FD::group($id);
         $uid = $group->category_id;
         $type = SOCIAL_TYPE_CLUSTERS;
     }
     if ($type === SOCIAL_TYPE_EVENT) {
         $event = FD::event($id);
         $uid = $event->category_id;
         $type = SOCIAL_TYPE_CLUSTERS;
     }
     $this->getDefaultValues($type);
     if (empty($loadedAccess[$type][$uid])) {
         // Load up the access based on the profile
         $model = FD::model('Access');
         $storedAccess = $model->getParams($uid, $type);
         // Merge all the group registries first.
         $registry = FD::registry($storedAccess);
         $loadedAccess[$type][$uid] = $registry;
     }
     $this->access = $loadedAccess[$type][$uid];
     return $this;
 }
Пример #24
0
 function request()
 {
     //init variable
     $app = JFactory::getApplication();
     $log_user = JFactory::getUser($this->plugin->get('user')->id);
     $group_id = $app->input->get('group_id', 0, 'INT');
     $req_val = $app->input->get('request', '', 'STRING');
     $other_user_id = $app->input->get('target_user', 0, 'INT');
     //$userid = ($other_user_id)?$other_user_id:$log_user->id;
     $data = array();
     $user = FD::user($other_user_id);
     $res = new stdClass();
     //$mapp = new EasySocialApiMappingHelper();
     //$grp_model = FD::model('Groups');
     if (!$group_id || !$other_user_id) {
         $res->success = 0;
         $res->message = "Insufficient inputs";
         return $res;
     } else {
         $group = FD::group($group_id);
         if ($group->isAdmin() != $log_user && $req_val != 'withdraw') {
             $res->success = 0;
             $res->message = "Unauthorised user to approve request";
             return $res;
         }
         switch ($req_val) {
             case 'Approve':
             case 'approve':
                 $res->success = $group->approveUser($other_user_id);
                 $res->message = $res->success ? "User request to join the group has been approved successfully" : "User request to join the group has been approved unsuccessfully";
                 break;
             case 'Reject':
             case 'reject':
                 $res->success = $group->rejectUser($other_user_id);
                 $res->message = $res->success ? "User application rejected successfully" : "Unable to reject application";
                 break;
             case 'Withdraw':
             case 'withdraw':
                 $res->success = $group->deleteMember($other_user_id);
                 $res->message = $res->success ? "You have successfully withdrawn your request to join the group" : "Unable to withdrawn your request to join the group";
                 break;
         }
         return $res;
     }
 }
 /**
  * Processes likes notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(&$item)
 {
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // When someone likes on the photo that you have uploaded in a group
     if ($item->context_type == 'files.group.uploaded') {
         $file = FD::table('File');
         $file->load($item->uid);
         // Get the group from the stream
         $group = FD::group($file->uid);
         // Set the content
         if ($file->hasPreview()) {
             $item->image = $file->getPreviewURI();
         }
         // We need to get the comment that is tied to this stream
         if (count($users) == 1) {
             $comment = FD::table('Comments');
             $comment->load(array('element' => 'files.group.uploaded', 'uid' => $item->uid));
             $item->content = $comment->comment;
         }
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($file->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $item->title = JText::sprintf('APP_GROUP_FILES_USER_COMMENTED_ON_YOUR_FILE', $names, $group->getName());
             return $item;
         }
         // This is for 3rd party viewers
         $item->title = JText::sprintf('APP_GROUP_FILES_USER_COMMENTED_ON_USERS_FILE', $names, FD::user($file->user_id)->getName(), $group->getName());
         return;
     }
     return;
 }
Пример #26
0
 /**
  * Renders the sidebar widget for group members
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return	
  */
 public function sidebarBottom($groupId)
 {
     if (!$this->app->getParams()->get('show_members', true)) {
         return;
     }
     $theme = FD::themes();
     $params = $this->app->getParams();
     $limit = (int) $params->get('limit', 10);
     // Load up the group
     $group = FD::group($groupId);
     $options = array('state' => SOCIAL_STATE_PUBLISHED, 'limit' => $limit);
     $model = FD::model('Groups');
     $members = $model->getMembers($group->id, $options);
     $link = FRoute::groups(array('id' => $group->getAlias(), 'appId' => $this->app->getAlias(), 'layout' => 'item'));
     $theme->set('members', $members);
     $theme->set('link', $link);
     echo $theme->output('themes:/apps/group/members/widgets/widget.members');
 }
 /**
  * Processes likes notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(&$item)
 {
     // Get likes participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // When someone likes on the photo that you have uploaded in a group
     if ($item->context_type == 'news.group.create') {
         // We do not want to display any content if the person likes a group announcement
         $item->content = '';
         // Get the news object
         $news = FD::table('ClusterNews');
         $news->load($item->uid);
         // Get the group from the stream
         $group = FD::group($news->cluster_id);
         // Set the content
         if ($group) {
             $item->image = $group->getAvatar();
         }
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($news->created_by == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $langString = FD::string()->computeNoun('APP_GROUP_NEWS_USER_LIKES_YOUR_ANNOUNCEMENT', count($users));
             $item->title = JText::sprintf($langString, $names, $group->getName());
             return $item;
         }
         // This is for 3rd party viewers
         $langString = FD::string()->computeNoun('APP_GROUP_NEWS_USER_LIKES_USER_ANNOUNCEMENT', count($users));
         $item->title = JText::sprintf($langString, $names, FD::user($news->created_by)->getName(), $group->getName());
         return;
     }
     return;
 }
 /**
  * Processes likes notifications
  *
  * @since   1.2
  * @access  public
  * @param   string
  * @return
  */
 public function execute(&$item)
 {
     // Get likes participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Include the actor of the stream item as the recipient
     $users = array_merge(array($item->actor_id), $users);
     // Ensure that the values are unique
     $users = array_unique($users);
     $users = array_values($users);
     // Exclude myself from the list of users.
     $index = array_search(FD::user()->id, $users);
     if ($index !== false) {
         unset($users[$index]);
         $users = array_values($users);
     }
     if ($item->context_ids) {
         $discussion = FD::table('Discussion');
         $discussion->load($item->context_ids);
         $item->content = JString::substr(strip_tags($discussion->content), 0, 30) . JText::_('COM_EASYSOCIAL_ELLIPSES');
     }
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // When someone likes on the photo that you have uploaded in a group
     if ($item->context_type == 'discussions.group.create') {
         $discussion = FD::table('Discussion');
         $discussion->load($item->context_ids);
         // Get the group from the stream
         $group = FD::group($discussion->uid);
         // Set the content to the discussion title.
         $item->content = $discussion->title;
         // We need to generate the notification message differently for the author of the item and the recipients of the item.
         if ($discussion->created_by == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
             $langString = FD::string()->computeNoun('APP_GROUP_DISCUSSIONS_USER_LIKES_YOUR_DISCUSSION', count($users));
             $item->title = JText::sprintf($langString, $names, $group->getName());
             return $item;
         }
         // This is for 3rd party viewers
         $langString = FD::string()->computeNoun('APP_GROUP_DISCUSSIONS_USER_LIKES_USERS_DISCUSSION', count($users));
         $item->title = JText::sprintf($langString, $names, FD::user($discussion->created_by)->getName(), $group->getName());
         return;
     }
     return;
 }
Пример #29
0
 function getGroup()
 {
     //init variable
     $app = JFactory::getApplication();
     $log_user = JFactory::getUser($this->plugin->get('user')->id);
     $group_id = $app->input->get('id', 0, 'INT');
     $other_user_id = $app->input->get('user_id', 0, 'INT');
     $userid = $other_user_id ? $other_user_id : $log_user->id;
     $data = array();
     $user = FD::user($userid);
     $mapp = new EasySocialApiMappingHelper();
     $grp_model = FD::model('Groups');
     if ($group_id) {
         $group[] = FD::group($group_id);
         //$pth = FD::photo($group[0]->creator_uid,'',$group[0]->id);
         $data['data'] = $mapp->mapItem($group, 'group', $log_user->id);
     }
     return $data;
 }
Пример #30
0
 /**
  * Displays the application output in the canvas.
  *
  * @since   1.0
  * @access  public
  * @param   int     The user id that is currently being viewed.
  */
 public function display($uid = null, $docType = null)
 {
     $group = FD::group($uid);
     if (!$group->isMember() && !$this->my->isSiteAdmin()) {
         FD::info()->set(false, JText::_('COM_EASYSOCIAL_GROUPS_ONLY_MEMBER_ARE_ALLOWED'), SOCIAL_MSG_ERROR);
         return $this->redirect($group->getPermalink(false));
     }
     // Set the page title
     FD::page()->title(JText::_('APP_GROUP_DISCUSSIONS_PAGE_TITLE_CREATE'));
     // Get the discussion item
     $discussion = FD::table('Discussion');
     // Determines if we should allow file sharing
     $access = $group->getAccess();
     $files = $access->get('files.enabled', true);
     $this->set('files', $files);
     $this->set('discussion', $discussion);
     $this->set('group', $group);
     echo parent::display('canvas/form');
 }