/** * 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; }
/** * 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"); }
/** * 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; }
$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();
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); }
//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)); } }
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);
// 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); }
$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 = "******" . $page_owner->guid; } } forward("pg/blog/{$username}");
$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); } ?>
// 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']);
// 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);
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()));
* @subpackage Form * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Kevin Jardine <*****@*****.**> * @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(); }
/** * 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; }
/** * Join a user to a group, add river event, clean-up invitations * * @param ElggGroup $group * @param ElggUser $user * @return bool */ function groups_join_group($group, $user) { global $NOTIFICATION_HANDLERS; // access ignore so user can be added to access collection of invisible group $ia = elgg_set_ignore_access(TRUE); $result = $group->join($user); elgg_set_ignore_access($ia); if ($result) { // flush user's access info so the collection is added get_access_list($user->guid, 0, true); // Remove any invite or join request flags remove_entity_relationship($group->guid, 'invited', $user->guid); remove_entity_relationship($user->guid, 'membership_request', $group->guid); //check if notifications are turned off for the group if ($group->notifications == "false") { //turn users notifications off foreach ($NOTIFICATION_HANDLERS as $method => $dummy) { error_log("group" . $method); remove_entity_relationship($user->getGUID(), "notify" . $method, $group->getGUID()); } } add_to_river('river/relationship/member/create', 'join', $user->guid, $group->guid); return true; } return false; }
exit; } else { register_error(elgg_echo("poll:novote")); forward($poll->getUrl()); } // Otherwise, save the poll vote } else { $user_guid = elgg_get_logged_in_user_guid(); // check to see if this user has already voted $options = array('annotation_name' => 'vote', 'annotation_owner_guid' => $user_guid, 'guid' => $guid); if (!elgg_get_annotations($options)) { //add vote as an annotation $poll->annotate('vote', $response, $poll->access_id); // Add to river $poll_vote_in_river = elgg_get_plugin_setting('vote_in_river', 'poll'); if ($poll_vote_in_river != 'no') { add_to_river('river/object/poll/vote', 'vote', $user_guid, $poll->guid); } if (get_input('callback')) { $response = elgg_view('poll/poll_widget_content', array('entity' => $poll)); echo json_encode(array('success' => true, 'result' => $response)); exit; } else { // Success message system_message(elgg_echo("poll:responded")); // Forward to the poll page forward($poll->getUrl()); } } } }
} } // go through custom fields if (sizeof($input) > 0) { foreach ($input as $shortname => $value) { remove_metadata($profile_owner->guid, $shortname); if (isset($accesslevel[$shortname])) { $access_id = (int) $accesslevel[$shortname]; } else { // this should never be executed since the access level should always be set $access_id = ACCESS_DEFAULT; } if (is_array($value)) { $i = 0; foreach ($value as $interval) { $i++; $multiple = $i > 1 ? TRUE : FALSE; create_metadata($profile_owner->guid, $shortname, $interval, 'text', $profile_owner->guid, $access_id, $multiple); } } else { create_metadata($profile_owner->getGUID(), $shortname, $value, 'text', $profile_owner->getGUID(), $access_id); } } $profile_owner->save(); // Notify of profile update trigger_elgg_event('profileupdate', $user->type, $user); //add to river add_to_river('river/user/default/profileupdate', 'update', $_SESSION['user']->guid, $_SESSION['user']->guid, get_default_access($_SESSION['user'])); system_message(elgg_echo("profile:saved")); } forward($profile_owner->getUrl());
$content = get_input('sitepages_content', '', FALSE); $page_type = get_input('page_type'); $tags = get_input('sitepages_tags'); $tag_array = string_to_tag_array($tags); // Cache to the session for sticky forms // @todo make these work. $_SESSION['sitepages_content'] = $content; $_SESSION['sitepages_type'] = $type; $_SESSION['sitepages_tags'] = $tags; if (!($sitepage = sitepages_get_sitepage_object($page_type))) { $sitepage = sitepages_create_sitepage_object($page_type); } if (empty($content)) { register_error(elgg_echo('sitepages:blank')); } else { $sitepage->title = $type; $sitepage->description = $content; $sitepage->tags = $tag_array; if (!$sitepage->save()) { register_error(elgg_echo('sitepages:error')); } else { system_message(elgg_echo('sitepages:posted')); // @todo this needs to be accurate for create or update. add_to_river('river/sitepages/create', 'create', $_SESSION['user']->guid, $sitepages->guid); } // @todo Good intensions... unset($_SESSION['sitepages_content']); unset($_SESSION['sitepagestitle']); unset($_SESSION['sitepagestags']); } forward($_SERVER['HTTP_REFERER']);
// remove sticky form entries elgg_clear_sticky_form('blog'); // remove autosave draft if exists $blog->deleteAnnotations('blog_auto_save'); // no longer a brand new post. $blog->deleteMetadata('new_post'); // if this was an edit, create a revision annotation if (!$new_post && $revision_text) { $blog->annotate('blog_revision', $revision_text); } system_message(elgg_echo('blog:message:saved')); $status = $blog->status; // add to river if changing status or published, regardless of new post // because we remove it for drafts. if (($new_post || $old_status == 'draft') && $status == 'published') { add_to_river('river/object/blog/create', 'create', $blog->owner_guid, $blog->getGUID()); // we only want notifications sent when post published register_notification_object('object', 'blog', elgg_echo('blog:newpost')); elgg_trigger_event('publish', 'object', $blog); // reset the creation time for posts that move from draft to published if ($guid) { $blog->time_created = time(); $blog->save(); } } elseif ($old_status == 'published' && $status == 'draft') { elgg_delete_river(array('object_guid' => $blog->guid, 'action_type' => 'create')); } //Khang Added forward(REFERER); if ($blog->status == 'published' || $save == false) { forward($blog->getURL());
/** * Web service post a reply * * @param string $username username * @param string $postid GUID of post * @param string $text text of reply * * @return bool */ function group_forum_save_reply($postid, $text, $username) { $topic = get_entity($postid); if (!$topic) { $msg = elgg_echo('grouppost:nopost'); throw new InvalidParameterException($msg); } if (!$username) { $user = get_loggedin_user(); } else { $user = get_user_by_username($username); if (!$user) { throw new InvalidParameterException('registration:usernamenotvalid'); } } $group = $topic->getContainerEntity(); if (!$group->canWriteToContainer($user)) { $msg = elgg_echo('groups:notmember'); throw new InvalidParameterException($msg); } $reply = $topic->annotate('group_topic_post', $text, $topic->access_id, $user->guid); if ($reply) { add_to_river('river/annotation/group_topic_post/reply', 'reply', $user->guid, $topic->guid, "", 0, $reply_id); } else { $msg = elgg_echo('grouppost:failure'); throw new InvalidParameterException($msg); } $return['success'] = true; return $return; }
* */ gatekeeper(); // Get input $entity_guid = (int) get_input('entity_guid'); $text = get_input('group_topic_post'); // reply cannot be empty if (empty($text)) { register_error(elgg_echo('grouppost:nopost')); forward(REFERER); } $topic = get_entity($entity_guid); if (!$topic) { register_error(elgg_echo('grouppost:nopost')); forward(REFERER); } $user = get_loggedin_user(); $group = $topic->getContainerEntity(); if (!$group->canWriteToContainer($user)) { register_error(elgg_echo('groups:notmember')); forward(REFERER); } // add the reply to the forum topic $reply_id = $topic->annotate('group_topic_post', $text, $topic->access_id, $user->guid); if ($reply_id == false) { system_message(elgg_echo('groupspost:failure')); forward(REFERER); } add_to_river('river/annotation/group_topic_post/reply', 'reply', $user->guid, $topic->guid, "", 0, $reply_id); system_message(elgg_echo('groupspost:success')); forward(REFERER);
if ($visibility != ACCESS_PUBLIC && $visibility != ACCESS_LOGGED_IN) { $visibility = $group->group_acl; } if ($group->access_id != $visibility) { $group->access_id = $visibility; } } $group->save(); // group saved so clear sticky form elgg_clear_sticky_form('groups'); // group creator needs to be member of new group and river entry created if ($is_new_group) { // @todo this should not be necessary... elgg_set_page_owner_guid($group->guid); $group->join($user); add_to_river('river/group/create', 'create', $user->guid, $group->guid, $group->access_id); } $has_uploaded_icon = !empty($_FILES['icon']['type']) && substr_count($_FILES['icon']['type'], 'image/'); if ($has_uploaded_icon) { $icon_sizes = elgg_get_config('icon_sizes'); $prefix = "groups/" . $group->guid; $filehandler = new ElggFile(); $filehandler->owner_guid = $group->owner_guid; $filehandler->setFilename($prefix . ".jpg"); $filehandler->open("write"); $filehandler->write(get_uploaded_file('icon')); $filehandler->close(); $filename = $filehandler->getFilenameOnFilestore(); $sizes = array('tiny', 'small', 'medium', 'large'); $thumbs = array(); foreach ($sizes as $size) {
// attachment if (get_input('timeline-attachment')) { if (create_metadata($timelinestyle_object->guid, 'timeline-attachment', get_input('timeline-attachment'), 'string', $_SESSION['guid'], $access_id) == false) { $error = true; } } // position if (get_input('timeline-position')) { if (create_metadata($timelinestyle_object->guid, 'timeline-position', get_input('timeline-position'), 'string', $_SESSION['guid'], $access_id) == false) { $error = true; } } // check for error if (!$error) { if (elgg_get_plugin_setting("showInRiver", "timeline_theme") != "no") { add_to_river('river/object/timelinestyle/update', 'update', $current_user, $current_user); // TM: update to current elgg 1.8 /* // $entity_guid = (int) get_input('entity_guid'); // add to river elgg_create_river_item(array( 'view' => 'river/object/timelinestyle/update', 'action_type' => 'create', 'subject_guid' => $user->guid, // 'object_guid' => $timelinestyle_object, // 'target_guid' => $entity_guid, )); */ } system_message(elgg_echo('timelinestyle:timeline:save:success'));
if (sizeof($input) > 0) { foreach ($input as $name => $value) { $markdown_wiki->{$name} = $value; } } if ($markdown_wiki->save()) { elgg_clear_sticky_form('markdown_wiki'); elgg_load_library('markdown_wiki:fineDiff'); // set diff $compare = new FineDiff($old_description, $markdown_wiki->description, array(FineDiff::wordDelimiters)); $compared['word'] = calc_diff_markdown_wiki($compare->renderDiffToHTML()); $compare = new FineDiff($old_description, $markdown_wiki->description, array(FineDiff::sentenceDelimiters)); $compared['sentence'] = calc_diff_markdown_wiki($compare->renderDiffToHTML()); $compare = new FineDiff($old_description, $markdown_wiki->description, array(FineDiff::paragraphDelimiters)); $compared['paragraph'] = calc_diff_markdown_wiki($compare->renderDiffToHTML()); $array_change = array('text' => $markdown_wiki->description, 'diff' => $compared, 'summary' => get_input('summary')); // Now save description as an annotation $annotation_id = create_annotation($markdown_wiki->guid, 'markdown_wiki', serialize($array_change), '', 0, $markdown_wiki->access_id); system_message(elgg_echo('markdown_wiki:saved')); if ($new_markdown_wiki) { add_to_river('river/object/markdown_wiki/create', 'create', $user_guid, $markdown_wiki->guid); } else { if (!get_input('minorchange', false)) { add_to_river('river/object/markdown_wiki/update', 'update', $user_guid, $markdown_wiki->guid, '', 0, $annotation_id); } } forward($markdown_wiki->getURL()); } else { register_error(elgg_echo('markdown_wiki:error:no_save')); forward(REFERER); }
$release->access_id = $release_access_id; $release->container_guid = $plugin_project->getGUID(); $release->version = $version; $release->release_notes = $release_notes; $release->elgg_version = $elgg_version; $release->comments = $comments; $release->save(); if ($release->savePluginFile('upload') != TRUE) { register_error(elgg_echo("plugins:error:uploadfailed")); forward(REFERER); } if (!$plugin_project->getGUID() || !$release->getGUID()) { register_error(elgg_echo("plugins:error:uploadfailed")); forward(REFERER); } if ($recommended == 'yes') { $plugin_project->recommended_release_guid = $release->getGUID(); } // check for any project images and associate them with the project $max_num_images = 4; for ($i = 1; $i <= $max_num_images; $i++) { if (!array_key_exists("image_{$i}", $_FILES)) { continue; } $desc = get_input("image_{$i}_desc"); $plugin_project->saveImage("image_{$i}", $desc, $i); } add_to_river('river/object/plugin_project/create', 'create', $user->getGUID(), $plugin_project->getGUID()); plugins_send_notifications($plugin_project); system_message(elgg_echo("plugins:project:saved")); forward($plugin_project->getURL());
$topic->subtype = 'groupforumtopic'; } else { // load original file object $topic = new ElggObject($guid); if (!$topic || !$topic->canEdit()) { register_error(elgg_echo('discussion:topic:notfound')); forward(REFERER); } } $topic->title = $title; $topic->description = $desc; $topic->status = $status; $topic->access_id = $access_id; $topic->container_guid = $container_guid; $tags = explode(",", $tags); $topic->tags = $tags; $result = $topic->save(); if (!$result) { register_error(elgg_echo('discussion:error:notsaved')); forward(REFERER); } // topic saved so clear sticky form elgg_clear_sticky_form('topic'); // handle results differently for new topics and topic edits if ($new_topic) { system_message(elgg_echo('discussion:topic:created')); add_to_river('river/object/groupforumtopic/create', 'create', elgg_get_logged_in_user_guid(), $topic->guid); } else { system_message(elgg_echo('discussion:topic:updated')); } forward($topic->getURL());
* * @package Elgg * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 * @author Curverider <curverider.co.uk> * @copyright Curverider Ltd 2008-2009 * @link http://elgg.org/ */ // Make sure we're logged in; forward to the front page if not gatekeeper(); action_gatekeeper(); // Get input $entity_guid = (int) get_input('entity_guid'); $comment_text = get_input('generic_comment'); // Let's see if we can get an entity with the specified GUID if ($entity = get_entity($entity_guid)) { // If posting the comment was successful, say so if ($entity->annotate('generic_comment', $comment_text, $entity->access_id, $_SESSION['guid'])) { if ($entity->owner_guid != $_SESSION['user']->getGUID()) { notify_user($entity->owner_guid, $_SESSION['user']->getGUID(), elgg_echo('generic_comment:email:subject'), sprintf(elgg_echo('generic_comment:email:body'), $entity->title, $_SESSION['user']->name, $comment_text, $entity->getURL(), $_SESSION['user']->name, $_SESSION['user']->getURL())); } system_message(elgg_echo("generic_comment:posted")); //add to river add_to_river('annotation/annotate', 'comment', $_SESSION['user']->guid, $entity->guid); } else { register_error(elgg_echo("generic_comment:failure")); } } else { register_error(elgg_echo("generic_comment:notfound")); } // Forward to the forward($entity->getURL());
/** * Join a user to a group, add river event, clean-up invitations * * @param ElggGroup $group * @param ElggUser $user * @return bool */ function groups_join_group($group, $user) { // access ignore so user can be added to access collection of invisible group $ia = elgg_set_ignore_access(TRUE); $result = $group->join($user); elgg_set_ignore_access($ia); if ($result) { // flush user's access info so the collection is added get_access_list($user->guid, 0, true); // 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('river/relationship/member/create', 'join', $user->guid, $group->guid); return true; } return false; }
if ($entity->canEdit()) { $canedit = true; } } if (!$canedit) { system_message(elgg_echo('notfound')); forward("pg/bookmarks"); } } $entity->title = $title; $entity->address = $address; $entity->description = $description; $entity->access_id = $access; $entity->tags = $tagarray; if ($entity->save()) { $entity->clearRelationships(); $entity->shares = $shares; if (is_array($shares) && sizeof($shares) > 0) { foreach ($shares as $share) { $share = (int) $share; add_entity_relationship($entity->getGUID(), 'share', $share); } } system_message(elgg_echo('bookmarks:save:success')); //add to river add_to_river('river/object/bookmarks/create', 'create', $_SESSION['user']->guid, $entity->guid); forward($entity->getURL()); } else { register_error(elgg_echo('bookmarks:save:failed')); forward("pg/bookmarks"); }