/** * 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'); }
public function main() { $db = FD::db(); $sql = $db->sql(); // First we get the core.view privacy id $sql->select('#__social_privacy')->column('id')->where('type', 'core')->where('rule', 'view'); $db->setQuery($sql); $origId = $db->loadResult(); // Then we cache a copy of all the new field rules and the id $sql->clear(); $sql->select('#__social_privacy')->column('id')->column('rule')->where('type', 'field'); $db->setQuery($sql); $rules = $db->loadObjectList('rule'); // Then we get all the privacy items with this id and type = 'field' $sql->clear(); $sql->select('#__social_privacy_items', 'a')->column('a.*')->column('c.element')->leftjoin('#__social_fields', 'b')->on('b.id', 'a.uid')->leftjoin('#__social_apps', 'c')->on('b.app_id', 'c.id')->where('(')->where('a.type', 'field')->where('a.type', 'field.datetime.year', '=', 'OR')->where(')'); $db->setQuery($sql); $result = $db->loadObjectList(); // Based on the element, we need to find the new id to map it to the rule foreach ($result as $row) { if (isset($rules[$row->element])) { $table = FD::table('privacyitems'); $table->bind($row); $table->privacy_id = $rules[$row->element]->id; $table->store(); } } // field.datetime.year need to change to year $sql->clear(); $sql->update('#__social_privacy_items')->set('type', 'year')->where('type', 'field.datetime.year'); $db->setQuery($sql); $db->query(); return true; }
/** * 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__); }
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; }
public function create_report() { $app = JFactory::getApplication(); $msg = $app->input->get('message', '', 'STRING'); $title = $app->input->get('user_title', '', 'STRING'); $item_id = $app->input->get('itemId', 0, 'INT'); $log_user = $this->plugin->get('user')->id; $data = array(); $data['message'] = $msg; $data['uid'] = $item_id; $data['type'] = 'stream'; $data['title'] = $title; $data['extension'] = 'com_easysocial'; //build share url use for share post through app $sharing = FD::get('Sharing', array('url' => FRoute::stream(array('layout' => 'item', 'id' => $item_id, 'external' => true, 'xhtml' => true)), 'display' => 'dialog', 'text' => JText::_('COM_EASYSOCIAL_STREAM_SOCIAL'), 'css' => 'fd-small')); $url = $sharing->url; $data['url'] = $url; // Get the reports model $model = FD::model('Reports'); // Determine if this user has the permissions to submit reports. $access = FD::access(); // Determine if this user has exceeded the number of reports that they can submit $total = $model->getCount(array('created_by' => $log_user)); if ($access->exceeded('reports.limit', $total)) { $final_result['message'] = "Limit exceeds"; $final_result['status'] = true; return $final_result; } // Create the report $report = FD::table('Report'); $report->bind($data); // Set the creator id. $report->created_by = $log_user; // Set the default state of the report to new $report->state = 0; // Try to store the report. $state = $report->store(); // If there's an error, throw it if (!$state) { $final_result['message'] = "Can't save report"; $final_result['status'] = true; return $final_result; } // @badge: reports.create // Add badge for the author when a report is created. $badge = FD::badges(); $badge->log('com_easysocial', 'reports.create', $log_user, JText::_('COM_EASYSOCIAL_REPORTS_BADGE_CREATED_REPORT')); // @points: reports.create // Add points for the author when a report is created. $points = FD::points(); $points->assign('reports.create', 'com_easysocial', $log_user); // Determine if we should send an email $config = FD::config(); if ($config->get('reports.notifications.moderators')) { $report->notify(); } $final_result['message'] = "Report logged successfully!"; $final_result['status'] = true; return $final_result; }
/** * Allows caller to delete an activity item * * @since 1.0 * @access public * @param string * @return */ public function delete() { FD::checkToken(); FD::requireLogin(); // get required form post variable $id = JRequest::getInt('id'); // Get the view. $view = $this->getCurrentView(); // Load the stream item $item = FD::table('StreamItem'); $item->load($id); // If id is invalid, throw an error. if (!$id || !$item->id) { //Internal error logging. FD::logError(__FILE__, __LINE__, 'Activity Log: Unable to delete item because id provided is invalid.'); $view->setError(JText::_('COM_EASYSOCIAL_ERROR_UNABLE_TO_LOCATE_ID')); return $view->call(__FUNCTION__); } // Check if the current user is allowed to delete this stream item if (!$item->deleteable()) { $view->setError(JText::_('COM_EASYSOCIAL_ACTIVITIES_NOT_ALLOWED_TO_DELETE_ITEM')); return $view->call(__FUNCTION__); } $model = FD::model('Activities'); $state = $model->delete($id); if (!$state) { //Internal error logging. FD::logError(__FILE__, __LINE__, 'Activity Log: Unable to delete item because model returned the error, ' . $model->getError()); $view->setError($model->getError()); return $view->call(__FUNCTION__); } return $view->call(__FUNCTION__); }
/** * 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 & are replaced with & $url = str_ireplace('&', '&', $table->url); $this->redirect(FRoute::_($url, false)); $this->close(); }
public function main() { $db = FD::db(); $sql = $db->sql(); $sql->select('#__social_apps'); $sql->where('type', 'fields'); $db->setQuery($sql); $result = $db->loadObjectList(); foreach ($result as $row) { $file = SOCIAL_FIELDS . '/' . $row->group . '/' . $row->element . '/' . $row->element . '.xml'; if (!JFile::exists($file)) { continue; } $table = FD::table('App'); $table->bind($row); $parser = FD::get('Parser'); $parser->load($file); $val = $parser->xpath('unique'); $unique = 0; if ($val) { $unique = (string) $val[0]; $unique = $unique == 'true' ? 1 : 0; } $table->unique = $unique; $table->store(); } return true; }
/** * Retrieves a list of broadcasts created on the site * * @since 4.0 * @access public * @param string * @return */ public function getBroadcasts($userId) { $db = FD::db(); $sql = $db->sql(); $sql->select('#__social_broadcasts'); $sql->where('target_id', $userId); $sql->where('target_type', SOCIAL_TYPE_USER); $sql->where('state', 1); $sql->order('created', 'DESC'); $db->setQuery($sql); $result = $db->loadObjectList(); if (!$result) { return false; } $broadcasts = array(); foreach ($result as $row) { $broadcast = FD::table('Broadcast'); $broadcast->bind($row); // When the broadcasts are alredy retrieved from the system, it should be marked as read. // Otherwise it would keep on spam the user's screen. $broadcast->markAsRead(); $broadcasts[] = $broadcast; } return $broadcasts; }
/** * Renders a login button. * * @since 1.0 * @access public */ public function getLoginButton($uid, $type, $callback = '', $permissions = array(), $display = 'popup') { $theme = FD::themes(); // Check if the user has already authenticated. $table = FD::table('OAuth'); $exists = $table->load(array('uid' => $uid, 'type' => $type)); if ($exists) { $output = $theme->output('site/login/linkedin.authenticated'); } else { $callback = urlencode($callback); // Ensure that the callback is urlencoded $callback = trim(JURI::root(), '/') . '/administrator/index.php?option=com_easysocial&controller=oauth&task=grant&client=linkedin&uid=' . $uid . '&type=' . $type . '&callback=' . $callback; $this->setCallbackUrl($callback); $requestToken = $this->retrieveTokenRequest(); $_SESSION['oauth']['linkedin']['request'] = $requestToken['linkedin']; $url = LINKEDIN::_URL_AUTH . $requestToken['linkedin']['oauth_token']; $theme->set('url', $url); $theme->set('appId', $this->appId); $theme->set('appSecret', $this->appSecret); $theme->set('callback', $callback); $theme->set('permissions', $permissions); $output = $theme->output('site/login/linkedin'); } return $output; }
/** * Set's the template as the default template * * @since 1.0 * @access public * @param string * @return */ public function makeDefault() { // Check for request forgeries FD::checkToken(); $element = JRequest::getVar('cid'); $element = $element[0]; $element = strtolower($element); // Get the current view $view = $this->getCurrentView(); // Get the configuration object $configTable = FD::table('Config'); $config = FD::registry(); if ($configTable->load('site')) { $config->load($configTable->value); } // Convert the config object to a json string. $config->set('theme.site', $element); // Convert the configuration to string $jsonString = $config->toString(); // Store the setting $configTable->value = $jsonString; if (!$configTable->store()) { $view->setMessage($configTable->getError(), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } return $view->call(__FUNCTION__); }
/** * 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; }
/** * Displays the application output in the canvas. * * @since 1.3 * @access public * @param integer $uid The event id. */ public function display($uid = null, $docType = null) { $event = FD::event($uid); // Check if the viewer is allowed here. if (!$event->canViewItem()) { return $this->redirect($event->getPermalink(false)); } // Get app params $params = $this->app->getParams(); // Load the milestone $id = JRequest::getInt('milestoneId'); $milestone = FD::table('Milestone'); $milestone->load($id); if (!empty($milestone->id)) { FD::page()->title(JText::_('APP_EVENT_TASKS_TITLE_EDITING_MILESTONE')); } else { FD::page()->title(JText::_('APP_EVENT_TASKS_TITLE_CREATE_MILESTONE')); } // Get a list of members from the group $members = FD::model('Events')->getMembers($event->id); $this->set('members', $members); $this->set('milestone', $milestone); $this->set('params', $params); $this->set('event', $event); echo parent::display('views/form'); }
/** * Displays the application output in the canvas. * * @since 1.2 * @access public * @param int The user id that is currently being viewed. */ public function display($groupId = null, $docType = null) { $group = FD::group($groupId); // Check if the viewer is allowed here. if (!$group->canViewItem()) { return $this->redirect($group->getPermalink(false)); } // Get app params $params = $this->app->getParams(); // Load the milestone $id = JRequest::getInt('milestoneId'); $milestone = FD::table('Milestone'); $milestone->load($id); FD::page()->title(JText::_('APP_GROUP_TASKS_TITLE_CREATE_MILESTONE')); if ($id && $milestone->id) { FD::page()->title(JText::_('APP_GROUP_TASKS_TITLE_EDITING_MILESTONE')); } // Get a list of members from the group $groupModel = FD::model('Groups'); $members = $groupModel->getMembers($group->id); $this->set('members', $members); $this->set('milestone', $milestone); $this->set('params', $params); $this->set('group', $group); echo parent::display('views/form'); }
/** * Does a remote call to the server to fetch contents of a given url. * * @since 1.0 * @access public */ public function fetch() { // Check for request forgeries! $urls = $this->input->get('urls', array(), 'array'); // Result placeholder $result = array(); if (!$urls) { $this->view->setMessage('COM_EASYSOCIAL_CRAWLER_INVALID_URL_PROVIDED', SOCIAL_MSG_ERROR); return $this->view->call(__FUNCTION__); } // Get the crawler $crawler = FD::get('crawler'); foreach ($urls as $url) { // Generate a hash for the url $hash = md5($url); $link = FD::table('Link'); $exists = $link->load(array('hash' => $hash)); // If it doesn't exist, store it. if (!$exists) { $crawler->crawl($url); // Get the data from our crawler library $data = $crawler->getData(); // Now we need to cache the link so that the next time, we don't crawl it again. $link->hash = $hash; $link->data = json_encode($data); $link->store(); } $result[$url] = json_decode($link->data); } return $this->view->call(__FUNCTION__, $result); }
/** * type : 'profile' == profile status, * content : shared content. */ public function add() { $type = JRequest::getString('type'); $content = JRequest::getVar('text'); $my = FD::get('People'); $streamId = ''; switch ($type) { case 'profile': $data = array(); $data['actor_node_id'] = $my->get('node_id'); $data['node_id'] = '1'; $data['content'] = $content; $storyTbl = FD::table('Story'); $storyTbl->bind($data); $storyTbl->store(); $streamId = $storyTbl->streamId; if (!empty($streamId)) { $story = FD::get('Stream')->get('people', '', '', false, $streamId); FD::get('AJAX')->success($story[0]); return; } break; default: break; } FD::get('AJAX')->success(); }
/** * 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); $editor = JFactory::getEditor(); $guest = $event->getGuest(); // Only allow group admin to create or edit news if (!$guest->isAdmin() && !$this->my->isSiteAdmin()) { FD::info()->set(false, JText::_('COM_EASYSOCIAL_EVENTS_ONLY_GUEST_ARE_ALLOWED'), SOCIAL_MSG_ERROR); return $this->redirect($event->getPermalink(false)); } // Determines if this item is being edited $id = $this->input->get('newsId', 0, 'int'); $news = FD::table('EventNews'); $news->load($id); FD::page()->title(JText::_('APP_EVENT_NEWS_FORM_UPDATE_PAGE_TITLE')); // Determine if this is a new record or not if (!$id) { $news->comments = true; FD::page()->title(JText::_('APP_EVENT_NEWS_FORM_CREATE_PAGE_TITLE')); } // Get app params $params = $this->app->getParams(); $this->set('params', $params); $this->set('news', $news); $this->set('editor', $editor); $this->set('event', $event); echo parent::display('canvas/form'); }
/** * Displays the application output in the canvas. * * @since 1.0 * @access public * @param int The user id that is currently being viewed. */ public function display($groupId = null, $docType = null) { $group = FD::group($groupId); // Render the rss model $model = FD::model('RSS'); $result = $model->getItems($group->id, SOCIAL_TYPE_GROUP); // If there are tasks, we need to bind them with the table. $feeds = array(); if ($result) { foreach ($result as $row) { // Bind the result back to the note object. $rss = FD::table('Rss'); $rss->bind($row); // Initialize the parser. $parser = @JFactory::getFeedParser($rss->url); $rss->parser = $parser; $rss->total = @$parser->get_item_quantity(); $rss->items = @$parser->get_items(); $feeds[] = $rss; } } // Get the app params $params = $this->app->getParams(); $limit = $params->get('total', 5); $this->set('totalDisplayed', $limit); $this->set('appId', $this->app->id); $this->set('group', $group); $this->set('feeds', $feeds); echo parent::display('views/default'); }
/** * 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'); }
/** * * * @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; }
/** * * * @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; }
/** * Displays the dialog to allow user to crop avatar * * @since 1.2 * @access public * @param string * @return */ public function crop() { // Require the user to be logged in FD::requireLogin(); // Load up the ajax library $ajax = FD::ajax(); // Get the unique object. $uid = JRequest::getInt('uid'); $type = JRequest::getCmd('type'); // Get photo id $id = JRequest::getInt('id'); $table = FD::table('Photo'); $table->load($id); $redirectUrl = JRequest::getVar('redirectUrl', ''); // Load up the library $lib = FD::photo($table->uid, $table->type, $table); if (!$table->id) { return $this->deleted($lib); } // Check if the user is really allowed to upload avatar if (!$lib->canUseAvatar()) { return $ajax->reject(); } $redirect = JRequest::getInt('redirect', 1); $theme = FD::themes(); $theme->set('uid', $uid); $theme->set('type', $type); $theme->set('redirectUrl', $redirectUrl); $theme->set('photo', $lib->data); $theme->set('redirect', $redirect); $output = $theme->output('site/avatar/crop'); return $ajax->resolve($output); }
/** * 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(); }
private function getElementSource() { $element = $this->item->context; $uid = $this->item->contextId; // photos has the special threatment. if the item is a aggregated item, then the context is album and the uid is albumid. if ($element == 'photos') { if (count($this->item->contextIds) > 1) { $photo = FD::table('Photo'); $photo->load($uid); $element = 'albums'; $uid = $photo->album_id; } } if ($element == 'story' || $element == 'links') { $uid = $this->item->uid; } if ($element == 'badges') { $tbl = FD::table('StreamItem'); $tbl->load(array('uid' => $this->item->uid)); $element = SOCIAL_TYPE_ACTIVITY; $uid = $tbl->id; } $obj = new stdClass(); $obj->element = $element; $obj->uid = $uid; return $obj; }
/** * Does a remote call to the server to fetch contents of a given url. * * @since 1.0 * @access public */ public function fetch() { // Check for request forgeries! $urls = JRequest::getVar('urls'); // Ensure that the urls are in an array FD::makeArray($urls); // Get the current view. $view = $this->getCurrentView(); // Result placeholder $result = array(); if (!$urls || empty($urls)) { $view->setMessage(JText::_('COM_EASYSOCIAL_CRAWLER_INVALID_URL_PROVIDED'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } $crawler = FD::get('Crawler'); foreach ($urls as $url) { $hash = md5($url); $link = FD::table('Link'); $exists = $link->load(array('hash' => $hash)); // If it doesn't exist, store it. if (!$exists) { $crawler->crawl($url); $data = $crawler->getData(); $link->hash = $hash; $link->data = FD::json()->encode($data); // Store the new link $link->store(); } $result[$url] = FD::json()->decode($link->data); } return $view->call(__FUNCTION__, $result); }
/** * Default method to display the registration page. * * @since 1.0 * @access public * @author Mark Lee <*****@*****.**> */ function item($tpl = null) { // Check for user profile completeness FD::checkCompleteProfile(); $config = FD::config(); if (!$config->get('badges.enabled')) { return $this->redirect(FRoute::dashboard(array(), false)); } // Get id of badge $id = JRequest::getInt('id'); $badge = FD::table('Badge'); $badge->load($id); if (!$id || !$badge->id) { FD::info()->set(JText::_('COM_EASYSOCIAL_BADGES_INVALID_BADGE_ID_PROVIDED'), SOCIAL_MSG_ERROR); $this->redirect(FRoute::badges()); $this->close(); } // Load the badge language $badge->loadLanguage(); // Set the page title FD::page()->title($badge->get('title')); // Set the page breadcrumb FD::page()->breadcrumb(JText::_('COM_EASYSOCIAL_PAGE_TITLE_BADGES'), FRoute::badges()); FD::page()->breadcrumb($badge->get('title')); // Get the badges model $options = array('start' => 0, 'limit' => FD::themes()->getConfig()->get('achieverslimit', 50)); $achievers = $badge->getAchievers($options); $totalAchievers = $badge->getTotalAchievers(); $this->set('totalAchievers', $totalAchievers); $this->set('achievers', $achievers); $this->set('badge', $badge); parent::display('site/badges/default.item'); }
/** * 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; }
/** * Displays the application output in the canvas. * * @since 1.0 * @access public * @param int The user id that is currently being viewed. */ public function display($uid = null, $docType = null) { $group = FD::group($uid); $editor = JFactory::getEditor(); // Only allow group admin to create or edit news if (!$group->isAdmin() && !$this->my->isSiteAdmin()) { FD::info()->set(false, JText::_('COM_EASYSOCIAL_GROUPS_ONLY_MEMBER_ARE_ALLOWED'), SOCIAL_MSG_ERROR); return $this->redirect($group->getPermalink(false)); } $id = JRequest::getInt('newsId'); $news = FD::table('GroupNews'); $news->load($id); FD::page()->title(JText::_('APP_GROUP_NEWS_FORM_UPDATE_PAGE_TITLE')); // Determine if this is a new record or not if (!$id) { $news->comments = true; FD::page()->title(JText::_('APP_GROUP_NEWS_FORM_CREATE_PAGE_TITLE')); } // Get app params $params = $this->app->getParams(); $this->set('params', $params); $this->set('news', $news); $this->set('editor', $editor); $this->set('group', $group); echo parent::display('canvas/form'); }
/** * 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(); // Render the headers FD::page()->start(); // Attach dialog's css file. JFactory::getDocument()->addStylesheet(rtrim(JURI::root(), '/') . '/administrator/components/com_easysocial/themes/default/styles/style.css'); $theme = FD::themes(); $label = (string) $this->element['label']; $name = (string) $this->name; $title = JText::_('COM_EASYSOCIAL_JFIELD_SELECT_BADGE'); if ($this->value) { $badge = FD::table('Badge'); $badge->load($this->value); $title = $badge->get('title'); } $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/badge'); // 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; }
/** * Unblocks a specific target item * * @since 1.3 * @access public * @param string * @return */ public function unblock($targetId) { $table = FD::table('BlockUser'); $table->load(array('user_id' => $this->my->id, 'target_id' => $targetId)); $state = $table->delete(); return $state; }