本文整理汇总了PHP中add_to_river函数的典型用法代码示例。如果您正苦于以下问题:PHP add_to_river函数的具体用法?PHP add_to_river怎么用?PHP add_to_river使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了add_to_river函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: tgswire_save_post
/**
* Create a new wire post, the TGS way
*
* @param string $text The post text
* @param int $userid The user's guid
* @param int $access_id Public/private etc
* @param int $parent_guid Parent post guid (if any)
* @param string $method The method (default: 'site')
* @param int $container_guid Container guid (for group wire posts)
* @return guid or false if failure
*/
function tgswire_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site", $container_guid = NULL)
{
$post = new ElggObject();
$post->subtype = "thewire";
$post->owner_guid = $userid;
$post->access_id = $access_id;
// Check if we're removing the limit
if (elgg_get_plugin_setting('limit_wire_chars', 'wire-extender') == 'yes') {
// only 200 characters allowed
$text = elgg_substr($text, 0, 200);
}
// If supplied with a container_guid, use it
if ($container_guid) {
$post->container_guid = $container_guid;
}
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, 'UTF-8');
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if ($tags) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, 'parent');
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
if ($guid) {
add_to_river('river/object/thewire/create', 'create', $post->owner_guid, $post->guid);
// let other plugins know we are setting a user status
$params = array('entity' => $post, 'user' => $post->getOwnerEntity(), 'message' => $post->description, 'url' => $post->getURL(), 'origin' => 'thewire');
elgg_trigger_plugin_hook('status', 'user', $params);
}
return $guid;
}
示例2: likes_add
/**
* Web service to like an entity
*
* @param string $entity_guid guid of object to like
*
* @return bool
*/
function likes_add($entity_guid)
{
if (elgg_annotation_exists($entity_guid, 'likes')) {
return elgg_echo("likes:alreadyliked");
}
// Let's see if we can get an entity with the specified GUID
$entity = get_entity($entity_guid);
if (!$entity) {
return elgg_echo("likes:notfound");
}
// limit likes through a plugin hook (to prevent liking your own content for example)
if (!$entity->canAnnotate(0, 'likes')) {
return elgg_echo("likes:notallowed");
}
$user = elgg_get_logged_in_user_entity();
$annotation = create_annotation($entity->guid, 'likes', "likes", "", $user->guid, $entity->access_id);
// tell user annotation didn't work if that is the case
if (!$annotation) {
return elgg_echo("likes:failure");
}
add_to_river('annotation/annotatelike', 'likes', $user->guid, $entity->guid, "", 0, $annotation);
return elgg_echo("likes:likes");
}
示例3: blog_save
/**
* Web service for making a blog post
*
* @param string $username username of author
* @param string $title the title of blog
* @param string $excerpt the excerpt of blog
* @param string $text the content of blog
* @param string $tags tags for blog
* @param string $access Access level of blog
*
* @return bool
*/
function blog_save($username, $title, $text, $excerpt = "", $tags = "blog", $access = ACCESS_PUBLIC)
{
$user = get_user_by_username($username);
if (!$user) {
throw new InvalidParameterException('registration:usernamenotvalid');
}
$obj = new ElggObject();
$obj->subtype = "blog";
$obj->owner_guid = $user->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();
add_to_river('river/object/blog/create', 'create', $user->guid, $obj->guid);
$return['success'] = true;
$return['message'] = elgg_echo('blog:message:saved');
return $return;
}
示例4: foreach
$batch->container_guid = $album->getGUID();
if ($batch->save()) {
foreach ($uploaded_images as $uploaded_guid) {
add_entity_relationship($uploaded_guid, "belongs_to_batch", $batch->getGUID());
}
}
$album->prependImageList($uploaded_images);
// "added images to album" river
if ($img_river_view == "batch" && $album->new_album == false) {
add_to_river('river/object/tidypics_batch/create', 'create', $batch->getOwnerGUID(), $batch->getGUID());
}
// "created album" river
if ($album->new_album) {
$album->new_album = false;
$album->first_upload = true;
add_to_river('river/object/album/create', 'create', $album->getOwnerGUID(), $album->getGUID());
// "created album" notifications
// we throw the notification manually here so users are not told about the new album until
// there are at least a few photos in it
if ($album->shouldNotify()) {
object_notifications('create', 'object', $album);
$album->last_notified = time();
}
} else {
// "added image to album" notifications
if ($album->first_upload) {
$album->first_upload = false;
}
if ($album->shouldNotify()) {
object_notifications('create', 'object', $album);
$album->last_notified = time();
示例5: elgg_get_entities_from_metadata
if ($page_guid == $tree_page->guid) {
$previous_parent = $page->parent_guid;
$children = elgg_get_entities_from_metadata(array('metadata_name' => 'parent_guid', 'metadata_value' => $page->getGUID()));
if ($children) {
foreach ($children as $child) {
$child->parent_guid = $previous_parent;
}
}
}
}
$page->parent_guid = $parent_guid;
}
if ($page->save()) {
//check in the page becaused the user just saved it
if ($page->deleteMetadata("checkedOut")) {
system_message(elgg_echo('pages:checked_in'));
} else {
system_message('Page could not be checked in. It is still locked for editing');
}
elgg_clear_sticky_form('page');
// Now save description as an annotation
$page->annotate('page', $page->description, $page->access_id);
system_message(elgg_echo('pages:saved'));
if ($new_page) {
add_to_river('river/object/page/create', 'create', elgg_get_logged_in_user_guid(), $page->guid);
}
forward($page->getURL());
} else {
register_error(elgg_echo('pages:error:notsaved'));
forward(REFERER);
}
示例6: get_input
//the actual message
$message = get_input('messageboard_content');
//the number of messages to display
$numToDisplay = get_input('numToDisplay');
//get the full page owner entity
$user = get_entity($_POST['pageOwner']);
//stage one - if a message was posted, add it as an annotation
if ($message) {
// If posting the comment was successful, send message
if ($user->annotate('messageboard', $message, $user->access_id, $_SESSION['user']->getGUID())) {
global $CONFIG;
if ($user->getGUID() != $_SESSION['user']->getGUID()) {
notify_user($user->getGUID(), $_SESSION['user']->getGUID(), elgg_echo('messageboard:email:subject'), sprintf(elgg_echo('messageboard:email:body'), $_SESSION['user']->name, $message, $CONFIG->wwwroot . "pg/messageboard/" . $user->username, $_SESSION['user']->name, $_SESSION['user']->getURL()));
}
// add to river
add_to_river('river/object/messageboard/create', 'messageboard', $_SESSION['user']->guid, $user->guid);
} else {
register_error(elgg_echo("messageboard:failure"));
}
} else {
echo elgg_echo('messageboard:somethingwentwrong');
}
//step two - grab the latest messageboard contents, this will include the message above, unless an issue
//has occurred.
$contents = $user->getAnnotations('messageboard', $numToDisplay, 0, 'desc');
//step three - display the latest results
if ($contents) {
foreach ($contents as $content) {
echo elgg_view("messageboard/messageboard_content", array('annotation' => $content));
}
}
示例7: array_unshift
array_unshift($container_guids, $context_container_guid);
}
// register_error("Container guids: " . print_r($container_guids, true) . ", raw: " . print_r($_REQUEST["group_selection"], true));
$file = null;
foreach ($container_guids as $container_guid) {
list($file, $guid) = create_file($container_guid, $title, $desc, $access_id, $original_guid, $tags, $new_file);
// make sure session cache is cleared
unset($_SESSION['uploadtitle']);
unset($_SESSION['uploaddesc']);
unset($_SESSION['uploadtags']);
unset($_SESSION['uploadaccessid']);
// handle results differently for new files and file updates
if ($new_file) {
if ($guid) {
system_message(elgg_echo("file:saved"));
add_to_river('river/object/file/create', 'create', get_loggedin_userid(), $file->guid);
} else {
// failed to save file object - nothing we can do about this
register_error(elgg_echo("file:uploadfailed") . "new");
}
} else {
if ($guid) {
system_message(elgg_echo("file:saved"));
} else {
register_error(elgg_echo("file:uploadfailed") . "existing");
}
}
}
// forward the user onward
if ($new_file) {
$container_user = get_entity($context_container_guid);
示例8: register_error
// Make sure the title / description aren't blank
if (empty($title)) {
register_error(elgg_echo('answers:question:blank'));
forward(REFERER);
}
// Otherwise, save the question
if ($guid) {
$question = get_entity($guid);
$new = false;
} else {
$question = new ElggObject();
$question->subtype = 'question';
$new = true;
}
$question->access_id = $access_id;
$question->title = $title;
$question->description = $description;
$question->tags = string_to_tag_array($tags);
$question->container_guid = $container_guid;
if ($question->save()) {
elgg_clear_sticky_form('question');
system_message(elgg_echo('answers:question:posted') . $sysmsg);
if ($new) {
// only add river item when this is a new question
add_to_river('river/object/question/create', 'create', $user_guid, $question->guid);
}
forward($question->getURL());
} else {
register_error(elgg_echo('answers:error'));
forward(REFERER);
}
示例9: register_error
$blog->description = $body;
// Now let's add tags. We can pass an array directly to the object property! Easy.
if (is_array($tagarray)) {
$blog->tags = $tagarray;
}
//whether the user wants to allow comments or not on the blog post
$blog->comments_on = $comments_on;
// Now save the object
if (!$blog->save()) {
register_error(elgg_echo("blog:error"));
forward($_SERVER['HTTP_REFERER']);
}
// Success message
system_message(elgg_echo("blog:posted"));
// add to river
add_to_river('river/object/blog/create', 'create', get_loggedin_userid(), $blog->guid);
// Remove the blog post cache
//unset($_SESSION['blogtitle']); unset($_SESSION['blogbody']); unset($_SESSION['blogtags']);
remove_metadata($_SESSION['user']->guid, 'blogtitle');
remove_metadata($_SESSION['user']->guid, 'blogbody');
remove_metadata($_SESSION['user']->guid, 'blogtags');
// Forward to the main blog page
$page_owner = get_entity($blog->container_guid);
if ($page_owner instanceof ElggUser) {
$username = $page_owner->username;
} else {
if ($page_owner instanceof ElggGroup) {
$username = "group:" . $page_owner->guid;
}
}
forward("pg/blog/{$username}");
示例10: register_error
$grouptopic->container_guid = $group_guid;
// For now, set its access to public (we'll add an access dropdown shortly)
$grouptopic->access_id = $access;
// Set its title and description appropriately
$grouptopic->title = $title;
// Before we can set metadata, we need to save the topic
if (!$grouptopic->save()) {
register_error(elgg_echo("grouptopic:error"));
forward("pg/groups/forum/{$group_guid}/");
}
// Now let's add tags. We can pass an array directly to the object property! Easy.
if (is_array($tagarray)) {
$grouptopic->tags = $tagarray;
}
// add metadata
$grouptopic->status = $status;
// the current status i.e sticky, closed, resolved, open
// now add the topic message as an annotation
$grouptopic->annotate('group_topic_post', $message, $access, $user);
// add to river
add_to_river('river/forum/topic/create', 'create', $_SESSION['user']->guid, $grouptopic->guid);
// Success message
system_message(elgg_echo("grouptopic:created"));
// Forward to the group forum page
global $CONFIG;
$url = $CONFIG->wwwroot . "pg/groups/forum/{$group_guid}/";
forward($url);
}
?>
示例11: gatekeeper
// Load configuration
global $CONFIG;
gatekeeper();
$user_guid = get_input('user_guid', get_loggedin_userid());
$group_guid = get_input('group_guid');
$user = get_entity($user_guid);
$group = get_entity($group_guid);
if ($user instanceof ElggUser && $group instanceof ElggGroup) {
if ($group->isPublicMembership()) {
if ($group->join($user)) {
system_message(elgg_echo("groups:joined"));
// Remove any invite or join request flags
remove_entity_relationship($group->guid, 'invited', $user->guid);
remove_entity_relationship($user->guid, 'membership_request', $group->guid);
// add to river
add_to_river('river/group/create', 'join', $user->guid, $group->guid);
forward($group->getURL());
exit;
} else {
register_error(elgg_echo("groups:cantjoin"));
}
} else {
// Closed group, request membership
system_message(elgg_echo('groups:privategroup'));
forward($CONFIG->url . "action/groups/joinrequest?user_guid={$user_guid}&group_guid={$group_guid}");
exit;
}
} else {
register_error(elgg_echo("groups:cantjoin"));
}
forward($_SERVER['HTTP_REFERER']);
示例12: get_entity
// Let's see if we can get an entity with the specified GUID
$entity = get_entity($entity_guid);
if (!$entity) {
register_error(elgg_echo("generic_comment:notfound"));
forward(REFERER);
}
$user = elgg_get_logged_in_user_entity();
$annotation = create_annotation($entity->guid, 'generic_comment', $comment_text, "", $user->guid, $entity->access_id);
// tell user annotation posted
if (!$annotation) {
register_error(elgg_echo("generic_comment:failure"));
forward(REFERER);
}
// Get who we need to notify
$to_notify = array($entity->owner_guid);
$annotations = elgg_get_annotations(array('annotation_name' => 'generic_comment', 'guid' => $entity->guid, 'limit' => 0, 'type' => 'object'));
foreach ($annotations as $a) {
$to_notify[] = $a->owner_guid;
}
$to_notify = array_unique($to_notify);
foreach ($to_notify as $to_guid) {
// notify if poster wasn't owner
if ($to_guid != $user->guid) {
notify_user($to_guid, $user->guid, elgg_echo('generic_comment:email:subject'), elgg_echo('generic_comment:email:body', array($entity->title, $user->name, $comment_text, $entity->getURL(), $user->name, $user->getURL())));
}
}
system_message(elgg_echo("generic_comment:posted"));
//add to river
add_to_river('river/annotation/generic_comment/create', 'comment', $user->guid, $entity->guid, "", 0, $annotation);
// Forward to the page the action occurred on
forward(REFERER);
示例13: forward
forward(REFERER);
}
if ($adding && !can_write_to_container(0, $container_guid, 'object', 'answer')) {
register_error(elgg_echo("questions:action:answer:save:error:container"));
forward(REFERER);
}
$question = get_entity($container_guid);
if (empty($question) || !elgg_instanceof($question, "object", "question")) {
register_error(elgg_echo("ClassException:ClassnameNotClass", array($container_guid, elgg_echo("item:object:question"))));
forward(REFERER);
}
if ($question->getStatus() != "open") {
elgg_clear_sticky_form('answer');
register_error(elgg_echo("questions:action:answer:save:error:question_closed"));
forward(REFERER);
}
$answer->description = $description;
$answer->access_id = $question->access_id;
$answer->container_guid = $container_guid;
try {
$answer->save();
if ($adding) {
update_entity_last_action($answer->container_guid, $answer->time_created);
add_to_river("river/object/answer/create", "create", elgg_get_logged_in_user_guid(), $answer->guid, $answer->access_id);
}
} catch (Exception $e) {
register_error(elgg_echo("questions:action:answer:save:error:save"));
register_error($e->getMessage());
}
elgg_clear_sticky_form('answer');
forward(get_input('forward', $answer->getURL()));
示例14: dirname
* @subpackage Form
* @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
* @author Kevin Jardine <kevin@radagast.biz>
* @copyright Radagast Solutions 2008
* @link http://radagast.biz/
*/
// Load flexprofile model
require_once dirname(dirname(__FILE__)) . "/models/model.php";
if ($user = page_owner()) {
$user = page_owner_entity();
} else {
$user = $_SESSION['user'];
set_page_owner($user->getGUID());
}
$query = "SELECT * FROM {$CONFIG->dbprefix}users_entity join {$CONFIG->dbprefix}_content_item_discrimination on {$CONFIG->dbprefix}users_entity.guid = {$CONFIG->dbprefix}_content_item_discrimination.guid and {$CONFIG->dbprefix}_content_item_discrimination.creator_guid = \"" . $_SESSION['id'] . "\"";
$result = get_data($query);
if ($user && $user->canEdit()) {
$data = form_get_profile_data_from_form_post();
form_set_data($user, $data);
// Notify of profile update
trigger_elgg_event('profileupdate', $user->type, $user);
//add to river
add_to_river('river/user/default/profileupdate', 'update', $user->guid, $user->guid);
system_message(elgg_echo("profile:saved"));
// Forward to the user's profile
forward($user->getUrl());
} else {
// If we can't, display an error
register_error(elgg_echo("profile:cantedit"));
forward();
}
示例15: thewire_tools_save_post
/**
* Save a wire post, overrules the default function because we need to support groups
*
* @param string $text the text of the post
* @param int $userid the owner of the post
* @param int $access_id the access level of the post
* @param int $parent_guid is this a reply on another post
* @param string $method which method was used
*
* @return bool|int the GUID of the new wire post or false
*/
function thewire_tools_save_post($text, $userid, $access_id, $parent_guid = 0, $method = "site")
{
// set correct container
$container_guid = $userid;
// check the access id
if ($access_id == ACCESS_PRIVATE) {
// private wire posts aren"t allowed
$access_id = ACCESS_LOGGED_IN;
} elseif (thewire_tools_groups_enabled()) {
// allow the saving of a wire post in a group (if enabled)
if (!in_array($access_id, array(ACCESS_FRIENDS, ACCESS_LOGGED_IN, ACCESS_PUBLIC))) {
// try to find a group with access_id
$group_options = array("type" => "group", "limit" => 1, "metadata_name_value_pairs" => array("group_acl" => $access_id));
$groups = elgg_get_entities_from_metadata($group_options);
if (!empty($groups)) {
$group = $groups[0];
if ($group->thewire_enable == "no") {
// not allowed to post in this group
register_error(elgg_echo("thewire_tools:groups:error:not_enabled"));
// let creation of object fail
return false;
} else {
$container_guid = $group->getGUID();
}
}
}
}
// create the new post
$post = new ElggObject();
$post->subtype = "thewire";
$post->owner_guid = $userid;
$post->container_guid = $container_guid;
$post->access_id = $access_id;
// only xxx characters allowed (see plugin setting)
$text = elgg_substr($text, 0, thewire_tools_get_wire_length());
// no html tags allowed so we escape
$post->description = htmlspecialchars($text, ENT_NOQUOTES, "UTF-8");
$post->method = $method;
//method: site, email, api, ...
$tags = thewire_get_hashtags($text);
if (!empty($tags)) {
$post->tags = $tags;
}
// must do this before saving so notifications pick up that this is a reply
if ($parent_guid) {
$post->reply = true;
}
$guid = $post->save();
// set thread guid
if ($parent_guid) {
$post->addRelationship($parent_guid, "parent");
// name conversation threads by guid of first post (works even if first post deleted)
$parent_post = get_entity($parent_guid);
$post->wire_thread = $parent_post->wire_thread;
} else {
// first post in this thread
$post->wire_thread = $guid;
}
if ($guid) {
add_to_river("river/object/thewire/create", "create", $post->getOwnerGUID(), $post->getGUID());
// let other plugins know we are setting a user status
$params = array("entity" => $post, "user" => $post->getOwnerEntity(), "message" => $post->description, "url" => $post->getURL(), "origin" => "thewire");
elgg_trigger_plugin_hook("status", "user", $params);
}
return $guid;
}