Пример #1
0
 /**
  * Method to add a member into an existing profile type.
  *
  * @param   null    All parameters are from HTTP $_POST
  * @return  JSON    JSON encoded string.
  */
 public function insertMember()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Get the id from request.
     $id = JRequest::getInt('id');
     // Get the profile id.
     $profile_id = JRequest::getInt('profile_id');
     // Get the current view.
     $view = $this->getCurrentView();
     if (!$id) {
         $view->setMessage(JText::_('Please enter a valid user id.'), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__);
     }
     // @TODO: Try to remove user from any other existing profile maps.
     $model = FD::model('Profiles');
     $model->removeUserFromProfiles($id);
     $table = FD::table('ProfileMap');
     $table->user_id = $id;
     $table->profile_id = $profile_id;
     $table->state = SOCIAL_STATE_PUBLISHED;
     // @rule: Store user profile bindings
     $table->store();
     $user = FD::user($id);
     return $view->call(__FUNCTION__, $user);
 }
Пример #2
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::getInstance('Ajax');
     // Get the userid
     $userid = JRequest::getInt('userid', 0);
     // Get the event
     $event = JRequest::getString('event');
     // Set the current username
     $current = '';
     if (!empty($userid)) {
         $user = FD::user($userid);
         $current = $user->username;
     }
     // Get the provided username that the user has typed.
     $username = JRequest::getVar('username', '');
     // Username is required, check if username is empty
     if (JString::strlen($username) < $this->params->get('min')) {
         return $ajax->reject(JText::sprintf('PLG_FIELDS_JOOMLA_USERNAME_MIN_CHARACTERS', $this->params->get('min')));
     }
     // Test if username is allowed (by pass for adminedit).
     if ($event !== 'onAdminEdit' && !SocialFieldsUserJoomlaUsernameHelper::allowed($username, $this->params)) {
         return $ajax->reject(JText::_('PLG_FIELDS_JOOMLA_USERNAME_NOT_ALLOWED'));
     }
     // Test if username exists.
     if (SocialFieldsUserJoomlaUsernameHelper::exists($username, $current)) {
         return $ajax->reject(JText::_('PLG_FIELDS_JOOMLA_USERNAME_NOT_AVAILABLE'));
     }
     // Test if the username is valid
     if (!SocialFieldsUserJoomlaUsernameHelper::isValid($username, $this->params)) {
         return $ajax->reject(JText::_('PLG_FIELDS_JOOMLA_USERNAME_IS_INVALID'));
     }
     $text = JText::_('PLG_FIELDS_JOOMLA_USERNAME_AVAILABLE');
     return $ajax->resolve($text);
 }
Пример #3
0
 /**
  * Deletes a file from the system.
  *
  * @since	1.0
  * @access	public
  * @param	null
  * @return	null
  */
 public function delete()
 {
     // Check for request forgeries
     FD::checkToken();
     // Only logged in users are allowed to delete anything
     FD::requireLogin();
     // Get the current view
     $view = $this->getCurrentView();
     // Get the current user
     $my = FD::user();
     // Get the uploader id
     $id = JRequest::getInt('id');
     $uploader = FD::table('Uploader');
     $uploader->load($id);
     // Check if the user is really permitted to delete the item
     if (!$id || !$uploader->id || $uploader->user_id != $my->id) {
         return $view->call(__FUNCTION__);
     }
     $state = $uploader->delete();
     // If deletion fails, silently log the error
     if (!$state) {
         FD::logError(__FILE__, __LINE__, JText::_('UPLOADER: Unable to delete the item [' . $uploader->id . '] because ' . $uploader->getError()));
     }
     return $view->call(__FUNCTION__);
 }
Пример #4
0
 /**
  * Deletes a feed item
  *
  * @since	1.0
  * @access	public
  */
 public function delete()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Ensure that the user is logged in.
     FD::requireLogin();
     // Get the ajax object.
     $ajax = FD::ajax();
     // Get current logged in user
     $my = FD::user();
     // Get app's id.
     $id = JRequest::getInt('id');
     // Get feed id.
     $feedId = JRequest::getInt('feedId');
     // Get feed table
     $feed = $this->getTable('Feed');
     $feed->load($feedId);
     if (!$feedId || !$feed->id) {
         return $ajax->reject(JText::_('APP_FEEDS_INVALID_ID_PROVIDED'));
     }
     // Ensure that the user is allowed to delete this feed.
     if ($feed->user_id != $my->id) {
         return $ajax->reject(JText::_('APP_FEEDS_NOT_ALLOWED_TO_DELETE'));
     }
     // Try to delete the feed now.
     $state = $feed->delete();
     if (!$state) {
         return $ajax->reject($feed->getError());
     }
     return $ajax->resolve();
 }
 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;
 }
Пример #6
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();
 }
Пример #7
0
 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;
 }
Пример #8
0
 public function __construct($config = array())
 {
     // Initialize page.
     $page = new stdClass();
     // Initialize page values.
     $page->icon = '';
     $page->iconUrl = '';
     $page->heading = '';
     $page->description = '';
     $this->page = $page;
     $this->my = FD::user();
     // Initialize the breadcrumbs
     $this->breadcrumbs = array();
     $view = $this->getName();
     // Disallow access if user does not have sufficient permissions
     $rule = 'easysocial.access.' . $view;
     // For fields, it uses a different view
     if ($view == 'fields') {
         $rule = 'easysocial.access.profiles';
     }
     if (!$this->authorise($rule)) {
         $this->redirect('index.php', JText::_('JERROR_ALERTNOAUTHOR'), 'error');
     }
     parent::__construct($config);
 }
Пример #9
0
 protected function _getURL($user, $sizex, $sizey)
 {
     $user = KunenaFactory::getUser($user);
     $user = FD::user($user->userid);
     $avatar = $user->getAvatar(SOCIAL_AVATAR_LARGE);
     return $avatar;
 }
Пример #10
0
 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;
 }
Пример #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)
 {
     $event = FD::event($uid);
     // Get the article item
     $news = FD::table('EventNews');
     $news->load($this->input->get('newsId', 0, 'int'));
     // Check if the user is really allowed to view this item
     if (!$event->canViewItem()) {
         return $this->redirect($event->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' => $event->getAlias(), 'type' => SOCIAL_TYPE_EVENT, 'id' => $this->app->getAlias(), 'articleId' => $news->id), false);
     // Apply comments for the article
     $comments = FD::comments($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT, array('url' => $url));
     // Apply likes for the article
     $likes = FD::likes()->get($news->id, 'news', 'create', SOCIAL_APPS_GROUP_EVENT);
     // Set the page title
     FD::page()->title($news->get('title'));
     // Retrieve the params
     $params = $this->app->getParams();
     $this->set('app', $this->app);
     $this->set('params', $params);
     $this->set('event', $event);
     $this->set('likes', $likes);
     $this->set('comments', $comments);
     $this->set('author', $author);
     $this->set('news', $news);
     echo parent::display('canvas/item');
 }
Пример #12
0
 /**
  * Displays the gender in the position profileHeaderA
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function profileHeaderA($key, $user, $field)
 {
     $value = $field->data;
     // If user didn't set their gender, don't need to do anything
     if (!$value) {
         return;
     }
     $my = FD::user();
     $privacyLib = FD::privacy($my->id);
     if (!$privacyLib->validate('core.view', $field->id, SOCIAL_TYPE_FIELD, $user->id)) {
         return;
     }
     $theme = FD::themes();
     $theme->set('value', $value);
     $theme->set('params', $field->getParams());
     // linkage to advanced search page.
     if ($field->searchable) {
         $params = array('layout' => 'advanced');
         $params['criterias[]'] = $field->unique_key . '|' . $field->element;
         $params['operators[]'] = 'equal';
         $params['conditions[]'] = $value;
         $advsearchLink = FRoute::search($params);
         $theme->set('advancedsearchlink', $advsearchLink);
     }
     echo $theme->output('fields/user/gender/widgets/display');
 }
Пример #13
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');
 }
Пример #14
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');
 }
Пример #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($userId = null, $docType = null)
 {
     // Require user to be logged in
     FD::requireLogin();
     $id = JRequest::getVar('schedule_id');
     // Get the user that's being accessed.
     $user = FD::user($userId);
     $calendar = FD::table('Calendar');
     $calendar->load($id);
     if (!$calendar->id || !$id) {
         FD::info()->set(false, JText::_('APP_CALENDAR_CANVAS_INVALID_SCHEDULE_ID'), SOCIAL_MSG_ERROR);
         return $this->redirect(FD::profile(array('id' => $user->getAlias()), false));
     }
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     $result = $privacy->validate('apps.calendar', $calendar->id, 'view', $user->id);
     if (!$result) {
         FD::info()->set(false, JText::_('APP_CALENDAR_NO_ACCESS'), SOCIAL_MSG_ERROR);
         JFactory::getApplication()->redirect(FRoute::dashboard());
     }
     FD::page()->title($calendar->title);
     // Render the comments and likes
     $likes = FD::likes();
     $likes->get($id, 'calendar', 'create', SOCIAL_APPS_GROUP_USER);
     // Apply comments on the stream
     $comments = FD::comments($id, 'calendar', 'create', SOCIAL_APPS_GROUP_USER, array('url' => FRoute::albums(array('layout' => 'item', 'id' => $id))));
     $params = $this->app->getParams();
     $this->set('params', $params);
     $this->set('likes', $likes);
     $this->set('comments', $comments);
     $this->set('calendar', $calendar);
     $this->set('user', $user);
     echo parent::display('canvas/item/default');
 }
Пример #16
0
 /**
  * Retrieve the title of the stream
  *
  * @since	1.2
  * @access	public
  * @param	string
  * @return
  */
 public function getTitle()
 {
     // Get the actors
     $actors = $this->item->actors;
     // Get the source id
     $sourceId = $this->share->uid;
     // Load the stream
     $stream = FD::table('Stream');
     $stream->load($sourceId);
     // If stream cannot be loaded, skip this altogether
     if (!$stream->id) {
         return;
     }
     // Build the permalink to the stream item
     $link = FRoute::stream(array('layout' => 'item', 'id' => $sourceId));
     // Get the target user.
     $target = FD::user($stream->actor_id);
     $actor = $actors[0];
     $theme = FD::get('Themes');
     $theme->set('actor', $actor);
     $theme->set('link', $link);
     $theme->set('target', $target);
     $title = $theme->output('apps/group/shares/streams/stream/title');
     return $title;
 }
Пример #17
0
 /**
  * Redirects a notification item to the intended location
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function route()
 {
     // The user needs to be logged in to access notifications
     FD::requireLogin();
     // Check for user profile completeness
     FD::checkCompleteProfile();
     $id = JRequest::getInt('id');
     $table = FD::table('Notification');
     $table->load($id);
     if (!$id || !$table->id) {
         FD::info()->set(JText::_('COM_EASYSOCIAL_NOTIFICATIONS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
         return $this->redirect(FRoute::dashboard(array(), false));
     }
     // Check if the user is allowed to view this notification item.
     $my = FD::user();
     if ($table->target_id != $my->id) {
         FD::info()->set(JText::_('COM_EASYSOCIAL_NOTIFICATIONS_NOT_ALLOWED'), SOCIAL_MSG_ERROR);
         return $this->redirect(FRoute::dashboard(array(), false));
     }
     // Mark the notification item as read
     $table->markAsRead();
     // Ensure that all &amp; are replaced with &
     $url = str_ireplace('&amp;', '&', $table->url);
     $this->redirect(FRoute::_($url, false));
     $this->close();
 }
Пример #18
0
 /**
  * Triggered before comments notify subscribers
  *
  * @since	1.0
  * @access	public
  * @param	SocialTableComments	The comment object
  * @return
  */
 public function onAfterCommentSave(&$comment)
 {
     $allowed = array('files.user.create');
     if (!in_array($comment->element, $allowed)) {
         return;
     }
     // For likes on albums when user uploads multiple photos within an album
     if ($comment->element == 'files.user.create') {
         // Since the uid is tied to the album we can get the album object
         $stream = FD::table('Stream');
         $stream->load($comment->uid);
         // Get the actor of the likes
         $actor = FD::user($comment->created_by);
         $owner = FD::user($stream->actor_id);
         // Set the email options
         $emailOptions = array('title' => 'APP_USER_FILES_EMAILS_COMMENT_STREAM_SUBJECT', 'template' => 'apps/user/files/comment.status.item', 'permalink' => $stream->getPermalink(true, true), 'comment' => $comment->comment, 'actor' => $actor->getName(), 'actorAvatar' => $actor->getAvatar(SOCIAL_AVATAR_SQUARE), 'actorLink' => $actor->getPermalink(true, true), 'target' => $owner->getName(), 'targetLink' => $owner->getPermalink(true, true));
         $systemOptions = array('context_type' => $comment->element, 'context_ids' => $comment->id, 'url' => $stream->getPermalink(false, false, false), 'actor_id' => $comment->created_by, 'uid' => $comment->uid, 'aggregate' => true);
         // Notify the owner of the photo first
         if ($stream->actor_id != $comment->created_by) {
             FD::notify('comments.item', array($stream->actor_id), $emailOptions, $systemOptions);
         }
         // Get a list of recipients to be notified for this stream item
         // We exclude the owner of the note and the actor of the like here
         $recipients = $this->getStreamNotificationTargets($comment->uid, 'files', 'user', 'create', array(), array($stream->actor_id, $comment->created_by));
         $emailOptions['title'] = 'APP_USER_FILES_EMAILS_COMMENT_STREAM_INVOLVED_SUBJECT';
         $emailOptions['template'] = 'apps/user/files/comment.status.involved';
         // Notify other participating users
         FD::notify('comments.involved', $recipients, $emailOptions, $systemOptions);
         return;
     }
 }
 /**
  *
  *
  * @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;
 }
Пример #20
0
 public function __construct()
 {
     // Define Joomla's app
     $this->app = JFactory::getApplication();
     $this->input = $this->app->input;
     // Load configuration object.
     $config = FD::config();
     $jConfig = FD::jconfig();
     // Define the current logged in user or guest
     if (is_null(self::$user)) {
         self::$user = FD::user();
     }
     // Define the current logged in user's access.
     if (is_null(self::$userAccess)) {
         self::$userAccess = FD::access();
     }
     if (is_null(self::$tmplMode)) {
         self::$tmplMode = $this->input->get('tmpl', '', 'default');
     }
     // Get the current access
     $this->my = self::$user;
     $this->access = self::$userAccess;
     // Define our own configuration
     $this->config = $config;
     // Define template's own configuration
     if (is_null(self::$templateConfig)) {
         self::$templateConfig = $this->getConfig();
     }
     $this->template = self::$templateConfig;
     // Define Joomla's configuration so the world can use it.
     $this->jConfig = $jConfig;
     // Determine if the current request has tmpl=xxx
     $this->tmpl = self::$tmplMode;
 }
Пример #21
0
 /**
  * Delete's the location from the database.
  *
  * @since	1.0
  * @access	public
  */
 public function delete()
 {
     // Check for valid token
     FD::checkToken();
     // Guest users shouldn't be allowed to delete any location at all.
     FD::requireLogin();
     $my = FD::user();
     $id = JRequest::getInt('id');
     $view = FD::getInstance('View', 'Location', false);
     $location = FD::table('Location');
     $location->load($id);
     // If id is invalid throw errors.
     if (!$location->id) {
         $view->setErrors(JText::_('COM_EASYSOCIAL_LOCATION_INVALID_ID'));
     }
     // If user do not own item, throw errors.
     if ($my->id !== $location->user_id) {
         $view->setErrors(JText::_('COM_EASYSOCIAL_LOCATION_ERROR_YOU_ARE_NOT_OWNER'));
     }
     // Try to delete location.
     if (!$location->delete()) {
         $view->setErrors($location->getError());
     }
     return $view->delete();
 }
Пример #22
0
 /**
  * subscription toggle.
  *
  * @since 1.0
  * @access public
  */
 public function toggle()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Ensure that the user needs to be logged in.
     FD::requireLogin();
     $uid = JRequest::getInt('uid');
     $type = JRequest::getVar('type');
     $group = JRequest::getVar('group', SOCIAL_APPS_GROUP_USER);
     $notify = JRequest::getVar('notify', '0');
     $my = FD::user();
     $view = FD::view('Subscriptions', false);
     $subscribe = FD::get('Subscriptions');
     $isFollowed = $subscribe->isFollowing($uid, $type, $group, $my->id);
     $verb = $isFollowed ? 'unfollow' : 'follow';
     $state = '';
     if ($isFollowed) {
         // unsubscribe user.
         $state = $subscribe->unfollow($uid, $type, $group, $my->id);
     } else {
         $state = $subscribe->follow($uid, $type, $group, $my->id, $notify);
     }
     if (!$state) {
         FD::logError(__FILE__, __LINE__, 'Subscription: Unable to ' . $verb . ' the stream item because of the error message ' . $subscribe->getError());
         // Set the view with error
         $view->setMessage($subscribe->getError(), SOCIAL_MSG_ERROR);
         return $view->call(__FUNCTION__, $verb);
     }
     return $view->call(__FUNCTION__, $verb);
 }
Пример #23
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;
 }
Пример #24
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 userid
     $userid = JRequest::getInt('userid', 0);
     // Set the current username
     $current = '';
     if (!empty($userid)) {
         $user = FD::user($userid);
         $current = $user->permalink;
     }
     // 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 (!SocialFieldsUserPermalinkHelper::valid($permalink, $this->params)) {
         return $ajax->reject(JText::_('PLG_FIELDS_PERMALINK_INVALID_PERMALINK'));
     }
     // Test if permalink exists
     if (SocialFieldsUserPermalinkHelper::exists($permalink, $current)) {
         return $ajax->reject(JText::_('PLG_FIELDS_PERMALINK_NOT_AVAILABLE'));
     }
     $text = JText::_('PLG_FIELDS_PERMALINK_AVAILABLE');
     return $ajax->resolve($text);
 }
Пример #25
0
 public function profileHeaderB($key, $user, $field)
 {
     // Get the data
     $data = $field->data;
     if (!$data) {
         return;
     }
     $my = FD::user();
     $privacyLib = FD::privacy($my->id);
     if (!$privacyLib->validate('core.view', $field->id, SOCIAL_TYPE_FIELD, $user->id)) {
         return;
     }
     $obj = FD::makeObject($data);
     $theme = FD::themes();
     $hide = true;
     foreach ($obj as $k => &$v) {
         $v = $theme->html('string.escape', $v);
         if (!empty($v)) {
             $hide = false;
         }
     }
     if ($hide) {
         return true;
     }
     $params = $field->getParams();
     // Convert country to full text
     if (!empty($obj->country)) {
         $obj->country_code = $obj->country;
         $obj->country = SocialFieldsUserAddressHelper::getCountryName($obj->country, $params->get('data_source'));
     }
     $theme->set('value', $obj);
     $theme->set('params', $field->getParams());
     echo $theme->output('fields/user/address/widgets/display');
 }
Пример #26
0
 /**
  *
  *
  * @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;
 }
Пример #27
0
 /**
  * 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;
 }
Пример #28
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();
 }
Пример #29
0
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     if ($stream->context != 'relationship') {
         return;
     }
     $params = $this->getParams();
     if (!$params->get('stream_approve', true)) {
         return;
     }
     // Get the actor
     $actor = $stream->actor;
     // check if the actor is ESAD profile or not, if yes, we skip the rendering.
     if (!$actor->hasCommunityAccess()) {
         $stream->title = '';
         return;
     }
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($includePrivacy && !$privacy->validate('core.view', $stream->contextId, 'relationship', $stream->actor->id)) {
         return;
     }
     $stream->color = '#DC554F';
     $stream->fonticon = 'ies-heart';
     $stream->label = FD::_('APP_USER_RELATIONSHIP_STREAM_TOOLTIP', true);
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $registry = FD::registry($stream->params);
     $this->set('type', $registry->get('type'));
     $this->set('actor', $stream->actor);
     $this->set('target', $stream->targets[0]);
     $stream->title = parent::display('streams/' . $stream->verb . '.title');
     if ($includePrivacy) {
         $stream->privacy = $privacy->form($stream->contextId, 'relationship', $stream->actor->id, 'core.view', false, $stream->uid);
     }
     return true;
 }
Пример #30
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;
 }