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


PHP FD::cluster方法代码示例

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


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

示例1: getCluster

 /**
  * Retrieves the cluster object
  *
  * @since	1.3.8
  * @access	public
  * @param	string
  * @return	
  */
 public function getCluster()
 {
     if (!$this->isCluster()) {
         return false;
     }
     // Get the cluster object
     $cluster = FD::cluster($this->cluster_type, $this->cluster_id);
     return $cluster;
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:17,代码来源:dependencies.php

示例2: onPrepareStream

 /**
  * Triggered to prepare the stream item
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function onPrepareStream(SocialStreamItem &$stream, $includePrivacy = true)
 {
     // If this is not it's context, we don't want to do anything here.
     if ($stream->context != 'story') {
         return;
     }
     $uid = $stream->uid;
     $my = FD::user();
     $privacy = FD::privacy($my->id);
     if ($stream->cluster_id) {
         // Group access checking
         $cluster = FD::cluster($stream->cluster_type, $stream->cluster_id);
         if (!$cluster) {
             return;
         }
         if (!$cluster->canViewItem()) {
             return;
         }
         // Allow editing of the stream item
         $stream->editable = $my->isSiteAdmin() || $cluster->isAdmin() || $stream->actor->id == $my->id;
     } else {
         // Allow editing of the stream item
         $stream->editable = $my->isSiteAdmin() || $stream->actor->id == $my->id;
     }
     // we stil need to check for the privacy because the context might come from the 'repost'
     if ($includePrivacy && !$privacy->validate('story.view', $uid, SOCIAL_TYPE_STORY, $stream->actor->id)) {
         return;
     }
     // Actor of this stream
     $actor = $stream->actor;
     $target = count($stream->targets) > 0 ? $stream->targets[0] : '';
     $stream->display = SOCIAL_STREAM_DISPLAY_FULL;
     $stream->color = '#16a085';
     $stream->fonticon = 'ies-pencil-2';
     $stream->label = FD::_('APP_USER_STORY_UPDATES_STREAM_TOOLTIP', true);
     if ($stream->cluster_id) {
         if ($stream->cluster_type == SOCIAL_TYPE_GROUP) {
             $stream->color = '#303229';
             $stream->fonticon = 'ies-users';
             $stream->label = FD::_('APP_USER_STORY_GROUPS_STREAM_TOOLTIP', true);
         }
         if ($stream->cluster_type == SOCIAL_TYPE_EVENT) {
             $stream->color = '#f06050';
             $stream->fonticon = 'ies-calendar';
             $stream->label = FD::_('APP_USER_STORY_EVENTS_STREAM_TOOLTIP', true);
         }
     }
     $appGroup = SOCIAL_APPS_GROUP_USER;
     if ($stream->cluster_id) {
         if ($stream->cluster_type == SOCIAL_TYPE_EVENT) {
             $appGroup = SOCIAL_APPS_GROUP_EVENT;
         } else {
             $appGroup = SOCIAL_APPS_GROUP_GROUP;
         }
     }
     // Apply likes on the stream
     $likes = FD::likes();
     $likes->get($stream->uid, $stream->context, $stream->verb, $appGroup, $stream->uid);
     $stream->likes = $likes;
     // Apply comments on the stream
     $comments = FD::comments($stream->uid, $stream->context, $stream->verb, $appGroup, array('url' => FRoute::stream(array('layout' => 'item', 'id' => $stream->uid))), $stream->uid);
     $stream->comments = $comments;
     // Apply repost on the stream
     $repost = FD::get('Repost', $stream->uid, SOCIAL_TYPE_STREAM, $appGroup);
     $stream->repost = $repost;
     // If this is a group type, and the viewer is not a member of the group, we need to hide these data
     if ($stream->cluster_id) {
         $cluster = FD::cluster($stream->cluster_type, $stream->cluster_id);
         if (!$cluster->isMember()) {
             $stream->commentLink = false;
             $stream->repost = false;
             $stream->commentForm = false;
         }
         // Sharing only show in public group
         if (!$cluster->isOpen()) {
             $stream->sharing = false;
         }
     }
     // Get application params
     $params = $this->getParams();
     $this->set('params', $params);
     $this->set('actor', $actor);
     $this->set('target', $target);
     $this->set('stream', $stream);
     if ($stream->cluster_id) {
         $clusterReg = FD::registry($stream->params);
         $object = $clusterReg->get($stream->cluster_type);
         $cluster = FD::cluster($stream->cluster_type);
         if ($object) {
             // If have the object only bind
             $cluster->bind($object);
         } else {
//.........这里部分代码省略.........
开发者ID:knigherrant,项目名称:decopatio,代码行数:101,代码来源:story.php

示例3: create

 /**
  * Creates a new stream item
  *
  * @since	1.0
  * @access	public
  * @param	string
  * @return
  */
 public function create($args = array())
 {
     // The content of the story
     $content = isset($args['content']) ? $args['content'] : '';
     // Context ids, and type that are related to the story
     $contextIds = isset($args['contextIds']) ? $args['contextIds'] : '';
     $contextType = isset($args['contextType']) ? $args['contextType'] : '';
     // The person that created this new story
     $actorId = isset($args['actorId']) ? $args['actorId'] : '';
     // If the object is posting on another object, the target object id should be passed in here.
     $targetId = isset($args['targetId']) ? $args['targetId'] : null;
     // If the story is associated with a location, it should be processed.
     $location = isset($args['location']) ? $args['location'] : null;
     // If the story is being tagged with other users.
     $with = isset($args['with']) ? $args['with'] : null;
     // If the content of the story contains mentions using @ and # tags.
     $mentions = isset($args['mentions']) ? $args['mentions'] : array();
     // If the story belongs in a cluster
     $cluster = isset($args['cluster']) ? $args['cluster'] : '';
     $clusterType = isset($args['clusterType']) ? $args['clusterType'] : SOCIAL_TYPE_GROUP;
     // If the story contains a mood
     $mood = isset($args['mood']) ? $args['mood'] : null;
     // Store this into the stream now.
     $stream = FD::stream();
     // Ensure that context ids are always array
     $contextIds = FD::makeArray($contextIds);
     // Determines which trigger group to call
     $group = $cluster ? $clusterType : SOCIAL_TYPE_USER;
     // Load apps
     FD::apps()->load($group);
     // Load up the dispatcher so that we can trigger this.
     $dispatcher = FD::dispatcher();
     // This is to satisfy the setContext method.
     $contextId = isset($contextIds[0]) ? $contextIds[0] : 0;
     // Get the stream template
     $template = $stream->getTemplate();
     $template->setActor($actorId, $this->type);
     $template->setContext($contextId, $contextType);
     $template->setContent($content);
     $verb = $contextType == 'photos' ? 'share' : 'create';
     $template->setVerb($verb);
     $privacyRule = isset($args['privacyRule']) ? $args['privacyRule'] : null;
     $privacyValue = isset($args['privacyValue']) ? $args['privacyValue'] : null;
     $privacyCustom = isset($args['privacyCustom']) ? $args['privacyCustom'] : null;
     if (!$privacyRule) {
         $privacyRule = $contextType == 'photos' ? 'photos.view' : 'story.view';
     }
     if ($privacyValue && is_string($privacyValue)) {
         $privacyValue = FD::privacy()->toValue($privacyValue);
     }
     if ($privacyCustom) {
         $privacyCustom = explode(',', $privacyCustom);
     }
     // Set this stream to be public
     $template->setAccess($privacyRule, $privacyValue, $privacyCustom);
     // Set mentions
     $template->setMentions($mentions);
     // Set the users tagged in the  stream.
     $template->setWith($with);
     // Set the location of the stream
     $template->setLocation($location);
     // Set the mood
     if (!is_null($mood)) {
         $template->setMood($mood);
     }
     // If there's a target, we want it to appear on their stream too
     if ($targetId) {
         $template->setTarget($targetId);
     }
     if ($contextType == 'photos') {
         if (count($contextIds) > 0) {
             foreach ($contextIds as $photoId) {
                 $template->setChild($photoId);
             }
         }
     }
     if ($cluster) {
         $clusterObj = FD::cluster($clusterType, $cluster);
         if ($clusterObj) {
             // Set the params to cache the group data
             $registry = FD::registry();
             $registry->set($clusterType, $clusterObj);
             // Set the params to cache the group data
             $template->setParams($registry);
             $template->setCluster($cluster, $clusterType, $clusterObj->type);
         } else {
             $template->setCluster($cluster, $clusterType, 1);
         }
     }
     // Build the arguments for the trigger
     $args = array(&$template, &$stream, &$content);
     // @trigger onBeforeStorySave
//.........这里部分代码省略.........
开发者ID:ppantilla,项目名称:bbninja,代码行数:101,代码来源:story.php

示例4: prepareUploadedStream

 /**
  * Prepares the stream item for new file uploads
  *
  * @since	1.0
  * @access	public
  * @param	SocialStreamItem	The stream item.
  * @return
  */
 private function prepareUploadedStream(&$item)
 {
     $params = FD::registry($item->params);
     // Get the file object
     $file = FD::table('File');
     $exists = $file->load($params->get('file')->id);
     if (!$exists) {
         return;
     }
     // Get the actor
     $actor = $item->actor;
     $this->set('actor', $actor);
     $this->set('file', $file);
     $clusterType = '';
     if ($item->cluster_id && $item->cluster_type) {
         $cluster = FD::cluster($item->cluster_type, $item->cluster_id);
         $this->set('cluster', $cluster);
         $clusterType = '.' . $item->cluster_type;
     }
     // Load up the contents now.
     $item->title = parent::display('streams/uploaded.title' . $clusterType);
     $item->content = parent::display('streams/uploaded.content');
 }
开发者ID:ppantilla,项目名称:bbninja,代码行数:31,代码来源:files.php

示例5: createStream

 /**
  * Central method to create stream for this task.
  * @param  string   $verb       The verb for the stream.
  * @param  integer  $actorId    The actor user id.
  */
 public function createStream($verb, $actorId = null)
 {
     $stream = FD::stream();
     $tpl = $stream->getTemplate();
     $actor = FD::user($actorId);
     $registry = FD::registry();
     // We set it to array because it is possible that 1 stream contains many tasks that are created from story form
     $registry->set('tasks', array($this));
     $registry->set('milestone', $this->getMilestone());
     if ($this->type == SOCIAL_TYPE_USER) {
         $user = FD::user($this->uid);
         // Cache the user data into the params
         $registry->set('user', $user);
     } else {
         // Get the cluster depending on the type
         $cluster = FD::cluster($this->type, $this->uid);
         // this is a cluster stream and it should be viewable in both cluster and user page.
         $tpl->setCluster($cluster->id, $this->type, $cluster->type);
         // Cache the cluster data into the params
         $registry->set($this->type, $cluster);
     }
     // Set the actor
     $tpl->setActor($actor->id, SOCIAL_TYPE_USER);
     // Set the context
     $tpl->setContext($this->id, 'tasks');
     // Set the verb
     $tpl->setVerb($verb);
     // Set the params to cache the group data
     $tpl->setParams($registry);
     // since this is a cluster and user stream, we need to call setPublicStream
     // so that this stream will display in unity page as well
     // This stream should be visible to the public
     $tpl->setAccess('core.view');
     $stream->add($tpl);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:40,代码来源:task.php

示例6: canSticky

 /**
  * Determines if the stream item can be made sticky
  *
  * @since	1.3
  * @access	public
  * @param	string
  * @return
  */
 public function canSticky()
 {
     $my = FD::user();
     $config = FD::config();
     if (!$config->get('stream.pin.enabled')) {
         return false;
     }
     // If the stream is moderated, it shouldn't be allowed to be stickied
     if ($this->isModerated()) {
         return false;
     }
     if ($my->isSiteAdmin()) {
         return true;
     }
     if ($this->isCluster()) {
         $cluster = FD::cluster($this->cluster_type, $this->cluster_id);
         // if user is not the cluster owner or the admin, then dont alllow to sticky
         if (!$cluster->isOwner() && !$cluster->isAdmin()) {
             return false;
         }
     } else {
         if (!$this->isOwner()) {
             return false;
         }
     }
     return true;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:35,代码来源:dependencies.php

示例7: getParent

 public function getParent()
 {
     if (empty($this->parent_id) || empty($this->parent_type)) {
         return false;
     }
     return FD::cluster($this->parent_type, $this->parent_id);
 }
开发者ID:knigherrant,项目名称:decopatio,代码行数:7,代码来源:cluster.php


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