diff options
Diffstat (limited to 'mod/messageboard')
21 files changed, 483 insertions, 860 deletions
diff --git a/mod/messageboard/actions/add.php b/mod/messageboard/actions/add.php index 98ffe4b47..971dd22fc 100644 --- a/mod/messageboard/actions/add.php +++ b/mod/messageboard/actions/add.php @@ -1,68 +1,38 @@ <?php +/** + * Elgg Message board: add message action + * + * @package ElggMessageBoard + */ - /** - * Elgg Message board: add message action - * - * @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.org/ - */ +$message_content = get_input('message_content'); +$owner_guid = get_input("owner_guid"); +$owner = get_entity($owner_guid); - // Make sure we're logged in; forward to the front page if not - if (!isloggedin()) forward(); - - // Get input - $message_content = get_input('message_content'); // the actual message - $page_owner = get_input("pageOwner"); // the message board owner - $message_owner = get_input("guid"); // the user posting the message - $user = get_entity($page_owner); // the message board owner's details - - // Let's see if we can get a user entity from the specified page_owner - if ($user && !empty($message_content)) { - - // If posting the comment was successful, say so - if ($user->annotate('messageboard',$message_content,$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_content, - $CONFIG->wwwroot . "pg/messageboard/" . $user->username, - $_SESSION['user']->name, - $_SESSION['user']->getURL() - ) - ); - - system_message(elgg_echo("messageboard:posted")); - // add to river - add_to_river('river/object/messageboard/create','messageboard',$_SESSION['user']->guid,$user->guid); +if ($owner && !empty($message_content)) { + $result = messageboard_add(elgg_get_logged_in_user_entity(), $owner, $message_content, $owner->access_id); - - } else { - - register_error(elgg_echo("messageboard:failure")); - - } - - //set the url to return the user to the correct message board - $url = "pg/messageboard/" . $user->username; - - } else { - - register_error(elgg_echo("messageboard:blank")); - - //set the url to return the user to the correct message board - $url = "pg/messageboard/" . $user->username; - - } - - // Forward back to the messageboard - forward($url); + if ($result) { + system_message(elgg_echo("messageboard:posted")); -?>
\ No newline at end of file + $options = array( + 'annotations_name' => 'messageboard', + 'guid' => $owner->getGUID(), + 'limit' => $num_display, + 'pagination' => false, + 'reverse_order_by' => true, + 'limit' => 1 + ); + + $output = elgg_list_annotations($options); + echo $output; + + } else { + register_error(elgg_echo("messageboard:failure")); + } + +} else { + register_error(elgg_echo("messageboard:blank")); +} + +forward(REFERER); diff --git a/mod/messageboard/actions/delete.php b/mod/messageboard/actions/delete.php index 9c17f1fcd..a1f62278c 100644 --- a/mod/messageboard/actions/delete.php +++ b/mod/messageboard/actions/delete.php @@ -1,44 +1,17 @@ <?php +/** + * Elgg Message board: delete message action + * + * @package ElggMessageBoard + */ - /** - * Elgg Message board: delete message action - * - * @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.org/ - */ +$annotation_id = (int) get_input('annotation_id'); +$message = elgg_get_annotation_from_id($annotation_id); - // Ensure we're logged in - if (!isloggedin()) forward(); - - // Make sure we can get the comment in question - $annotation_id = (int) get_input('annotation_id'); - - //make sure that there is a message on the message board matching the passed id - if ($message = get_annotation($annotation_id)) { - - //grab the user or group entity - $entity = get_entity($message->entity_guid); - - //check to make sure the current user can actually edit the message board - if ($message->canEdit()) { - //delete the comment - $message->delete(); - //display message - system_message(elgg_echo("messageboard:deleted")); - //generate the url to forward to - $url = "pg/messageboard/" . $entity->username; - //forward the user back to their message board - forward($url); - } - - } else { - $url = ""; - system_message(elgg_echo("messageboard:notdeleted")); - } - - forward($url); +if ($message && $message->canEdit() && $message->delete()) { + system_message(elgg_echo("messageboard:deleted")); +} else { + system_message(elgg_echo("messageboard:notdeleted")); +} -?>
\ No newline at end of file +forward(REFERER); diff --git a/mod/messageboard/ajax_endpoint/load.php b/mod/messageboard/ajax_endpoint/load.php deleted file mode 100644 index 5bba34681..000000000 --- a/mod/messageboard/ajax_endpoint/load.php +++ /dev/null @@ -1,73 +0,0 @@ -<?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/ - */ - - // 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)); - - } - - } - - -?>
\ No newline at end of file diff --git a/mod/messageboard/history.php b/mod/messageboard/history.php deleted file mode 100644 index 1f7ecd0e4..000000000 --- a/mod/messageboard/history.php +++ /dev/null @@ -1,43 +0,0 @@ -<?php - - /** - * Elgg Message board history 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 - * @link http://elgg.com/ - */ - - - // Load Elgg engine - require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - - // Get the user who is the owner of the message board - $current_user = $_SESSION['user']->getGUID(); //history is only available for your own wall - $history_user = get_input('user'); // this is the user how has posted on your messageboard that you want to display your history with - - - // Get any annotations for their message board - // $contents = $entity->getAnnotations('messageboard', 50, 0, 'desc'); - - $users_array = array($current_user, $history_user); - - $contents = get_annotations($users_array, "user", "", "messageboard", $value = "", $users_array, $limit = 10, $offset = 0, $order_by = "desc"); - - // Get the content to display - $area2 = elgg_view_title(elgg_echo('messageboard:history:title')); - $area2 .= elgg_view("messageboard/messageboard", array('annotation' => $contents)); - - //$area1 = "<h2>Profile owner: " . $current_user . "</h2>"; - //$area1 .= "<h2>User guid: " . $history_user . "</h2>"; - - - //select the correct canvas area - $body = elgg_view_layout("two_column_left_sidebar", '', $area2); - - // Display page - page_draw(elgg_echo('messageboard:history:title'),$body); - -?>
\ No newline at end of file diff --git a/mod/messageboard/index.php b/mod/messageboard/index.php deleted file mode 100644 index 5c73bf168..000000000 --- a/mod/messageboard/index.php +++ /dev/null @@ -1,39 +0,0 @@ -<?php - - /** - * Elgg Message board index 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 - * @link http://elgg.com/ - */ - - - // Load Elgg engine - require_once(dirname(dirname(dirname(__FILE__))) . "/engine/start.php"); - - // Get the user who is the owner of the message board - $entity = get_entity(page_owner()); - - // Get any annotations for their message board - $contents = $entity->getAnnotations('messageboard', 50, 0, 'desc'); - - // Get the content to display - $area2 = elgg_view_title(elgg_echo('messageboard:board')); - - // only display the add form and board to logged in users - if(isloggedin()){ - $area2 .= elgg_view("messageboard/forms/add"); - $area2 .= elgg_view("messageboard/messageboard", array('annotation' => $contents)); - } - - - //select the correct canvas area - $body = elgg_view_layout("two_column_left_sidebar", '', $area2); - - // Display page - page_draw(sprintf(elgg_echo('messageboard:user'),$entity->name),$body); - -?>
\ No newline at end of file diff --git a/mod/messageboard/languages/en.php b/mod/messageboard/languages/en.php index ebe2cd50c..9027eb650 100644 --- a/mod/messageboard/languages/en.php +++ b/mod/messageboard/languages/en.php @@ -1,51 +1,48 @@ <?php - $english = array( - - /** - * Menu items and titles - */ - - 'messageboard:board' => "Message board", - 'messageboard:messageboard' => "message board", - 'messageboard:viewall' => "View all", - 'messageboard:postit' => "Post it", - 'messageboard:history:title' => "History", - 'messageboard:none' => "There is nothing on this message board yet", - 'messageboard:num_display' => "Number of messages to display", - 'messageboard:desc' => "This is a message board that you can put on your profile where other users can comment.", - - 'messageboard:user' => "%s's message board", - - 'messageboard:replyon' => 'reply on', - 'messageboard:history' => "history", - - /** - * Message board widget river - **/ - - 'messageboard:river:annotate' => "%s has had a new comment posted on their message board.", - 'messageboard:river:create' => "%s added the message board widget.", - 'messageboard:river:update' => "%s updated their message board widget.", - 'messageboard:river:added' => "%s posted on", - 'messageboard:river:messageboard' => "message board", - - - /** - * Status messages - */ - - 'messageboard:posted' => "You successfully posted on the message board.", - 'messageboard:deleted' => "You successfully deleted the message.", - - /** - * Email messages - */ - - 'messageboard:email:subject' => 'You have a new message board comment!', - 'messageboard:email:body' => "You have a new message board comment from %s. It reads: - - +$english = array( + + /** + * Menu items and titles + */ + + 'messageboard:board' => "Message board", + 'messageboard:messageboard' => "message board", + 'messageboard:viewall' => "View all", + 'messageboard:postit' => "Post", + 'messageboard:history:title' => "History", + 'messageboard:none' => "There is nothing on this message board yet", + 'messageboard:num_display' => "Number of messages to display", + 'messageboard:desc' => "This is a message board that you can put on your profile where other users can comment.", + + 'messageboard:user' => "%s's message board", + + 'messageboard:replyon' => 'reply on', + 'messageboard:history' => "history", + + 'messageboard:owner' => '%s\'s message board', + 'messageboard:owner_history' => '%s\'s posts on %s\'s message board', + + /** + * Message board widget river + */ + 'river:messageboard:user:default' => "%s posted on %s's message board", + + /** + * Status messages + */ + + 'messageboard:posted' => "You successfully posted on the message board.", + 'messageboard:deleted' => "You successfully deleted the message.", + + /** + * Email messages + */ + + 'messageboard:email:subject' => 'You have a new message board comment!', + 'messageboard:email:body' => "You have a new message board comment from %s. It reads: + + %s @@ -58,20 +55,18 @@ To view %s's profile, click here: %s You cannot reply to this email.", - - /** - * Error messages - */ - - 'messageboard:blank' => "Sorry; you need to actually put something in the message area before we can save it.", - 'messageboard:notfound' => "Sorry; we could not find the specified item.", - 'messageboard:notdeleted' => "Sorry; we could not delete this message.", - 'messageboard:somethingwentwrong' => "Something went wrong when trying to save your message, make sure you actually wrote a message.", - - 'messageboard:failure' => "An unexpected error occurred when adding your message. Please try again.", - - ); - - add_translation("en",$english); - -?>
\ No newline at end of file + + /** + * Error messages + */ + + 'messageboard:blank' => "Sorry; you need to actually put something in the message area before we can save it.", + 'messageboard:notfound' => "Sorry; we could not find the specified item.", + 'messageboard:notdeleted' => "Sorry; we could not delete this message.", + 'messageboard:somethingwentwrong' => "Something went wrong when trying to save your message, make sure you actually wrote a message.", + + 'messageboard:failure' => "An unexpected error occurred when adding your message. Please try again.", + +); + +add_translation("en", $english); diff --git a/mod/messageboard/manifest.xml b/mod/messageboard/manifest.xml index 4c89bdc40..617813725 100644 --- a/mod/messageboard/manifest.xml +++ b/mod/messageboard/manifest.xml @@ -1,10 +1,17 @@ <?xml version="1.0" encoding="UTF-8"?> -<plugin_manifest> - <field key="author" value="Curverider" /> - <field key="version" value="1.7" /> - <field key="description" value="This plugin allows users to put a message board on their profile for other users to post comments." /> - <field key="website" value="http://www.elgg.org/" /> - <field key="copyright" value="(C) Curverider 2008-2010" /> - <field key="licence" value="GNU Public License version 2" /> - <field key="elgg_version" value="2010030101" /> +<plugin_manifest xmlns="http://www.elgg.org/plugin_manifest/1.8"> + <name>Message Board</name> + <author>Core developers</author> + <version>1.8</version> + <category>bundled</category> + <category>widget</category> + <description>This plugin allows users to put a message board on their profile for other users to post comments.</description> + <website>http://www.elgg.org/</website> + <copyright>See COPYRIGHT.txt</copyright> + <license>GNU General Public License version 2</license> + <requires> + <type>elgg_release</type> + <version>1.8</version> + </requires> + <activate_on_install>true</activate_on_install> </plugin_manifest> diff --git a/mod/messageboard/pages/messageboard/owner.php b/mod/messageboard/pages/messageboard/owner.php new file mode 100644 index 000000000..b3e9f45b0 --- /dev/null +++ b/mod/messageboard/pages/messageboard/owner.php @@ -0,0 +1,57 @@ +<?php +/** + * Elgg Message board index page + * + * @package MessageBoard + */ + +$page_owner_guid = get_input('page_owner_guid'); +elgg_set_page_owner_guid($page_owner_guid); +$page_owner = elgg_get_page_owner_entity(); +$history_username = get_input('history_username'); +$history_user = get_user_by_username($history_username); + +elgg_push_breadcrumb($page_owner->name, $page_owner->getURL()); + +$options = array( + 'annotations_name' => 'messageboard', + 'guid' => $page_owner_guid, + 'reverse_order_by' => true, +); + +if ($history_user) { + $options['annotations_owner_guid'] = $history_user->getGUID(); + $title = elgg_echo('messageboard:owner_history', array($history_user->name, $page_owner->name)); + + if ($page_owner instanceof ElggGroup) { + $mb_url = "messageboard/group/$page_owner->guid/all"; + } else { + $mb_url = "messageboard/owner/$page_owner->username"; + } +} else { + $title = elgg_echo('messageboard:owner', array($page_owner->name)); + $mb_url = ''; +} + +elgg_push_breadcrumb(elgg_echo('messageboard:board'), $mb_url); + +if ($history_user) { + elgg_push_breadcrumb($history_user->name); +} + +$content = elgg_list_annotations($options); + +if (!$content) { + $content = elgg_echo('messageboard:none'); +} + +$vars = array( + 'filter' => false, + 'content' => $content, + 'title' => $title, + 'reverse_order_by' => true +); + +$body = elgg_view_layout('content', $vars); + +echo elgg_view_page($title, $body);
\ No newline at end of file diff --git a/mod/messageboard/readme.txt b/mod/messageboard/readme.txt deleted file mode 100644 index feffd6651..000000000 --- a/mod/messageboard/readme.txt +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Elgg message board - * - * @package ElggMessageBoard - * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 - * @author Dave Tosh <dave@elgg.com> - * @copyright Curverider Ltd 2008-2009 - * @link http://elgg.com/ -*/ - -This plugin provides Elgg profiles, both users and groups, with a basic message board for comments and media. - -Install: Just drop it into the mod directory and that should be it. diff --git a/mod/messageboard/start.php b/mod/messageboard/start.php index 0d9033a82..0c65edc4f 100644 --- a/mod/messageboard/start.php +++ b/mod/messageboard/start.php @@ -1,71 +1,163 @@ <?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 MessageBoard + */ - /** - * 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]); +/** + * MessageBoard initialisation + */ +function messageboard_init() { + // js + elgg_extend_view('js/elgg', 'messageboard/js'); + + // css + elgg_extend_view('css/elgg', 'messageboard/css'); + + elgg_register_page_handler('messageboard', 'messageboard_page_handler'); + + // messageboard widget - only for profile for now + elgg_register_widget_type('messageboard', elgg_echo("messageboard:board"), elgg_echo("messageboard:desc"), "profile"); + + // actions + $action_path = dirname(__FILE__) . '/actions'; + elgg_register_action("messageboard/add", "$action_path/add.php"); + elgg_register_action("messageboard/delete", "$action_path/delete.php"); + + // delete annotations for posts + elgg_register_plugin_hook_handler('register', 'menu:annotation', 'messageboard_annotation_menu_setup'); +} + +/** + * Messageboard dispatcher for flat message board. + * Profile (and eventually group) widgets handle their own. + * + * URLs take the form of + * User's messageboard: messageboard/owner/<username> + * Y's history of posts on X's board: messageboard/owner/<X>/history/<Y> + * New post: messageboard/add/<guid> (container: user or group) + * Group messageboard: messageboard/group/<guid>/all (not implemented) + * + * @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 = "messageboard/owner/{$page[0]}"; + forward($url); + } + + $pages = dirname(__FILE__) . '/pages/messageboard'; + + 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 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 + + 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; + + default: + return false; + } + return true; +} + +/** + * 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) { + $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 = elgg_echo('messageboard:email:body', array( + $poster->name, + $message, + elgg_get_site_url() . "messageboard/" . $owner->username, + $poster->name, + $poster->getURL() + )); + + notify_user($owner->guid, $poster->guid, $subject, $body); + } + + return $result; +} + + +/** + * Add edit and delete links for forum replies + */ +function messageboard_annotation_menu_setup($hook, $type, $return, $params) { + $annotation = $params['annotation']; + if ($annotation->name != 'messageboard') { + return $return; + } + + if ($annotation->canEdit()) { + $url = elgg_http_add_url_query_elements('action/messageboard/delete', array( + 'annotation_id' => $annotation->id, + )); + + $options = array( + 'name' => 'delete', + 'href' => $url, + 'text' => "<span class=\"elgg-icon elgg-icon-delete\"></span>", + 'confirm' => elgg_echo('deleteconfirm'), + 'encode_text' => false + ); + $return[] = ElggMenuItem::factory($options); + } + + return $return; +} + +elgg_register_event_handler('init', 'system', 'messageboard_init');
\ No newline at end of file diff --git a/mod/messageboard/views/default/forms/messageboard/add.php b/mod/messageboard/views/default/forms/messageboard/add.php new file mode 100644 index 000000000..b219fd800 --- /dev/null +++ b/mod/messageboard/views/default/forms/messageboard/add.php @@ -0,0 +1,20 @@ +<?php +/** + * Elgg Message board add form body + * + * @package ElggMessageBoard + */ + +echo elgg_view('input/plaintext', array( + 'name' => 'message_content', + 'class' => 'messageboard-input mbs' +)); + +echo elgg_view('input/hidden', array( + 'name' => 'owner_guid', + 'value' => elgg_get_page_owner_guid() +)); + +echo elgg_view('input/submit', array( + 'value' => elgg_echo('post') +)); diff --git a/mod/messageboard/views/default/messageboard/css.php b/mod/messageboard/views/default/messageboard/css.php index 0bf150bc2..b3cfab957 100644 --- a/mod/messageboard/views/default/messageboard/css.php +++ b/mod/messageboard/views/default/messageboard/css.php @@ -1,95 +1,10 @@ <?php - - /** - * Elgg Messageboard CSS extender - * - * @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/ - */ - +/** + * Elgg Messageboard CSS view + * + */ ?> -/* input msg area */ -#mb_input_wrapper { - margin:0 10px 5px 10px; - padding:5px; - background: white; - -webkit-border-radius: 8px; - -moz-border-radius: 8px; -} - -#mb_input_wrapper .input_textarea { - width:675px; -} -.collapsable_box_content #mb_input_wrapper .input_textarea { - width:259px; -} -.message_item_timestamp { - font-size:90%; - padding:10px 0 0 0; -} -p.message_item_timestamp { - margin-bottom: 10px; -} -/* wraps each message */ -.messageboard { - margin:0 10px 5px 10px; - padding:0; - background: white; - -webkit-border-radius: 8px; - -moz-border-radius: 8px; -} -.messageboard .message_sender { - float:left; - margin: 5px 10px 0 5px; -} -/* IE6 */ -* html .messageboard { width: 280px; } -* html #two_column_left_sidebar_maincontent .messageboard { width: 667px; } -* html .messageboard .message_sender { margin: 5px 10px 0 2px; } -* html #mb_input_wrapper .input_textarea { width:645px; } -/* IE7 */ -*:first-child+html .messageboard { width: 280px; } -*:first-child+html #two_column_left_sidebar_maincontent .messageboard { width: 698px; } -*:first-child+html .messageboard .message_sender { margin: 5px 10px 0 2px; } - -.messageboard .message p { - line-height: 1.2em; - background:#dedede; - margin:0 6px 4px 6px; - padding:4px; - -webkit-border-radius: 4px; - -moz-border-radius: 4px; - overflow-y:hidden; - overflow-x:auto; - color:#333333; +.messageboard-input { + height: 100px; } - -.message_buttons { - padding:0 0 3px 4px; - margin:0; - font-size: 90%; - color:#666666; -} - -.messageboard .delete_message a { - display:block; - float:right; - cursor: pointer; - width:14px; - height:14px; - margin:0 3px 3px 0; - background: url("<?php echo $vars['url']; ?>_graphics/icon_customise_remove.png") no-repeat 0 0; - text-indent: -9000px; -} -.messageboard .delete_message a:hover { - background-position: 0 -16px; -} - - - - - diff --git a/mod/messageboard/views/default/messageboard/forms/add.php b/mod/messageboard/views/default/messageboard/forms/add.php deleted file mode 100644 index 91337fdc9..000000000 --- a/mod/messageboard/views/default/messageboard/forms/add.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php - - /** - * Elgg Message board add form - * - * @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/ - */ - -?> -<div id="mb_input_wrapper"> -<form action="<?php echo $vars['url']; ?>action/messageboard/add" method="post" name="messageboardForm"> - - <!-- textarea for the contents --> - <textarea name="message_content" value="" class="input_textarea"></textarea><br /> - - <!-- the person posting an item on the message board --> - <input type="hidden" name="guid" value="<?php echo $_SESSION['guid']; ?>" /> - - <!-- the page owner, this will be the profile owner --> - <input type="hidden" name="pageOwner" value="<?php echo page_owner(); ?>" /> - - <?php echo elgg_view('input/securitytoken'); ?> - - <!-- submit messages input --> - <input type="submit" id="postit" value="<?php echo elgg_echo('messageboard:postit'); ?>"> - -</form> -</div> diff --git a/mod/messageboard/views/default/messageboard/group_messageboard.php b/mod/messageboard/views/default/messageboard/group_messageboard.php deleted file mode 100644 index 8662d45ac..000000000 --- a/mod/messageboard/views/default/messageboard/group_messageboard.php +++ /dev/null @@ -1,96 +0,0 @@ -<?php - - /** - * Elgg messageboard group profile view - * - * @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/ - */ - - // get the groups passed over here - - //get the full page owner entity - $entity = $vars['entity']; - - $num_display = 10; - -?> -<script type="text/JavaScript"> -$(document).ready(function(){ - - $("#postit").click(function(){ - - //display the ajax loading gif at the start of the function call - //$('#loader').html('<img src="<?php echo $vars['url']; ?>_graphics/ajax_loader.gif" />'); - $('#loader').html('<?php echo elgg_view('ajax/loader',array('slashes' => true)); ?>'); - - - //load the results back into the message board contents and remove the loading gif - //remember that the actual div being populated is determined on views/default/messageboard/messageboard.php - $("#messageboard_wrapper").load("<?php echo $vars['url']; ?>mod/messageboard/ajax_endpoint/load.php", {messageboard_content:$("[name=message_content]").val(), pageOwner:$("[name=pageOwner]").val(), numToDisplay:<?php echo $num_display; ?>}, function(){ - $('#loader').empty(); // remove the loading gif - $('[name=message_content]').val(''); // clear the input textarea - }); //end - - }); // end of the main click function - -}); //end of the document .ready function -</script> - -<div id="mb_input_wrapper"><!-- start of mb_input_wrapper div --> - - <h2><?php echo elgg_echo("messageboard:board"); ?></h2> - -<?php - //if not a member don't display the add comment to messageboard - if(is_group_member($entity->guid, $_SESSION['guid'])){ -?> - - <!-- message textarea --> - <textarea name="message_content" id="testing" value="" class="input_textarea"></textarea> - - <!-- the person posting an item on the message board --> - <input type="hidden" name="guid" value="<?php echo $_SESSION['guid']; ?>" class="guid" /> - - <!-- the page owner, this will be the profile owner --> - <input type="hidden" name="pageOwner" value="<?php echo page_owner(); ?>" class="pageOwner" /> - - <!-- submit button --> - <input type="submit" id="postit" value="<?php echo elgg_echo('messageboard:postit'); ?>"> - - <!-- menu options --> - <div id="messageboard_widget_menu"> - <a href="<?php echo $vars['url']; ?>pg/messageboard/<?php echo get_entity(page_owner())->username; ?>"><?php echo elgg_echo("messageboard:viewall"); ?></a> - </div> - - <!-- loading graphic --> - <div id="loader" class="loading"> </div> - -<?php - } -?> - -</div><!-- end of mb_input_wrapper div --> - - - <?php - - //this for the first time the page loads, grab the latest 5 messages. - $contents = $entity->getAnnotations('messageboard', $num_display, 0, 'desc'); - - //as long as there is some content to display, display it - if (!empty($contents)) { - - echo elgg_view('messageboard/messageboard',array('annotation' => $contents)); - - } else { - - //put the required div on the page for the first message - echo "<div id=\"messageboard_wrapper\" /></div>"; - - } - - ?> diff --git a/mod/messageboard/views/default/messageboard/js.php b/mod/messageboard/views/default/messageboard/js.php new file mode 100644 index 000000000..79472069d --- /dev/null +++ b/mod/messageboard/views/default/messageboard/js.php @@ -0,0 +1,56 @@ +//<script> +elgg.provide('elgg.messageboard'); + +elgg.messageboard.init = function() { + var form = $('form[name=elgg-messageboard]'); + form.find('input[type=submit]').live('click', elgg.messageboard.submit); + + // remove the default binding for confirmation since we're doing extra stuff. + // @todo remove if we add a hook to the requires confirmation callback + form.parent().find('a.elgg-requires-confirmation') + .click(elgg.messageboard.deletePost) + + // double whammy for in case the load order changes. + .unbind('click', elgg.ui.requiresConfirmation) + .removeClass('elgg-requires-confirmation'); +}; + +elgg.messageboard.submit = function(e) { + var form = $(this).parents('form'); + var data = form.serialize(); + + elgg.action('messageboard/add', { + data: data, + success: function(json) { + // the action always returns the full ul and li wrapped annotation. + var ul = form.next('ul.elgg-list-annotation'); + + if (ul.length < 1) { + form.parent().append(json.output); + } else { + ul.prepend($(json.output).find('li:first')); + }; + form.find('textarea').val(''); + } + }); + + e.preventDefault(); +}; + +elgg.messageboard.deletePost = function(e) { + var link = $(this); + var confirmText = link.attr('title') || elgg.echo('question:areyousure'); + + if (confirm(confirmText)) { + elgg.action($(this).attr('href'), { + success: function() { + var item = $(link).closest('.elgg-item'); + item.remove(); + } + }); + } + + e.preventDefault(); +}; + +elgg.register_hook_handler('init', 'system', elgg.messageboard.init); diff --git a/mod/messageboard/views/default/messageboard/messageboard.php b/mod/messageboard/views/default/messageboard/messageboard.php deleted file mode 100644 index bb563d7fb..000000000 --- a/mod/messageboard/views/default/messageboard/messageboard.php +++ /dev/null @@ -1,37 +0,0 @@ -<?php - - /** - * Elgg Message board display 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 - * @link http://elgg.com/ - */ - - - // If there is any content to view, view it - if (is_array($vars['annotation']) && sizeof($vars['annotation']) > 0) { - - //start the div which will wrap all the message board contents - echo "<div id=\"messageboard_wrapper\">"; - - //loop through all annotations and display - foreach($vars['annotation'] as $content) { - - echo elgg_view("messageboard/messageboard_content", array('annotation' => $content)); - - } - - //close the wrapper div - echo "</div>"; - - } else { - - echo "<div class='contentWrapper'>" . elgg_echo("messageboard:none") . "</div>"; - - } - - -?>
\ No newline at end of file diff --git a/mod/messageboard/views/default/messageboard/messageboard_content.php b/mod/messageboard/views/default/messageboard/messageboard_content.php deleted file mode 100644 index 86240e910..000000000 --- a/mod/messageboard/views/default/messageboard/messageboard_content.php +++ /dev/null @@ -1,65 +0,0 @@ -<?php - - /** - * Elgg Message board individual item display 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 - * @link http://elgg.com/ - */ - -?> - -<div class="messageboard"><!-- start of messageboard div --> - - <!-- display the user icon of the user that posted the message --> - <div class="message_sender"> - <?php - echo elgg_view("profile/icon",array('entity' => get_entity($vars['annotation']->owner_guid), 'size' => 'tiny')); - ?> - </div> - - <!-- display the user's name who posted and the date/time --> - <p class="message_item_timestamp"> - <?php echo get_entity($vars['annotation']->owner_guid)->name . " " . friendly_time($vars['annotation']->time_created); ?> - </p> - - <!-- output the actual comment --> - <div class="message"><?php echo elgg_view("output/longtext",array("value" => parse_urls($vars['annotation']->value))); ?></div> - <div class="message_buttons"> - - <?php - - // if the user looking at the comment can edit, show the delete link - if ($vars['annotation']->canEdit()) { - - - echo "<div class='delete_message'>" . elgg_view("output/confirmlink",array( - 'href' => $vars['url'] . "action/messageboard/delete?annotation_id=" . $vars['annotation']->id, - 'text' => elgg_echo('delete'), - 'confirm' => elgg_echo('deleteconfirm'), - )) . "</div>"; - - } //end of can edit if statement - ?> -<?php - // If the message being looked at is owned by the current user, don't show the reply - // Also do not show if the user is not logged in - if (isloggedin() && $vars['annotation']->owner_guid != get_loggedin_userid()){ - - //get the message owner - $msg_owner = get_entity($vars['annotation']->owner_guid); - //create the url to their messageboard - $user_mb = "pg/messageboard/" . $msg_owner->username; - - echo "<a href=\"" . $vars['url'] . $user_mb . "\">".elgg_echo('messageboard:replyon')." " . $msg_owner->name . "'s " . elgg_echo('messageboard:messageboard') . "</a> | "; - - echo "<a href=\"" . $vars['url'] . "mod/messageboard/history.php?user=" . $msg_owner->guid ."\">" . elgg_echo('messageboard:history') . "</a>"; - } -?> - - </div> - <div class="clearfloat"></div> -</div><!-- end of messageboard div --> diff --git a/mod/messageboard/views/default/river/object/messageboard/create.php b/mod/messageboard/views/default/river/object/messageboard/create.php index 9f65122d0..ac10a55c1 100644 --- a/mod/messageboard/views/default/river/object/messageboard/create.php +++ b/mod/messageboard/views/default/river/object/messageboard/create.php @@ -1,12 +1,12 @@ -<?php - - $performed_by = get_entity($vars['item']->subject_guid); // $statement->getSubject(); - $performed_on = get_entity($vars['item']->object_guid); - - $url = "<a href=\"{$performed_by->getURL()}\">{$performed_by->name}</a>"; - $string = sprintf(elgg_echo("messageboard:river:added"),$url) . " <a href=\"{$performed_on->getURL()}\">" . $performed_on->name . "'s</a> " . elgg_echo("messageboard:river:messageboard"); - - - echo $string; - -?>
\ No newline at end of file +<?php
+/**
+ * Messageboard river view
+ */
+
+$messageboard = $vars['item']->getAnnotation();
+$excerpt = elgg_get_excerpt($messageboard->value);
+
+echo elgg_view('river/elements/layout', array(
+ 'item' => $vars['item'],
+ 'message' => $excerpt,
+));
diff --git a/mod/messageboard/views/default/widgets/messageboard/content.php b/mod/messageboard/views/default/widgets/messageboard/content.php new file mode 100644 index 000000000..35954e7a3 --- /dev/null +++ b/mod/messageboard/views/default/widgets/messageboard/content.php @@ -0,0 +1,35 @@ +<?php +/** + * Elgg messageboard widget view + * + */ + +$owner = elgg_get_page_owner_entity(); + +$num_display = $vars['entity']->num_display; + +if (elgg_is_logged_in()) { + echo elgg_view_form('messageboard/add', array('name' => 'elgg-messageboard')); +} + +$options = array( + 'annotations_name' => 'messageboard', + 'guid' => $owner->getGUID(), + 'limit' => $num_display, + 'pagination' => false, + 'reverse_order_by' => true, +); + +echo elgg_list_annotations($options); + +if ($owner instanceof ElggGroup) { + $url = "messageboard/group/$owner->guid/all"; +} else { + $url = "messageboard/owner/$owner->username"; +} + +echo elgg_view('output/url', array( + 'href' => $url, + 'text' => elgg_echo('messageboard:viewall'), + 'is_trusted' => true, +));
\ No newline at end of file diff --git a/mod/messageboard/views/default/widgets/messageboard/edit.php b/mod/messageboard/views/default/widgets/messageboard/edit.php index cf0741a36..74848f832 100644 --- a/mod/messageboard/views/default/widgets/messageboard/edit.php +++ b/mod/messageboard/views/default/widgets/messageboard/edit.php @@ -1,28 +1,22 @@ <?php +/** + * Messageboard widget edit view + */ - /** - * Elgg message board edit 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 - * @link http://elgg.com/ - */ +// set default value +if (!isset($vars['entity']->num_display)) { + $vars['entity']->num_display = 5; +} + +$params = array( + 'name' => 'params[num_display]', + 'value' => $vars['entity']->num_display, + 'options' => array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10), +); +$dropdown = elgg_view('input/dropdown', $params); ?> -<p> - <?php echo elgg_echo("messageboard:num_display"); ?>: - <select name="params[num_display]"> - <option value="1" <?php if($vars['entity']->num_display == 1) echo "SELECTED"; ?>>1</option> - <option value="2" <?php if($vars['entity']->num_display == 2) echo "SELECTED"; ?>>2</option> - <option value="3" <?php if($vars['entity']->num_display == 3) echo "SELECTED"; ?>>3</option> - <option value="4" <?php if($vars['entity']->num_display == 4) echo "SELECTED"; ?>>4</option> - <option value="5" <?php if($vars['entity']->num_display == 5) echo "SELECTED"; ?>>5</option> - <option value="6" <?php if($vars['entity']->num_display == 6) echo "SELECTED"; ?>>6</option> - <option value="7" <?php if($vars['entity']->num_display == 7) echo "SELECTED"; ?>>7</option> - <option value="8" <?php if($vars['entity']->num_display == 8) echo "SELECTED"; ?>>8</option> - <option value="9" <?php if($vars['entity']->num_display == 9) echo "SELECTED"; ?>>9</option> - <option value="10" <?php if($vars['entity']->num_display == 10) echo "SELECTED"; ?>>10</option> - </select> -</p>
\ No newline at end of file +<div> + <?php echo elgg_echo('messageboard:num_display'); ?>: + <?php echo $dropdown; ?> +</div> diff --git a/mod/messageboard/views/default/widgets/messageboard/view.php b/mod/messageboard/views/default/widgets/messageboard/view.php deleted file mode 100644 index 9a0d8e251..000000000 --- a/mod/messageboard/views/default/widgets/messageboard/view.php +++ /dev/null @@ -1,93 +0,0 @@ -<?php - - /** - * Elgg messageboard plugin view page - * - * @todo let users choose how many messages they want displayed - * - * @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/ - */ - - // a couple of required variables - - //get the full page owner entity - $entity = get_entity(page_owner()); - - //the number of message to display - $num_display = $vars['entity']->num_display; - - //if no num set, set to one - if(!$num_display) - $num_display = 5; - -//Just the loggedin user can send messages -if(isloggedin()){ -?> - <script type="text/JavaScript"> - $(document).ready(function(){ - - $("#postit").click(function(){ - - //display the ajax loading gif at the start of the function call - //$('#loader').html('<img src="<?php echo $vars['url']; ?>_graphics/ajax_loader.gif" />'); - $('#loader').html('<?php echo elgg_view('ajax/loader',array('slashes' => true)); ?>'); - - //load the results back into the message board contents and remove the loading gif - //remember that the actual div being populated is determined on views/default/messageboard/messageboard.php - $("#messageboard_wrapper").load("<?php echo $vars['url']; ?>mod/messageboard/ajax_endpoint/load.php", {messageboard_content:$("[name=message_content]").val(), pageOwner:$("[name=pageOwner]").val(), numToDisplay:<?php echo $num_display; ?>}, function(){ - $('#loader').empty(); // remove the loading gif - $('[name=message_content]').val(''); // clear the input textarea - }); //end - - }); // end of the main click function - - }); //end of the document .ready function - </script> - - <div id="mb_input_wrapper"><!-- start of mb_input_wrapper div --> - - <!-- message textarea --> - <textarea name="message_content" id="testing" value="" class="input_textarea"></textarea> - - <!-- the person posting an item on the message board --> - <input type="hidden" name="guid" value="<?php echo $_SESSION['guid']; ?>" class="guid" /> - - <!-- the page owner, this will be the profile owner --> - <input type="hidden" name="pageOwner" value="<?php echo page_owner(); ?>" class="pageOwner" /> - - <!-- submit button --> - <input type="submit" id="postit" value="<?php echo elgg_echo('messageboard:postit'); ?>"> - - <!-- menu options --> - <div id="messageboard_widget_menu"> - <a href="<?php echo $vars['url']; ?>pg/messageboard/<?php echo get_entity(page_owner())->username; ?>"><?php echo elgg_echo("messageboard:viewall"); ?></a> - </div> - - <!-- loading graphic --> - <div id="loader" class="loading"> </div> - - </div><!-- end of mb_input_wrapper div --> - -<?php -} // if(isloggedin()) - - //this for the first time the page loads, grab the latest 5 messages. - $contents = $entity->getAnnotations('messageboard', $num_display, 0, 'desc'); - - //as long as there is some content to display, display it - if (!empty($contents)) { - - echo elgg_view('messageboard/messageboard',array('annotation' => $contents)); - - } else { - - //put the required div on the page for the first message - echo "<div id=\"messageboard_wrapper\"></div>"; - - } - -?>
\ No newline at end of file |
