Example #1
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;
 }
Example #2
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');
 }
Example #3
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');
 }
Example #4
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');
 }
Example #5
0
 /**
  * Displays the age in the position profileHeaderA
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function profileHeaderA($key, $user, $field)
 {
     $my = FD::user();
     $privacyLib = FD::privacy($my->id);
     if (!$privacyLib->validate('core.view', $field->id, SOCIAL_TYPE_FIELD, $user->id)) {
         return;
     }
     $params = $field->getParams();
     if ($params->get('show_age') && !$privacyLib->validate('field.birthday', $field->id, 'year', $user->id)) {
         return;
     }
     // Get the current stored value.
     $value = $field->data;
     if (empty($value)) {
         return false;
     }
     if (is_array($value) && isset($value['date']) && !$value['date']) {
         // empty value. just return empty string.
         return false;
     }
     $data = new SocialFieldsUserDateTimeObject($value);
     $date = null;
     if (!empty($data->year) && !empty($data->month) && !empty($data->day)) {
         $date = $data->year . '-' . $data->month . '-' . $data->day;
     }
     if (!$date) {
         return;
     }
     $allowYear = true;
     $theme = FD::themes();
     if ($params->get('show_age')) {
         // Compute the age now.
         $age = $this->getAge($date);
         $theme->set('value', $age);
     } else {
         $allowYear = $privacyLib->validate('field.birthday', $field->id, 'year', $user->id);
         $format = $allowYear ? 'j F Y' : 'j F';
         $birthday = FD::date($date, false)->format($format);
         $theme->set('value', $birthday);
     }
     // linkage to advanced search page.
     if ($allowYear && $field->searchable) {
         $date = $data->format('Y-m-d');
         $params = array('layout' => 'advanced');
         $params['criterias[]'] = $field->unique_key . '|' . $field->element;
         $params['operators[]'] = 'between';
         $params['conditions[]'] = $date . ' 00:00:00' . '|' . $date . ' 23:59:59';
         $advsearchLink = FRoute::search($params);
         $theme->set('advancedsearchlink', $advsearchLink);
     }
     $theme->set('params', $params);
     echo $theme->output('fields/user/birthday/widgets/display');
 }
Example #6
0
 /**
  * Displays the dashboard widget
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function sidebarBottom()
 {
     // Get the app params
     $params = $this->app->getParams();
     $key = $params->get('dashboard_show_uniquekey', 'BIRTHDAY');
     $displayYear = $params->get('dashboard_show_birthday', 1);
     // Get current logged in user
     $my = FD::user();
     $birthdays = $this->getUpcomingBirthdays($key, $my->id);
     $ids = array();
     $dateToday = FD::date()->toFormat('md');
     $today = array();
     $otherDays = array();
     // Hide app when there's no upcoming birthdays
     if (!$birthdays) {
         return;
     }
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($birthdays) {
         foreach ($birthdays as $birthday) {
             $ids[] = $birthday->uid;
         }
         // Preload list of users
         FD::user($ids);
         foreach ($birthdays as $birthday) {
             $obj = new stdClass();
             $obj->user = FD::user($birthday->uid);
             $obj->birthday = $birthday->displayday;
             //Checking to display year here
             if ($displayYear) {
                 $dateFormat = JText::_('COM_EASYSOCIAL_DATE_DMY');
                 //check birtday the year privacy
                 if (!$privacy->validate('field.birthday', $birthday->field_id, 'year', $birthday->uid)) {
                     $dateFormat = JText::_('COM_EASYSOCIAL_DATE_DM');
                 }
             } else {
                 $dateFormat = JText::_('COM_EASYSOCIAL_DATE_DM');
             }
             $obj->display = FD::date($obj->birthday)->format($dateFormat);
             if ($birthday->day == $dateToday) {
                 $today[] = $obj;
             } else {
                 $otherDays[] = $obj;
             }
         }
     }
     $this->set('ids', $ids);
     $this->set('birthdays', $birthdays);
     $this->set('today', $today);
     $this->set('otherDays', $otherDays);
     echo parent::display('widgets/upcoming.birthday');
 }
Example #7
0
 /**
  * Retrieves a list of feeds created by a particular user.
  *
  * @since   1.0
  * @access  public
  * @param   int     $userId     The user's / creator's id.
  *
  * @return  Array               A list of notes item.
  */
 public function getItems($userId)
 {
     $db = FD::db();
     $sql = $db->sql();
     $sql->select('#__social_apps_calendar');
     $sql->where('user_id', $userId);
     $db->setQuery($sql);
     $result = $db->loadObjectList();
     $items = array();
     $privacy = FD::privacy(FD::user()->id);
     foreach ($result as $row) {
         if ($privacy->validate('apps.calendar', $row->id, 'view', $userId)) {
             $items[] = $row;
         }
     }
     return $items;
 }
Example #8
0
 public function getContent()
 {
     $message = $this->formatContent($this->share->content);
     $sourceId = $this->share->uid;
     // Load the album object
     $album = FD::table('Album');
     $album->load($sourceId);
     // Get user's privacy.
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if (!$privacy->validate('albums.view', $album->id, SOCIAL_TYPE_ALBUM, $album->uid)) {
         return false;
     }
     $theme = FD::get('Themes');
     $theme->set('album', $album);
     $theme->set('message', $message);
     $html = $theme->output('apps/user/shares/streams/albums/content');
     return $html;
 }
Example #9
0
 public function profileHeaderD($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;
     }
     // If there's no http:// or https:// , automatically append http://
     if (stristr($data, 'http://') === false && stristr($data, 'https://') === false) {
         $data = 'http://' . $data;
     }
     $theme = FD::themes();
     $theme->set('value', $data);
     $theme->set('params', $field->getParams());
     echo $theme->output('fields/user/url/widgets/display');
 }
Example #10
0
 /**
  * Triggered to validate the stream item whether should put the item as valid count or not.
  *
  * @since	1.2
  * @access	public
  * @param	jos_social_stream, boolean
  * @return  0 or 1
  */
 public function onStreamCountValidation(&$item, $includePrivacy = true)
 {
     // If this is not it's context, we don't want to do anything here.
     if ($item->context_type != 'feeds') {
         return false;
     }
     $item->cnt = 1;
     if ($includePrivacy) {
         $uid = $item->id;
         $my = FD::user();
         $privacy = FD::privacy($my->id);
         $sModel = FD::model('Stream');
         $aItem = $sModel->getActivityItem($item->id, 'uid');
         if ($aItem) {
             $uid = $aItem[0]->id;
             if (!$privacy->validate('core.view', $uid, SOCIAL_TYPE_ACTIVITY, $item->actor_id)) {
                 $item->cnt = 0;
             }
         }
     }
     return true;
 }
Example #11
0
 /**
  * to update privacy on an object by current logged in user
  *
  * @since	1.0
  * @access	public
  * @param
  * @return	string
  */
 public function update()
 {
     FD::checkToken();
     FD::requireLogin();
     $my = FD::user();
     // get data from form post.
     $uid = JRequest::getInt('uid');
     $utype = JRequest::getVar('utype');
     $value = JRequest::getVar('value');
     $pid = JRequest::getVar('pid');
     $customIds = JRequest::getVar('custom', '');
     $streamid = JRequest::getVar('streamid', '');
     $view = FD::view('Privacy', false);
     // If id is invalid, throw an error.
     if (!$uid) {
         //Internal error logging.
         FD::logError(__FILE__, __LINE__, 'Privacy Log: Unable to update privacy on item because id provided is invalid.');
         $view->setError(JText::_('COM_EASYSOCIAL_ERROR_UNABLE_TO_LOCATE_ID'));
         return $view->call(__FUNCTION__);
     }
     $model = FD::model('Privacy');
     $state = $model->update($my->id, $pid, $uid, $utype, $value, $customIds);
     // If there's an error, log this down.
     if (!$state) {
         //Internal error logging.
         FD::logError(__FILE__, __LINE__, 'Privacy Log: Unable to update privacy on item because model returned the error, ' . $model->getError());
         $view->setError($model->getError());
         return $view->call(__FUNCTION__);
     }
     // lets check if there is stream id presented or not. if yes, means we need to update
     // privacy access in stream too.
     if ($streamid) {
         $access = FD::privacy()->toValue($value);
         $stream = FD::stream();
         $stream->updateAccess($streamid, $access, $customIds);
     }
     return $view->call(__FUNCTION__);
 }
Example #12
0
 /**
  * return formated string from the fields value
  *
  * @since	1.0
  * @access	public
  * @param	userfielddata
  * @return	array array of objects with two attribute, ffriend_id, score
  *
  * @author	Jason Rey <*****@*****.**>
  */
 public function onIndexerSearch($itemCreatorId, $keywords, $userFieldData)
 {
     if (!$this->field->searchable) {
         return false;
     }
     $data = trim($userFieldData);
     $content = '';
     if (JString::stristr($data, $keywords) !== false) {
         $content = $data;
     }
     if ($content) {
         $my = FD::user();
         $privacyLib = FD::privacy($my->id);
         if (!$privacyLib->validate('core.view', $this->field->id, SOCIAL_TYPE_FIELD, $itemCreatorId)) {
             return -1;
         } else {
             // okay this mean the user can view this fields. let hightlight the content.
             // building the pattern for regex replace
             $searchworda = preg_replace('#\\xE3\\x80\\x80#s', ' ', $keywords);
             $searchwords = preg_split("/\\s+/u", $searchworda);
             $needle = $searchwords[0];
             $searchwords = array_unique($searchwords);
             $pattern = '#(';
             $x = 0;
             foreach ($searchwords as $k => $hlword) {
                 $pattern .= $x == 0 ? '' : '|';
                 $pattern .= preg_quote($hlword, '#');
                 $x++;
             }
             $pattern .= ')#iu';
             $content = preg_replace($pattern, '<span class="search-highlight">\\0</span>', $content);
             $content = JText::sprintf('PLG_FIELDS_JOOMLA_EMAIL_SEARCH_RESULT', $content);
         }
     }
     if ($content) {
         return $content;
     } else {
         return false;
     }
 }
Example #13
0
 /**
  * Get's the content in html form.
  *
  * @since	1.0
  * @access	public
  * @param	bool	Determine whether or not to show the current status.
  * @return
  */
 public function html($showCurrentStory = true)
 {
     $my = FD::user();
     // Let's test if the current viewer is allowed to view this profile.
     if ($this->requirePrivacy()) {
         if ($this->target && $my->id != $this->target) {
             $privacy = FD::privacy($my->id);
             $state = $privacy->validate('profiles.post.status', $this->target, SOCIAL_TYPE_USER);
             if (!$state) {
                 return '';
             }
         }
     }
     // Prepare the story.
     $this->prepare();
     // Determines if the story form should be expanded by default.
     $expanded = false;
     if (!empty($this->content)) {
         $expanded = true;
     }
     // Get moods
     $gender = $my->getGenderLang();
     $moods = $this->getMoods($gender);
     $theme = FD::get('Themes');
     $theme->set('moods', $moods);
     $theme->set('expanded', $expanded);
     $theme->set('story', $this);
     $output = $theme->output('site/story/default');
     return $output;
 }
Example #14
0
 public function setPrivacy($privacy, $customPrivacy)
 {
     $lib = FD::privacy();
     $lib->add('albums.view', $this->album->id, 'albums', $privacy, null, $customPrivacy);
 }
Example #15
0
 public function privacy()
 {
     // @TODO: Get proper photo privacy
     return FD::privacy();
 }
Example #16
0
?>
-date" name="<?php 
echo $inputName;
?>
[date]" value="<?php 
echo $date;
?>
" data-field-datetime-value />

    <?php 
if ($yearPrivacy) {
    ?>
        <div class="data-field-datetime-yearprivacy mt-10">
            <div class="es-privacy pull-right">
                <?php 
    echo FD::privacy()->form($field->id, 'year', $this->my->id, 'field.birthday');
    ?>
            </div>
            <h4 class="es-title"><?php 
    echo JText::_('PLG_FIELDS_BIRTHDAY_YEAR_PRIVACY_TITLE');
    ?>
</h4>
            <div class="fd-small">
                <?php 
    echo JText::_('PLG_FIELDS_BIRTHDAY_YEAR_PRIVACY_INFO');
    ?>
            </div>
        </div>
    <?php 
}
?>
Example #17
0
 /**
  * Save user's privacy.
  *
  * @since	1.0
  * @access	public
  */
 public function savePrivacy()
 {
     // Check for request forgeries.
     FD::checkToken();
     // Ensure that the user is registered
     FD::requireLogin();
     // Get the current view.
     $view = $this->getCurrentView();
     // current logged in user
     $my = FD::user();
     // $resetMap = array( 'story.view', 'photos.view', 'albums.view', 'core.view' );
     $privacyLib = FD::privacy();
     //$resetMap 	= call_user_func_array( array( $privacyLib , 'getResetMap' ) );
     $resetMap = $privacyLib->getResetMap();
     $post = JRequest::get('POST');
     $privacy = $post['privacy'];
     $ids = $post['privacyID'];
     $curValues = $post['privacyOld'];
     $customIds = $post['privacyCustom'];
     $requireReset = isset($post['privacyReset']) ? true : false;
     $data = array();
     if (count($privacy)) {
         foreach ($privacy as $group => $items) {
             foreach ($items as $rule => $val) {
                 $id = $ids[$group][$rule];
                 $custom = $customIds[$group][$rule];
                 $curVal = $curValues[$group][$rule];
                 $customUsers = array();
                 if (!empty($custom)) {
                     $tmp = explode(',', $custom);
                     foreach ($tmp as $tid) {
                         if (!empty($tid)) {
                             $customUsers[] = $tid;
                         }
                     }
                 }
                 $id = explode('_', $id);
                 $obj = new stdClass();
                 $obj->id = $id[0];
                 $obj->mapid = $id[1];
                 $obj->value = $val;
                 $obj->custom = $customUsers;
                 $obj->reset = false;
                 //check if require to reset or not.
                 $gr = strtolower($group . '.' . $rule);
                 if ($requireReset && in_array($gr, $resetMap)) {
                     $obj->reset = true;
                 }
                 $data[] = $obj;
             }
         }
     }
     // Set the privacy for this user
     if (count($data) > 0) {
         $privacyModel = FD::model('Privacy');
         $state = $privacyModel->updatePrivacy($my->id, $data, SOCIAL_PRIVACY_TYPE_USER);
         if ($state !== true) {
             $view->setMessage($state, SOCIAL_MSG_ERROR);
             return $view->call(__FUNCTION__);
         }
     }
     // @points: privacy.update
     // Assign points when user updates their privacy
     $points = FD::points();
     $points->assign('privacy.update', 'com_easysocial', $my->id);
     //index user access in finder
     $my->syncIndex();
     $view->setMessage(JText::_('COM_EASYSOCIAL_PRIVACY_UPDATED_SUCESSFULLY'), SOCIAL_MSG_SUCCESS);
     return $view->call(__FUNCTION__);
 }
Example #18
0
			this.parent.close();
		}
	}
	</bindings>
	<title><?php 
echo $calendar->get('title');
?>
</title>
	<content>
		<h2><?php 
echo $calendar->get('title');
?>
</h2>
		<div class="pull-right">
			<?php 
echo FD::privacy()->form($calendar->id, 'view', $calendar->user_id, 'apps.calendar');
?>
		</div>
		<div class="event-time" style="color: #ccc;">
			<?php 
echo $calendar->getStartDate()->format($timeformat);
?>
 - <?php 
echo $calendar->getEndDate()->format($timeformat);
?>
		</div>
		<hr />

		<p class="mt-20"><?php 
echo str_replace("\n", '<br />', $calendar->get('description'));
?>
Example #19
0
 /**
  * Responsible to generate the activity logs.
  *
  * @since    1.0
  * @access    public
  * @param    object    $params        A standard object with key / value binding.
  *
  * @return    none
  */
 public function onPrepareActivityLog(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != 'links') {
         return;
     }
     //get story object, in this case, is the stream_item
     $tbl = FD::table('StreamItem');
     $tbl->load($item->uid);
     // item->uid is now streamitem.id
     $uid = $tbl->uid;
     //get story object, in this case, is the stream_item
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     $actor = $item->actor;
     $target = count($item->targets) > 0 ? $item->targets[0] : '';
     $assets = $item->getAssets($uid);
     if (empty($assets)) {
         return;
     }
     $assets = $assets[0];
     $this->set('assets', $assets);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $item);
     $item->display = SOCIAL_STREAM_DISPLAY_MINI;
     $item->title = parent::display('logs/' . $item->verb);
     return true;
 }
Example #20
0
<?php

/**
* @package		EasySocial
* @copyright	Copyright (C) 2010 - 2014 Stack Ideas Sdn Bhd. All rights reserved.
* @license		GNU/GPL, see LICENSE.php
* EasySocial is free software. This version may have been modified pursuant
* to the GNU General Public License, and as distributed it includes or
* is derivative of works licensed under the GNU General Public License or
* other free or open source software licenses.
* See COPYRIGHT.php for copyright notices and details.
*/
defined('_JEXEC') or die('Unauthorized Access');
?>
<div class="es-privacy pull-right">
	<?php 
echo FD::privacy()->form($field->id, SOCIAL_TYPE_FIELD, $user->id, 'field.' . $element, isset($html) ? $html : false);
?>
</div>
Example #21
0
 /**
  * Formats a stream item with the necessary data.
  *
  * Example:
  * <code>
  * </code>
  *
  * @since	1.0
  * @access	public
  * @param	Array
  *
  */
 public function format($items, $context = 'all', $viewer = null, $loadCoreAction = true, $defaultEvent = 'onPrepareStream', $options = array())
 {
     // Get the current user
     $my = is_null($viewer) ? FD::user() : FD::user($viewer);
     // Basic display options
     $commentLink = isset($options['commentLink']) && $options['commentLink'] || !isset($options['commentLink']) ? true : false;
     $commentForm = isset($options['commentForm']) && $options['commentForm'] || !isset($options['commentForm']) ? true : false;
     // Default the event to onPrepareStream
     if (!$defaultEvent) {
         $defaultEvent = 'onPrepareStream';
     }
     // Determines if this is a stream
     $isStream = false;
     if ($defaultEvent == 'onPrepareStream') {
         $isStream = true;
     }
     // If there's no items, skip formatting this because it's pointless to run after this.
     if (!$items) {
         return $items;
     }
     // Prepare default data
     $data = array();
     $activeUser = FD::user();
     // Get stream model
     $model = FD::model('Stream');
     //current user being view.
     $targetUser = JRequest::getInt('id', '');
     if (empty($targetUser)) {
         $targetUser = $my->id;
     }
     if ($targetUser && strpos($targetUser, ':')) {
         $tmp = explode(':', $targetUser);
         $targetUser = $tmp[0];
     }
     // Get template configuration
     $templateConfig = FD::themes()->getConfig();
     // Get the site configuration
     $config = FD::config();
     // Link options
     // We only have to do this once instead of putting inside the loop.
     $linkOptions = array('target' => '_blank');
     if ($config->get('stream.content.nofollow')) {
         $linkOptions['rel'] = 'nofollow';
     }
     // Format items with appropriate objects.
     foreach ($items as &$row) {
         // Get the uid
         $uid = $row->id;
         // Get the last updated time
         $lastupdate = $row->modified;
         // Determines if this is a cluster
         $isCluster = $row->cluster_id ? true : false;
         // Obtain related activities for aggregation.
         $relatedActivities = null;
         if ($isStream) {
             $relatedActivities = $model->getRelatedActivities($uid, $row->context_type, $viewer);
         } else {
             $relatedActivities = $model->getActivityItem($uid);
         }
         $aggregatedData = $this->buildAggregatedData($relatedActivities);
         // Get the stream item.
         $streamItem = new SocialStreamItem();
         if (isset($row->isNew)) {
             $streamItem->isNew = $row->isNew;
         }
         // Set the state
         $streamItem->state = $row->state;
         // Set the actors (Aggregated actors )
         $streamItem->actors = $aggregatedData->actors;
         // Set the edited value
         $streamItem->edited = isset($row->edited) ? $row->edited : false;
         // Set the content
         $streamItem->content = $row->content;
         $streamItem->content_raw = $row->content;
         // Set the title of the stream item.
         $streamItem->title = $row->title;
         // Set the targets (Aggregated targets )
         $streamItem->targets = $aggregatedData->targets;
         // Set the aggregated items here so 3rd party can manipulate the data.
         $streamItem->aggregatedItems = $relatedActivities;
         $streamItem->contextIds = $aggregatedData->contextIds;
         // Set the context params. ( Aggregated params )
         $streamItem->contextParams = $aggregatedData->params;
         // main stream params
         $streamItem->params = $row->params;
         // Set the stream uid / activity id.
         $streamItem->uid = $uid;
         // Set stream lapsed time
         $streamItem->lapsed = FD::date($row->created)->toLapsed();
         $streamItem->created = FD::date($row->created);
         // Set the actor with the user object.
         $streamItem->actor = FD::user($row->actor_id);
         // Set the context id.
         $streamItem->contextId = $aggregatedData->contextIds[0];
         // Set the verb for this item.
         $streamItem->verb = $aggregatedData->verbs[0];
         // Set the context type.
         $streamItem->context = $row->context_type;
         // stream display type
         $streamItem->display = $row->stream_type;
         // stream cluster_id
         $streamItem->cluster_id = $row->cluster_id;
         // stream cluster_type
         $streamItem->cluster_type = $row->cluster_type;
         // stream cluster_type
         $streamItem->cluster_access = $row->cluster_access;
         // stream privacy access
         $streamItem->access = $row->access;
         // stream privacy access
         $streamItem->custom_access = $row->custom_access;
         // Define an empty color
         $streamItem->color = '';
         // Define an empty favicon
         $streamItem->icon = '';
         // Always enable labels
         $streamItem->label = true;
         $streamItem->custom_label = '';
         $streamItem->opengraph = FD::opengraph();
         // Determines if this stream item has been bookmarked by the viewer
         $streamItem->bookmarked = false;
         if ($row->bookmarked) {
             $streamItem->bookmarked = true;
         }
         // Determines if this stream item has been bookmarked by the viewer
         $streamItem->sticky = false;
         if ($row->sticky) {
             $streamItem->sticky = true;
         }
         // @TODO: Since our stream has a unique favi on for each item. We need to get it here.
         // Each application is responsible to override this favicon, or stream wil use the context type.
         $streamItem->favicon = $row->context_type;
         $streamItem->type = $row->context_type;
         $streamDateDisplay = $templateConfig->get('stream_datestyle');
         $streamItem->friendlyDate = $streamItem->lapsed;
         if ($streamDateDisplay == 'datetime') {
             $streamItem->friendlyDate = $streamItem->created->toFormat($templateConfig->get('stream_dateformat_format', 'Y-m-d H:i'));
         }
         // getting the the with and mention tagging for the stream, only if the item is a stream.
         $streamItem->with = array();
         $streamItem->mention = array();
         if ($isStream) {
             $streamItem->with = $this->getStreamTagWith($uid);
             $streamItem->tags = $this->getTags($uid);
         }
         // Format the mood
         if (!empty($row->mood_id)) {
             $mood = FD::table('Mood');
             $mood->id = $row->md_id;
             $mood->namespace = $row->md_namespace;
             $mood->namespace_uid = $row->md_namespace_uid;
             $mood->icon = $row->md_icon;
             $mood->verb = $row->md_verb;
             $mood->subject = $row->md_subject;
             $mood->custom = $row->md_custom;
             $mood->text = $row->md_text;
             $mood->user_id = $row->md_user_id;
             $mood->created = $row->md_created;
             $streamItem->mood = $mood;
         }
         // Format the users that are tagged in this stream.
         if (!empty($row->location_id)) {
             $location = FD::table('Location');
             //$location->load( $row->location_id );
             // lets  assign the values into location jtable.
             $location->id = $row->loc_id;
             $location->uid = $row->loc_uid;
             $location->type = $row->loc_type;
             $location->user_id = $row->loc_user_id;
             $location->created = $row->loc_created;
             $location->short_address = $row->loc_short_address;
             $location->address = $row->loc_address;
             $location->latitude = $row->loc_latitude;
             $location->longitude = $row->loc_longitude;
             $location->params = $row->loc_params;
             $streamItem->location = $location;
         }
         // target user. this target user is different from the targets. this is the user who are being viewed currently.
         $streamItem->targetUser = $targetUser;
         // privacy
         $streamItem->privacy = null;
         // Check if the content is not empty. We need to perform some formatings
         if (isset($streamItem->content) && !empty($streamItem->content)) {
             $content = $streamItem->content;
             // Format mentions
             $content = $this->formatMentions($streamItem);
             // Apply e-mail replacements
             $content = FD::string()->replaceEmails($content);
             // Apply bbcode
             $content = FD::string()->parseBBCode($content, array('escape' => false, 'links' => true, 'code' => true));
             // Some app might want the raw contents
             $streamItem->content_raw = $streamItem->content;
             $streamItem->content = $content;
         }
         // Stream meta
         $streamItem->meta = '';
         if (!empty($streamItem->with) || !empty($streamItem->location) || !empty($streamItem->mood)) {
             $theme = FD::themes();
             $theme->set('stream', $streamItem);
             $streamItem->meta = $theme->output('site/stream/meta');
         }
         // Determines if the stream item is deleteable
         $streamItem->deleteable = false;
         // Determines if the stream item is editable
         $streamItem->editable = false;
         // Group stream should allow cluster admins to delete
         if ($streamItem->cluster_id) {
             $cluster = FD::cluster($streamItem->cluster_type, $streamItem->cluster_id);
             if ($cluster->isAdmin() || FD::user()->isSiteAdmin() || FD::user()->getAccess()->allowed('stream.delete', false) && FD::user()->id == $streamItem->actor->id) {
                 $streamItem->deleteable = true;
             }
         } else {
             if (FD::user()->getAccess()->allowed('stream.delete', false) && FD::user()->id == $streamItem->actor->id) {
                 $streamItem->deleteable = true;
             }
         }
         if (FD::user()->isSiteAdmin()) {
             $streamItem->deleteable = true;
         }
         // streams actions.
         $streamItem->comments = $defaultEvent == 'onPrepareStream' ? true : false;
         $streamItem->likes = $defaultEvent == 'onPrepareStream' ? true : false;
         $streamItem->repost = $defaultEvent == 'onPrepareStream' ? true : false;
         // @trigger onPrepareStream / onPrepareActivity
         $includePrivacy = $isCluster ? false : true;
         $result = $this->{$defaultEvent}($streamItem, $includePrivacy);
         // Allow app to stop loading / generating the stream and
         // if there is still no title, we need to skip this stream altogether.
         if ($result === false || !$streamItem->title) {
             continue;
         }
         // Set the plain content here.
         if (empty($streamItem->opengraph->properties['description'])) {
             $streamItem->opengraph->addDescription(strip_tags($streamItem->content));
         }
         // This mean the plugin did not set any privacy. lets use the stream / activity.
         if (is_null($streamItem->privacy) && !$isCluster) {
             $privacyObj = FD::privacy($activeUser->id);
             $privacy = isset($row->privacy) ? $row->privacy : null;
             $pUid = $uid;
             $tmpStreamId = $defaultEvent == 'onPrepareActivityLog' ? $row->uid : $row->id;
             $sModel = FD::model('Stream');
             $aItem = $sModel->getActivityItem($tmpStreamId, 'uid');
             if (count($streamItem->contextIds) == 1 && is_null($privacy)) {
                 if ($aItem) {
                     $pUid = $aItem[0]->id;
                 }
             }
             if (!$privacyObj->validate('core.view', $pUid, SOCIAL_TYPE_ACTIVITY, $streamItem->actor->id)) {
                 continue;
             }
             $tmpStreamId = $streamItem->aggregatedItems[0]->uid;
             if ($defaultEvent == 'onPrepareActivityLog') {
                 $tmpStreamId = count($aItem) > 1 ? '' : $tmpStreamId;
             }
             $streamItem->privacy = $privacyObj->form($pUid, SOCIAL_TYPE_ACTIVITY, $streamItem->actor->id, null, false, $tmpStreamId);
         }
         $itemGroup = $streamItem->cluster_id ? $streamItem->cluster_type : SOCIAL_APPS_GROUP_USER;
         if ($streamItem->display != SOCIAL_STREAM_DISPLAY_MINI) {
             $canComment = true;
             // comments
             if (isset($streamItem->comments) && $streamItem->comments) {
                 if (!$streamItem->comments instanceof SocialCommentBlock) {
                     $streamItem->comments = FD::comments($streamItem->contextId, $streamItem->context, $streamItem->verb, $itemGroup, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $streamItem->uid))), $streamItem->uid);
                 }
                 // for comments, we need to check against the actor privacy and see if the current viewer allow to
                 // post comments on their stream items or not.
                 if (!$isCluster) {
                     $privacyObj = FD::privacy($activeUser->id);
                     if (!$privacyObj->validate('story.post.comment', $streamItem->actor->id, SOCIAL_TYPE_USER)) {
                         $canComment = false;
                     }
                 }
             }
             // Set comment option the streamid
             if ($streamItem->comments) {
                 $streamItem->comments->setOption('streamid', $streamItem->uid);
             }
             // If comments link is meant to be disabled, hide it
             if (!$commentLink) {
                 $streamItem->commentLink = false;
             }
             // If comments is meant to be disabled, hide it.
             if ($streamItem->comments && (isset($streamItem->commentForm) && !$streamItem->commentForm || !$commentForm || !$canComment)) {
                 $streamItem->comments->setOption('hideForm', true);
             }
             //likes
             if (isset($streamItem->likes) && $streamItem->likes) {
                 if (!$streamItem->likes instanceof SocialLikes) {
                     $likes = FD::likes();
                     $likes->get($streamItem->contextId, $streamItem->context, $streamItem->verb, $itemGroup, $streamItem->uid);
                     $streamItem->likes = $likes;
                 }
             }
             //set likes option the streamid
             if ($streamItem->likes) {
                 $streamItem->likes->setOption('streamid', $streamItem->uid);
             }
             // Build repost links
             if (isset($streamItem->repost) && $streamItem->repost) {
                 if (!$streamItem->repost instanceof SocialRepost) {
                     $repost = FD::get('Repost', $streamItem->uid, SOCIAL_TYPE_STREAM, $itemGroup);
                     $streamItem->repost = $repost;
                 }
             }
             // set cluseter into repost
             if ($isCluster && $streamItem->repost) {
                 $streamItem->repost->setCluster($streamItem->cluster_id, $streamItem->cluster_type);
             }
             // Enable sharing on the stream
             if ($config->get('stream.sharing.enabled')) {
                 if (!isset($streamItem->sharing) || isset($streamItem->sharing) && $streamItem->sharing !== false && !$streamItem->sharing instanceof SocialSharing) {
                     $sharing = FD::get('Sharing', array('url' => FRoute::stream(array('layout' => 'item', 'id' => $streamItem->uid, 'external' => true), true), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small'));
                     $streamItem->sharing = $sharing;
                 }
             }
             // Now we have all the appropriate data, populate the actions
             $streamItem->actions = $this->getActions($streamItem);
         } else {
             $streamItem->comments = false;
             $streamItem->likes = false;
             $streamItem->repost = false;
             $streamItem->actions = '';
         }
         // Re-assign stream item to the result list.
         $data[] = $streamItem;
     }
     // here we know, the result from queries contain some records but it might return empty data due to privacy.
     // if that is the case, then we return TRUE so that the library will go retrieve the next set of data.
     if (count($data) <= 0) {
         return true;
     }
     return $data;
 }
Example #22
0
 public function post()
 {
     $app = JFactory::getApplication();
     //$share_for = $app->input->get('share_for','','CMD');
     $type = $app->input->get('type', 'story', 'STRING');
     $content = $app->input->get('content', '', 'RAW');
     //$targetId = $app->input->get('target_user','All','raw');
     $targetId = $app->input->get('target_user', 0, 'INT');
     $cluster = $app->input->get('cluster_id', null, 'INT');
     $clusterType = $app->input->get('cluster_type', null, 'STRING');
     $friends_tags = $app->input->get('friends_tags', null, 'ARRAY');
     $log_usr = intval($this->plugin->get('user')->id);
     //now take login user stream for target
     $targetId = $targetId != $log_usr ? $targetId : $log_usr;
     $valid = 1;
     $result = new stdClass();
     $story = FD::story(SOCIAL_TYPE_USER);
     // Check whether the user can really post something on the target
     if ($targetId) {
         $tuser = FD::user($targetId);
         $allowed = $tuser->getPrivacy()->validate('profiles.post.status', $targetId, SOCIAL_TYPE_USER);
         if (!$allowed) {
             $result->id = 0;
             $result->status = 0;
             $result->message = 'User not allowed any post in share';
             $valid = 0;
         }
     }
     if (empty($type)) {
         $result->id = 0;
         $result->status = 0;
         $result->message = 'Empty type not allowed';
         $valid = 0;
     } else {
         if ($valid) {
             // Determines if the current posting is for a cluster
             $cluster = isset($cluster) ? $cluster : 0;
             //$clusterType = ($cluster) ? 'group' : null;
             $isCluster = $cluster ? true : false;
             if ($isCluster) {
                 $group = FD::group($cluster);
                 $permissions = $group->getParams()->get('stream_permissions', null);
                 if ($permissions != null) {
                     // If the user is not an admin, ensure that permissions has member
                     if ($group->isMember() && !in_array('member', $permissions) && !$group->isOwner() && !$group->isAdmin()) {
                         $result->message = 'This group memder do not have share data permission';
                     }
                     // If the user is an admin, ensure that permissions has admin
                     if ($group->isAdmin() && !in_array('admin', $permissions) && !$group->isOwner()) {
                         $result->message = 'This group admin do not have share data permission';
                     }
                     $result->id = 0;
                     $result->status = 0;
                     $this->plugin->setResponse($result);
                     return;
                 }
             }
             //validate friends
             $friends = array();
             if (!empty($friends_tags)) {
                 // Get the friends model
                 $model = FD::model('Friends');
                 // Check if the user is really a friend of him / her.
                 foreach ($friends_tags as $id) {
                     if (!$model->isFriends($log_usr, $id)) {
                         continue;
                     }
                     $friends[] = $id;
                 }
             } else {
                 $friends = null;
             }
             $privacyRule = $type == 'photos' ? 'photos.view' : 'story.view';
             //for hashtag mentions
             $mentions = null;
             //if($type == 'hashtag' || !empty($content))
             if (!empty($content)) {
                 //$type = 'story';
                 $start = 0;
                 $posn = array();
                 //code adjust for 0 position hashtag
                 $content = 'a ' . $content;
                 while ($pos = strpos($content, '#', $start)) {
                     //echo 'Found # at position '.$pos."\n";
                     $posn[] = $pos - 2;
                     $start = $pos + 1;
                 }
                 $content = substr($content, 2);
                 //
                 //$pos = strpos(($content),'#',$start);
                 $cont_arr = explode(' ', $content);
                 $indx = 0;
                 foreach ($cont_arr as $val) {
                     if (preg_match('/[\'^#,|=_+¬-]/', $val)) {
                         //$vsl = substr_count($val,'#');
                         $val_arr = array_filter(explode('#', $val));
                         foreach ($val_arr as $subval) {
                             $subval = '#' . $subval;
                             $mention = new stdClass();
                             $mention->start = $posn[$indx++];
                             $mention->length = strlen($subval) - 0;
                             $mention->value = str_replace('#', '', $subval);
                             $mention->type = 'hashtag';
                             $mentions[] = $mention;
                         }
                     }
                 }
                 //print_r( $mentions );die("in share api");
             }
             $contextIds = 0;
             if ($type == 'photos') {
                 $photo_obj = $this->uploadPhoto($log_usr, 'user');
                 $photo_ids[] = $photo_obj->id;
                 $contextIds = count($photo_ids) ? $photo_ids : null;
             } else {
                 $type = 'story';
             }
             // Process moods here
             $mood = FD::table('Mood');
             // Options that should be sent to the stream lib
             $args = array('content' => $content, 'actorId' => $log_usr, 'targetId' => $targetId, 'location' => null, 'with' => $friends, 'mentions' => $mentions, 'cluster' => $cluster, 'clusterType' => $clusterType, 'mood' => null, 'privacyRule' => $privacyRule, 'privacyValue' => 'public', 'privacyCustom' => '');
             $photo_ids = array();
             $args['actorId'] = $log_usr;
             $args['contextIds'] = $contextIds;
             $args['contextType'] = $type;
             // Create the stream item
             $stream = $story->create($args);
             // Privacy is only applicable to normal postings
             if (!$isCluster) {
                 $privacyLib = FD::privacy();
                 if ($type == 'photos') {
                     $photoIds = FD::makeArray($contextIds);
                     foreach ($photoIds as $photoId) {
                         $privacyLib->add($privacyRule, $photoId, $type, 'public', null, '');
                     }
                 } else {
                     $privacyLib->add($privacyRule, $stream->uid, $type, 'public', null, '');
                 }
             }
             // Add badge for the author when a report is created.
             $badge = FD::badges();
             $badge->log('com_easysocial', 'story.create', $log_usr, JText::_('Posted a new update'));
             // @points: story.create
             // Add points for the author when a report is created.
             $points = FD::points();
             $points->assign('story.create', 'com_easysocial', $log_usr);
             if ($stream->id) {
                 $result->id = $stream->id;
                 $result->status = 1;
                 $result->message = 'data share successfully';
             }
         }
     }
     $this->plugin->setResponse($result);
 }
Example #23
0
        echo JText::_('COM_EASYSOCIAL_NO_BADGES_YET');
        ?>
							<?php 
    }
    ?>
						</a>
					</li>
					<?php 
}
?>

					<?php 
if ($this->config->get('conversations.enabled') && $user->id && $this->my->id != $user->id && $this->access->allowed('conversations.create')) {
    ?>
						<?php 
    if (FD::privacy($this->my->id)->validate('profiles.post.message', $user->id)) {
        ?>
						<li data-followers-item-compose>
							<a href="javascript:void(0);" class="fd-small muted">
								<i class="ies-mail-2 "></i> <?php 
        echo JText::_('COM_EASYSOCIAL_CONVERSATIONS_SEND_MESSAGE');
        ?>
							</a>
						</li>
						<?php 
    }
    ?>
					<?php 
}
?>
				</ul>
 /**
  * Method to index an item. The item must be a FinderIndexerResult object.
  *
  * @param   FinderIndexerResult  $item    The item to index as an FinderIndexerResult object.
  * @param   string               $format  The item format
  *
  * @return  void
  *
  * @since   2.5
  * @throws  Exception on database error.
  */
 protected function index(FinderIndexerResult $item, $format = 'html')
 {
     // Check if the extension is enabled
     if (JComponentHelper::isEnabled($this->extension) == false) {
         return;
     }
     $access = 1;
     if (is_null($item->privacy)) {
         $privacy = FD::privacy($item->user_id);
         $privacyValue = $privacy->getValue('photos', 'view');
         $item->privacy = $privacyValue;
     }
     if ($item->privacy == SOCIAL_PRIVACY_PUBLIC) {
         $access = 1;
     } else {
         if ($item->privacy == SOCIAL_PRIVACY_MEMBER) {
             $access = 2;
         } else {
             // this is not public / member items. do not index this item
             return;
         }
     }
     // $sql->select('a.id, a.title, a.alias, a.introtext AS summary, a.fulltext AS body');
     // $sql->select('a.state, a.catid, a.created AS start_date, a.created_by');
     // $sql->select('a.created_by_alias, a.modified, a.modified_by, a.attribs AS params');
     // $sql->select('a.metakey, a.metadesc, a.metadata, a.language, a.access, a.version, a.ordering');
     // $sql->select('a.publish_up AS publish_start_date, a.publish_down AS publish_end_date');
     // $sql->select('c.title AS category, c.published AS cat_state, c.access AS cat_access');
     // album onwer
     $user = FD::user($item->user_id);
     $userAlias = $user->getAlias(false);
     $photo = FD::table('Photo');
     $photo->load($item->id);
     // Build the necessary route and path information.
     // index.php?option=com_easysocial&view=photos&layout=item&id=510:00000690&type=user&uid=84:jenny-siew
     $item->url = 'index.php?option=com_easysocial&view=photos&layout=item&id=' . $photo->getAlias() . '&type=' . $photo->type . '&uid=' . $userAlias;
     $item->route = $photo->getPermalink();
     $item->route = $this->removeAdminSegment($item->route);
     $item->path = FinderIndexerHelper::getContentPath($item->route);
     $category = 'user photo';
     if ($item->type == SOCIAL_TYPE_GROUP) {
         $category = 'group photo';
     }
     $item->access = $access;
     $item->alias = $photo->getAlias();
     $item->state = 1;
     $item->catid = $photo->type == SOCIAL_TYPE_GROUP ? 2 : 1;
     $item->start_date = $photo->created;
     $item->created_by = $photo->user_id;
     $item->created_by_alias = $userAlias;
     $item->modified = $photo->assigned_date == '0000-00-00 00:00:00' ? $photo->created : $photo->assigned_date;
     $item->modified_by = $photo->user_id;
     $item->params = '';
     $item->metakey = $category . ' ' . $photo->title;
     $item->metadesc = $category . ' ' . $photo->title;
     $item->metadata = '';
     $item->publish_start_date = $item->modified;
     $item->category = $category;
     $item->cat_state = 1;
     $item->cat_access = 0;
     $item->summary = $photo->title;
     $item->body = $photo->title;
     // Add the meta-author.
     $item->metaauthor = $userAlias;
     $item->author = $userAlias;
     // add image param
     $registry = FD::registry();
     $registry->set('image', $photo->getSource());
     $item->params = $registry;
     // Add the meta-data processing instructions.
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metakey');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metadesc');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'metaauthor');
     $item->addInstruction(FinderIndexer::META_CONTEXT, 'author');
     // Add the type taxonomy data.
     $item->addTaxonomy('Type', 'EasySocial.Photos');
     // Add the author taxonomy data.
     $item->addTaxonomy('Author', $userAlias);
     // Add the category taxonomy data.
     $item->addTaxonomy('Category', $item->category, $item->cat_state, $item->cat_access);
     // Add the language taxonomy data.
     $langParams = JComponentHelper::getParams('com_languages');
     $item->language = $langParams->get('site', 'en-GB');
     $item->addTaxonomy('Language', $item->language);
     // Get content extras.
     FinderIndexerHelper::getContentExtras($item);
     // Index the item.
     if (FD::isJoomla30()) {
         $this->indexer->index($item);
     } else {
         FinderIndexer::index($item);
     }
 }
Example #25
0
 /**
  * Triggered to prepare the stream item
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     // If this is not it's context, we don't want to do anything here.
     if ($stream->context != 'story') {
         return;
     }
     $uid = $stream->uid;
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($stream->cluster_id) {
         // Group access checking
         $cluster = FD::cluster($stream->cluster_type, $stream->cluster_id);
         if (!$cluster) {
             return;
         }
         if (!$cluster->canViewItem()) {
             return;
         }
         // Allow editing of the stream item
         $stream->editable = $my->isSiteAdmin() || $cluster->isAdmin() || $stream->actor->id == $my->id;
     } else {
         // Allow editing of the stream item
         $stream->editable = $my->isSiteAdmin() || $stream->actor->id == $my->id;
     }
     // we stil need to check for the privacy because the context might come from the 'repost'
     if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_STORY, $stream->actor->id)) {
         return;
     }
     // Actor of this stream
     $actor = $stream->actor;
     $target = count($stream->targets) > 0 ? $stream->targets[0] : '';
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $stream->color = '#16a085';
     $stream->fonticon = 'ies-pencil-2';
     $stream->label = FD::_('APP_USER_STORY_UPDATES_STREAM_TOOLTIP', true);
     if ($stream->cluster_id) {
         if ($stream->cluster_type == SOCIAL_TYPE_GROUP) {
             $stream->color = '#303229';
             $stream->fonticon = 'ies-users';
             $stream->label = FD::_('APP_USER_STORY_GROUPS_STREAM_TOOLTIP', true);
         }
         if ($stream->cluster_type == SOCIAL_TYPE_EVENT) {
             $stream->color = '#f06050';
             $stream->fonticon = 'ies-calendar';
             $stream->label = FD::_('APP_USER_STORY_EVENTS_STREAM_TOOLTIP', true);
         }
     }
     $appGroup = SOCIAL_APPS_GROUP_USER;
     if ($stream->cluster_id) {
         if ($stream->cluster_type == SOCIAL_TYPE_EVENT) {
             $appGroup = SOCIAL_APPS_GROUP_EVENT;
         } else {
             $appGroup = SOCIAL_APPS_GROUP_GROUP;
         }
     }
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($stream->uid, $stream->context, $stream->verb, $appGroup, $stream->uid);
     $stream->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($stream->uid, $stream->context, $stream->verb, $appGroup, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream->uid))), $stream->uid);
     $stream->comments = $comments;
     // Apply repost on the stream
     $repost = FD::get('Repost', $stream->uid, SOCIAL_TYPE_STREAM, $appGroup);
     $stream->repost = $repost;
     // If this is a group type, and the viewer is not a member of the group, we need to hide these data
     if ($stream->cluster_id) {
         $cluster = FD::cluster($stream->cluster_type, $stream->cluster_id);
         if (!$cluster->isMember()) {
             $stream->commentLink = false;
             $stream->repost = false;
             $stream->commentForm = false;
         }
         // Sharing only show in public group
         if (!$cluster->isOpen()) {
             $stream->sharing = false;
         }
     }
     // Get application params
     $params = $this->getParams();
     $this->set('params', $params);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $stream);
     if ($stream->cluster_id) {
         $clusterReg = FD::registry($stream->params);
         $object = $clusterReg->get($stream->cluster_type);
         $cluster = FD::cluster($stream->cluster_type);
         if ($object) {
             // If have the object only bind
             $cluster->bind($object);
         } else {
             $cluster = $stream->getCluster();
         }
         $this->set('cluster', $cluster);
     }
     $titleFileName = $stream->cluster_type ? $stream->cluster_type . '.' . $stream->verb : $stream->verb;
     $stream->title = parent::display('streams/title.' . $titleFileName);
     $stream->content = parent::display('streams/content.' . $stream->verb);
     $stream->opengraph->addDescription($stream->content);
     if ($includePrivacy) {
         $stream->privacy = $privacy->form($uid, SOCIAL_TYPE_STORY, $stream->actor->id, 'story.view', false, $stream->uid);
     }
     return true;
 }
Example #26
0
 /**
  * Responsible to generate the stream contents.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != SOCIAL_TYPE_FOLLOWERS) {
         return;
     }
     // Check if the app should be able to generate the stream.
     $params = $this->getParams();
     if (!$params->get('stream_follow', true)) {
         return;
     }
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($includePrivacy) {
         if (!$privacy->validate('followers.view', $item->contextId, SOCIAL_TYPE_FOLLOWERS, $item->actor->id)) {
             return;
         }
     }
     $item->display = SOCIAL_STREAM_DISPLAY_MINI;
     $item->color = '#415457';
     $item->fonticon = 'ies-tree-view';
     $item->label = JText::_('APP_USER_FOLLOWERS_STREAM_TOOLTIP');
     // Get the context id.
     $id = $item->contextId;
     // Get the target.
     $table = FD::table('Subscription');
     $table->load($id);
     // Get the actor
     $actor = $item->actor;
     // Receiving actor.
     $target = FD::user($table->uid);
     // Get the current id.
     $id = JRequest::getInt('id');
     $this->set('actor', $actor);
     $this->set('target', $target);
     // User A following user B
     if ($item->verb == 'follow') {
         $item->title = parent::display('streams/' . $item->verb . '.title');
     }
     $item->opengraph->addDescription($item->title);
     if ($includePrivacy) {
         $item->privacy = $privacy->form($id, SOCIAL_TYPE_FOLLOWERS, $item->actor->id, 'followers.view', false, $item->uid);
     }
     return true;
 }
Example #27
0
 /**
  * Given a path to the file, install the privacy rules.
  *
  * @since	1.0
  * @access	public
  * @param	string		The path to the privacy .json file.
  * @return	bool		True if success false otherwise.
  */
 public function install($path)
 {
     // Import platform's file library.
     jimport('joomla.filesystem.file');
     // Read the contents
     $contents = JFile::read($path);
     // If contents is empty, throw an error.
     if (empty($contents)) {
         $this->setError(JText::_('COM_EASYSOCIAL_PRIVACY_UNABLE_TO_READ_PRIVACY_RULE_FILE'));
         return false;
     }
     $json = FD::json();
     $data = $json->decode($contents);
     if (!is_array($data)) {
         $data = array($data);
     }
     // Let's test if there's data.
     if (empty($data)) {
         $this->setError(JText::_('COM_EASYSOCIAL_PRIVACY_UNABLE_TO_READ_PRIVACY_RULE_FILE'));
         return false;
     }
     $privLib = FD::privacy();
     $result = array();
     foreach ($data as $row) {
         $type = $row->type;
         $rules = $row->rules;
         if (count($rules) > 0) {
             foreach ($rules as $rule) {
                 $command = $rule->command;
                 $description = $rule->description;
                 $default = $rule->default;
                 $options = $rule->options;
                 $optionsArr = array();
                 foreach ($options as $option) {
                     $optionsArr[] = $option->name;
                 }
                 $ruleOptions = array('options' => $optionsArr);
                 $optionString = $json->encode($ruleOptions);
                 // Load the tables
                 $privacy = FD::table('Privacy');
                 // If this already exists, we need to skip this.
                 $state = $privacy->load(array('type' => $type, 'rule' => $command));
                 if ($state) {
                     continue;
                 }
                 $privacy->core = isset($rule->core) && $rule->core ? true : false;
                 $privacy->state = SOCIAL_STATE_PUBLISHED;
                 $privacy->type = $type;
                 $privacy->rule = $command;
                 $privacy->description = $description;
                 $privacy->value = $privLib->toValue($default);
                 $privacy->options = $optionString;
                 $addState = $privacy->store();
                 if ($addState) {
                     // now we need to add this new privacy rule into all the profile types.
                     $this->addRuleProfileTypes($privacy->id, $privacy->value);
                 }
                 $result[] = $type . '.' . $command;
             }
         }
     }
     return $result;
 }
Example #28
0
 /**
  * Responsible to generate the stream contents.
  *
  * @since	1.0
  * @access	public
  * @param	object	$params		A standard object with key / value binding.
  *
  * @return	none
  */
 public function onPrepareStream(SocialStreamItem &$item, $includePrivacy = true)
 {
     if ($item->context != 'friends') {
         return;
     }
     // Determines if the stream should be generated
     $params = $this->getParams();
     if (!$params->get('stream_friends', true)) {
         return;
     }
     // Get the actor
     $actor = $item->actor;
     // check if the actor is ESAD profile or not, if yes, we skip the rendering.
     if (!$actor->hasCommunityAccess()) {
         $item->title = '';
         return;
     }
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($includePrivacy) {
         if (!$privacy->validate('core.view', $item->contextId, 'friends', $item->actor->id)) {
             return;
         }
     }
     // Get the context id.
     $id = $item->contextId;
     // no target. this could be data error. ignore this item.
     if (!$item->targets) {
         return;
     }
     // Receiving actor.
     $target = $item->targets[0];
     // Get the current id.
     $id = JRequest::getInt('id');
     // Decorate the stream
     $item->display = SOCIAL_STREAM_DISPLAY_MINI;
     $item->color = '#7AD7EE';
     $item->fonticon = 'ies-user';
     $item->label = FD::_('APP_USER_FRIENDS_STREAM_TOOLTIP', true);
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($item->contextId, $item->context, $item->verb, SOCIAL_APPS_GROUP_USER, $item->uid);
     $item->likes = $likes;
     $this->set('actor', $actor);
     $this->set('target', $target);
     $item->title = parent::display('streams/' . $item->verb . '.title');
     if ($includePrivacy) {
         $item->privacy = $privacy->form($item->contextId, 'friends', $item->actor->id, 'core.view', false, $item->uid);
     }
     return true;
 }
							</div>

							<div class="media-body pl-5">
								<?php 
        echo $this->html('html.user', $user->id);
        ?>

								<div>
									<i class="icon-es-cake mr-5"></i>
									<?php 
        echo $item->display;
        ?>
								</div>

								<?php 
        if (FD::privacy($this->my->id)->validate('profiles.post.message', $user->id) && $this->config->get('conversations.enabled')) {
            ?>

								<div class="fd-small total-no" data-upcoming-birthday-button >
									<a href="javascript:void(0);" data-upcoming-birthday-message-button>
										<span><?php 
            echo JText::_('APP_BIRTHDAYS_SEND_MESSAGE');
            ?>
</span>
									</a>
								</div>

								<?php 
        }
        ?>
Example #30
0
 public function onStreamValidatePrivacy(SocialStreamItem $item)
 {
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     $tbl = FD::table('StreamItem');
     $tbl->load(array('uid' => $item->uid));
     if (!$privacy->validate('core.view', $tbl->id, SOCIAL_TYPE_ACTIVITY, $item->actor->id)) {
         return false;
     }
     return true;
 }