/** * Validates the permalink. * * @author Jason Rey <*****@*****.**> * @since 1.3 * @access public * @return JSON A jsong encoded string. */ public function isValid() { // Render the ajax lib. $ajax = FD::ajax(); // Get the cluster id. $clusterId = JRequest::getInt('clusterid', 0); // Init the current alias. $current = ''; if (!empty($clusterId)) { $event = FD::event($clusterId); $current = $event->alias; } // Get the provided permalink $permalink = JRequest::getVar('permalink', ''); // Check if the field is required if (!$this->field->isRequired() && empty($permalink)) { return true; } // Check if the permalink provided is valid if (!SocialFieldsEventPermalinkHelper::valid($permalink, $this->params)) { return $ajax->reject(JText::_('FIELDS_EVENT_PERMALINK_INVALID_PERMALINK')); } // Test if permalink exists if (SocialFieldsEventPermalinkHelper::exists($permalink) && $permalink != $current) { return $ajax->reject(JText::_('FIELDS_EVENT_PERMALINK_NOT_AVAILABLE')); } $text = JText::_('FIELDS_EVENT_PERMALINK_AVAILABLE'); return $ajax->resolve($text); }
public function confirmMigration() { $ajax = FD::ajax(); $theme = FD::themes(); $contents = $theme->output('admin/migrators/dialog.confirm'); return $ajax->resolve($contents); }
/** * 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); }
public function confirmRestore() { $ajax = FD::ajax(); $theme = FD::themes(); $output = $theme->output('admin/stream/dialog.restore'); return $ajax->resolve($output); }
/** * Returns an array of news item in JSON format. * * @since 1.0 * @access public * @param Array A list of news items. * @return SocialAjax * */ public function getNews($news, $appNews = array()) { $ajax = FD::ajax(); // Format the output of the news item since we need the following values // day,month foreach ($news as &$item) { $date = explode('/', $item->date); $item->day = $date[0]; $item->month = $date[1]; } $theme = FD::themes(); $theme->set('items', $news); $content = $theme->output('admin/news/items'); if ($appNews) { foreach ($appNews as &$appItem) { $date = FD::date($appItem->updated); $appItem->lapsed = $date->toLapsed(); $appItem->day = $date->format('d'); $appItem->month = $date->format('M'); } } $theme = FD::themes(); $theme->set('items', $appNews); $apps = $theme->output('admin/news/apps'); return $ajax->resolve($content, $apps); }
/** * Displays the amazon settings form * * @since 1.0 * @access public * @param string * @return */ public function amazon() { $ajax = FD::ajax(); $theme = FD::themes(); $contents = $theme->output('admin/settings/forms/dialog.storage.amazon'); $ajax->resolve($contents); }
/** * Validates the username. * * @since 1.0 * @access public * @param null * @return JSON A jsong encoded string. * * @author Jason Rey <*****@*****.**> */ public function isValid() { // Render the ajax lib. $ajax = FD::ajax(); // Get the group id $groupId = JRequest::getInt('groupid', 0); // Set the current username $current = ''; if (!empty($groupId)) { $group = FD::group($groupId); $current = $group->alias; } // Get the provided permalink $permalink = JRequest::getVar('permalink', ''); // Check if the field is required if (!$this->field->isRequired() && empty($permalink)) { return true; } // Check if the permalink provided is valid if (!SocialFieldsGroupPermalinkHelper::valid($permalink, $this->params)) { return $ajax->reject(JText::_('PLG_FIELDS_GROUP_PERMALINK_INVALID_PERMALINK')); } // Test if permalink exists if (SocialFieldsGroupPermalinkHelper::exists($permalink) && $permalink != $current) { return $ajax->reject(JText::_('PLG_FIELDS_GROUP_PERMALINK_NOT_AVAILABLE')); } $text = JText::_('PLG_FIELDS_GROUP_PERMALINK_AVAILABLE'); return $ajax->resolve($text); }
/** * 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); }
/** * 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(); }
/** * Dialog to confirm a report. * * @since 1.0 * @access public */ public function confirmReport() { $ajax = FD::ajax(); // Determine if the user is a guest $my = FD::user(); $config = FD::config(); if (!$my->id) { if (!$config->get('reports.guests', false)) { return; } } else { // Check if user is really allowed to submit any reports. $access = FD::access(); if (!$access->allowed('reports.submit')) { $this->setMessage(JText::_('COM_EASYSOCIAL_REPORTS_NOT_ALLOWED_TO_SUBMIT_REPORTS'), SOCIAL_MSG_ERROR); return $ajax->reject($this->getMessage()); } } $title = JRequest::getVar('title', JText::_('COM_EASYSOCIAL_REPORTS_DIALOG_TITLE')); $description = JRequest::getVar('description', ''); $theme = FD::themes(); $theme->set('title', $title); $theme->set('description', $description); $html = $theme->output('site/reports/dialog.form'); return $ajax->resolve($html); }
/** * Displays confirmation to uninstall apps * * @since 1.0 * @access public */ public function confirmUninstall() { $ajax = FD::ajax(); $theme = FD::themes(); $contents = $theme->output('admin/apps/dialog.uninstall'); $ajax->resolve($contents); }
/** * Displays confirmation before deleting an album * * @since 1.0 * @access public * @param string * @return */ public function confirmDelete() { $ajax = FD::ajax(); $theme = FD::themes(); $output = $theme->output('admin/albums/dialog.delete'); return $ajax->resolve($output); }
/** * Confirmation before purging pending e-mails * * @since 1.0 * @access public */ public function confirmPurgePending() { $ajax = FD::ajax(); $theme = FD::themes(); $contents = $theme->output('admin/mailer/dialog.purge.pending'); $ajax->resolve($contents); }
public function loadAchievers($html) { $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } return $ajax->resolve($html); }
/** * Post processing after a report has been deleted. * * @since 1.0 * @access public */ public function removeItem() { $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } return $ajax->resolve($this->getMessage()); }
/** * Allows a user to follow an object. * * @since 1.0 * @access public */ public function unfollow() { $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } return $ajax->resolve(); }
/** * Does a remote call to the server to fetch contents of a given url. * * @since 1.0 * @access public */ public function fetch($result = array()) { $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } return $ajax->resolve($result); }
public function installFile($obj = null) { $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } $message = JText::sprintf('COM_EASYSOCIAL_DISCOVER_CHECKED_OUT', $obj->file, count($obj->rules)); return $ajax->resolve($message); }
public function send($state, $msg = '') { if ($state) { FD::ajax()->resolve(); } else { FD::ajax()->reject($msg); } return true; }
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')); }
/** * Returns an ajax chain. * * @since 1.0 * @access public * @param */ public function showOthers($users) { $ajax = FD::ajax(); $html = ''; // Get user list $theme = FD::get('Themes'); $theme->set('users', $users); $html = $theme->output('site/users/simplelist'); return $ajax->resolve($html); }
public function indexing($max, $progress) { $ajax = FD::ajax(); // Determine if there's any errors on the form. $error = $this->getError(); if ($error) { return $ajax->reject($error); } return $ajax->resolve($max, $progress); }
/** * Post processing after an item is unfollowed * * @since 1.0 * @access public * @param string * @return */ public function follow() { $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } // We should display a nicer message $theme = FD::themes(); $contents = $theme->output('site/followers/suggest.removed'); return $ajax->resolve($contents); }
public function getStates() { $country = FD::input()->getString('country'); $region = FD::table('Region'); $region->load(array('type' => SOCIAL_REGION_TYPE_COUNTRY, 'name' => $country, 'state' => SOCIAL_STATE_PUBLISHED)); $states = $region->getChildren(array('ordering' => $this->params->get('sort'))); $data = new stdClass(); foreach ($states as $state) { $data->{$state->code} = $state->name; } FD::ajax()->resolve($data); }
public function __construct() { $this->app = JFactory::getApplication(); $this->my = FD::user(); $this->config = FD::config(); $this->doc = JFactory::getDocument(); if ($this->doc->getType() == 'ajax') { $this->ajax = FD::ajax(); } parent::__construct(); $this->input = FD::request(); }
/** * Post processes after a user submits a story. * * @since 1.0 * @access public * @param string * @return */ public function update($streamTable = '') { // Only logged in users allowed here FD::requireLogin(); $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } $stream = FD::stream(); $stream->getItem($streamTable->uid); $output = $stream->html(false, '', array('contentOnly' => true)); return $ajax->resolve($output, $streamTable->uid); }
/** * Allows caller to set the avatar based on the default avatars * * @since 1.2 * @access public * @param string * @return */ public function loadDefault() { $ajax = FD::ajax(); // Get the avatar id $id = JRequest::getInt('avatarId'); if (!$id) { return $ajax->reject(JText::_('PLG_FIELDS_AVATAR_ERROR_RETRIEVING_AVATAR')); } $default = FD::table('defaultavatar'); $default->load($id); $uri = $default->getSource(SOCIAL_AVATAR_SQUARE, true); return $ajax->resolve($uri); }
/** * Displays the revoke confirmation dialog. * * @since 1.0 * @access public * @param string * @return */ public function confirmRevoke() { // Only required users allowed here. FD::requireLogin(); $ajax = FD::ajax(); // Get client and callback $client = JRequest::getWord('client'); $callback = JRequest::getVar('callbackUrl'); $theme = FD::themes(); $theme->set('callback', $callback); $theme->set('client', $client); $contents = $theme->output('site/' . $client . '/revoke.dialog'); return $ajax->resolve($contents); }
/** * Post processing after creating a cover from a photo. * * @since 1.2 * @access public * @param string * @return */ public function create($cover = null) { $ajax = FD::ajax(); if ($this->hasErrors()) { return $ajax->reject($this->getMessage()); } // Format the output $result = new stdClass(); $result->url = $cover->getSource(); $result->position = $cover->getPosition(); $result->x = $cover->x; $result->y = $cover->y; return $ajax->resolve($result); }
/** * Responsible to display the generic login form via ajax * * @since 1.0 * @access public */ public function form($tpl = null) { $ajax = FD::ajax(); $my = FD::user(); // If user is already logged in, they should not see this page. if ($my->id > 0) { $this->setMessage(JText::_('COM_EASYSOCIAL_LOGIN_ALREADY_LOGGED_IN'), SOCIAL_MSG_ERROR); return $ajax->reject($this->getMessage()); } // Facebook codes. $facebook = FD::oauth('Facebook'); // Get any callback urls. $return = FD::getCallback(); // If return value is empty, always redirect back to the dashboard if (!$return) { $return = FRoute::dashboard(array(), false); } // Determine if there's a login redirection $config = FD::config(); $loginMenu = $config->get('general.site.login'); if ($loginMenu != 'null') { $return = FD::get('toolbar')->getRedirectionUrl($loginMenu); } $return = base64_encode($return); $this->set('return', $return); $this->set('facebook', $facebook); if ($config->get('registrations.enabled')) { $profileId = $config->get('registrations.mini.profile', 'default'); if ($profileId === 'default') { $profileId = Foundry::model('profiles')->getDefaultProfile()->id; } $options = array('visible' => SOCIAL_PROFILES_VIEW_MINI_REGISTRATION, 'profile_id' => $profileId); $fieldsModel = FD::model('Fields'); $fields = $fieldsModel->getCustomFields($options); if (!empty($fields)) { FD::language()->loadAdmin(); $fieldsLib = FD::fields(); $session = JFactory::getSession(); $registration = FD::table('Registration'); $registration->load($session->getId()); $data = $registration->getValues(); $args = array(&$data, &$registration); $fieldsLib->trigger('onRegisterMini', SOCIAL_FIELDS_GROUP_USER, $fields, $args); $this->set('fields', $fields); } } $contents = parent::display('site/login/dialog.login'); return $ajax->resolve($contents); }