From 4766f36a4d74924f21ff329c4318ce4e069ffa04 Mon Sep 17 00:00:00 2001 From: brettp Date: Wed, 3 Mar 2010 17:53:05 +0000 Subject: Pulled in the interface changes. git-svn-id: http://code.elgg.org/elgg/trunk@5257 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/messageboard/actions/add.php | 68 +++++++++++++++ mod/messageboard/actions/delete.php | 44 ++++++++++ mod/messageboard/ajax_endpoint/load.php | 73 ++++++++++++++++ mod/messageboard/history.php | 43 ++++++++++ mod/messageboard/index.php | 39 +++++++++ mod/messageboard/languages/en.php | 77 +++++++++++++++++ mod/messageboard/manifest.xml | 10 +++ mod/messageboard/readme.txt | 13 +++ mod/messageboard/start.php | 71 ++++++++++++++++ .../views/default/messageboard/css.php | 95 +++++++++++++++++++++ .../views/default/messageboard/forms/add.php | 32 ++++++++ .../default/messageboard/group_messageboard.php | 96 ++++++++++++++++++++++ .../views/default/messageboard/messageboard.php | 37 +++++++++ .../default/messageboard/messageboard_content.php | 65 +++++++++++++++ .../default/river/object/messageboard/create.php | 12 +++ .../views/default/widgets/messageboard/edit.php | 28 +++++++ .../views/default/widgets/messageboard/view.php | 93 +++++++++++++++++++++ 17 files changed, 896 insertions(+) create mode 100644 mod/messageboard/actions/add.php create mode 100644 mod/messageboard/actions/delete.php create mode 100644 mod/messageboard/ajax_endpoint/load.php create mode 100644 mod/messageboard/history.php create mode 100644 mod/messageboard/index.php create mode 100644 mod/messageboard/languages/en.php create mode 100644 mod/messageboard/manifest.xml create mode 100644 mod/messageboard/readme.txt create mode 100644 mod/messageboard/start.php create mode 100644 mod/messageboard/views/default/messageboard/css.php create mode 100644 mod/messageboard/views/default/messageboard/forms/add.php create mode 100644 mod/messageboard/views/default/messageboard/group_messageboard.php create mode 100644 mod/messageboard/views/default/messageboard/messageboard.php create mode 100644 mod/messageboard/views/default/messageboard/messageboard_content.php create mode 100644 mod/messageboard/views/default/river/object/messageboard/create.php create mode 100644 mod/messageboard/views/default/widgets/messageboard/edit.php create mode 100644 mod/messageboard/views/default/widgets/messageboard/view.php (limited to 'mod/messageboard') diff --git a/mod/messageboard/actions/add.php b/mod/messageboard/actions/add.php new file mode 100644 index 000000000..98ffe4b47 --- /dev/null +++ b/mod/messageboard/actions/add.php @@ -0,0 +1,68 @@ + + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.org/ + */ + + // 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); + + + } 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); + +?> \ No newline at end of file diff --git a/mod/messageboard/actions/delete.php b/mod/messageboard/actions/delete.php new file mode 100644 index 000000000..9c17f1fcd --- /dev/null +++ b/mod/messageboard/actions/delete.php @@ -0,0 +1,44 @@ + + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.org/ + */ + + // 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); + +?> \ No newline at end of file diff --git a/mod/messageboard/ajax_endpoint/load.php b/mod/messageboard/ajax_endpoint/load.php new file mode 100644 index 000000000..5bba34681 --- /dev/null +++ b/mod/messageboard/ajax_endpoint/load.php @@ -0,0 +1,73 @@ + + * @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 new file mode 100644 index 000000000..1f7ecd0e4 --- /dev/null +++ b/mod/messageboard/history.php @@ -0,0 +1,43 @@ + + * @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 = "

Profile owner: " . $current_user . "

"; + //$area1 .= "

User guid: " . $history_user . "

"; + + + //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 new file mode 100644 index 000000000..5c73bf168 --- /dev/null +++ b/mod/messageboard/index.php @@ -0,0 +1,39 @@ + + * @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 new file mode 100644 index 000000000..ebe2cd50c --- /dev/null +++ b/mod/messageboard/languages/en.php @@ -0,0 +1,77 @@ + "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: + + +%s + + +To view your message board comments, click here: + + %s + +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 diff --git a/mod/messageboard/manifest.xml b/mod/messageboard/manifest.xml new file mode 100644 index 000000000..4c89bdc40 --- /dev/null +++ b/mod/messageboard/manifest.xml @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/mod/messageboard/readme.txt b/mod/messageboard/readme.txt new file mode 100644 index 000000000..feffd6651 --- /dev/null +++ b/mod/messageboard/readme.txt @@ -0,0 +1,13 @@ +/** + * 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 + * @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 new file mode 100644 index 000000000..0d9033a82 --- /dev/null +++ b/mod/messageboard/start.php @@ -0,0 +1,71 @@ + + * @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 diff --git a/mod/messageboard/views/default/messageboard/css.php b/mod/messageboard/views/default/messageboard/css.php new file mode 100644 index 000000000..0bf150bc2 --- /dev/null +++ b/mod/messageboard/views/default/messageboard/css.php @@ -0,0 +1,95 @@ + + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + +?> + +/* 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; +} + +.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("_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 new file mode 100644 index 000000000..91337fdc9 --- /dev/null +++ b/mod/messageboard/views/default/messageboard/forms/add.php @@ -0,0 +1,32 @@ + + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + +?> +
+
+ + +
+ + + + + + + + + + + + +
+
diff --git a/mod/messageboard/views/default/messageboard/group_messageboard.php b/mod/messageboard/views/default/messageboard/group_messageboard.php new file mode 100644 index 000000000..8662d45ac --- /dev/null +++ b/mod/messageboard/views/default/messageboard/group_messageboard.php @@ -0,0 +1,96 @@ + + * @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; + +?> + + +
+ +

+ +guid, $_SESSION['guid'])){ +?> + + + + + + + + + + + + + + +
+ +
+ + +
+ + + +
+ + + 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 "
"; + + } + + ?> diff --git a/mod/messageboard/views/default/messageboard/messageboard.php b/mod/messageboard/views/default/messageboard/messageboard.php new file mode 100644 index 000000000..bb563d7fb --- /dev/null +++ b/mod/messageboard/views/default/messageboard/messageboard.php @@ -0,0 +1,37 @@ + + * @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 "
"; + + //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 "
"; + + } else { + + echo "
" . elgg_echo("messageboard:none") . "
"; + + } + + +?> \ 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 new file mode 100644 index 000000000..86240e910 --- /dev/null +++ b/mod/messageboard/views/default/messageboard/messageboard_content.php @@ -0,0 +1,65 @@ + + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + +?> + +
+ + +
+ get_entity($vars['annotation']->owner_guid), 'size' => 'tiny')); + ?> +
+ + +

+ owner_guid)->name . " " . friendly_time($vars['annotation']->time_created); ?> +

+ + +
parse_urls($vars['annotation']->value))); ?>
+
+ + canEdit()) { + + + echo "
" . elgg_view("output/confirmlink",array( + 'href' => $vars['url'] . "action/messageboard/delete?annotation_id=" . $vars['annotation']->id, + 'text' => elgg_echo('delete'), + 'confirm' => elgg_echo('deleteconfirm'), + )) . "
"; + + } //end of can edit if statement + ?> +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 "".elgg_echo('messageboard:replyon')." " . $msg_owner->name . "'s " . elgg_echo('messageboard:messageboard') . " | "; + + echo "" . elgg_echo('messageboard:history') . ""; + } +?> + +
+
+
diff --git a/mod/messageboard/views/default/river/object/messageboard/create.php b/mod/messageboard/views/default/river/object/messageboard/create.php new file mode 100644 index 000000000..9f65122d0 --- /dev/null +++ b/mod/messageboard/views/default/river/object/messageboard/create.php @@ -0,0 +1,12 @@ +subject_guid); // $statement->getSubject(); + $performed_on = get_entity($vars['item']->object_guid); + + $url = "getURL()}\">{$performed_by->name}"; + $string = sprintf(elgg_echo("messageboard:river:added"),$url) . " getURL()}\">" . $performed_on->name . "'s " . elgg_echo("messageboard:river:messageboard"); + + + echo $string; + +?> \ 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 new file mode 100644 index 000000000..cf0741a36 --- /dev/null +++ b/mod/messageboard/views/default/widgets/messageboard/edit.php @@ -0,0 +1,28 @@ + + * @copyright Curverider Ltd 2008-2010 + * @link http://elgg.com/ + */ + +?> +

+ : + +

\ No newline at end of file diff --git a/mod/messageboard/views/default/widgets/messageboard/view.php b/mod/messageboard/views/default/widgets/messageboard/view.php new file mode 100644 index 000000000..9a0d8e251 --- /dev/null +++ b/mod/messageboard/views/default/widgets/messageboard/view.php @@ -0,0 +1,93 @@ + + * @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()){ +?> + + +
+ + + + + + + + + + + + + + +
+ +
+ + +
+ +
+ +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 "
"; + + } + +?> \ No newline at end of file -- cgit v1.2.3