public function execute($item)
 {
     $model = FD::model('comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     $users[] = $item->actor_id;
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     $content = '';
     if (count($users) == 1 && !empty($item->content)) {
         $content = JString::substr(strip_tags($item->content), 0, 30);
         if (JString::strlen($item->content) > 30) {
             $content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
         }
     }
     $item->content = $content;
     list($element, $group, $verb) = explode('.', $item->context_type);
     $streamItem = FD::table('streamitem');
     $state = $streamItem->load(array('context_type' => $element, 'actor_type' => $group, 'verb' => $verb, 'context_id' => $item->uid));
     if (!$state) {
         return;
     }
     $owner = $streamItem->actor_id;
     if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner) {
         $item->title = JText::sprintf('APP_USER_ARTICLE_USER_COMMENTED_ON_YOUR_ITEM' . $plurality, $names);
         return $item;
     }
     if ($item->actor_id == $owner && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_ARTICLE_OWNER_COMMENTED_ON_ITEM' . FD::user($owner)->getGenderLang(), $names);
         return $item;
     }
     $item->title = JText::sprintf('APP_USER_ARTICLE_USER_COMMENTED_ON_USER_ITEM' . $plurality, $names, FD::user($owner)->getName());
     return $item;
 }
Example #2
0
 /**
  * Method to get the field input markup.
  *
  * @return  string	The field input markup.
  * @since   1.6
  */
 protected function getInput()
 {
     // Load the language file.
     FD::language()->loadAdmin();
     // Attach dialog's css file.
     JFactory::getDocument()->addStylesheet(rtrim(JURI::root(), '/') . '/administrator/components/com_easysocial/themes/default/styles/style.css');
     // Render the headers
     FD::page()->start();
     $theme = FD::themes();
     $label = (string) $this->element['label'];
     $name = (string) $this->name;
     $title = JText::_('COM_EASYSOCIAL_JFIELD_SELECT_USER');
     if ($this->value) {
         $model = FD::model('Users');
         $id = (int) $model->getUserIdFromAlias($this->value);
         $user = FD::user($id);
         $title = $user->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/user');
     // 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;
 }
 public function execute($item, $calendar)
 {
     $model = FD::model('comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Include the notification actor
     $users[] = $item->actor_id;
     // Exclude the current user
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     $content = '';
     if (count($users) == 1 && !empty($item->content)) {
         $content = JString::substr(strip_tags($item->content), 0, 30);
         if (JString::strlen($item->content) > 30) {
             $content .= JText::_('COM_EASYSOCIAL_ELLIPSES');
         }
     }
     $item->content = $content;
     if ($calendar->user_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $item->title = JText::sprintf('APP_USER_CALENDAR_USER_COMMENTED_ON_YOUR_EVENT' . $plurality, $names);
         return $item;
     }
     if ($calendar->user_id == $item->actor_id && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_CALENDAR_OWNER_COMMENTED_ON_EVENT' . FD::user($calendar->user_id)->getGendarLang(), $names);
         return $item;
     }
     $item->title = JText::sprintf('APP_USER_CALENDAR_USER_COMMENTED_ON_USER_EVENT' . $plurality, $names, FD::user($calendar->user_id)->getName());
     return $item;
 }
 /**
  *
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function execute($item)
 {
     // Get the badge
     $badge = FD::table('Badge');
     $badge->load($item->uid);
     // Break the namespace
     list($element, $group, $verb, $owner) = explode('.', $item->context_type);
     // Get the permalink of the achievement item which is the stream item
     $streamItem = FD::table('StreamItem');
     $streamItem->load(array('context_type' => $element, 'verb' => $verb, 'actor_type' => $group, 'actor_id' => $owner));
     // Get comment participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     $users[] = $item->actor_id;
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // Get the badge image
     $item->image = $badge->getAvatar();
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     // We need to generate the notification message differently for the author of the item and the recipients of the item.
     if ($owner == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $item->title = JText::sprintf('APP_USER_BADGES_USER_COMMENTED_ON_YOUR_ACHIEVEMENT' . $plurality, $names, $badge->get('title'));
         return $item;
     }
     if ($owner == $item->actor_id && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_BADGES_OWNER_COMMENTED_ON_ACHIEVEMENT' . FD::user($owner)->getGenderLang(), $names, $badge->get('title'));
         return $item;
     }
     // This is for 3rd party viewers
     $item->title = JText::sprintf('APP_USER_BADGES_USER_COMMENTED_ON_USERS_ACHIEVEMENT' . $plurality, $names, FD::user($stream->actor_id)->getName(), $badge->get('title'));
     return $item;
 }
 public function execute($item)
 {
     $model = FD::model('likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     $users[] = $item->actor_id;
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     list($element, $group, $verb) = explode('.', $item->context_type);
     $streamItem = FD::table('streamitem');
     $state = $streamItem->load(array('context_type' => $element, 'actor_type' => $group, 'verb' => $verb, 'context_id' => $item->uid));
     if (!$state) {
         return;
     }
     $owner = $streamItem->actor_id;
     if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner) {
         $item->title = JText::sprintf('APP_USER_ARTICLE_USER_LIKES_YOUR_ITEM' . $plurality, $names);
         return $item;
     }
     if ($item->actor_id == $owner && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_ARTICLE_OWNER_LIKES_ITEM' . FD::user($owner)->getGenderLang(), $names);
         return $item;
     }
     $item->title = JText::sprintf('APP_USER_ARTICLE_USER_LIKES_USER_ITEM' . $plurality, $names, FD::user($owner)->getName());
     return $item;
 }
Example #6
0
 public function display($tpl = null)
 {
     $auth = JRequest::getString('auth');
     // Get the current logged in user's information
     $model = FD::model('Users');
     $id = $model->getUserIdFromAuth($auth);
     $userId = JRequest::getInt('userid');
     // If user id is not passed in, return logged in user
     if (!$userId) {
         $userId = $id;
     }
     // If we still can't find user's details, throw an error
     if (!$userId) {
         $this->set('code', 403);
         $this->set('message', JText::_('Invalid user id provided.'));
         return parent::display();
     }
     $me = FD::user($id);
     $user = FD::user($userId);
     $this->set('id', $userId);
     $this->set('isself', $id == $userId);
     $this->set('isfriend', $user->isFriends($id));
     $this->set('isfollower', $user->isFollowed($id));
     $this->set('username', $user->username);
     $this->set('friend_count', $user->getTotalFriends());
     $this->set('follower_count', $user->getTotalFollowing());
     $this->set('badges', $user->getTotalBadges());
     $this->set('points', $user->getPoints());
     $this->set('avatar_thumb', $user->getAvatar());
     $birthday = $user->getFieldValue('BIRTHDAY');
     if (!empty($birthday)) {
         $this->set('age', $birthday->value->toAge());
     }
     $gender = $user->getFieldValue('GENDER');
     $this->set('gender', !empty($gender) ? $gender->data : 0);
     // Prepare DISPLAY custom fields
     FD::language()->loadAdmin();
     // FD::apps()->loadAllLanguages();
     $steps = FD::model('steps')->getSteps($user->profile_id, SOCIAL_TYPE_PROFILES, SOCIAL_PROFILES_VIEW_DISPLAY);
     $fields = FD::model('fields')->getCustomFields(array('profile_id' => $user->profile_id, 'data' => true, 'dataId' => $user->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_DISPLAY));
     $library = FD::fields();
     $args = array(&$user);
     $library->trigger('onGetValue', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Get the step mapping first
     $profileSteps = array();
     foreach ($steps as $step) {
         $profileSteps[$step->id] = JText::_($step->title);
     }
     $profileFields = array();
     foreach ($fields as $field) {
         $value = (string) $field->value;
         if (!empty($value)) {
             $data = array('group_id' => $field->step_id, 'group_name' => $profileSteps[$field->step_id], 'field_id' => $field->id, 'field_name' => JText::_($field->title), 'field_value' => (string) $field->value);
             $profileFields[] = $data;
         }
     }
     $this->set('more_info', $profileFields);
     $this->set('code', 200);
     parent::display();
 }
Example #7
0
 /**
  * Main method to display the badges view.
  *
  * @since	1.0
  * @access	public
  * @return	null
  *
  * @author	Mark Lee <*****@*****.**>
  */
 public function display($tpl = null)
 {
     // Add heading here.
     $this->setHeading('COM_EASYSOCIAL_HEADING_ALERTS');
     $this->setDescription('COM_EASYSOCIAL_DESCRIPTION_ALERTS');
     // Default filters
     $options = array();
     JToolbarHelper::publishList();
     JToolbarHelper::unpublishList();
     JToolbarHelper::divider();
     JToolbarHelper::custom('emailPublish', 'publish', '', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_PUBLISH_EMAIL'));
     JToolbarHelper::custom('emailUnpublish', 'unpublish', '', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_UNPUBLISH_EMAIL'));
     JToolbarHelper::divider();
     JToolbarHelper::custom('systemPublish', 'publish', '', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_PUBLISH_SYSTEM'));
     JToolbarHelper::custom('systemUnpublish', 'unpublish', '', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_UNPUBLISH_SYSTEM'));
     // Load badges model.
     $model = FD::model('Alert', array('initState' => true));
     // Get the current ordering.
     $ordering = $model->getState('ordering');
     $direction = $model->getState('direction');
     $published = $model->getState('published');
     $limit = $model->getState('limit');
     // Get the badges
     $alerts = $model->getItems();
     // Get pagination
     $pagination = $model->getPagination();
     $this->set('limit', $limit);
     $this->set('ordering', $ordering);
     $this->set('direction', $direction);
     $this->set('published', $published);
     $this->set('alerts', $alerts);
     $this->set('pagination', $pagination);
     echo parent::display('admin/alerts/default');
 }
Example #8
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');
 }
 public function execute($item)
 {
     // Get comment participants
     $model = FD::model('Likes');
     $users = $model->getLikerIds($item->uid, $item->context_type);
     // Merge to include actor, diff to exclude self, unique to remove dups, and values to reset the index
     $users = array_values(array_unique(array_diff(array_merge($users, array($item->actor_id)), array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     list($element, $group, $verb) = explode('.', $item->context_type);
     $event = FD::event($item->uid);
     $owner = FD::user($item->getParams()->get('owner_id'));
     // Verbs
     // makeadmin
     // going
     // notgoing
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_MAKEADMIN_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_MAKEADMIN_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_GOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_GOING_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_NOTGOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_NOTGOING_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_MAKEADMIN_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_MAKEADMIN_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_GOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_GOING_PLURAL
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_NOTGOING_SINGULAR
     // APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_NOTGOING_PLURAL
     if ($item->target_type === SOCIAL_TYPE_USER && $item->target_id == $owner->id) {
         $item->title = JText::sprintf(FD::string()->computeNoun('APP_USER_EVENTS_GUESTS_USER_LIKES_YOUR_UPDATE_' . strtoupper($verb), count($users)), $names);
         return $item;
     }
     $item->title = JText::sprintf(FD::string()->computeNoun('APP_USER_EVENTS_GUESTS_USER_LIKES_USERS_UPDATE_' . strtoupper($verb), count($users)), $names, $owner->getName());
     return $item;
 }
Example #10
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');
 }
Example #11
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);
 }
Example #12
0
 /**
  * Retrieves the list of groups
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function getGroups($user, $params)
 {
     $model = FD::model('Groups');
     $isUserAViewer = FD::user()->id == $user->id ? true : false;
     $groupOptions = array('uid' => $user->id, 'state' => SOCIAL_CLUSTER_PUBLISHED);
     // if $user is the current viewer, we will get all the groups
     if ($isUserAViewer) {
         $groupOptions['types'] = 'all';
     }
     $groups = $model->getGroups($groupOptions);
     $limit = $params->get('widget_profile_total', 5);
     // Get the total groups the user owns
     $groupCntOptions = array('types' => 'open');
     // if $user is the current viewer, we will get all the groups
     if ($isUserAViewer) {
         $groupCntOptions = array();
     }
     $total = $user->getTotalGroups($groupCntOptions);
     $theme = FD::themes();
     $theme->set('user', $user);
     $theme->set('limit', $limit);
     $theme->set('groups', $groups);
     $theme->set('total', $total);
     return $theme->output('themes:/apps/user/groups/widgets/profile/groups');
 }
Example #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);
     // 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');
 }
Example #14
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;
 }
Example #15
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');
 }
Example #16
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');
 }
 /**
  *
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function execute($item)
 {
     // Get the owner of the stream item since we need to notify the person
     $stream = FD::table('Stream');
     $stream->load($item->uid);
     // Get comment 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);
     $plurality = count($users) > 1 ? '_PLURAL' : 'SINGULAR';
     // We need to generate the notification message differently for the author of the item and the recipients of the item.
     if ($stream->actor_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $item->title = JText::sprintf('APP_USER_PROFILES_USER_LIKES_YOUR_PROFILE_UPDATES' . $plurality, $names);
         return $item;
     }
     if ($stream->actor_id == $item->actor_id && count($users)) {
         $item->title = JText::sprintf('APP_USER_PROFILES_OWNER_LIKES_PROFILE_UPDATE' . FD::user($stream->actor_id)->getGenderLang(), $names);
     }
     // This is for 3rd party viewers
     $item->title = JText::sprintf('APP_USER_PROFILES_USER_LIKES_USER_PROFILE_UPDATES' . $plurality, $names, FD::user($stream->actor_id)->getName());
     return $item;
 }
Example #18
0
 /**
  * Displays the application output in the canvas.
  *
  * @since   1.3
  * @access  public
  * @param   integer $uid    The event id.
  */
 public function display($uid = null, $docType = null)
 {
     $event = FD::event($uid);
     // Check if the viewer is allowed here.
     if (!$event->canViewItem()) {
         return $this->redirect($event->getPermalink(false));
     }
     // Get app params
     $params = $this->app->getParams();
     // Load the milestone
     $id = JRequest::getInt('milestoneId');
     $milestone = FD::table('Milestone');
     $milestone->load($id);
     if (!empty($milestone->id)) {
         FD::page()->title(JText::_('APP_EVENT_TASKS_TITLE_EDITING_MILESTONE'));
     } else {
         FD::page()->title(JText::_('APP_EVENT_TASKS_TITLE_CREATE_MILESTONE'));
     }
     // Get a list of members from the group
     $members = FD::model('Events')->getMembers($event->id);
     $this->set('members', $members);
     $this->set('milestone', $milestone);
     $this->set('params', $params);
     $this->set('event', $event);
     echo parent::display('views/form');
 }
Example #19
0
 /**
  * Main method to display the privacy view.
  *
  * @since	1.0
  * @access	public
  * @return	null
  *
  * @author	Sam <*****@*****.**>
  */
 public function display($tpl = null)
 {
     $this->setHeading('COM_EASYSOCIAL_HEADING_PRIVACY');
     $this->setDescription('COM_EASYSOCIAL_DESCRIPTION_PRIVACY');
     $state = JRequest::getInt('state', 1);
     JToolbarHelper::divider();
     JToolbarHelper::publishList('publish');
     JToolbarHelper::unpublishList('unpublish');
     JToolbarHelper::divider();
     JToolbarHelper::deleteList('', 'delete', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_DELETE'));
     $model = FD::model('Privacy', array('initState' => true));
     $limit = $model->getState('limit');
     $ordering = $model->getState('ordering');
     $direction = $model->getState('direction');
     $search = $model->getState('search');
     $privacy = $model->getList();
     // Get pagination
     $pagination = $model->getPagination();
     $this->set('ordering', $ordering);
     $this->set('direction', $direction);
     $this->set('limit', $limit);
     $this->set('search', $search);
     $this->set('pagination', $pagination);
     $this->set('privacy', $privacy);
     $this->set('state', $state);
     FD::language()->loadSite();
     FD::apps()->loadAllLanguages();
     echo parent::display('admin/privacy/default');
 }
Example #20
0
 public function getParents()
 {
     FD::checkToken();
     $type = $this->input->get('type', '', 'string');
     $parents = FD::model('Regions')->getRegions(array('type' => $type, 'state' => SOCIAL_STATE_PUBLISHED));
     return $this->view->call(__FUNCTION__, $parents);
 }
Example #21
0
 /**
  * Allows remote user to authenticate via a normal http request and returns with an authentication code.
  *
  * @since	1.2.8
  * @access	public
  * @param	string
  * @return
  */
 public function auth()
 {
     $username = JRequest::getVar('username');
     $password = JRequest::getVar('password');
     $data = array('username' => $username, 'password' => $password);
     $app = JFactory::getApplication();
     $state = $app->login($data);
     if ($state === false) {
         $this->set('code', 403);
         $this->set('message', JText::_('Invalid username or password provided'));
         return parent::display();
     }
     // Get the user's id based on the username.
     $model = FD::model('Users');
     $id = $model->getUserId('username', $username);
     if (!$id) {
         $this->set('code', 403);
         $this->set('message', JText::_('Unable to locate the user id with the given username.'));
         return parent::display();
     }
     $user = FD::user($id);
     // User logs in successfully. Generate an authentication code for the user
     $user->auth = md5($user->password . JFactory::getDate()->toSql());
     $user->store();
     $this->set('auth', $user->auth);
     $this->set('code', 200);
     $this->set('id', $user->id);
     return parent::display();
 }
Example #22
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($eventId = null, $docType = null)
 {
     $event = FD::event($eventId);
     // Check if the viewer is allowed here.
     if (!$event->canViewItem()) {
         return $this->redirect($event->getPermalink(false));
     }
     // Get app params
     $params = $this->app->getParams();
     $model = FD::model('Discussions');
     $options = array('limit' => $params->get('total', 10));
     $discussions = $model->getDiscussions($event->id, SOCIAL_TYPE_EVENT, $options);
     $pagination = $model->getPagination();
     $pagination->setVar('option', 'com_easysocial');
     $pagination->setVar('view', 'events');
     $pagination->setVar('layout', 'item');
     $pagination->setVar('id', $event->getAlias());
     $pagination->setVar('appId', $this->app->getAlias());
     $this->set('app', $this->app);
     $this->set('params', $params);
     $this->set('pagination', $pagination);
     $this->set('event', $event);
     $this->set('discussions', $discussions);
     echo parent::display('events/default');
 }
Example #23
0
 public function display($tpl = null)
 {
     // Check access
     if (!$this->authorise('easysocial.access.stream')) {
         $this->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
     }
     // Set page heading
     $this->setHeading(JText::_('COM_EASYSOCIAL_HEADING_STREAM'));
     // Set page description
     $this->setDescription(JText::_('COM_EASYSOCIAL_DESCRIPTION_STREAM'));
     // Set page icon
     $this->setIcon('ies-database');
     // Check if this is from after execution
     $success = JRequest::getInt('success');
     $model = FD::model('stream', array('initState' => true));
     $items = $model->getItemsWithState();
     $ordering = $model->getState('ordering');
     $direction = $model->getState('direction');
     $limit = $model->getState('limit');
     $state = $model->getState('state');
     $pagination = $model->getPagination();
     // Add button
     $this->toolbar($state);
     // set variable into themes.
     $this->set('pagination', $pagination);
     $this->set('ordering', $ordering);
     $this->set('direction', $direction);
     $this->set('limit', $limit);
     $this->set('state', $state);
     $this->set('items', $items);
     // var_dump($state);
     echo parent::display('admin/stream/default');
 }
Example #24
0
 /**
  * Default application listings page.
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	null
  */
 public function display($tpl = null)
 {
     // redirect to main page.
     $mainframe = JFactory::getApplication();
     $mainframe->redirect('index.php?option=com_easysocial');
     return;
     $info = FD::info();
     $info->set($this->getMessage());
     // Set the page heading
     $this->setHeading(JText::_('COM_EASYSOCIAL_HEADING_INDEXER'));
     // Set the page icon
     $this->setIcon('icon-jar jar-console_command');
     // Set the page description
     $this->setDescription(JText::_('COM_EASYSOCIAL_DESCRIPTION_INDEXER'));
     // set joomla toolbar buttons
     $this->toolbar();
     $component = JRequest::getVar('component', '');
     $type = JRequest::getVar('type', '');
     // Get the applications model.
     $model = FD::model('Indexer');
     $filterItems = $model->getFilters();
     // Load the applications.
     $items = $model->getItems(array('type' => $type, 'component' => $component));
     // Get the pagination.
     $pagination = $model->getPagination();
     $this->set('type', $type);
     $this->set('component', $component);
     $this->set('filterItem', $filterItems);
     $this->set('items', $items);
     $this->set('pagination', $pagination);
     parent::display('admin/indexer/default');
 }
Example #25
0
 public function create_report()
 {
     $app = JFactory::getApplication();
     $msg = $app->input->get('message', '', 'STRING');
     $title = $app->input->get('user_title', '', 'STRING');
     $item_id = $app->input->get('itemId', 0, 'INT');
     $log_user = $this->plugin->get('user')->id;
     $data = array();
     $data['message'] = $msg;
     $data['uid'] = $item_id;
     $data['type'] = 'stream';
     $data['title'] = $title;
     $data['extension'] = 'com_easysocial';
     //build share url use for share post through app
     $sharing = FD::get('Sharing', array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item_id, 'external' => true, 'xhtml' => true)), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small'));
     $url = $sharing->url;
     $data['url'] = $url;
     // Get the reports model
     $model = FD::model('Reports');
     // Determine if this user has the permissions to submit reports.
     $access = FD::access();
     // Determine if this user has exceeded the number of reports that they can submit
     $total = $model->getCount(array('created_by' => $log_user));
     if ($access->exceeded('reports.limit', $total)) {
         $final_result['message'] = "Limit exceeds";
         $final_result['status'] = true;
         return $final_result;
     }
     // Create the report
     $report = FD::table('Report');
     $report->bind($data);
     // Set the creator id.
     $report->created_by = $log_user;
     // Set the default state of the report to new
     $report->state = 0;
     // Try to store the report.
     $state = $report->store();
     // If there's an error, throw it
     if (!$state) {
         $final_result['message'] = "Can't save report";
         $final_result['status'] = true;
         return $final_result;
     }
     // @badge: reports.create
     // Add badge for the author when a report is created.
     $badge = FD::badges();
     $badge->log('com_easysocial', 'reports.create', $log_user, JText::_('COM_EASYSOCIAL_REPORTS_BADGE_CREATED_REPORT'));
     // @points: reports.create
     // Add points for the author when a report is created.
     $points = FD::points();
     $points->assign('reports.create', 'com_easysocial', $log_user);
     // Determine if we should send an email
     $config = FD::config();
     if ($config->get('reports.notifications.moderators')) {
         $report->notify();
     }
     $final_result['message'] = "Report logged successfully!";
     $final_result['status'] = true;
     return $final_result;
 }
Example #26
0
 /**
  * Retrieves a list of countries from the manifest file.
  *
  * @since   1.0
  * @access  public
  * @return  Array    An array of countries.
  *
  * @author  Jason Rey <*****@*****.**>
  */
 public static function getCountries($source = 'regions')
 {
     static $countries = array();
     if (!isset($countries[$source])) {
         $data = new stdClass();
         if ($source === 'file') {
             $file = JPATH_ADMINISTRATOR . '/components/com_easysocial/defaults/countries.json';
             $contents = JFile::read($file);
             $json = FD::json();
             $data = $json->decode($contents);
             $data = (array) $data;
             // Sort by alphabet
             asort($data);
             $data = (object) $data;
         }
         if ($source === 'regions') {
             $countries = FD::model('Regions')->getRegions(array('type' => SOCIAL_REGION_TYPE_COUNTRY, 'state' => SOCIAL_STATE_PUBLISHED, 'ordering' => 'ordering'));
             foreach ($countries as $country) {
                 $data->{$country->code} = $country->name;
             }
         }
         $countries[$source] = $data;
     }
     return $countries[$source];
 }
Example #27
0
 public function runscript()
 {
     // Check for request forgeries
     FD::checkToken();
     // Get the key
     $key = $this->input->get('key', '', 'default');
     // Get the model
     $model = FD::model('Maintenance');
     $script = $model->getItemByKey($key);
     if (!$script) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_MAINTENANCE_SCRIPT_NOT_FOUND'), SOCIAL_MSG_ERROR);
         return $this->view->call(__FUNCTION__);
     }
     $classname = $script->classname;
     if (!class_exists($classname)) {
         $this->view->setMessage(JText::_('COM_EASYSOCIAL_MAINTENANCE_CLASS_NOT_FOUND'), SOCIAL_MSG_ERROR);
         return $this->view->call(__FUNCTION__);
     }
     $class = new $classname();
     try {
         $class->main();
     } catch (Exception $e) {
         $this->view->setMessage($e->getMessage(), SOCIAL_MSG_ERROR);
         return $this->view->call(__FUNCTION__);
     }
     return $this->view->call(__FUNCTION__);
 }
 /**
  * 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);
     // Merge to include actor, diff to exclude self, unique to remove dups, and values to reset the index
     $users = array_values(array_unique(array_diff(array_merge($users, array($item->actor_id)), array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     // When someone likes on the photo that you have uploaded in a event
     if ($item->context_type == 'news.event.create') {
         // We do not want to display any content if the person likes a event announcement
         $item->content = '';
         // Get the news object
         $news = FD::table('EventNews');
         $news->load($item->uid);
         // Get the event from the stream
         $event = FD::event($news->cluster_id);
         // Set the content
         if ($event) {
             $item->image = $event->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_EVENT_NEWS_USER_LIKES_YOUR_ANNOUNCEMENT', count($users));
             $item->title = JText::sprintf($langString, $names, $event->getName());
             return $item;
         }
         // This is for 3rd party viewers
         $langString = FD::string()->computeNoun('APP_EVENT_NEWS_USER_LIKES_USER_ANNOUNCEMENT', count($users));
         $item->title = JText::sprintf($langString, $names, FD::user($news->created_by)->getName(), $event->getName());
         return;
     }
     return;
 }
 public function execute($item)
 {
     $contexts = explode('.', $item->context_type);
     $streamItem = FD::table('StreamItem');
     $streamItem->load(array('context_id' => $item->uid, 'context_type' => $contexts[0], 'verb' => $contexts[2]));
     $stream = FD::table('Stream');
     $stream->load($streamItem->uid);
     // Get likes participants
     $model = FD::model('Comments');
     $users = $model->getParticipants($item->uid, $item->context_type);
     // Include the notification actor
     $users[] = $item->actor_id;
     $users = array_values(array_unique(array_diff($users, array(FD::user()->id))));
     // Convert the names to stream-ish
     $names = FD::string()->namesToNotifications($users);
     $plurality = count($users) > 1 ? '_PLURAL' : '_SINGULAR';
     if ($stream->actor_id == $item->target_id && $item->target_type == SOCIAL_TYPE_USER) {
         $item->title = JText::sprintf('APP_USER_RELATIONSHIP_USER_COMMENTED_ON_YOUR_RELATIONSHIP_STATUS' . $plurality, $names);
         return $item;
     }
     if ($stream->actor_id == $item->actor_id && count($users) == 1) {
         $item->title = JText::sprintf('APP_USER_RELATIONSHIP_OWNER_COMMENTED_ON_RELATIONSHIP_STATUS' . FD::user($stream->actor_id)->getGenderLang(), $names);
         return $item;
     }
     $item->title = JText::sprintf('APP_USER_RELATIONSHIP_USER_COMMENTED_ON_USER_RELATIONSHIP_STATUS' . $plurality, $names, FD::user($stream->actor_id)->getName());
     return $item;
 }
Example #30
-1
 /**
  * Display a list of items that are reported on the site.
  *
  * @access	public
  * @return	null
  *
  */
 public function display($tpl = null)
 {
     // Apply buttons
     JToolbarHelper::custom('purge', 'trash', '', JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_BUTTON_PURGE_REPORTS'), false);
     JToolbarHelper::deleteList();
     // Set the structure heading here.
     $this->setHeading(JText::_('COM_EASYSOCIAL_TOOLBAR_TITLE_REPORTS'));
     // Set the page icon here.
     $this->setIcon('icon-jar jar-warning_cleanup');
     // Set the structure description here.
     $this->setDescription(JText::_('COM_EASYSOCIAL_DESCRIPTION_REPORTS'));
     $model = FD::model('Reports', array('initState' => true));
     $search = $model->getState('search');
     $limit = $model->getState('limit');
     $ordering = $model->getState('ordering');
     $direction = $model->getState('direction');
     // Get list of reports
     $reports = $model->getReports();
     // Get pagination
     $pagination = $model->getPagination();
     $this->set('ordering', $ordering);
     $this->set('direction', $direction);
     $this->set('search', $search);
     $this->set('limit', $limit);
     $this->set('pagination', $pagination);
     $this->set('reports', $reports);
     return parent::display('admin/reports/default');
 }