aboutsummaryrefslogtreecommitdiff
path: root/mod/messageboard/ajax_endpoint
diff options
context:
space:
mode:
authorcash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-05-12 23:31:00 +0000
committercash <cash@36083f99-b078-4883-b0ff-0f9b5a30f544>2010-05-12 23:31:00 +0000
commit4ae064871ba9dca9f03e095671db48815632d070 (patch)
treeccccacdac0f608e2d262d1d3a8916408c033f132 /mod/messageboard/ajax_endpoint
parent8618288ed51942c814f45c67354b14eec43c2422 (diff)
downloadelgg-4ae064871ba9dca9f03e095671db48815632d070.tar.gz
elgg-4ae064871ba9dca9f03e095671db48815632d070.tar.bz2
merging messageboard cleanup from 1.7 branch [5908],[5909],[5917]
git-svn-id: http://code.elgg.org/elgg/trunk@6019 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/messageboard/ajax_endpoint')
-rw-r--r--mod/messageboard/ajax_endpoint/load.php111
1 files changed, 42 insertions, 69 deletions
diff --git a/mod/messageboard/ajax_endpoint/load.php b/mod/messageboard/ajax_endpoint/load.php
index 5bba34681..28f6766ff 100644
--- a/mod/messageboard/ajax_endpoint/load.php
+++ b/mod/messageboard/ajax_endpoint/load.php
@@ -1,73 +1,46 @@
<?php
- /**
- * Elgg message board widget ajax logic page
- *
- * @package ElggMessageBoard
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
- * @author Curverider Ltd <info@elgg.com>
- * @copyright Curverider Ltd 2008-2010 - 2009
- * @link http://elgg.com/
- */
+/**
+ * Elgg message board widget ajax logic page
+ *
+ * @package ElggMessageBoard
+ * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
+ * @author Curverider Ltd <info@elgg.com>
+ * @copyright Curverider Ltd 2008-2010 - 2009
+ * @link http://elgg.com/
+ */
- // Load Elgg engine will not include plugins
- require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php");
-
- //get the required info
-
- //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));
-
- }
-
- }
+// Load Elgg engine will not include plugins
+require_once(dirname(dirname(dirname(dirname(__FILE__)))) . "/engine/start.php");
-
-?> \ No newline at end of file
+//get the required info
+
+//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(get_input('pageOwner'));
+
+//stage one - if a message was posted, add it as an annotation
+if ($message) {
+
+ if (!messageboard_add(get_loggedin_user(), $user, $message, $user->access_id)) {
+ echo 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));
+ }
+}