本文整理汇总了PHP中elgg_create_river_item函数的典型用法代码示例。如果您正苦于以下问题:PHP elgg_create_river_item函数的具体用法?PHP elgg_create_river_item怎么用?PHP elgg_create_river_item使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了elgg_create_river_item函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: publishBlogs
/**
* Publish blogs based on advanced publication settings
*
* @param int $time the timestamp the entity was published
*
* @return void
*/
protected static function publishBlogs($time)
{
$dbprefix = elgg_get_config('dbprefix');
$publication_id = elgg_get_metastring_id('publication_date');
$publish_options = ['type' => 'object', 'subtype' => 'blog', 'limit' => false, 'joins' => ["JOIN {$dbprefix}metadata mdtime ON e.guid = mdtime.entity_guid", "JOIN {$dbprefix}metastrings mstime ON mdtime.value_id = mstime.id"], 'metadata_name_value_pairs' => [['name' => 'status', 'value' => 'draft']], 'wheres' => ["((mdtime.name_id = {$publication_id}) AND (DATE(mstime.string) = DATE(NOW())))"]];
// get unpublished blogs that need to be published
$entities = new \ElggBatch('elgg_get_entities_from_metadata', $publish_options);
foreach ($entities as $entity) {
// add river item
elgg_create_river_item(['view' => 'river/object/blog/create', 'action_type' => 'create', 'subject_guid' => $entity->getOwnerGUID(), 'object_guid' => $entity->getGUID()]);
// set correct time created
$entity->time_created = $time;
// publish blog
$entity->status = 'published';
// revert access
$entity->access_id = $entity->future_access;
unset($entity->future_access);
// send notifications when post published
elgg_trigger_event('publish', 'object', $entity);
// notify owner
notify_user($entity->getOwnerGUID(), $entity->site_guid, elgg_echo('blog_tools:notify:publish:subject'), elgg_echo('blog_tools:notify:publish:message', [$entity->title, $entity->getURL()]));
// save everything
$entity->save();
}
}
示例2: post
/**
* {@inheritdoc}
*/
public function post(ParameterBag $params)
{
$user = elgg_get_logged_in_user_entity();
$object = get_entity($params->guid);
if (!$object || !$object->canWriteToContainer(0, 'object', 'comment')) {
throw new GraphException("You are not allowed to comment on this object", 403);
}
$comment_text = $params->comment;
$comment = new ElggComment();
$comment->owner_guid = $user->guid;
$comment->container_guid = $object->guid;
$comment->description = $comment_text;
$comment->access_id = $object->access_id;
if (!$comment->save()) {
throw new GraphException(elgg_echo("generic_comment:failure"));
}
// Notify if poster wasn't owner
if ($object->owner_guid != $user->guid) {
$owner = $object->getOwnerEntity();
notify_user($owner->guid, $user->guid, elgg_echo('generic_comment:email:subject', array(), $owner->language), elgg_echo('generic_comment:email:body', array($object->title, $user->name, $comment->description, $comment->getURL(), $user->name, $user->getURL()), $owner->language), array('object' => $comment, 'action' => 'create'));
}
$return = array('nodes' => array('comment' => $comment));
// Add to river
$river_id = elgg_create_river_item(array('view' => 'river/object/comment/create', 'action_type' => 'comment', 'subject_guid' => $user->guid, 'object_guid' => $comment->guid, 'target_guid' => $object->guid));
if ($river_id) {
$river = elgg_get_river(array('ids' => $river_id));
$return['nodes']['activity'] = $river ? $river[0] : $river_id;
}
return $return;
}
示例3: app2_blog_save
function app2_blog_save($title, $text, $excerpt, $tags, $access, $container_guid)
{
$user = elgg_get_logged_in_user_entity();
if (!$user) {
throw new InvalidParameterException('registration:usernamenotvalid');
}
$obj = new ElggObject();
$obj->subtype = "blog";
$obj->owner_guid = $user->guid;
$obj->container_guid = $container_guid;
$obj->access_id = strip_tags($access);
$obj->method = "api";
$obj->description = strip_tags($text);
$obj->title = elgg_substr(strip_tags($title), 0, 140);
$obj->status = 'published';
$obj->comments_on = 'On';
$obj->excerpt = strip_tags($excerpt);
$obj->tags = strip_tags($tags);
$guid = $obj->save();
elgg_create_river_item('river/object/blog/create', 'create', $user->guid, $obj->guid);
if ($guid) {
return true;
} else {
return false;
}
}
示例4: post
/**
* {@inheritdoc}
*/
public function post(ParameterBag $params)
{
$user = get_entity($params->guid);
$friend = $params->friend_uid ? $this->graph->get($params->friend_uid) : null;
if (!$user instanceof ElggUser || !$friend instanceof ElggUser) {
throw new GraphException("User or friend not found", HttpResponse::HTTP_NOT_FOUND);
}
if (!$user->canEdit()) {
throw new GraphException("You are not allowed to modify this user's friends list", HttpResponse::HTTP_FORBIDDEN);
}
if ($user->guid == $friend->guid) {
throw new GraphException("You are trying to friend yourself", HttpResponse::HTTP_BAD_REQUEST);
}
if (check_entity_relationship($user->guid, 'friend', $friend->guid)) {
throw new GraphException("Already a friend", HttpResponse::HTTP_BAD_REQUEST);
}
if (!add_entity_relationship($user->guid, 'friend', $friend->guid)) {
throw new GraphException("Unable to create friendship");
}
$river_id = elgg_create_river_item(array('view' => 'river/relationship/friend/create', 'action_type' => 'friend', 'subject_guid' => $user->guid, 'object_guid' => $friend->guid));
$return = array('nodes' => array('friend' => check_entity_relationship($user->guid, 'friend', $friend->guid), 'friend_of' => check_entity_relationship($friend->guid, 'friend', $user->guid)));
if (!empty($river_id)) {
$river = elgg_get_river(array('ids' => $river_id));
$return['nodes']['activity'] = $river ? $river[0] : $river_id;
}
return $return;
}
示例5: badges_userpoints
/**
* This method is called when a users points are updated.
* We check to see what the users current balance is and
* assign the appropriate badge.
*/
function badges_userpoints($hook, $type, $return, $params)
{
if ($params['entity']->badges_locked) {
return true;
}
$points = $params['entity']->userpoints_points;
$badge = get_entity($params['entity']->badges_badge);
$options = array('type' => 'object', 'subtype' => 'badge', 'limit' => false, 'order_by_metadata' => array('name' => 'badges_userpoints', 'direction' => DESC, 'as' => integer));
$options['metadata_name_value_pairs'] = array(array('name' => 'badges_userpoints', 'value' => $points, 'operand' => '<='));
$entities = elgg_get_entities_from_metadata($options);
if ((int) elgg_get_plugin_setting('lock_high', 'elggx_badges')) {
if ($badge->badges_userpoints > $entities[0]->badges_userpoints) {
return true;
}
}
if ($badge->guid != $entities[0]->guid) {
$params['entity']->badges_badge = $entities[0]->guid;
if (!elgg_trigger_plugin_hook('badges:update', 'object', array('entity' => $user), true)) {
$params['entity']->badges_badge = $badge->guid;
return false;
}
// Announce it on the river
$user_guid = $params['entity']->getGUID();
elgg_delete_river(array("view" => 'river/object/badge/assign', "subject_guid" => $user_guid, "object_guid" => $user_guid));
elgg_delete_river(array("view" => 'river/object/badge/award', "subject_guid" => $user_guid, "object_guid" => $user_guid));
elgg_create_river_item(array('view' => 'river/object/badge/award', 'action_type' => 'award', 'subject_guid' => $user_guid, 'object_guid' => $user_guid));
}
return true;
}
示例6: profile_river_updates
function profile_river_updates($event, $type, $object)
{
$user = get_entity($object->guid);
if ($user instanceof ElggUser) {
$view = 'river/user/default/profileupdate';
elgg_delete_river(array('subject_guid' => $user->guid, 'view' => $view));
elgg_create_river_item(array('view' => $view, 'action_type' => 'update', 'subject_guid' => $user->guid, 'object_guid' => $user->guid, 'access_id' => get_default_access($user)));
}
return true;
}
示例7: post
/**
* {@inheritdoc}
*/
public function post(ParameterBag $params)
{
$subject = $this->graph->get($params->subject_uid);
if (!$subject || !$subject->canEdit()) {
throw new GraphException('You are not allowed to create new activity items with this subject', 403);
}
$id = elgg_create_river_item(array_filter(array('view' => $params->view, 'subject_guid' => $this->graph->get($params->subject_uid)->guid ?: ELGG_ENTITIES_ANY_VALUE, 'object_guid' => $this->graph->get($params->object_uid)->guid ?: ELGG_ENTITIES_ANY_VALUE, 'target_guid' => $this->graph->get($params->target_uid)->guid ?: ELGG_ENTITIES_ANY_VALUE, 'action_type' => $params->action, 'annotation_id' => $this->graph->get($params->annotation_uid)->id)));
if (!$id) {
throw new GraphException('Unable to create a new activity item with such parameters', 400);
}
$params->id = $id;
$ctrl = new RiverItem($this->request, $this->graph);
return $ctrl->get($params);
}
示例8: testElggCreateRiverItemBadEntity
public function testElggCreateRiverItemBadEntity()
{
$entity = elgg_get_entities(array('limit' => 1));
$entity = $entity[0];
$params = array('view' => 'river/relationship/friend/create', 'action_type' => 'create', 'subject_guid' => $entity->guid, 'object_guid' => $entity->guid, 'target_guid' => $entity->guid);
$bad_subject = $params;
$bad_subject['subject_guid'] = -1;
$this->assertFalse(elgg_create_river_item($bad_subject));
$bad_object = $params;
$bad_object['object_guid'] = -1;
$this->assertFalse(elgg_create_river_item($bad_object));
$bad_target = $params;
$bad_target['target_guid'] = -1;
$this->assertFalse(elgg_create_river_item($bad_target));
}
示例9: messageboard_add
/**
* Add messageboard post
*
* @param ElggUser $poster User posting the message
* @param ElggUser $owner User who owns the message board
* @param string $message The posted message
* @param int $access_id Access level (see defines in elgglib.php)
* @return bool
*/
function messageboard_add($poster, $owner, $message, $access_id = ACCESS_PUBLIC)
{
$result_id = $owner->annotate('messageboard', $message, $access_id, $poster->guid);
if (!$result_id) {
return false;
}
elgg_create_river_item(array('view' => 'river/object/messageboard/create', 'action_type' => 'messageboard', 'subject_guid' => $poster->guid, 'object_guid' => $owner->guid, 'access_id' => $access_id, 'annotation_id' => $result_id));
// Send notification only if poster isn't the owner
if ($poster->guid != $owner->guid) {
$subject = elgg_echo('messageboard:email:subject', array(), $owner->language);
$body = elgg_echo('messageboard:email:body', array($poster->name, $message, elgg_get_site_url() . "messageboard/owner/" . $owner->username, $poster->name, $poster->getURL()), $owner->language);
notify_user($owner->guid, $poster->guid, $subject, $body);
}
return $result_id;
}
示例10: daily
/**
* Publish blogs based on advanced publication options
*
* @param string $hook 'cron'
* @param string $type 'daily'
* @param string $return_value optional stdout text
* @param array $params supplied params
*
* @return void
*/
public static function daily($hook, $type, $return_value, $params)
{
// only do if this is configured
if (!blog_tools_use_advanced_publication_options()) {
return $return_value;
}
$dbprefix = elgg_get_config("dbprefix");
$publication_id = elgg_get_metastring_id("publication_date");
$expiration_id = elgg_get_metastring_id("expiration_date");
$time = elgg_extract("time", $params, time());
$publish_options = array("type" => "object", "subtype" => "blog", "limit" => false, "joins" => array("JOIN " . $dbprefix . "metadata mdtime ON e.guid = mdtime.entity_guid", "JOIN " . $dbprefix . "metastrings mstime ON mdtime.value_id = mstime.id"), "metadata_name_value_pairs" => array(array("name" => "status", "value" => "draft")), "wheres" => array("((mdtime.name_id = " . $publication_id . ") AND (DATE(mstime.string) = DATE(NOW())))"));
$unpublish_options = array("type" => "object", "subtype" => "blog", "limit" => false, "joins" => array("JOIN " . $dbprefix . "metadata mdtime ON e.guid = mdtime.entity_guid", "JOIN " . $dbprefix . "metastrings mstime ON mdtime.value_id = mstime.id"), "metadata_name_values_pairs" => array(array("name" => "status", "value" => "published")), "wheres" => array("((mdtime.name_id = " . $expiration_id . ") AND (DATE(mstime.string) = DATE(NOW())))"));
// ignore access
$ia = elgg_set_ignore_access(true);
// get unpublished blogs that need to be published
$entities = new \ElggBatch("elgg_get_entities_from_metadata", $publish_options);
foreach ($entities as $entity) {
// add river item
elgg_create_river_item(array("view" => "river/object/blog/create", "action_type" => "create", "subject_guid" => $entity->getOwnerGUID(), "object_guid" => $entity->getGUID()));
// set correct time created
$entity->time_created = $time;
// publish blog
$entity->status = "published";
// revert access
$entity->access_id = $entity->future_access;
unset($entity->future_access);
// send notifications when post published
elgg_trigger_event('publish', 'object', $entity);
// notify owner
notify_user($entity->getOwnerGUID(), $entity->site_guid, elgg_echo("blog_tools:notify:publish:subject"), elgg_echo("blog_tools:notify:publish:message", array($entity->title, $entity->getURL())));
// save everything
$entity->save();
}
// get published blogs that need to be unpublished
$entities = new \ElggBatch("elgg_get_entities_from_metadata", $unpublish_options);
foreach ($entities as $entity) {
// remove river item
elgg_delete_river(array("object_guid" => $entity->getGUID(), "action_type" => "create"));
// unpublish blog
$entity->status = "draft";
// notify owner
notify_user($entity->getOwnerGUID(), $entity->site_guid, elgg_echo("blog_tools:notify:expire:subject"), elgg_echo("blog_tools:notify:expire:message", array($entity->title, $entity->getURL())));
// save everything
$entity->save();
}
// reset access
elgg_set_ignore_access($ia);
}
示例11: createMember
/**
* Adds a river event when a user joins the site
*
* @param string $event Event name
* @param string $object_type Event type
* @param ElggRelationship $object Relationship object being created
*
* @return void
*/
public static function createMember($event, $object_type, $object)
{
if ($object->relationship !== 'member_of_site') {
return;
}
$enable_river_event = elgg_get_plugin_setting('enable_site_join_river_event', 'profile_manager');
if ($enable_river_event == 'no') {
return;
}
$user_guid = $object->guid_one;
$site_guid = $object->guid_two;
// clear current river events
elgg_delete_river(['view' => 'river/relationship/member_of_site/create', 'subject_guid' => $user_guid, 'object_guid' => $site_guid]);
// add new join river event
elgg_create_river_item(['view' => 'river/relationship/member_of_site/create', 'action_type' => 'join', 'subject_guid' => $user_guid, 'object_guid' => $site_guid]);
}
示例12: friend_request_create_river_events
/**
* Create river events when a friend is added
*
* @param int $user_guid the user who is accepting
* @param int $friend_guid the friend who he accepted
*
* @return bool
*/
function friend_request_create_river_events($user_guid, $friend_guid)
{
$user_guid = sanitise_int($user_guid, false);
$friend_guid = sanitise_int($friend_guid, false);
if (empty($user_guid) || empty($friend_guid)) {
return false;
}
// check plugin setting
if (elgg_get_plugin_setting('add_river', 'friend_request') === 'no') {
// no event are to be created
return true;
}
// add to river
elgg_create_river_item(['view' => 'river/relationship/friend/create', 'action_type' => 'friend', 'subject_guid' => $user_guid, 'object_guid' => $friend_guid]);
elgg_create_river_item(['view' => 'river/relationship/friend/create', 'action_type' => 'friend', 'subject_guid' => $friend_guid, 'object_guid' => $user_guid]);
return true;
}
示例13: invitefriends_add_friends
/**
* Add friends if invite code was set
*
* @param string $hook Hook name
* @param string $type Hook type
* @param bool $result Whether to allow registration
* @param array $params Hook params
* @return void
*/
function invitefriends_add_friends($hook, $type, $result, $params)
{
$user = $params['user'];
$friend_guid = $params['friend_guid'];
$invite_code = $params['invitecode'];
// If $friend_guid has been set, make mutual friends
if ($friend_guid) {
if ($friend_user = get_user($friend_guid)) {
if ($invite_code == generate_invite_code($friend_user->username)) {
$user->addFriend($friend_guid);
$friend_user->addFriend($user->guid);
// @todo Should this be in addFriend?
elgg_create_river_item(array('view' => 'river/relationship/friend/create', 'action_type' => 'friend', 'subject_guid' => $user->getGUID(), 'object_guid' => $friend_guid));
elgg_create_river_item(array('view' => 'river/relationship/friend/create', 'action_type' => 'friend', 'subject_guid' => $friend_guid, 'object_guid' => $user->getGUID()));
}
}
}
}
示例14: hypefaker_add_page
function hypefaker_add_page($owner, $container, $parent = null)
{
$locale = elgg_get_plugin_setting('locale', 'hypeFaker', 'en_US');
$faker = Factory::create($locale);
$access_array = get_write_access_array($owner->guid);
$access_id = array_rand($access_array, 1);
$write_access_array = get_write_access_array($owner->guid);
unset($write_access_array[ACCESS_PUBLIC]);
$write_access_id = array_rand($write_access_array, 1);
$page = new ElggObject();
$page->subtype = $parent ? 'page' : 'page_top';
$page->owner_guid = $owner->guid;
$page->container_guid = $container->guid;
$page->title = $faker->sentence(6);
$page->description = $faker->text(500);
$page->tags = $faker->words(5);
$page->access_id = $access_id;
$page->write_access_id = $write_access_id;
$page->__faker = true;
if ($parent) {
$page->parent_guid = $parent->guid;
}
if ($page->save()) {
$page->annotate('page', $page->description, $page->access_id, $page->owner_guid);
elgg_create_river_item(array('view' => 'river/object/page/create', 'action_type' => 'create', 'subject_guid' => $page->owner_guid, 'object_guid' => $page->getGUID()));
// add some revisions
$users = elgg_get_entities_from_metadata(array('types' => 'user', 'limit' => rand(1, 10), 'order_by' => 'RAND()', 'metadata_names' => '__faker'));
foreach ($users as $user) {
if ($page->canAnnotate($user->guid, 'page')) {
$last_revision = $faker->text(500);
$page->annotate('page', $last_annotation, $page->access_id, $user->guid);
}
}
if (!empty($last_revision)) {
$page->description = $last_revision;
$page->save();
}
return $page;
}
return false;
}
示例15: hypefaker_add_wire
function hypefaker_add_wire($owner, $parent = null)
{
$locale = elgg_get_plugin_setting('locale', 'hypeFaker', 'en_US');
$faker = Factory::create($locale);
$wire = new ElggObject();
$wire->subtype = 'thewire';
$wire->owner_guid = $owner->guid;
$tags = $faker->words(5);
$text = $faker->text(80);
foreach ($tags as $tag) {
$text .= " #{$tag}";
}
if ($parent) {
$wire->reply = true;
$username = $parent->getOwnerEntity()->username;
$text = "@{$username} {$text}";
}
$limit = elgg_get_plugin_setting('limit', 'thewire');
if ($limit > 0) {
$text = elgg_substr($text, 0, $limit);
}
$wire->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$wire->tags = $tags;
$wire->method = 'faker';
$wire->access_id = ACCESS_PUBLIC;
$wire->__faker = true;
if ($wire->save()) {
if ($parent) {
$wire->addRelationship($parent->guid, 'parent');
$wire->wire_thread = $parent->wire_thread;
} else {
$wire->wire_thread = $wire->guid;
}
elgg_create_river_item(array('view' => 'river/object/thewire/create', 'action_type' => 'create', 'subject_guid' => $wire->owner_guid, 'object_guid' => $wire->guid));
$params = array('entity' => $wire, 'user' => $owner, 'message' => $wire->description, 'url' => $wire->getURL(), 'origin' => 'thewire');
elgg_trigger_plugin_hook('status', 'user', $params);
return $wire;
}
return false;
}