From a7add808c43b0758a90791359bed0c075b0c35e6 Mon Sep 17 00:00:00 2001 From: dave Date: Mon, 29 Mar 2010 13:12:24 +0000 Subject: simple comment wall added to profiles git-svn-id: http://code.elgg.org/elgg/trunk@5537 36083f99-b078-4883-b0ff-0f9b5a30f544 --- mod/profile/actions/addcomment.php | 48 ++++++++++++++++++++++ mod/profile/actions/deletecomment.php | 29 +++++++++++++ mod/profile/languages/en.php | 39 +++++++++++++++--- mod/profile/profile_lib.php | 5 ++- mod/profile/start.php | 4 +- .../default/profile/commentwall/commentwall.php | 22 ++++++++++ .../profile/commentwall/commentwall_content.php | 32 +++++++++++++++ .../default/profile/commentwall/commentwalladd.php | 18 ++++++++ .../profile/profile_contents/commentwall.php | 13 ++++++ .../views/default/profile/profile_navigation.php | 7 +++- 10 files changed, 208 insertions(+), 9 deletions(-) create mode 100644 mod/profile/actions/addcomment.php create mode 100644 mod/profile/actions/deletecomment.php create mode 100644 mod/profile/views/default/profile/commentwall/commentwall.php create mode 100644 mod/profile/views/default/profile/commentwall/commentwall_content.php create mode 100644 mod/profile/views/default/profile/commentwall/commentwalladd.php create mode 100644 mod/profile/views/default/profile/profile_contents/commentwall.php diff --git a/mod/profile/actions/addcomment.php b/mod/profile/actions/addcomment.php new file mode 100644 index 000000000..b5c5e0708 --- /dev/null +++ b/mod/profile/actions/addcomment.php @@ -0,0 +1,48 @@ +annotate('commentwall',$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('profile:comment:subject'), + sprintf( + elgg_echo('profile:comment:body'), + $_SESSION['user']->name, + $message_content, + $CONFIG->wwwroot . "pg/profile/" . $user->username, + $_SESSION['user']->name, + $_SESSION['user']->getURL() + ) + ); + + system_message(elgg_echo("profile:commentwall:posted")); + // add to river + add_to_river('river/object/profile/commentwall/create','commentwall',$_SESSION['user']->guid,$user->guid); + + } else { + register_error(elgg_echo("profile:commentwall:failure")); + } + +} else { + register_error(elgg_echo("profile:commentwall:blank")); +} + +// Forward back to the messageboard +forward($_SERVER['HTTP_REFERER']); \ No newline at end of file diff --git a/mod/profile/actions/deletecomment.php b/mod/profile/actions/deletecomment.php new file mode 100644 index 000000000..48399af4a --- /dev/null +++ b/mod/profile/actions/deletecomment.php @@ -0,0 +1,29 @@ +entity_guid); + //check to make sure the current user can actually edit the commentwall + if ($message->canEdit()) { + //delete the comment + $message->delete(); + //display message + system_message(elgg_echo("profile:commentwall:deleted")); + forward($_SERVER['HTTP_REFERER']); + } + +} else { + system_message(elgg_echo("profile:commentwall:notdeleted")); +} + +forward($_SERVER['HTTP_REFERER']); \ No newline at end of file diff --git a/mod/profile/languages/en.php b/mod/profile/languages/en.php index ee1c20115..bb4230070 100644 --- a/mod/profile/languages/en.php +++ b/mod/profile/languages/en.php @@ -1,12 +1,6 @@ "Your profile was successfully saved.", 'profile:icon:uploaded' => "Your profile picture was successfully uploaded.", + +/** + * Profile comment wall + **/ + 'profile:commentwall:add' => "Add to the wall", + 'profile:commentwall:posted' => "You successfully posted on the comment wall.", + 'profile:commentwall:deleted' => "You successfully deleted the message.", + 'profile:commentwall:blank' => "Sorry; you need to actually put something in the message area before we can save it.", + 'profile:commentwall:notfound' => "Sorry; we could not find the specified item.", + 'profile:commentwall:notdeleted' => "Sorry; we could not delete this message.", + 'profile:commentwall:somethingwentwrong' => "Something went wrong when trying to save your message, make sure you actually wrote a message.", + 'profile:commentwall:failure' => "An unexpected error occurred when adding your message. Please try again.", + +/** + * Email messages commentwall + */ + + 'profile:comment:subject' => 'You have a new message board comment!', + 'profile:comment: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.", /** * Profile error messages diff --git a/mod/profile/profile_lib.php b/mod/profile/profile_lib.php index 7e092c003..993985279 100644 --- a/mod/profile/profile_lib.php +++ b/mod/profile/profile_lib.php @@ -29,7 +29,10 @@ function profile_get_user_profile_html($user, $section = 'activity') { case 'twitter': $body .= elgg_view('profile/profile_contents/twitter', $view_options); break; - + case 'commentwall': + $comments = $user->getAnnotations('commentwall', 200, 0, 'desc'); + $body .= elgg_view('profile/profile_contents/commentwall', array("entity" => $user, "comments" => $comments)); + break; case 'details': $body .= elgg_view('profile/profile_contents/details', $view_options); break; diff --git a/mod/profile/start.php b/mod/profile/start.php index e66554d08..138de1e35 100644 --- a/mod/profile/start.php +++ b/mod/profile/start.php @@ -294,4 +294,6 @@ register_action("profile/iconupload",false,$CONFIG->pluginspath . "profile/actio register_action("profile/cropicon",false,$CONFIG->pluginspath . "profile/actions/cropicon.php"); register_action("profile/editdefault",false,$CONFIG->pluginspath . "profile/actions/editdefault.php", true); register_action("profile/editdefault/delete",false,$CONFIG->pluginspath . "profile/actions/deletedefaultprofileitem.php", true); -register_action("profile/editdefault/reset",false,$CONFIG->pluginspath . "profile/actions/resetdefaultprofile.php", true); \ No newline at end of file +register_action("profile/editdefault/reset",false,$CONFIG->pluginspath . "profile/actions/resetdefaultprofile.php", true); +register_action("profile/addcomment",false,$CONFIG->pluginspath . "profile/actions/addcomment.php"); +register_action("profile/deletecomment",false,$CONFIG->pluginspath . "profile/actions/deletecomment.php"); \ No newline at end of file diff --git a/mod/profile/views/default/profile/commentwall/commentwall.php b/mod/profile/views/default/profile/commentwall/commentwall.php new file mode 100644 index 000000000..9c1ff3fdb --- /dev/null +++ b/mod/profile/views/default/profile/commentwall/commentwall.php @@ -0,0 +1,22 @@ + 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("profile/commentwall/commentwall_content", array('annotation' => $content)); + } + + //close the wrapper div + echo "
"; + +} else { + echo "
" . elgg_echo("profile:commentwall:none") . "
"; +} \ No newline at end of file diff --git a/mod/profile/views/default/profile/commentwall/commentwall_content.php b/mod/profile/views/default/profile/commentwall/commentwall_content.php new file mode 100644 index 000000000..d2a313d93 --- /dev/null +++ b/mod/profile/views/default/profile/commentwall/commentwall_content.php @@ -0,0 +1,32 @@ + +
+ +
+ 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/profile/deletecomment?annotation_id=" . $vars['annotation']->id, + 'text' => elgg_echo('delete'), + 'confirm' => elgg_echo('deleteconfirm'), + )) . "
"; + } //end of can edit if statement + ?> +
+
+
diff --git a/mod/profile/views/default/profile/commentwall/commentwalladd.php b/mod/profile/views/default/profile/commentwall/commentwalladd.php new file mode 100644 index 000000000..0d696b955 --- /dev/null +++ b/mod/profile/views/default/profile/commentwall/commentwalladd.php @@ -0,0 +1,18 @@ + +
+
+ +
+ + + + + + + +
+
diff --git a/mod/profile/views/default/profile/profile_contents/commentwall.php b/mod/profile/views/default/profile/profile_contents/commentwall.php new file mode 100644 index 000000000..c13c16331 --- /dev/null +++ b/mod/profile/views/default/profile/profile_contents/commentwall.php @@ -0,0 +1,13 @@ + +
+ $vars['comments'])); +?> +
\ No newline at end of file diff --git a/mod/profile/views/default/profile/profile_navigation.php b/mod/profile/views/default/profile/profile_navigation.php index c6ba3054a..1c2c782c7 100755 --- a/mod/profile/views/default/profile/profile_navigation.php +++ b/mod/profile/views/default/profile/profile_navigation.php @@ -26,6 +26,10 @@ switch($section){ case 'twitter': $twitter = 'class="selected"'; break; + + case 'commentwall': + $commentwall = 'class="selected"'; + break; case 'activity': default: @@ -39,6 +43,7 @@ switch($section){
  • >Activity
  • >Details
  • >Friends
  • +
  • >Comment Wall
  • twitter){ @@ -50,4 +55,4 @@ switch($section){ echo elgg_view('profilenav/extend', $profile); ?> - + \ No newline at end of file -- cgit v1.2.3