/** * Purges the less cache files on the site * * @since 1.0 * @access public * @param string * @return */ public function clearCache() { // Check for request forgeries FD::checkToken(); // Determines if we should purge all javascripts. $purgeScripts = $this->input->get('script-cache', false, 'bool'); // Clear javascript files if ($purgeScripts) { FD::purgeJavascriptResources(); } // Determines if we should purge the cached less stylesheets $purgeCssCache = $this->input->get('stylesheet-cache', false, 'bool'); if ($purgeCssCache) { $templates = JFolder::folders(EASYSOCIAL_SITE_THEMES); foreach ($templates as $template) { $task = FD::stylesheet('site', $template)->purge(); } // Compile admin themes $templates = JFolder::folders(EASYSOCIAL_ADMIN_THEMES); foreach ($templates as $template) { $task = FD::stylesheet('admin', $template)->purge(); } // Compile modules $modules = FD::stylesheet('module')->modules(); foreach ($modules as $module) { $task = FD::stylesheet('module', $module)->purge(); } } $message = JText::sprintf('COM_EASYSOCIAL_CACHE_PURGED_FROM_SITE'); $this->view->setMessage($message, SOCIAL_MSG_SUCCESS); return $this->view->call(__FUNCTION__); }
/** * Filters the output of members * * @since 1.2 * @access public * @return */ public function filterMembers() { // Check for request forgeriess FD::checkToken(); // Ensure that the user is logged in. FD::requireLogin(); // Load up ajax lib $ajax = FD::ajax(); // Get the group $id = JRequest::getInt('id'); $group = FD::group($id); // @TODO: Check whether the viewer can really view the contents // Get the current filter $filter = JRequest::getWord('filter'); $options = array(); if ($filter == 'admin') { $options['admin'] = true; } if ($filter == 'pending') { $options['state'] = SOCIAL_GROUPS_MEMBER_PENDING; } $model = FD::model('Groups'); $users = $model->getMembers($group->id, $options); $pagination = $model->getPagination(); // Load the contents $theme = FD::themes(); $theme->set('pagination', $pagination); $theme->set('group', $group); $theme->set('users', $users); $contents = $theme->output('apps/group/members/groups/default.list'); return $ajax->resolve($contents); }
/** * Stores the theme parameter * * @since 1.0 * @access public * @param string * @return */ public function store() { // Check for request forgeries FD::checkToken(); // @TODO: Check if the user has privilege to access this section. // Get the element from the query $element = JRequest::getWord('element', ''); // Get the current view $view = $this->getCurrentView(); if (!$element) { $view->setMessage(JText::_('COM_EASYSOCIAL_THEMES_INVALID_ELEMENT_PROVIDED'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__, $this->getTask()); } // Load the model $model = FD::model('Themes'); // Format through all the properties that we want to save here. $data = JRequest::get('post'); // Remove unwanted stuffs from the post data. unset($data[FD::token()]); unset($data['option']); unset($data['controller']); unset($data['task']); unset($data['element']); $state = $model->update($element, $data); if (!$state) { $view->setMessage($model->getError(), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__, $this->getTask(), $element); } $view->setMessage(JText::sprintf('COM_EASYSOCIAL_THEMES_SETTINGS_SAVED_SUCCESS', $element), SOCIAL_MSG_SUCCESS); return $view->call(__FUNCTION__, $this->getTask(), $element); }
/** * Revokes the access for the user that has already authenticated * * @since 1.0 * @access public * @param string * @return */ public function revoke() { // Check for request forgeries FD::checkToken(); // Get the current view. $view = $this->getCurrentView(); $client = JRequest::getWord('client'); // Get the oauth library for the consumer type. $oauth = FD::oauth(ucfirst($client)); $uid = JRequest::getVar('uid'); $type = JRequest::getVar('type'); $callback = JRequest::getVar('callback'); // Grab the token. $table = FD::table('OAuth'); $table->load(array('uid' => $uid, 'type' => $type)); // Set the access token. $oauth->setAccess($table->token); $result = $oauth->revoke(); if (!$result) { $view->setError(JText::_('COM_EASYSOCIAL_OAUTH_THERE_WAS_ERROR_REVOKING_ACCESS'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__, $callback); } // Try to delete the record permanently $state = $table->delete(); if (!$state) { $view->setError(JText::_('COM_EASYSOCIAL_OAUTH_THERE_WAS_DELETING_OAUTH_RECORD'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__, $callback); } $view->setMessage(JText::_('COM_EASYSOCIAL_OAUTH_REVOKED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS); return $view->call(__FUNCTION__, $callback); }
/** * Deletes a feed item * * @since 1.0 * @access public */ public function delete() { // Check for request forgeries. FD::checkToken(); // Ensure that the user is logged in. FD::requireLogin(); // Get the ajax object. $ajax = FD::ajax(); // Get current logged in user $my = FD::user(); // Get app's id. $id = JRequest::getInt('id'); // Get feed id. $feedId = JRequest::getInt('feedId'); // Get feed table $feed = $this->getTable('Feed'); $feed->load($feedId); if (!$feedId || !$feed->id) { return $ajax->reject(JText::_('APP_FEEDS_INVALID_ID_PROVIDED')); } // Ensure that the user is allowed to delete this feed. if ($feed->user_id != $my->id) { return $ajax->reject(JText::_('APP_FEEDS_NOT_ALLOWED_TO_DELETE')); } // Try to delete the feed now. $state = $feed->delete(); if (!$state) { return $ajax->reject($feed->getError()); } return $ajax->resolve(); }
/** * 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(); }
/** * Unfollows a user * * @since 1.0 * @access public */ public function unfollow() { // Check for valid tokens. FD::checkToken(); // Check for valid user. FD::requireLogin(); // Load friends model. $model = FD::model('Followers'); // Load the view. $view = $this->getCurrentView(); // Get the user id that we should load for. $userId = JRequest::getInt('id'); // Get the current logged in user $my = FD::user(); // Loads the followers record $follower = FD::table('Subscription'); $follower->load(array('uid' => $userId, 'type' => 'user.user', 'user_id' => $my->id)); if (!$follower->id || !$userId) { $view->setMessage(JText::_('COM_EASYSOCIAL_FOLLOWERS_INVALID_ID'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } // Delete the record $state = $follower->delete(); $view->call(__FUNCTION__); }
public function runscript() { // Check for request forgeries FD::checkToken(); // Get the key $key = $this->input->get('key', '', 'default'); // Get the model $model = FD::model('Maintenance'); $script = $model->getItemByKey($key); if (!$script) { $this->view->setMessage(JText::_('COM_EASYSOCIAL_MAINTENANCE_SCRIPT_NOT_FOUND'), SOCIAL_MSG_ERROR); return $this->view->call(__FUNCTION__); } $classname = $script->classname; if (!class_exists($classname)) { $this->view->setMessage(JText::_('COM_EASYSOCIAL_MAINTENANCE_CLASS_NOT_FOUND'), SOCIAL_MSG_ERROR); return $this->view->call(__FUNCTION__); } $class = new $classname(); try { $class->main(); } catch (Exception $e) { $this->view->setMessage($e->getMessage(), SOCIAL_MSG_ERROR); return $this->view->call(__FUNCTION__); } return $this->view->call(__FUNCTION__); }
/** * 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__); }
/** * Retrieves a list of languages from API server * * @since 1.0 * @access public */ public function getLanguages() { // Check for request forgeries here FD::checkToken(); // Get the stored key $key = $this->config->get('general.key'); // Start connecting $connector = FD::connector(); $connector->addUrl(SOCIAL_UPDATER_LANGUAGE); $connector->setMethod('POST'); $connector->addQuery('key', $key); $connector->connect(); $result = $connector->getResult(SOCIAL_UPDATER_LANGUAGE); $obj = json_decode($result); if (!$obj || !isset($obj->code) || $obj->code != 200) { return $this->view->call(__FUNCTION__, $obj); } // Go through each of the languages now foreach ($obj->languages as $language) { // Check if the language was previously installed thorugh our system. // If it does, load it instead of overwriting it. $table = FD::table('Language'); $exists = $table->load(array('locale' => $language->locale)); // We do not want to bind the id unset($language->id); // Since this is the retrieval, the state should always be disabled if (!$exists) { $table->state = SOCIAL_STATE_UNPUBLISHED; } // If the language file has been installed, we want to check the last updated time if ($exists && $table->state == SOCIAL_LANGUAGES_INSTALLED) { // Then check if the language needs to be updated. If it does, update the ->state to SOCIAL_LANGUAGES_NEEDS_UPDATING // We need to check if the language updated time is greater than the local updated time $languageTime = strtotime($language->updated); $localLanguageTime = strtotime($table->updated); if ($languageTime > $localLanguageTime && $table->state == SOCIAL_LANGUAGES_INSTALLED) { $table->state = SOCIAL_LANGUAGES_NEEDS_UPDATING; } } // Set the title $table->title = $language->title; // Set the locale $table->locale = $language->locale; // Set the translator $table->translator = $language->translator; // Set the updated time $table->updated = $language->updated; // Update the progress $table->progress = $language->progress; // Update the table with the appropriate params $params = FD::registry(); $params->set('download', $language->download); $params->set('md5', $language->md5); $table->params = $params->toString(); $table->store(); } return $this->view->call(__FUNCTION__, $obj); }
public function loadStoryForm() { FD::checkToken(); FD::requireLogin(); FD::language()->loadAdmin(); $categoryid = FD::input()->getInt('id', 0); $category = FD::table('EventCategory'); $category->load($categoryid); $db = FD::db(); $sql = $db->sql(); $sql->select('#__social_fields', 'a'); $sql->column('a.*'); $sql->column('d.element'); $sql->leftjoin('#__social_fields_steps', 'b'); $sql->on('a.step_id', 'b.id'); $sql->leftjoin('#__social_clusters_categories', 'c'); $sql->on('b.uid', 'c.id'); $sql->leftjoin('#__social_apps', 'd'); $sql->on('a.app_id', 'd.id'); $sql->where('b.type', SOCIAL_TYPE_CLUSTERS); $sql->where('c.id', $category->id); $sql->where('d.group', SOCIAL_FIELDS_GROUP_EVENT); $sql->where('d.type', SOCIAL_APPS_TYPE_FIELDS); $sql->where('d.element', array('startend', 'title', 'description'), 'in'); $db->setQuery($sql); $result = $db->loadObjectList(); $theme = FD::themes(); foreach ($result as $row) { $field = FD::table('Field'); $field->bind($row); $params = $field->getParams(); if ($row->element === 'startend') { $dateFormat = $params->get('date_format', 'DD-MM-YYYY'); if ($params->get('allow_time', true)) { $dateFormat .= ' ' . $params->get('time_format', 'hh:mm A'); } if ($params->get('allow_timezone', true)) { $theme->set('timezones', $this->getTimezones()); } $theme->set('dateFormat', $dateFormat); $theme->set('allowTimezone', $params->get('allow_timezone', 1)); $theme->set('allowTime', $params->get('allow_time', 1)); $theme->set('yearfrom', $params->get('yearfrom')); $theme->set('yearto', $params->get('yearto')); $theme->set('disallowPast', $params->get('disallow_past', 0)); $theme->set('minuteStepping', $params->get('minute_stepping', 15)); } if ($row->element === 'title') { $theme->set('titlePlaceholder', $field->get('title')); } if ($row->element === 'description') { $theme->set('descriptionPlaceholder', $field->get('description')); } } FD::ajax()->resolve($theme->output('apps/user/events/story/panel.form')); }
/** * Sends a new share to a user. * * @since 1.0 * @access public */ public function send() { FD::checkToken(); $token = JRequest::getString('token', ''); $recipients = JRequest::getVar('recipients', array()); $content = JRequest::getVar('content', ''); // Get the current view. $view = $this->getCurrentView(); // Cleaning if (is_string($recipients)) { $recipients = explode(',', FD::string()->escape($recipients)); } if (is_array($recipients)) { foreach ($recipients as &$recipient) { $recipient = FD::string()->escape($recipient); if (!JMailHelper::isEmailAddress($recipient)) { return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_INVALID_RECIPIENT')); } } } $content = FD::string()->escape($content); // Check for valid data if (empty($recipients)) { return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_NO_RECIPIENTS')); } if (empty($token)) { return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_INVALID_TOKEN')); } $session = JFactory::getSession(); $config = FD::config(); $limit = $config->get('sharing.email.limit', 0); $now = FD::date()->toUnix(); $time = $session->get('easysocial.sharing.email.time'); $count = $session->get('easysocial.sharing.email.count'); if (is_null($time)) { $session->set('easysocial.sharing.email.time', $now); $time = $now; } if (is_null($count)) { $session->set('easysocial.sharing.email.count', 0); } $diff = $now - $time; if ($diff <= 3600) { if ($limit > 0 && $count >= $limit) { return $view->call(__FUNCTION__, false, JText::_('COM_EASYSOCIAL_SHARING_EMAIL_SHARING_LIMIT_MAXED')); } $count++; $session->set('easysocial.sharing.email.count', $count); } else { $session->set('easysocial.sharing.email.time', $now); $session->set('easysocial.sharing.email.count', 1); } $library = FD::get('Sharing'); $library->sendLink($recipients, $token, $content); $view->call(__FUNCTION__, true); }
public function installFile() { FD::checkToken(); $view = $this->getCurrentView(); $file = JRequest::getVar('file', ''); if (empty($file)) { $view->setError('Invalid file path given to scan.'); return $view->call(__FUNCTION__); } $model = FD::model('accessrules'); $obj = (object) array('file' => str_ireplace(JPATH_ROOT, '', $file), 'rules' => $model->install($file)); return $view->call(__FUNCTION__, $obj); }
/** * Get's the latest news from updater server. * * @since 1.0 * @access public */ public function getNews() { // Check for request forgeries FD::checkToken(); // Get the current view $view = $this->getCurrentView(); // Get the current model $model = FD::model('News'); // Get the manifest data $obj = $model->getNews(); // Get the news $news = $obj->news; // Get app news $appNews = $obj->apps; return $view->call(__FUNCTION__, $news, $appNews); }
/** * Allows user to purge indexed items * * @since 1.0 * @access public * @param string * @return */ public function purge() { // Check for request forgeries FD::checkToken(); // Get the current view $view = $this->getCurrentView(); $model = FD::model('Indexer'); $state = $model->purge(); if ($state !== true) { $view->setMessage(JText::_('COM_EASYSOCIAL_INDEXER_PURGE_FAILED'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } $message = JText::_('COM_EASYSOCIAL_INDEXER_PURGED_SUCCESS'); $view->setMessage($message, SOCIAL_MSG_SUCCESS); $view->call(__FUNCTION__); }
/** * Filters the output of members * * @since 1.3 * @access public * @return */ public function filterGuests() { // Check for request forgeriess FD::checkToken(); // Ensure that the user is logged in. FD::requireLogin(); // Get the event object $id = $this->input->get('id', 0, 'int'); $event = FD::event($id); if (!$event || !$id) { return $this->ajax->reject(); } // Check whether the viewer can really view the contents if (!$event->canViewItem()) { return $this->ajax->reject(); } // Get the current filter $filter = $this->input->get('filter', '', 'word'); $options = array(); if ($filter == 'admin') { $options['admin'] = true; } if ($filter == 'going') { $options['state'] = SOCIAL_EVENT_GUEST_GOING; } if ($filter == 'maybe') { $options['state'] = SOCIAL_EVENT_GUEST_MAYBE; } if ($filter == 'notgoing') { $options['state'] = SOCIAL_EVENT_GUEST_NOT_GOING; } if ($filter == 'pending') { $options['state'] = SOCIAL_EVENT_GUEST_PENDING; } $model = FD::model('Events'); $guests = $model->getGuests($event->id, $options); $pagination = $model->getPagination(); $myGuest = $event->getGuest(); // Load the contents $theme = FD::themes(); $theme->set('pagination', $pagination); $theme->set('event', $event); $theme->set('guests', $guests); $theme->set('myGuest', $myGuest); $contents = $theme->output('apps/event/guests/events/default.list'); return $this->ajax->resolve($contents, count($guests)); }
/** * Suggests a list of hash tags to the user * * @since 1.0 * @access public * @param string * @return */ public function suggest() { // Check for valid tokens. FD::checkToken(); // Only valid registered user has friends. FD::requireLogin(); // Get current logged in user $my = FD::user(); // Load the view. $view = $this->getCurrentView(); // Properties $search = $this->input->get('search', '', 'default'); // Get the stream model $model = FD::model('Hashtags'); // Try to get the search result $result = $model->search($search); return $view->call(__FUNCTION__, $result); }
public function remove() { // Check for valid token FD::checkToken(); // Ensure that the user is logged in FD::requireLogin(); $sId = JRequest::getVar('id'); if (empty($sId)) { FD::getInstance('View', 'Subscriptions', false)->setErrors(JText::_('COM_EASYSOCIAL_ERROR_UNABLE_TO_LOCATE_ID')); return FD::getInstance('View', 'Subscriptions', false)->remove(); } $state = FD::get('Subscriptions')->remove($sId); if (!$state) { FD::getInstance('View', 'Subscriptions', false)->setErrors(JText::_('COM_EASYSOCIAL_SUBSCRIPTION_FAILED_TO_UNSUBSCRIBE')); return FD::getInstance('View', 'Subscriptions', false)->remove(); } return FD::getInstance('View', 'Subscriptions', false)->remove(); }
public function loadAchievers() { FD::checkToken(); $view = $this->getCurrentView(); $id = JRequest::getInt('id'); $start = JRequest::getInt('start'); $theme = FD::themes(); $options = array('start' => $start, 'limit' => $theme->getConfig()->get('achieverslimit', 50)); $model = FD::model('badges'); $achievers = $model->getAchievers($id, $options); $html = ''; if ($achievers) { foreach ($achievers as $user) { $html .= $theme->loadTemplate('site/badges/default.item.achiever', array('user' => $user)); } } $view->call(__FUNCTION__, $html); }
/** * Unblock a user * * @since 1.3 * @access public * @param string * @return */ public function unblock() { // Check for request forgeries FD::checkToken(); // Ensure that the current user is logged in FD::requireLogin(); // Get the current view $view = $this->getCurrentView(); // Get the target id $target = $this->input->get('target', 0, 'int'); if (!$target) { $view->setError(JText::_('COM_EASYSOCIAL_INVALID_USER_ID_PROVIDED')); return $view->call(__FUNCTION__, $target); } // Load up the block library $lib = FD::blocks(); $lib->unblock($target); return $view->call(__FUNCTION__, $target); }
/** * Deletes a label * * @since 1.0 * @access public * @param string * @return */ public function delete() { // Check for request forgeries FD::checkToken(); $ids = JRequest::getVar('cid'); $ids = FD::makeArray($ids); $view = $this->getCurrentView(); if (empty($ids)) { $view->setMessage(JText::_('COM_EASYSOCIAL_LABELS_EMPTY_ID_PROVIDED'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } foreach ($ids as $id) { $label = FD::table('Label'); $label->load($id); $label->delete(); } $view->setMessage(JText::_('COM_EASYSOCIAL_LABELS_LABEL_DELETED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS); return $view->call(__FUNCTION__); }
/** * Revokes the access for the user that has already authenticated * * @since 1.0 * @access public * @param string * @return */ public function revoke() { // Check for request forgeries FD::checkToken(); // Get the current view. $view = $this->getCurrentView(); // Get the client from the request. $client = JRequest::getWord('client'); $callback = JRequest::getVar('callback'); // Get the current view. $view = $this->getCurrentView(); // Get component's configuration $config = FD::config(); // Get allowed clients $allowedClients = array_keys((array) $config->get('oauth')); // Check if the client is valid. if (!$client || !in_array($client, $allowedClients)) { $view->setMessage(JText::_('Invalid client type provided.'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } // Get the oauth library for the consumer type. $oauth = FD::oauth(ucfirst($client)); // Load the users access $my = FD::user(); $oauthTable = $my->getOAuth($client); // Set the access token. $oauth->setAccess($oauthTable->token); // Try to revoke the user's access $result = $oauth->revoke(); if (!$result) { $view->setError(JText::_('COM_EASYSOCIAL_OAUTH_THERE_WAS_ERROR_REVOKING_ACCESS'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__, $callback); } // Once the remote site has de-authorized the access, we need to delete the table. $state = $oauthTable->delete(); if (!$state) { $view->setError(JText::_('COM_EASYSOCIAL_OAUTH_THERE_WAS_DELETING_OAUTH_RECORD'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__, $callback); } $view->setMessage(JText::sprintf('COM_EASYSOCIAL_OAUTH_REVOKED_SUCCESSFULLY', ucfirst($client)), SOCIAL_MSG_SUCCESS); return $view->call(__FUNCTION__, $callback); }
public function getfriends($userid = '') { // Check for valid tokens. FD::checkToken(); // Only valid registered user has friends. FD::requireLogin(); $query = JRequest::getVar('q', ''); $uId = JRequest::getVar('userid', ''); $exclude = JRequest::getVar('exclude'); $ajax = FD::ajax(); if (!$query) { $ajax->reject(JText::_('Empty query')); return $ajax->send(); } if (empty($userid)) { $userid = $uId; } $my = FD::user($userid); // Load friends model. $model = FD::model('Friends'); // Determine what type of string we should search for. $config = FD::config(); $type = $config->get('users.displayName'); //check if we need to apply privacy or not. $options = array(); if ($exclude) { $options['exclude'] = $exclude; } // Try to get the search result. $friends = $model->search($my->id, $query, $type, $options); $return = array(); if ($friends) { foreach ($friends as $row) { $friend = new stdClass(); $friend->id = $row->id; $friend->title = $row->getName(); $return[] = $friend; } } return $ajax->resolve($return); }
/** * Deletes an album from the site * * @since 1.0 * @access public */ public function remove() { // Check for request forgeries FD::checkToken(); // Get the current view $view = $this->getCurrentView(); // Get the list of ids $ids = JRequest::getVar('cid'); // Ensure that the id's are in an array $ids = FD::makeArray($ids); foreach ($ids as $id) { $album = FD::table('Album'); $album->load($id); $album->delete(); // @points: photos.albums.delete // Deduct points from creator when his album is deleted. $album->assignPoints('photos.albums.delete', $album->uid); } $view->setMessage(JText::_('COM_EASYSOCIAL_ALBUMS_ALBUM_DELETED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS); return $view->call(__FUNCTION__); }
/** * Service Hook for explorer * * @since 1.3 * @access public * @param string * @return */ public function hook() { // Check for request forgeries FD::checkToken(); // Require the user to be logged in FD::requireLogin(); // Get the event object $uid = $this->input->get('uid', 0, 'int'); $type = $this->input->get('type', '', 'cmd'); // Load up the explorer library $explorer = FD::explorer($uid, $type); // Determine if the viewer can really view items if (!$explorer->hook('canViewItem')) { return $this->view->call(__FUNCTION__); } // Get the hook $hook = $this->input->get('hook', '', 'cmd'); // Get the result $result = $explorer->hook($hook); $exception = FD::exception('Folder retrieval successful', SOCIAL_MSG_SUCCESS); return $this->view->call(__FUNCTION__, $exception, $result); }
public function store() { FD::checkToken(); $id = $this->input->get('id', 0, 'int'); $type = $this->input->get('type', '', 'string'); $parent_uid = $this->input->get('parent_uid', 0, 'int'); $parent_type = $this->input->get('parent_type', '', 'string'); $name = $this->input->get('name', '', 'string'); $code = $this->input->get('code', '', 'string'); $state = $this->input->get('state', 0, 'int'); $region = FD::table('Region'); $region->load($id); $region->type = $type; $region->name = $name; $region->code = $code; $region->state = $state; $region->parent_type = $parent_type; $region->parent_uid = !empty($parent_type) ? $parent_uid : 0; $region->store(); $this->view->setMessage(JText::_('COM_EASYSOCIAL_REGIONS_STORED_SUCCESS'), SOCIAL_MSG_SUCCESS); return $this->view->call(__FUNCTION__, $this->getTask(), $region); }
/** * Delete's an avatar from the system. * * @since 1.0 * @access public * @param null * @return null * * @author Mark Lee <*****@*****.**> */ public function delete() { // Check for request forgeries FD::checkToken(); $id = JRequest::getInt('id'); // Get the current view $view = $this->getCurrentView(); $avatar = FD::table('DefaultAvatar'); // If avatar doesn't exist, break and throw errors immediately. if (!$avatar->load($id) || !$id) { // Throw error here. $view->setMessage(JText::_('COM_EASYSOCIAL_PROFILES_DEFAULT_AVATAR_INVALID_ID'), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } if (!$avatar->delete()) { // Throw error here. $view->setMessage($avatar->getError(), SOCIAL_MSG_ERROR); return $view->call(__FUNCTION__); } $view->setMessage(JText::_('COM_EASYSOCIAL_PROFILES_DEFAULT_AVATAR_DELETED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS); return $view->call(__FUNCTION__); }
/** * Retrieves the list of users on the site. * * @since 1.0 * @access public */ public function getUsers() { // Check for request forgeries FD::checkToken(); // Get the current filter $filter = $this->input->get('filter', 'all', 'word'); // Get the current sorting $sort = $this->input->get('sort', $this->config->get('users.listings.sorting'), 'word'); $isSort = $this->input->get('isSort', false, 'bool'); $showPagination = $this->input->get('showpagination', 0, 'default'); $model = FD::model('Users'); $options = array('exclusion' => $this->my->id); if ($sort == 'alphabetical') { $nameField = $this->config->get('users.displayName') == 'username' ? 'a.username' : 'a.name'; $options['ordering'] = $nameField; $options['direction'] = 'ASC'; } elseif ($sort == 'latest') { $options['ordering'] = 'a.id'; $options['direction'] = 'DESC'; } elseif ($sort == 'lastlogin') { $options['ordering'] = 'a.lastvisitDate'; $options['direction'] = 'DESC'; } if ($filter == 'online') { $options['login'] = true; } if ($filter == 'photos') { $options['picture'] = true; } // setup the limit $limit = FD::themes()->getConfig()->get('userslimit'); $options['limit'] = $limit; // Determine if we should display admins $admin = $this->config->get('users.listings.admin') ? true : false; $options['includeAdmin'] = $admin; // we only want published user. $options['published'] = 1; // exclude users who blocked the current logged in user. $options['excludeblocked'] = 1; $result = $model->getUsers($options); $pagination = null; if ($showPagination) { $pagination = $model->getPagination(); // Define those query strings here $pagination->setVar('Itemid', FRoute::getItemId('users')); $pagination->setVar('view', 'users'); $pagination->setVar('filter', $filter); $pagination->setVar('sort', $sort); } $users = array(); // preload users. $arrIds = array(); foreach ($result as $obj) { $arrIds[] = FD::user($obj->id); } if ($arrIds) { FD::user($arrIds); } foreach ($result as $obj) { $users[] = FD::user($obj->id); } return $this->view->call(__FUNCTION__, $users, $isSort, $pagination); }
/** * Allows caller to update a reply * * @since 1.2 * @access public * @return */ public function update() { // Check for request forgeriess FD::checkToken(); // Ensure that the user is logged in. FD::requireLogin(); // Load up ajax lib $ajax = FD::ajax(); // Get the discussion $id = JRequest::getInt('id'); $reply = FD::table('Discussion'); $reply->load($id); // Get the group $groupId = JRequest::getInt('groupId'); $group = FD::group($reply->uid); // Get the discussion $discussion = FD::table('Discussion'); $discussion->load($reply->parent_id); // Get the current user $my = FD::user(); // Check whether the viewer can really reply to the discussion if (!$group->isMember()) { return $this->reject(); } // Get the content // $content = JRequest::getVar( 'content' , '' ); $content = JRequest::getVar('content', '', 'post', 'none', JREQUEST_ALLOWRAW); // var_dump($content);exit; if (empty($content)) { $obj = new stdClass(); $obj->message = JText::_('APP_GROUP_DISCUSSIONS_EMPTY_REPLY_ERROR'); $obj->type = SOCIAL_MSG_ERROR; return $ajax->reject($obj); } // Update the content $reply->content = $content; // Save the reply. $reply->store(); // Update the parent's reply counter. $discussion->sync($reply); return $ajax->resolve($reply->getContent()); }
/** * Purges the less cache files on the site * * @since 1.0 * @access public * @param string * @return */ public function clearCache() { // Check for request forgeries FD::checkToken(); // Get the current view $view = $this->getCurrentView(); $purgeJS = JRequest::getBool('script-cache'); if ($purgeJS) { // Clear javascript files $configuration = FD::getInstance('Configuration'); $configuration->purge(); $compiler = FD::getInstance('Compiler'); $compiler->purgeResources(); } $purgeLess = JRequest::getBool('stylesheet-cache'); if ($purgeLess) { // Compile site themes $templates = JFolder::folders(EASYSOCIAL_SITE_THEMES); foreach ($templates as $template) { $task = FD::stylesheet('site', $template)->purge(); } // Compile admin themes $templates = JFolder::folders(EASYSOCIAL_ADMIN_THEMES); foreach ($templates as $template) { $task = FD::stylesheet('admin', $template)->purge(); } // Compile modules $modules = FD::stylesheet('module')->modules(); foreach ($modules as $module) { $task = FD::stylesheet('module', $module)->purge(); } } $message = JText::sprintf('COM_EASYSOCIAL_CACHE_PURGED_FROM_SITE'); $view->setMessage($message, SOCIAL_MSG_SUCCESS); return $view->call(__FUNCTION__); }