当前位置: 首页>>代码示例>>PHP>>正文


PHP FD::dispatcher方法代码示例

本文整理汇总了PHP中FD::dispatcher方法的典型用法代码示例。如果您正苦于以下问题:PHP FD::dispatcher方法的具体用法?PHP FD::dispatcher怎么用?PHP FD::dispatcher使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FD的用法示例。


在下文中一共展示了FD::dispatcher方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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;
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:26,代码来源:points.php

示例2: 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();
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:46,代码来源:cron.php

示例3: getUnAccessilbleUserApps

 private function getUnAccessilbleUserApps($userId = null, $group = SOCIAL_APPS_GROUP_USER)
 {
     static $_cache = array();
     if (!isset($_cache[$group])) {
         $db = FD::db();
         $sql = $db->sql();
         $apps = array();
         // if ($userId) {
         $query = "select `element` from `#__social_apps`";
         $query .= " where `type` = 'apps'";
         $query .= " and `state` = 0";
         $query .= ' and `group` = ' . $db->Quote($group);
         // $query .= " union ";
         // $query .= "select a.`element` from `#__social_apps` as a";
         // $query .= " left join `#__social_apps_map` as b on a.`id` = b.`app_id`";
         // $query .= "	and b.`type` = 'user'";
         // $query .= "	and b.`uid` = '$userId'";
         // $query .= " where a.`type` = 'apps'";
         // $query .= " and a.`group` = 'user'";
         // $query .= " and a.`default` = 0";
         // $query .= " and a.`system` = 0";
         // $query .= " and a.`state` = 1";
         // $query .= " and b.`app_id` is null";
         $sql->raw($query);
         $db->setQuery($sql);
         $results = $db->loadColumn();
         if ($results) {
             foreach ($results as $app) {
                 $apps[$app] = true;
             }
         }
         // }
         //now we need to triggers all the apps to see if there is any setting to exclude certain verb's item or not.
         $appLib = FD::getInstance('Apps');
         $appLib->load($group);
         // load user apps
         // Pass arguments by reference.
         $args = array(&$apps);
         // @trigger: onStreamVerbExclude
         $dispatcher = FD::dispatcher();
         $result = $dispatcher->trigger($group, 'onStreamVerbExclude', $args);
         $_cache[$group] = $apps;
     }
     return $_cache[$group];
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:45,代码来源:stream.php

示例4: update


//.........这里部分代码省略.........
     // lets check if this user already has the record or not.
     // if not, we will add it here.
     // if exists, we will update the record.
     $db = FD::db();
     // check if user selected custom but there is no userids, then we do not do anything.
     if ($value == 'custom' && empty($custom)) {
         return false;
     }
     $query = 'select `id` from `#__social_privacy_items`';
     $query .= ' where `user_id` = ' . $db->Quote($userId);
     $query .= ' and `uid` = ' . $db->Quote($uId);
     $query .= ' and `type` = ' . $db->Quote($uType);
     $db->setQuery($query);
     $result = $db->loadResult();
     $privacy = FD::privacy($userId);
     $valueInInt = $privacy->toValue($value);
     $tbl = FD::table('PrivacyItems');
     if ($result) {
         // record exist. update here.
         $tbl->load($result);
         $tbl->value = $valueInInt;
     } else {
         // record not found. add new here.
         $tbl->user_id = $userId;
         $tbl->privacy_id = $pid;
         $tbl->uid = $uId;
         $tbl->type = $uType;
         $tbl->value = $valueInInt;
     }
     if (!$tbl->store()) {
         return false;
     }
     //clear the existing customized privacy data.
     $sql = FD::sql();
     $sql->delete('#__social_privacy_customize');
     $sql->where('uid', $tbl->id);
     $sql->where('utype', SOCIAL_PRIVACY_TYPE_ITEM);
     $db->setQuery($sql);
     $db->query();
     // if there is custom userids.
     if ($value == 'custom' && !empty($custom)) {
         $customList = explode(',', $custom);
         for ($i = 0; $i < count($customList); $i++) {
             $customUserId = $customList[$i];
             if (empty($customUserId)) {
                 continue;
             }
             $tblCustom = FD::table('PrivacyCustom');
             $tblCustom->uid = $tbl->id;
             $tblCustom->utype = SOCIAL_PRIVACY_TYPE_ITEM;
             $tblCustom->user_id = $customUserId;
             $tblCustom->store();
         }
     }
     // need to update the stream's ispublic flag.
     if ($uType != SOCIAL_TYPE_FIELD) {
         $context = $uType;
         $column = 'context_id';
         $updateId = $uId;
         $isPublic = $valueInInt == SOCIAL_PRIVACY_PUBLIC ? 1 : 0;
         $updateQuery = 'update #__social_stream set ispublic = ' . $db->Quote($isPublic);
         switch ($context) {
             case SOCIAL_TYPE_ACTIVITY:
                 $updateQuery .= ' where `id` = ( select `uid` from `#__social_stream_item` where `id` = ' . $db->Quote($uId) . ')';
                 break;
             case SOCIAL_TYPE_STORY:
             case SOCIAL_TYPE_LINKS:
                 $updateQuery .= ' where `id` = ' . $db->Quote($uId);
                 break;
             default:
                 $updateQuery .= ' where `id` IN ( select `uid` from `#__social_stream_item` where `context_type` = ' . $db->Quote($context) . ' and `context_id` = ' . $db->Quote($uId) . ')';
                 break;
         }
         $sql->clear();
         $sql->raw($updateQuery);
         $db->setQuery($sql);
         $db->query();
     }
     // lets trigger the onPrivacyChange event here so that apps can handle their items accordingly.
     $obj = new stdClass();
     $obj->user_id = $userId;
     $obj->privacy_id = $pid;
     $obj->uid = $uId;
     $obj->utype = $uType;
     $obj->value = $valueInInt;
     $obj->custom = $custom;
     // Get apps library.
     $apps = FD::getInstance('Apps');
     // Try to load user apps
     $state = $apps->load(SOCIAL_APPS_GROUP_USER);
     if ($state) {
         // Only go through dispatcher when there is some apps loaded, otherwise it's pointless.
         $dispatcher = FD::dispatcher();
         // Pass arguments by reference.
         $args = array($obj);
         // @trigger: onPrepareStream for the specific context
         $result = $dispatcher->trigger(SOCIAL_APPS_GROUP_USER, 'onPrivacyChange', $args, $uType);
     }
     return true;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:privacy.php

示例5: getHtml

 /**
  * Function to return HTML of 1 comments block
  *
  * @since	1.0
  * @access	public
  * @param	array	$options	Various options to manipulate the comments
  *
  * @return	string	Html block of the comments
  */
 public function getHtml($options = array())
 {
     // Ensure that language file is loaded
     FD::language()->loadSite();
     // Construct mandatory options
     $options['uid'] = $this->uid;
     $options['element'] = $this->getElement();
     $options['hideEmpty'] = isset($options['hideEmpty']) ? $options['hideEmpty'] : false;
     $options['hideForm'] = isset($options['hideForm']) ? $options['hideForm'] : false;
     $options['deleteable'] = isset($options['deleteable']) ? $options['deleteable'] : false;
     if ($this->stream_id) {
         $options['stream_id'] = $this->stream_id;
     }
     // Super admins should always be able to delete comments
     $my = FD::user();
     if ($my->isSiteAdmin()) {
         $options['deleteable'] = true;
     }
     // Check view mode (with childs or not)
     if (empty($options['fullview'])) {
         $options['parentid'] = 0;
     }
     $model = FD::model('comments');
     // Get the total comments first
     $total = $model->getCommentCount($options);
     // Construct bounderies
     if (!isset($options['limit'])) {
         $options['limit'] = FD::config()->get('comments.limit', 5);
     }
     $options['start'] = max($total - $options['limit'], 0);
     // Construct ordering
     $options['order'] = 'created';
     $options['direction'] = 'asc';
     // Check if it is coming from a permalink
     $commentid = JRequest::getInt('commentid', 0);
     if ($commentid !== 0) {
         $options['commentid'] = $commentid;
         // If permalink is detected, then no limit is required
         $options['limit'] = 0;
     }
     $comments = array();
     $count = 0;
     if ($total) {
         $comments = $model->getComments($options);
         $count = count($comments);
     }
     // @trigger: onPrepareComments
     $dispatcher = FD::dispatcher();
     $args = array(&$comments);
     $dispatcher->trigger($this->group, 'onPrepareComments', $args);
     // Check for permalink
     if (!empty($options['url'])) {
         $this->options['url'] = $options['url'];
     }
     // Check for stream id
     if (!empty($options['streamid'])) {
         $this->options['streamid'] = $options['streamid'];
     } else {
         if ($this->stream_id) {
             $this->options['streamid'] = $this->stream_id;
         }
     }
     $themes = FD::themes();
     $themes->set('deleteable', $options['deleteable']);
     $themes->set('hideEmpty', $options['hideEmpty']);
     $themes->set('hideForm', $options['hideForm']);
     $themes->set('my', FD::user());
     $themes->set('element', $this->element);
     $themes->set('group', $this->group);
     $themes->set('verb', $this->verb);
     $themes->set('uid', $this->uid);
     $themes->set('total', $total);
     $themes->set('count', $count);
     $themes->set('comments', $comments);
     if (!empty($this->options['url'])) {
         $themes->set('url', $this->options['url']);
     }
     if (!empty($this->options['streamid'])) {
         $themes->set('streamid', $this->options['streamid']);
     }
     if (isset($this->options['hideForm'])) {
         $themes->set('hideForm', $this->options['hideForm']);
     }
     $html = $themes->output('site/comments/frame');
     return $html;
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:95,代码来源:comments.php

示例6: save


//.........这里部分代码省略.........
     $disallowed = array(FD::token(), 'option', 'task', 'controller');
     // Process $_POST vars
     foreach ($post as $key => $value) {
         if (!in_array($key, $disallowed)) {
             if (is_array($value)) {
                 $value = $json->encode($value);
             }
             $registry->set($key, $value);
         }
     }
     // Convert the values into an array.
     $data = $registry->toArray();
     // Perform field validations here. Validation should only trigger apps that are loaded on the form
     // @trigger onRegisterValidate
     $fieldsLib = FD::fields();
     // Get the general field trigger handler
     $handler = $fieldsLib->getHandler();
     // Build arguments to be passed to the field apps.
     $args = array(&$data, &$my);
     // Ensure that there is no errors.
     // @trigger onEditValidate
     $errors = $fieldsLib->trigger('onEditValidate', SOCIAL_FIELDS_GROUP_USER, $fields, $args, array($handler, 'validate'));
     // If there are errors, we should be exiting here.
     if (is_array($errors) && count($errors) > 0) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_SAVE_ERRORS'), SOCIAL_MSG_ERROR);
         // We need to set the proper vars here so that the es-wrapper contains appropriate class
         JRequest::setVar('view', 'profile', 'POST');
         JRequest::setVar('layout', 'edit', 'POST');
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $view->call('edit', $errors, $data);
     }
     // @trigger onEditBeforeSave
     $errors = $fieldsLib->trigger('onEditBeforeSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args, array($handler, 'beforeSave'));
     if (is_array($errors) && count($errors) > 0) {
         $view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_ERRORS_IN_FORM'), SOCIAL_MSG_ERROR);
         // We need to set the proper vars here so that the es-wrapper contains appropriate class
         JRequest::setVar('view', 'profile');
         JRequest::setVar('layout', 'edit');
         // We need to set the data into the post again because onEditValidate might have changed the data structure
         JRequest::set($data, 'post');
         return $view->call('edit', $errors);
     }
     // Bind the my object with appropriate data.
     $my->bind($data);
     // Save the user object.
     $my->save();
     // Reconstruct args
     $args = array(&$data, &$my);
     // @trigger onEditAfterSave
     $fieldsLib->trigger('onEditAfterSave', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Bind custom fields for the user.
     $my->bindCustomFields($data);
     // Reconstruct args
     $args = array(&$data, &$my);
     // @trigger onEditAfterSaveFields
     $fieldsLib->trigger('onEditAfterSaveFields', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     // Now we update the Facebook details if it is available
     $associatedFacebook = $this->input->get('associatedFacebook', 0, 'int');
     if (!empty($associatedFacebook)) {
         $facebookPull = $this->input->get('oauth_facebook_pull', null, 'default');
         $facebookPush = $this->input->get('oauth_facebook_push', null, 'default');
         $my = FD::user();
         $facebookTable = $my->getOAuth(SOCIAL_TYPE_FACEBOOK);
         if ($facebookTable) {
             $facebookTable->pull = $facebookPull;
             $facebookTable->push = $facebookPush;
             $facebookTable->store();
         }
     }
     // Add stream item to notify the world that this user updated their profile.
     $my->addStream('updateProfile');
     // Update indexer
     $my->syncIndex();
     // @points: profile.update
     // Assign points to the user when their profile is updated
     $points = FD::points();
     $points->assign('profile.update', 'com_easysocial', $my->id);
     // 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);
     // @trigger onProfileCompleteCheck
     // This should return an array of booleans to state which field is filled in.
     // We count the returned result since it will be an array of trues that marks the field that have data for profile completeness checking.
     // We do this after all the data has been saved, and we reget the fields from the model again.
     // We also need to reset the cached field data
     SocialTableField::$_fielddata = array();
     $fields = $fieldsModel->getCustomFields(array('profile_id' => $my->getProfile()->id, 'data' => true, 'dataId' => $my->id, 'dataType' => SOCIAL_TYPE_USER, 'visible' => SOCIAL_PROFILES_VIEW_EDIT, 'group' => SOCIAL_FIELDS_GROUP_USER));
     $args = array(&$my);
     $completedFields = $fieldsLib->trigger('onProfileCompleteCheck', SOCIAL_FIELDS_GROUP_USER, $fields, $args);
     $table = FD::table('Users');
     $table->load(array('user_id' => $my->id));
     $table->completed_fields = count($completedFields);
     $table->store();
     $view->setMessage(JText::_('COM_EASYSOCIAL_PROFILE_ACCOUNT_UPDATED_SUCCESSFULLY'), SOCIAL_MSG_SUCCESS);
     return $view->call(__FUNCTION__, $my);
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:101,代码来源:profile.php

示例7: 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;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:72,代码来源:avatar.php

示例8: 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));
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:73,代码来源:events.php

示例9: 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);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:users.php

示例10: delete

 public function delete($pk = null)
 {
     $state = parent::delete();
     if ($state) {
         // Get dispatcher library
         $dispatcher = FD::dispatcher();
         $args = array(&$this);
         $group = SOCIAL_APPS_GROUP_USER;
         $dispatcher->trigger($group, 'onAfterLikeDelete', $args);
     }
     return $state;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:12,代码来源:likes.php

示例11: approveUser

 /**
  * Approves the user application
  *
  * @since	1.2
  * @access	public
  * @param	int		The user id
  * @return
  */
 public function approveUser($userId)
 {
     $member = FD::table('GroupMember');
     $member->load(array('cluster_id' => $this->id, 'uid' => $userId));
     $member->state = SOCIAL_GROUPS_MEMBER_PUBLISHED;
     $state = $member->store();
     // Additional triggers to be processed when the page starts.
     FD::apps()->load(SOCIAL_TYPE_GROUP);
     $dispatcher = FD::dispatcher();
     // Trigger: onComponentStart
     $dispatcher->trigger('user', 'onJoinGroup', array($userId, $this));
     // @points: groups.join
     // Add points when user joins a group
     $points = FD::points();
     $points->assign('groups.join', 'com_easysocial', $userId);
     // Publish on the stream
     if ($state) {
         // Add stream item so the world knows that the user joined the group
         $this->createStream($userId, 'join');
     }
     // Notify the user that his request to join the group has been approved
     $this->notifyMembers('approved', array('targets' => array($userId)));
     // Send notifications to group members when a new member joined the group
     $this->notifyMembers('join', array('userId' => $userId));
     return $state;
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:34,代码来源:group.php

示例12: loadApp

 /**
  * Responsible to attach the application into the SocialDispatcher object.
  * In short, it does the requiring of files here.
  *
  * @since	1.0
  * @access	private
  * @param	SocialTableApp	The application ORM.
  * @return	bool
  *
  * @author	Mark Lee <mark@stackideas.com>
  */
 private function loadApp(SocialTableApp &$app)
 {
     static $loadedApps = array();
     // Application type and element should always be in lowercase.
     $group = strtolower($app->group);
     $element = strtolower($app->element);
     if (!isset($loadedApps[$group][$element])) {
         // Get dispatcher object.
         $dispatcher = FD::dispatcher();
         // Application trigger file paths.
         $filePath = SOCIAL_APPS . '/' . $group . '/' . $element . '/' . $element . '.php';
         $fileExists = JFile::exists($filePath);
         // If file doesn't exist, skip the entire block.
         if (!$fileExists) {
             $loadedApps[$group][$element] = false;
             return $loadedApps[$group][$element];
         }
         // Assuming that the file exists here (It should)
         require_once $filePath;
         $className = 'Social' . ucfirst($group) . 'App' . ucfirst($element);
         // If the class doesn't exist in this context,
         // the application might be using a different class. Ignore this.
         if (!class_exists($className)) {
             $loadedApps[$group][$element] = false;
             return $loadedApps[$group][$element];
         }
         $appObj = new $className();
         $appObj->group = $group;
         $appObj->element = $app->element;
         self::$cachedApps[$group][$element] = $appObj;
         // Attach the application into the observer list.
         $dispatcher->attach($group, $app->element, $appObj);
         // Add a state for this because we know it has already been loaded.
         $loadedApps[$group][$element] = true;
     }
     return $loadedApps[$group][$element];
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:48,代码来源:apps.php

示例13: 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();
     }
//.........这里部分代码省略.........
开发者ID:ppantilla,项目名称:bbninja,代码行数:101,代码来源:events.php

示例14: getItems

 /**
  * Retrieves a list of notification items.
  *
  * @since	1.0
  * @access	public
  * @param	bool	To aggregate the notification items or not.
  * @return	Array	An array of @SocialTableNotification
  */
 public function getItems($options = array())
 {
     $model = FD::model('Notifications');
     $items = $model->getItems($options);
     if (!$items) {
         return false;
     }
     // Retrieve applications and trigger onNotificationLoad
     $dispatcher = FD::dispatcher();
     // Trigger apps
     foreach ($items as $item) {
         // Add a `since` column to the result so that user's could use the `since` time format.
         $item->since = FD::date($item->created)->toLapsed();
         $args = array(&$item);
         // @trigger onNotificationLoad
         $dispatcher->trigger(SOCIAL_APPS_GROUP_USER, 'onNotificationLoad', $args);
         // @trigger onNotificationLoad
         $dispatcher->trigger(SOCIAL_APPS_GROUP_GROUP, 'onNotificationLoad', $args);
         // @trigger onNotificationLoad
         $dispatcher->trigger(SOCIAL_APPS_GROUP_EVENT, 'onNotificationLoad', $args);
         // Let's format the item title.
         $this->formatItem($item);
     }
     // Group up items.
     if (isset($options['group']) && $options['group'] == SOCIAL_NOTIFICATION_GROUP_ITEMS) {
         $items = $this->group($items);
     }
     return $items;
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:37,代码来源:notification.php

示例15: triggerResponse

 /**
  * Performs trigger when user responds to an event.
  *
  * @since   1.3
  * @access  public
  * @param   string
  * @return
  */
 public function triggerResponse($method)
 {
     // Perform event trigger for this action
     // @onEventGuestResponse
     FD::apps()->load('user');
     $user = FD::user($this->uid);
     $args = array($method, &$user);
     $dispatcher = FD::dispatcher();
     $dispatcher->trigger('user', 'onEventGuestResponse', $args);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:18,代码来源:eventguest.php


注:本文中的FD::dispatcher方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。