aboutsummaryrefslogtreecommitdiff
path: root/mod/messageboard/start.php
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-19 19:31:34 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-19 19:31:34 +0000
commit02a52af62e1579ad174b1160071b82ec11ee31e3 (patch)
treecd14f5338df64b69dffb03499ce7222f93c9f988 /mod/messageboard/start.php
parent93cf8041ef996eae3912116cee572f7ff26efc92 (diff)
downloadelgg-02a52af62e1579ad174b1160071b82ec11ee31e3.tar.gz
elgg-02a52af62e1579ad174b1160071b82ec11ee31e3.tar.bz2
Refs #2916. More cleanup of the messageboard widget.
git-svn-id: http://code.elgg.org/elgg/trunk@8344 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'mod/messageboard/start.php')
-rw-r--r--mod/messageboard/start.php79
1 files changed, 59 insertions, 20 deletions
diff --git a/mod/messageboard/start.php b/mod/messageboard/start.php
index a4792d322..ecf5615b5 100644
--- a/mod/messageboard/start.php
+++ b/mod/messageboard/start.php
@@ -1,48 +1,89 @@
<?php
-
/**
* 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
+ * @package MessageBoard
*/
/**
* MessageBoard initialisation
*/
function messageboard_init() {
-
- // add css and js
- elgg_extend_view('css/screen', 'messageboard/css');
+ // js
elgg_extend_view('js/elgg', 'messageboard/js');
- // Register a page handler, so we can have nice URLs
elgg_register_page_handler('messageboard', 'messageboard_page_handler');
- // add a messageboard widget - only for profile
+ // messageboard widget - only for profile for now
elgg_register_widget_type('messageboard', elgg_echo("messageboard:board"), elgg_echo("messageboard:desc"), "profile");
- // Register actions
- $action_path = elgg_get_plugins_path() . 'messageboard/actions';
+ // actions
+ $action_path = dirname(__FILE__) . '/actions';
elgg_register_action("messageboard/add", "$action_path/add.php");
elgg_register_action("messageboard/delete", "$action_path/delete.php");
}
/**
- * Messageboard page handler
+ * Messageboard dispatcher for flat message board.
+ * Profile (and eventually group) widgets handle their own.
+ *
+ * URLs take the form of
+ * User's messageboard: pg/messageboard/owner/<username>
+ * Y's history of posts on X's board: pg/messageboard/owner/<X>/history/<Y>
+ * New post: pg/messageboard/add/<guid> (container: user or group)
+ * Group messageboard: pg/messageboard/group/<guid>/owner
*
- * @param array $page Array of page elements, forwarded by the page handling mechanism
+ * @param array $page Array of page elements
+ * @return bool
*/
function messageboard_page_handler($page) {
+ $new_section_one = array('owner', 'add', 'group');
+
+ // if the first part is a username, forward to new format
+ if (isset($page[0]) && !in_array($page[0], $new_section_one) && get_user_by_username($page[0])) {
+ register_error(elgg_echo("changebookmark"));
+ $url = "pg/messageboard/owner/{$page[0]}";
+ forward($url);
+ }
- // The username should be the first array entry
- if (isset($page[0])) {
- set_input('username', $page[0]);
+ $pages = dirname(__FILE__) . '/pages';
+
+ switch ($page[0]) {
+ case 'owner':
+ //@todo if they have the widget disabled, don't allow this.
+ $owner_name = elgg_extract(1, $page);
+ $owner = get_user_by_username($owner_name);
+ set_input('page_owner_guid', $owner->guid);
+ $history = elgg_extract(2, $page);
+ $username = elgg_extract(3, $page);
+
+ if ($history && $username) {
+ set_input('history_username', $username);
+ }
+
+ include "$pages/owner.php";
+ break;
+
+ case 'add':
+ $container_guid = elgg_extract(1, $page);
+ set_input('container_guid', $container_guid);
+ include "$pages/add.php";
+ break;
+
+ case 'group':
+ group_gatekeeper();
+ $owner_guid = elgg_extract(1, $page);
+ set_input('page_owner_guid', $owner_guid);
+ include "$pages/owner.php";
+ break;
}
// Include the standard messageboard index
include(elgg_get_plugins_path() . "messageboard/index.php");
+
+ return true;
}
/**
@@ -55,10 +96,10 @@ function messageboard_page_handler($page) {
* @return bool
*/
function messageboard_add($poster, $owner, $message, $access_id = ACCESS_PUBLIC) {
-
$result = $owner->annotate('messageboard', $message, $access_id, $poster->guid);
+
if (!$result) {
- return FALSE;
+ return false;
}
add_to_river('river/object/messageboard/create',
@@ -83,9 +124,7 @@ function messageboard_add($poster, $owner, $message, $access_id = ACCESS_PUBLIC)
notify_user($owner->guid, $poster->guid, $subject, $body);
}
- return TRUE;
+ return $result;
}
-
-// Register initialisation callback
-elgg_register_event_handler('init', 'system', 'messageboard_init');
+elgg_register_event_handler('init', 'system', 'messageboard_init'); \ No newline at end of file