From 02a52af62e1579ad174b1160071b82ec11ee31e3 Mon Sep 17 00:00:00 2001 From: brettp Date: Sat, 19 Feb 2011 19:31:34 +0000 Subject: Refs #2916. More cleanup of the messageboard widget. git-svn-id: http://code.elgg.org/elgg/trunk@8344 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/messageboard/start.php | 79 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 59 insertions(+), 20 deletions(-) (limited to 'mod/messageboard/start.php') 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 @@ + * Y's history of posts on X's board: pg/messageboard/owner//history/ + * New post: pg/messageboard/add/ (container: user or group) + * Group messageboard: pg/messageboard/group//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 -- cgit v1.2.3