本文整理汇总了PHP中FD::apps方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::apps方法的具体用法?PHP FD::apps怎么用?PHP FD::apps使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FD
的用法示例。
在下文中一共展示了FD::apps方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getAppContents
/**
* Responsible to output the application contents.
*
* @since 1.0
* @access public
* @param SocialAppTable The application ORM.
*/
public function getAppContents($app)
{
// If there's an error throw it back to the caller.
if ($this->hasErrors()) {
return $this->ajax->reject($this->getMessage());
}
// Load the library.
$lib = FD::apps();
$contents = $lib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'dashboard', $app, array('userId' => $this->my->id));
// Return the contents
return $this->ajax->resolve($contents);
}
示例2: updateUserPoints
/**
* Updates the cache copy of the user's points.
*
* @since 1.0
* @access public
* @param int The user's id.
* @param int The total number of points
* @return bool True if success false otherwise.
*/
public function updateUserPoints($userId, $points)
{
// Load user's app
FD::apps()->load(SOCIAL_TYPE_USER);
// Load the user
$user = FD::user($userId);
// Get the dispatcher
$dispatcher = FD::dispatcher();
// Construct the arguments to pass to the apps
$args = array(&$user, &$points);
// @trigger onBeforeAssignPoints
$dispatcher->trigger(SOCIAL_TYPE_USER, 'onBeforeAssignPoints', $args);
$user->addPoints($points);
// @trigger onAfterAssignPoints
$dispatcher->trigger(SOCIAL_TYPE_USER, 'onAfterAssignPoints', $args);
return true;
}
示例3: trigger
/**
* Single method to run specific triggers. Caller can specify callbacks which can be
* executed by the caller.
*
* @param string $group The addon group
* @param string $element The element name.
* @param string $method The method to be called.
* @param array $data An array of data to be passed on to the addon.
* @param array $callbacks An array of callback methods with key/value pairs
* @return mixed
*/
public function trigger($group, $eventName, $args, $elements = null, $callbacks = array())
{
// Hot load this so that trigger caller doesn't need to load the apps
FD::apps()->load($group);
// Check if there's anything to load at all.
if (!isset($this->observers[$group])) {
return false;
}
// Get the list of observers
$observers = $this->observers[$group];
// If elements is an array, this means that
// we only want to trigger those specific group of apps,
// in that specific ordering as in that array.
if (is_array($elements)) {
$observers = array();
foreach ($elements as $element) {
if (isset($this->observers[$group][$element])) {
$observers[] = $this->observers[$group][$element];
}
}
}
$result = array();
// Arguments must always be an array.
$args = FD::makeArray($args);
foreach ($observers as $observer) {
// If the observer is not an instance of SocialAppItem, we just skip this.
if (!$observer instanceof SocialAppItem) {
continue;
}
// Execute any callback methods.
if (!empty($callbacks)) {
foreach ($callbacks as $callback => $value) {
if (method_exists($observer, $callback)) {
call_user_func_array(array($observer, $callback), array($value));
}
}
}
// Run the initial execution.
$result[] = $observer->update($eventName, $args);
}
return $result;
}
示例4: store
public function store($updateNulls = false)
{
if (!$this->params instanceof SocialRegistry) {
$this->params = FD::registry($this->params);
}
$this->params = $this->params->toString();
$isNew = false;
if (empty($this->id)) {
$isNew = true;
}
// Get the necessary group
$namespace = explode('.', $this->element);
$group = isset($namespace[1]) ? $namespace[1] : SOCIAL_APPS_GROUP_USER;
FD::apps()->load($group);
if ($isNew && $this->_trigger) {
if (!empty($this->parent)) {
$parent = $this->getParent();
if ($parent) {
$this->depth = $parent->depth + 1;
$parent->addChildCount();
}
}
$this->setBoundary();
// Get the dispatcher object
$dispatcher = FD::dispatcher();
$args = array(&$this);
// @trigger: onBeforeCommentSave
$dispatcher->trigger($group, 'onBeforeCommentSave', $args);
}
$state = parent::store();
if (!$state) {
FD::logError(__FILE__, __LINE__, $this->getError());
return false;
}
if ($isNew && $this->_trigger) {
// @trigger: onAfterCommentSave
$dispatcher->trigger($group, 'onAfterCommentSave', $args);
}
return $state;
}
示例5: execute
/**
* Triggers the cron service
*
* @since 1.0
* @access public
* @param string
* @return
*/
public function execute()
{
$config = FD::config();
// Check if we need a secure phrase.
$requirePhrase = $config->get('general.cron.secure');
$storedPhrase = $config->get('general.cron.key');
$phrase = JRequest::getVar('phrase', '');
if ($requirePhrase && empty($phrase) || $requirePhrase && $storedPhrase != $phrase) {
$this->setStatus('failed');
$this->output(JText::_('COM_EASYSOCIAL_CRONJOB_PASSPHRASE_INVALID'));
return $this->render();
}
// Data to be passed to the triggers.
$data = array();
// Array of states
$states = array();
// @trigger: fields.onBeforeCronExecute
// Retrieve custom fields for the current step
$fieldsModel = FD::model('Fields');
$customFields = $fieldsModel->getCustomFields(array('appgroup' => SOCIAL_TYPE_USER));
$fields = FD::fields();
$fields->trigger('onCronExecute', SOCIAL_TYPE_USER, $customFields, $data);
// @trigger: apps.onBeforeCronExecute
$apps = FD::apps();
$dispatcher = FD::dispatcher();
$dispatcher->trigger(SOCIAL_TYPE_USER, 'onCronExecute', $data);
// Load up files in hooks
$this->hook($states);
if (!empty($states)) {
foreach ($states as $state) {
$this->output($state);
}
}
// Perform maintenance
$maintenance = FD::get('Maintenance');
$maintenance->cleanup();
$this->render();
}
示例6: display
/**
* Displays a user profile to a 3rd person perspective.
*
* @since 1.0
* @access public
* @param null
* @return null
**/
public function display($tpl = null)
{
// Get the user's id.
$id = $this->input->get('id', 0, 'int');
// The current logged in user might be viewing their own profile.
if ($id == 0) {
$id = FD::user()->id;
}
// When the user tries to view his own profile but if he isn't logged in, throw a login page.
if ($id == 0) {
return FD::requireLogin();
}
// Check for user profile completeness
FD::checkCompleteProfile();
// Get the user's object.
$user = FD::user($id);
// If the user still don't exist, throw a 404
if (!$user->id) {
return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
}
if (Foundry::user()->id != $user->id) {
if (FD::user()->isBlockedBy($user->id)) {
return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
}
}
if ($user->isBlock()) {
FD::info()->set(JText::sprintf('COM_EASYSOCIAL_PROFILE_USER_NOT_EXIST', $user->getName()), SOCIAL_MSG_ERROR);
return $this->redirect(FRoute::dashboard(array(), false));
}
// Set the page title
FD::page()->title(FD::string()->escape($user->getName()));
// Set the page breadcrumb
FD::page()->breadcrumb(FD::string()->escape($user->getName()));
// Apply opengraph tags.
FD::opengraph()->addProfile($user);
// Get the current logged in user's object.
$my = FD::user();
// Do not assign badge if i view myself.
if ($user->id != $my->id && $my->id) {
// @badge: profile.view
$badge = FD::badges();
$badge->log('com_easysocial', 'profile.view', $my->id, JText::_('COM_EASYSOCIAL_PROFILE_VIEWED_A_PROFILE'));
}
$startlimit = JRequest::getInt('limitstart', 0);
// Determine if the current request is to load an app
$appId = JRequest::getInt('appId');
// Get site configuration
$config = FD::config();
// Get the apps library.
$appsLib = FD::apps();
$contents = '';
if ($appId) {
// Load the app
$app = FD::table('App');
$app->load($appId);
// Check if the user has access to this app
if (!$app->accessible($user->id)) {
FD::info()->set(null, JText::_('COM_EASYSOCIAL_PROFILE_APP_IS_NOT_INSTALLED_BY_USER'), SOCIAL_MSG_ERROR);
return $this->redirect(FRoute::profile(array('id' => $user->getAlias()), false));
}
// Set the page title
FD::page()->title(FD::string()->escape($user->getName()) . ' - ' . $app->get('title'));
$contents = $appsLib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'profile', $app, array('userId' => $user->id));
}
$layout = JRequest::getCmd('layout');
// @since 1.3.7
// If layout is empty, means we want to get the default view
// Previously timeline is always the default
if (empty($appId) && empty($layout)) {
$defaultDisplay = FD::config()->get('users.profile.display', 'timeline');
$layout = $defaultDisplay;
}
if ($layout === 'about') {
FD::language()->loadAdmin();
$currentStep = JRequest::getInt('step', 1);
$steps = FD::model('Steps')->getSteps($user->profile_id, SOCIAL_TYPE_PROFILES, SOCIAL_PROFILES_VIEW_DISPLAY);
$fieldsLib = FD::fields();
$fieldsModel = FD::model('Fields');
$index = 1;
foreach ($steps as $step) {
$step->fields = $fieldsModel->getCustomFields(array('step_id' => $step->id, 'data' => true, 'dataId' => $user->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_DISPLAY));
if (!empty($step->fields)) {
$args = array($user);
$fieldsLib->trigger('onDisplay', SOCIAL_FIELDS_GROUP_USER, $step->fields, $args);
}
$step->hide = true;
foreach ($step->fields as $field) {
// As long as one of the field in the step has an output, then this step shouldn't be hidden
// If step has been marked false, then no point marking it as false again
// We don't break from the loop here because there is other checking going on
if (!empty($field->output) && $step->hide === true) {
$step->hide = false;
//.........这里部分代码省略.........
示例7: loadLanguage
private function loadLanguage($extension = 'com_easysocial')
{
static $loaded = array();
if (!in_array($extension, $loaded)) {
$loaded[] = $extension;
if ($extension === 'com_easysocial') {
FD::apps()->loadAllLanguages();
}
JFactory::getLanguage()->load($extension, JPATH_ROOT . '/administrator');
JFactory::getLanguage()->load($extension, JPATH_ROOT);
}
return true;
}
示例8: createEvent
/**
* Creates a new event based on the session.
*
* @author Jason Rey <jasonrey@stackideas.com>
* @since 1.3
* @access public
* @param SocialTableStepSession $session The step session.
* @return SocialEvent The SocialEvent object.
*/
public function createEvent(SocialTableStepSession $session)
{
FD::import('admin:/includes/event/event');
$event = new SocialEvent();
$event->creator_uid = FD::user()->id;
$event->creator_type = SOCIAL_TYPE_USER;
$event->category_id = $session->uid;
$event->cluster_type = SOCIAL_TYPE_EVENT;
$event->created = FD::date()->toSql();
$event->key = md5(JFactory::getDate()->toSql() . FD::user()->password . uniqid());
$params = FD::registry($session->values);
// Support for group event
if ($params->exists('group_id')) {
$group = FD::group($params->get('group_id'));
$event->setMeta('group_id', $group->id);
}
$data = $params->toArray();
$customFields = FD::model('Fields')->getCustomFields(array('visible' => SOCIAL_EVENT_VIEW_REGISTRATION, 'group' => SOCIAL_TYPE_EVENT, 'uid' => $session->uid));
$fieldsLib = FD::fields();
$args = array(&$data, &$event);
$callback = array($fieldsLib->getHandler(), 'beforeSave');
$errors = $fieldsLib->trigger('onRegisterBeforeSave', SOCIAL_FIELDS_GROUP_EVENT, $customFields, $args, $callback);
if (!empty($errors)) {
$this->setError($errors);
return false;
}
// Get the current user.
$my = FD::user();
$event->state = SOCIAL_CLUSTER_PENDING;
// If the event is created by site admin or user doesn't need to be moderated, publish event immediately.
if ($my->isSiteAdmin() || !$my->getAccess()->get('events.moderate')) {
$event->state = SOCIAL_CLUSTER_PUBLISHED;
}
// Trigger apps
FD::apps()->load(SOCIAL_TYPE_USER);
$dispatcher = FD::dispatcher();
$triggerArgs = array(&$event, &$my, true);
// @trigger: onEventBeforeSave
$dispatcher->trigger(SOCIAL_TYPE_USER, 'onEventBeforeSave', $triggerArgs);
$state = $event->save();
if (!$state) {
$this->setError($event->getError());
return false;
}
// Notifies admin when a new event is created
if ($event->state === SOCIAL_CLUSTER_PENDING || !$my->isSiteAdmin()) {
$this->notifyAdmins($event);
}
// Recreate the event object
SocialEvent::$instances[$event->id] = null;
$event = FD::event($event->id);
// Create a new owner object
$event->createOwner($my->id);
// Support for group event
if ($event->isGroupEvent()) {
// Check for transfer flag to insert group member as event guest
$transferMode = isset($data['member_transfer']) ? $data['member_transfer'] : 'invite';
if (!empty($transferMode) && $transferMode != 'none') {
$nodeState = SOCIAL_EVENT_GUEST_INVITED;
if ($transferMode == 'attend') {
$nodeState = SOCIAL_EVENT_GUEST_GOING;
}
/*
insert into jos_social_clusters_nodes (cluster_id, uid, type, created, state, owner, admin, invited_by)
select $eventId as cluster_id, uid, type, $now as created, $nodeState as state, 0 as owner, admin, $userId as invited_by from jos_social_clusters_nodes
where cluster_id = $groupId
and state = 1
and type = 'user'
and uid not in (select uid from jos_social_clusters_nodes where cluster_id = $eventId and type = 'user')
*/
$eventId = $event->id;
$groupId = $event->getMeta('group_id');
$userId = $my->id;
$now = FD::date()->toSql();
$query = "INSERT INTO `#__social_clusters_nodes` (`cluster_id`, `uid`, `type`, `created`, `state`, `owner`, `admin`, `invited_by`) SELECT '{$eventId}' AS `cluster_id`, `uid`, `type`, '{$now}' AS `created`, '{$nodeState}' AS `state`, '0' AS `owner`, `admin`, '{$userId}' AS `invited_by` FROM `#__social_clusters_nodes` WHERE `cluster_id` = '{$groupId}' AND `state` = '" . SOCIAL_GROUPS_MEMBER_PUBLISHED . "' AND `type` = '" . SOCIAL_TYPE_USER . "' AND `uid` NOT IN (SELECT `uid` FROM `#__social_clusters_nodes` WHERE `cluster_id` = '{$eventId}' AND `type` = '" . SOCIAL_TYPE_USER . "')";
$db = FD::db();
$sql = $db->sql();
$sql->raw($query);
$db->setQuery($sql);
$db->query();
}
}
// Trigger the fields again
$args = array(&$data, &$event);
$fieldsLib->trigger('onRegisterAfterSave', SOCIAL_FIELDS_GROUP_EVENT, $customFields, $args);
$event->bindCustomFields($data);
$fieldsLib->trigger('onRegisterAfterSaveFields', SOCIAL_FIELDS_GROUP_EVENT, $customFields, $args);
if (empty($event->alias)) {
$event->alias = $this->getUniqueAlias($event->getName());
$event->save();
}
//.........这里部分代码省略.........
示例9: prepare
/**
* Trigger to prepare the story item before being output.
*
* @since 1.0
* @access public
*/
public function prepare()
{
// Load up the necessary apps
FD::apps()->load($this->type);
// Pass arguments by reference.
$args = array(&$this);
// Only go through dispatcher when there is some apps loaded, otherwise it's pointless.
$dispatcher = FD::dispatcher();
// StoryAttachment service
$panels = $dispatcher->trigger($this->type, 'onPrepareStoryPanel', $args);
if ($panels) {
foreach ($panels as $panel) {
if ($panel instanceof SocialStoryPanel) {
$this->panels[] = $panel;
$this->plugins[] = $panel;
}
}
}
return true;
}
示例10: store
/**
* Creates the necessary images to be used as an avatar.
*
* @since 1.0
* @access public
* @param SocialTablePhoto The photo table
* @param array options - createStream
* @return
*/
public function store(SocialTablePhoto &$photo, $options = array())
{
// setup the options.
$createStream = isset($options['addstream']) ? $options['addstream'] : true;
// default to true.
// Check if there's a profile photos album that already exists.
$model = FD::model('Albums');
// Create default album if necessary
$album = $model->getDefaultAlbum($this->uid, $this->type, SOCIAL_ALBUM_PROFILE_PHOTOS);
// Load avatar table
$avatarTable = FD::table('Avatar');
$exists = $avatarTable->load(array('uid' => $this->uid, 'type' => $this->type));
// Cleanup previous avatars only if they exist.
if ($exists) {
$this->cleanup($avatarTable);
}
// Create the images
$this->create($avatarTable, $options);
// Set the avatar composite indices.
$avatarTable->uid = $this->uid;
$avatarTable->type = $this->type;
// Link the avatar to the photo
$avatarTable->photo_id = $photo->id;
// Unlink the avatar from gallery item
$avatarTable->avatar_id = 0;
// Set the last modified time to now.
$avatarTable->modified = FD::date()->toMySQL();
// We need to always reset the avatar back to "joomla"
$avatarTable->storage = SOCIAL_STORAGE_JOOMLA;
// Store the avatar now
$avatarTable->store();
// @points: profile.avatar.update
// Assign points to the current user for uploading their avatar
$photo->assignPoints('profile.avatar.update', $this->uid);
// @Add stream item when a new profile avatar is uploaded
if ($createStream) {
$photo->addPhotosStream('uploadAvatar');
}
// Once the photo is finalized as the profile picture we need to update the state
$photo->state = SOCIAL_STATE_PUBLISHED;
// If album doesn't have a cover, set the current photo as the cover.
if (!$album->hasCover()) {
$album->cover_id = $photo->id;
// Store the album
$album->store();
}
// Prepare the dispatcher
FD::apps()->load($this->type);
if ($this->type == SOCIAL_TYPE_USER) {
$node = FD::user($this->uid);
} else {
$node = FD::group($this->uid);
}
$args = array(&$photo, $node);
$dispatcher = FD::dispatcher();
// @trigger: onUserAvatarUpdate
$dispatcher->trigger($this->type, 'onAvatarBeforeSave', $args);
// Once it is created, store the photo as we need to update
$state = $photo->store();
// @trigger: onUserAvatarUpdate
$dispatcher->trigger($this->type, 'onAvatarAfterSave', $args);
return $state;
}
示例11: onBeforeStorySave
public function onBeforeStorySave(&$template, &$stream, &$content)
{
$params = $this->getParams();
// Determine if we should attach ourselves here.
if (!$params->get('story_event', true)) {
return;
}
$in = FD::input();
$title = $in->getString('event_title');
$description = $in->getString('event_description');
$categoryid = $in->getInt('event_category');
$start = $in->getString('event_start');
$end = $in->getString('event_end');
$timezone = $in->getString('event_timezone');
// If no category id, then we don't proceed
if (empty($categoryid)) {
return;
}
// Perhaps in the future we use FD::model('Event')->createEvent() instead.
// For now just hardcode it here to prevent field triggering and figuring out how to punch data into the respective field data because the form is not rendered through field trigger.
$my = FD::user();
$event = FD::event();
$event->title = $title;
$event->description = $description;
// Set a default params for this event first
$event->params = '{"photo":{"albums":true},"news":true,"discussions":true,"allownotgoingguest":false,"allowmaybe":true,"guestlimit":0}';
$event->type = SOCIAL_EVENT_TYPE_PUBLIC;
$event->creator_uid = $my->id;
$event->creator_type = SOCIAL_TYPE_USER;
$event->category_id = $categoryid;
$event->cluster_type = SOCIAL_TYPE_EVENT;
$event->alias = FD::model('Events')->getUniqueAlias($title);
$event->created = FD::date()->toSql();
$event->key = md5($event->created . $my->password . uniqid());
$event->state = SOCIAL_CLUSTER_PENDING;
if ($my->isSiteAdmin() || !$my->getAccess()->get('events.moderate')) {
$event->state = SOCIAL_CLUSTER_PUBLISHED;
}
// Trigger apps
FD::apps()->load(SOCIAL_TYPE_USER);
$dispatcher = FD::dispatcher();
$triggerArgs = array(&$event, &$my, true);
// @trigger: onEventBeforeSave
$dispatcher->trigger(SOCIAL_TYPE_USER, 'onEventBeforeSave', $triggerArgs);
$state = $event->save();
// Notifies admin when a new event is created
if ($event->state === SOCIAL_CLUSTER_PENDING || !$my->isSiteAdmin()) {
FD::model('Events')->notifyAdmins($event);
}
// Set the meta for start end timezone
$meta = $event->meta;
$meta->cluster_id = $event->id;
$meta->start = FD::date($start)->toSql();
$meta->end = FD::date($end)->toSql();
$meta->timezone = $timezone;
$meta->store();
// Recreate the event object
$event = FD::event($event->id);
// Create a new owner object
$event->createOwner($my->id);
// @trigger: onEventAfterSave
$triggerArgs = array(&$event, &$my, true);
$dispatcher->trigger(SOCIAL_TYPE_USER, 'onEventAfterSave', $triggerArgs);
// Due to inconsistency, we don't use SOCIAL_TYPE_EVENT.
// Instead we use "events" because app elements are named with 's', namely users, groups, events.
$template->context_type = 'events';
$template->context_id = $event->id;
$template->cluster_access = $event->type;
$template->cluster_type = $event->cluster_type;
$template->cluster_id = $event->id;
$params = array('event' => $event);
$template->setParams(FD::json()->encode($params));
}
示例12: display
/**
* Displays a user profile to a 3rd person perspective.
*
* @since 1.0
* @access public
* @param null
* @return null
**/
public function display($tpl = null)
{
// Get the user's id.
$id = $this->input->get('id', 0, 'int');
// Check if there is any stream filtering or not.
$filter = $this->input->get('type', '', 'word');
// The current logged in user might be viewing their own profile.
if ($id == 0) {
$id = FD::user()->id;
}
// When the user tries to view his own profile but if he isn't logged in, throw a login page.
if ($id == 0) {
return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
}
// Check for user profile completeness
FD::checkCompleteProfile();
// Get the user's object.
$user = FD::user($id);
// If the user doesn't exist throw an error
if (!$user->id) {
return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
}
// If the user is blocked or the user doesn't have community access
if ($this->my->id != $user->id && $this->my->isBlockedBy($user->id) || !$user->hasCommunityAccess()) {
return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
}
// If the user is blocked, they should not be accessible
if ($user->isBlock()) {
return JError::raiseError(404, JText::_('COM_EASYSOCIAL_PROFILE_INVALID_USER'));
}
// Set the page properties
$this->page->title($this->string->escape($user->getName()));
$this->page->breadcrumb($this->string->escape($user->getName()));
// Get the current user's privacy object
$privacy = $this->my->getPrivacy();
// Let's test if the current viewer is allowed to view this profile.
if ($this->my->id != $user->id && !$privacy->validate('profiles.view', $user->id, SOCIAL_TYPE_USER)) {
$this->set('user', $user);
return parent::display('site/profile/restricted');
}
// Apply opengraph tags.
FD::opengraph()->addProfile($user);
// Do not assign badge if i view myself.
if ($user->id != $this->my->id && $this->my->id) {
// @badge: profile.view
$badge = FD::badges();
$badge->log('com_easysocial', 'profile.view', $this->my->id, JText::_('COM_EASYSOCIAL_PROFILE_VIEWED_A_PROFILE'));
}
// Get the limit start
$startLimit = $this->input->get('limitstart', 0, 'int');
// Determine if the current request is to load an app
$appId = $this->input->get('appId', 0, 'int');
// Get the apps library.
$appsLib = FD::apps();
// Default contents
$contents = '';
// Load the app when necessary
if ($appId) {
$app = FD::table('App');
$app->load($appId);
// Check if the user has access to this app
if (!$app->accessible($user->id)) {
FD::info()->set(false, JText::_('COM_EASYSOCIAL_PROFILE_APP_IS_NOT_INSTALLED_BY_USER'), SOCIAL_MSG_ERROR);
$redirect = FRoute::profile(array('id' => $user->getAlias()), false);
return $this->redirect($redirect);
}
// Set the page title
$this->page->title(FD::string()->escape($user->getName()) . ' - ' . $app->get('title'));
// Render the app contents
$contents = $appsLib->renderView(SOCIAL_APPS_VIEW_TYPE_EMBED, 'profile', $app, array('userId' => $user->id));
}
// Get the layout
$layout = $this->input->get('layout', '', 'cmd');
// @since 1.3.7
// If layout is empty, means we want to get the default view
// Previously timeline is always the default
if (empty($appId) && empty($layout) && $filter != 'appFilter') {
$defaultDisplay = $this->config->get('users.profile.display', 'timeline');
$layout = $defaultDisplay;
}
// Default variables
$timeline = null;
$newCover = false;
// Viewing info of a user.
if ($layout === 'about') {
$showTimeline = false;
$usersModel = FD::model('Users');
$steps = $usersModel->getAbout($user);
// We should generate a canonical link if user is viewing the about section and the default page is about
if ($this->config->get('users.profile.display') == 'about') {
$this->page->canonical($user->getPermalink(false, true));
}
//.........这里部分代码省略.........
示例13: canvas
/**
* Displays the application in a main canvas layout which is the full width of the component.
* Example:
* index.php?option=com_easysocial&view=apps&layout=canvas&id=[id]&appView=[appView]
*
* @since 1.0
* @access public
* @param null
* @return null
*
*/
public function canvas()
{
// Check for user profile completeness
FD::checkCompleteProfile();
// Get the unique id of the item that is being viewed
$uid = $this->input->get('uid', null, 'int');
$type = $this->input->get('type', SOCIAL_TYPE_USER, 'word');
// Determines if the type is accessible
if (!$this->allowed($uid, $type)) {
return;
}
// Get the current app id.
$id = $this->input->get('id', 0, 'int');
// Get the current app.
$app = FD::table('App');
$state = $app->load($id);
// Default redirection url
$redirect = FRoute::dashboard(array(), false);
// Check if the user has access to this app
if (!$app->accessible($uid, $type) && $type == SOCIAL_TYPE_USER) {
$this->info->set(null, JText::_('COM_EASYSOCIAL_APPS_CANVAS_APP_IS_NOT_INSTALLED'), SOCIAL_MSG_ERROR);
return $this->redirect($redirect);
}
// If id is not provided, we need to throw some errors here.
if (!$id || !$state) {
$this->setMessage(JText::_('COM_EASYSOCIAL_APPS_INVALID_ID_PROVIDED'), SOCIAL_MSG_ERROR);
$info->set($this->getMessage());
return $this->redirect($redirect);
}
// Try to load the app's css.
$app->loadCss();
// Check if the app provides any custom view
$appView = $this->input->get('customView', 'canvas', 'default');
// We need to set the breadcrumb for the cluster type
if ($type == 'group') {
$group = FD::group($uid);
$this->page->breadcrumb($group->getName());
}
// Set the breadcrumbs with the app's title
$this->page->breadcrumb($app->get('title'));
// Load the library.
$lib = FD::apps();
$contents = $lib->renderView(SOCIAL_APPS_VIEW_TYPE_CANVAS, $appView, $app, array('uid' => $uid));
$this->set('uid', $uid);
$this->set('contents', $contents);
$template = 'site/apps/default.canvas.' . strtolower($type);
echo parent::display($template);
}
示例14: delete
public function delete()
{
// Check for request forgeries.
FD::checkToken();
// Only registered users are allowed here.
FD::requireLogin();
// Get the view
$view = FD::view('comments', false);
// Check for permission first
$access = FD::access();
// Get the comment id
$id = JRequest::getInt('id', 0);
// Get the current logged in user
$my = FD::user();
// Load the comment object
$table = FD::table('comments');
$state = $table->load($id);
if (!$state) {
$view->setMessage($table->getError(), SOCIAL_MSG_ERROR);
return $view->call(__FUNCTION__);
}
// There are cases where the app may need to allow the user to delete the comments.
$apps = FD::apps();
$apps->load(SOCIAL_TYPE_USER);
$args = array(&$table, &$my);
$dispatcher = FD::dispatcher();
$allowed = $dispatcher->trigger(SOCIAL_TYPE_USER, 'canDeleteComment', $args);
if ($my->isSiteAdmin() || $access->allowed('comments.delete') || $table->isAuthor() && $access->allowed('comments.deleteown') || in_array(true, $allowed)) {
$state = $table->delete();
if (!$state) {
$view->setMessage($table->getError(), SOCIAL_MSG_ERROR);
}
} else {
$view->setMessage(JText::_('COM_EASYSOCIAL_COMMENTS_NOT_ALLOWED_TO_DELETE'), SOCIAL_MSG_ERROR);
}
return $view->call(__FUNCTION__);
}
示例15: store
//.........这里部分代码省略.........
}
}
// Test to see if the points has changed.
$points = $this->input->get('points', 0, 'int');
// Lets get the difference of the points
$userPoints = $user->getPoints();
// If there is a difference, the admin may have altered the user points
if ($userPoints != $points) {
// Insert a new points record for this new adjustments.
if ($points > $userPoints) {
// If the result points is larger, we always need to subtract and get the balance.
$totalPoints = $points - $userPoints;
} else {
// If the result points is smaller, we always need to subtract.
$totalPoints = -($userPoints - $points);
}
$pointsLib = FD::points();
$pointsLib->assignCustom($user->id, $totalPoints, JText::_('COM_EASYSOCIAL_POINTS_ADJUSTMENTS'));
$user->points = $points;
}
// Convert the values into an array.
$data = $registry->toArray();
// Get the fields lib
$fieldsLib = FD::fields();
// Build arguments to be passed to the field apps.
$args = array(&$data, &$user);
// @trigger onAdminEditValidate
$errors = $fieldsLib->trigger('onAdminEditValidate', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
// If there are errors, we should be exiting here.
if (is_array($errors) && count($errors) > 0) {
$this->view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
// We need to set the data into the post again because onEditValidate might have changed the data structure
JRequest::set($data, 'post');
return $this->view->call('form', $errors);
}
// @trigger onAdminEditBeforeSave
$errors = $fieldsLib->trigger('onAdminEditBeforeSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
if (is_array($errors) && count($errors) > 0) {
$this->view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_ERRORS_IN_FORM'), SOCIAL_MSG_ERROR);
// We need to set the data into the post again because onEditValidate might have changed the data structure
JRequest::set($data, 'post');
return $this->view->call('form', $errors);
}
// Update the user's gid
$gid = $this->input->get('gid', array(), 'array');
$data['gid'] = $gid;
// Bind the user object with the form data.
$user->bind($data);
// Create a new user record if the id don't exist yet.
if (!$id) {
$model = ES::model('Users');
$user = $model->create($data, $user, $profile);
if (!$user) {
$this->view->setMessage($model->getError(), SOCIAL_MSG_ERROR);
// We need to set the data into the post again because onEditValidate might have changed the data structure
JRequest::set($data, 'post');
return $this->view->call('form');
}
// If admin selected auto approval, automatically approve this user.
if ($autoApproval) {
$user->approve(false);
}
$message = $autoApproval ? JText::_('COM_EASYSOCIAL_USERS_CREATED_SUCCESSFULLY_AND_APPROVED') : JText::_('COM_EASYSOCIAL_USERS_CREATED_SUCCESSFULLY');
} else {
// If this was an edited user, save the user object.
$user->save();
$message = JText::_('COM_EASYSOCIAL_USERS_USER_UPDATED_SUCCESSFULLY');
}
// Reconstruct args
$args = array(&$data, &$user);
// @trigger onEditAfterSave
$fieldsLib->trigger('onAdminEditAfterSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
// Bind the custom fields for the user.
$user->bindCustomFields($data);
// Reconstruct args
$args = array(&$data, &$user);
// @trigger onEditAfterSaveFields
$fieldsLib->trigger('onAdminEditAfterSaveFields', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
// Prepare the dispatcher
FD::apps()->load(SOCIAL_TYPE_USER);
$dispatcher = FD::dispatcher();
$args = array(&$user, &$fields, &$data);
// @trigger: onUserProfileUpdate
$dispatcher->trigger(SOCIAL_TYPE_USER, 'onUserProfileUpdate', $args);
// Process notifications
if (isset($post['notifications']) && !empty($post['notifications'])) {
$systemNotifications = $post['notifications']['system'];
$emailNotifications = $post['notifications']['email'];
// Store the notification settings for this user.
$model = ES::model('Notifications');
$model->saveNotifications($systemNotifications, $emailNotifications, $user);
}
// Process privacy items
if (isset($post['privacy']) && !empty($post['privacy'])) {
$resetPrivacy = isset($post['privacyReset']) ? true : false;
$user->bindPrivacy($post['privacy'], $post['privacyID'], $post['privacyCustom'], $post['privacyOld'], $resetPrivacy);
}
$this->view->setMessage($message, SOCIAL_MSG_SUCCESS);
return $this->view->call(__FUNCTION__, $task, $user);
}