aboutsummaryrefslogtreecommitdiff
path: root/mod/messageboard/views/default
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/views/default
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/views/default')
-rw-r--r--mod/messageboard/views/default/annotation/messageboard.php11
-rw-r--r--mod/messageboard/views/default/messageboard/js.php31
-rw-r--r--mod/messageboard/views/default/messageboard/messageboard_content.php61
-rw-r--r--mod/messageboard/views/default/widgets/messageboard/content.php28
-rw-r--r--mod/messageboard/views/default/widgets/messageboard/edit.php4
5 files changed, 62 insertions, 73 deletions
diff --git a/mod/messageboard/views/default/annotation/messageboard.php b/mod/messageboard/views/default/annotation/messageboard.php
new file mode 100644
index 000000000..fa4b43ff3
--- /dev/null
+++ b/mod/messageboard/views/default/annotation/messageboard.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Message board post
+ *
+ * @uses $vars['annotation'] ElggAnnotation object
+ * @uses $vars['full'] Display fill view or brief view
+ */
+
+$vars['delete_action'] = 'action/messageboard/delete';
+
+echo elgg_view('annotation/generic_comment', $vars); \ No newline at end of file
diff --git a/mod/messageboard/views/default/messageboard/js.php b/mod/messageboard/views/default/messageboard/js.php
index c76040945..b51c59209 100644
--- a/mod/messageboard/views/default/messageboard/js.php
+++ b/mod/messageboard/views/default/messageboard/js.php
@@ -1,7 +1,13 @@
elgg.provide('elgg.messageboard');
elgg.messageboard.init = function() {
- $('form.elgg-messageboard input[type=submit]').live('click', elgg.messageboard.submit);
+ var form = $('form[name=elgg-messageboard]');
+ form.find('input[type=submit]').live('click', elgg.messageboard.submit);
+
+ // can't undelete because of init load order
+ form.parent().find('a.elgg-requires-confirmation').removeClass('elgg-requires-confirmation');
+ // delegate() instead of live() because live() has to be at the top level of chains...can't use parent().
+ form.parent().delegate('.delete-button a', 'click', elgg.messageboard.delete);
}
elgg.messageboard.submit = function(e) {
@@ -11,7 +17,14 @@ elgg.messageboard.submit = function(e) {
elgg.action('messageboard/add', {
data: data,
success: function(json) {
- form.parent().find('#messageboard_wrapper').prepend(json.output.post);
+ // the action always returns the full ul and li wrapped annotation.
+ var ul = form.next('ul.elgg-annotation-list');
+
+ if (ul.length < 1) {
+ form.parent().append(json.output.post);
+ } else {
+ ul.prepend($(json.output.post).find('li:first'));
+ };
form.find('textarea').val('');
}
});
@@ -19,6 +32,20 @@ elgg.messageboard.submit = function(e) {
e.preventDefault();
}
+elgg.messageboard.delete = function(e) {
+ var link = $(this);
+ var confirmText = link.attr('title') || elgg.echo('question:areyousure');
+
+ if (confirm(confirmText)) {
+ elgg.action($(this).attr('href'), {
+ success: function() {
+ $(link).closest('li').remove();
+ }
+ });
+ }
+
+ e.preventDefault();
+}
elgg.register_event_handler('init', 'system', elgg.messageboard.init); \ 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 abd81d0ad..000000000
--- a/mod/messageboard/views/default/messageboard/messageboard_content.php
+++ /dev/null
@@ -1,61 +0,0 @@
-<?php
-
-/**
- * Elgg Message board individual item display view
- *
- * @package ElggMessageBoard
- */
-
-?>
-
-<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 . " " . elgg_view_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' => "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 (elgg_is_logged_in() && $vars['annotation']->owner_guid != elgg_get_logged_in_user_guid()) {
-
- //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=\"" . elgg_get_site_url() . $user_mb . "\">".elgg_echo('messageboard:replyon')." " . $msg_owner->name . "'s " . elgg_echo('messageboard:messageboard') . "</a> | ";
-
- echo "<a href=\"" . elgg_get_site_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/widgets/messageboard/content.php b/mod/messageboard/views/default/widgets/messageboard/content.php
index 5f0cc8676..7ec3e5d4e 100644
--- a/mod/messageboard/views/default/widgets/messageboard/content.php
+++ b/mod/messageboard/views/default/widgets/messageboard/content.php
@@ -6,7 +6,7 @@
* @package ElggMessageBoard
*/
-$user = elgg_get_page_owner_entity();
+$owner = elgg_get_page_owner_entity();
$num_display = 5;
if (isset($vars['entity']->num_display)) {
@@ -14,12 +14,26 @@ if (isset($vars['entity']->num_display)) {
}
if (elgg_is_logged_in()) {
- echo elgg_view_form('messageboard/add', array('class' => 'elgg-messageboard'));
+ echo elgg_view_form('messageboard/add', array('name' => 'elgg-messageboard'));
}
-//this for the first time the page loads, grab the latest messages.
-$contents = $user->getAnnotations('messageboard', $num_display, 0, 'desc');
+$options = array(
+ 'annotations_name' => 'messageboard',
+ 'guid' => $owner->getGUID(),
+ 'limit' => $num_display,
+ 'pagination' => false,
+ 'reverse_order_by' => true
+);
-if ($contents) {
- echo elgg_view('messageboard/messageboard', array('annotation' => $contents));
-} \ No newline at end of file
+echo elgg_list_annotations($options);
+
+if ($owner instanceof ElggGroup) {
+ $url = "pg/messageboard/group/$owner->guid/owner";
+} else {
+ $url = "pg/messageboard/owner/$owner->username";
+}
+
+echo elgg_view('output/url', array(
+ 'href' => $url,
+ 'text' => elgg_echo('messageboard:viewall')
+)); \ 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 470d49060..2157da6c4 100644
--- a/mod/messageboard/views/default/widgets/messageboard/edit.php
+++ b/mod/messageboard/views/default/widgets/messageboard/edit.php
@@ -1,18 +1,16 @@
<?php
-
/**
* Elgg message board widget edit view
*
* @package ElggMessageBoard
*/
-// default value
$num_display = 5;
+
if (isset($vars['entity']->num_display)) {
$num_display = $vars['entity']->num_display;
}
-
?>
<p>
<?php echo elgg_echo("messageboard:num_display"); ?>: