aboutsummaryrefslogtreecommitdiff
path: root/mod/messageboard/start.php
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/start.php
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/start.php')
-rw-r--r--mod/messageboard/start.php164
1 files changed, 95 insertions, 69 deletions
diff --git a/mod/messageboard/start.php b/mod/messageboard/start.php
index 0d9033a82..0ddb58169 100644
--- a/mod/messageboard/start.php
+++ b/mod/messageboard/start.php
@@ -1,71 +1,97 @@
<?php
- /**
- * Elgg Message board
- * This plugin allows users and groups to attach a message board to their profile for other users
- * to post comments and media.
- *
- * @todo allow users to attach media such as photos and videos as well as other resources such as bookmarked content
- *
- * @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
- * @link http://elgg.com/
- */
-
- /**
- * MessageBoard initialisation
- *
- * These parameters are required for the event API, but we won't use them:
- *
- * @param unknown_type $event
- * @param unknown_type $object_type
- * @param unknown_type $object
- */
-
- function messageboard_init() {
-
- // Load system configuration
- global $CONFIG;
-
- // Extend system CSS with our own styles, which are defined in the messageboard/css view
- elgg_extend_view('css','messageboard/css');
-
- // Register a page handler, so we can have nice URLs
- register_page_handler('messageboard','messageboard_page_handler');
-
- // add a messageboard widget
- add_widget_type('messageboard',"". elgg_echo("messageboard:board") . "","" . elgg_echo("messageboard:desc") . ".", "profile");
-
-
- }
-
- /**
- * Messageboard page handler
- *
- * @param array $page Array of page elements, forwarded by the page handling mechanism
- */
- function messageboard_page_handler($page) {
-
- global $CONFIG;
-
- // The username should be the file we're getting
- if (isset($page[0])) {
- set_input('username',$page[0]);
- }
- // Include the standard messageboard index
- include($CONFIG->pluginspath . "messageboard/index.php");
-
- }
-
-
- // Make sure the shouts initialisation function is called on initialisation
- register_elgg_event_handler('init','system','messageboard_init');
-
- // Register actions
- global $CONFIG;
- register_action("messageboard/add",false,$CONFIG->pluginspath . "messageboard/actions/add.php");
- register_action("messageboard/delete",false,$CONFIG->pluginspath . "messageboard/actions/delete.php");
-
-?> \ No newline at end of file
+/**
+ * Elgg Message board
+ * This plugin allows users and groups to attach a message board to their profile for other users
+ * to post comments.
+ *
+ * @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
+ * @link http://elgg.com/
+ */
+
+/**
+ * MessageBoard initialisation
+ */
+function messageboard_init() {
+
+ // Extend system CSS with our own styles, which are defined in the messageboard/css view
+ elgg_extend_view('css', 'messageboard/css');
+
+ // Register a page handler, so we can have nice URLs
+ register_page_handler('messageboard', 'messageboard_page_handler');
+
+ // add a messageboard widget - only for profile
+ add_widget_type('messageboard', elgg_echo("messageboard:board"), elgg_echo("messageboard:desc"), "profile");
+}
+
+/**
+ * Messageboard page handler
+ *
+ * @param array $page Array of page elements, forwarded by the page handling mechanism
+ */
+function messageboard_page_handler($page) {
+
+ global $CONFIG;
+
+ // The username should be the first array entry
+ if (isset($page[0])) {
+ set_input('username', $page[0]);
+ }
+
+ // Include the standard messageboard index
+ include($CONFIG->pluginspath . "messageboard/index.php");
+}
+
+/**
+ * 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) {
+ global $CONFIG;
+
+ $result = $owner->annotate('messageboard', $message, $access_id, $poster->guid);
+ if (!$result) {
+ return FALSE;
+ }
+
+ add_to_river('river/object/messageboard/create',
+ 'messageboard',
+ $poster->guid,
+ $owner->guid,
+ $access_id,
+ 0,
+ $result);
+
+ // only send notification if not self
+ if ($poster->guid != $owner->guid) {
+ $subject = elgg_echo('messageboard:email:subject');
+ $body = sprintf(
+ elgg_echo('messageboard:email:body'),
+ $poster->name,
+ $message,
+ $CONFIG->wwwroot . "pg/messageboard/" . $owner->username,
+ $poster->name,
+ $poster->getURL()
+ );
+
+ notify_user($owner->guid, $poster->guid, $subject, $body);
+ }
+
+ return TRUE;
+}
+
+
+// Register initialisation callback
+register_elgg_event_handler('init', 'system', 'messageboard_init');
+
+// Register actions
+register_action("messageboard/add", FALSE, $CONFIG->pluginspath . "messageboard/actions/add.php");
+register_action("messageboard/delete", FALSE, $CONFIG->pluginspath . "messageboard/actions/delete.php");