diff options
-rw-r--r-- | mod/profile/actions/addcomment.php | 48 | ||||
-rw-r--r-- | mod/profile/actions/deletecomment.php | 29 | ||||
-rw-r--r-- | mod/profile/languages/en.php | 39 | ||||
-rw-r--r-- | mod/profile/profile_lib.php | 5 | ||||
-rw-r--r-- | mod/profile/start.php | 4 | ||||
-rw-r--r-- | mod/profile/views/default/profile/commentwall/commentwall.php | 22 | ||||
-rw-r--r-- | mod/profile/views/default/profile/commentwall/commentwall_content.php | 32 | ||||
-rw-r--r-- | mod/profile/views/default/profile/commentwall/commentwalladd.php | 18 | ||||
-rw-r--r-- | mod/profile/views/default/profile/profile_contents/commentwall.php | 13 | ||||
-rwxr-xr-x | mod/profile/views/default/profile/profile_navigation.php | 7 |
10 files changed, 208 insertions, 9 deletions
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 @@ +<?php
+/**
+ * Elgg profile commentwall: add message action
+ */
+
+// 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 commentwall owner 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('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 @@ +<?php
+/**
+ * Elgg profile commentwall: delete message action
+ */
+
+// 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 commentwall 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 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 @@ <?php /** * Elgg profile plugin language pack - * - * @package ElggProfile - * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2 - * @author Curverider Ltd - * @copyright Curverider Ltd 2008-2010 - * @link http://elgg.com/ */ $english = array( @@ -78,6 +72,39 @@ $english = array( 'profile:saved' => "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 @@ +<?php
+/**
+ * Elgg Commentwall display page
+ */
+
+// 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("profile/commentwall/commentwall_content", array('annotation' => $content));
+ }
+
+ //close the wrapper div
+ echo "</div>";
+
+} else {
+ echo "<div class='ContentWrapper'>" . elgg_echo("profile:commentwall:none") . "</div>";
+}
\ 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 @@ +<?php
+/**
+* Elgg Message board individual item display page
+ */
+?>
+<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/profile/deletecomment?annotation_id=" . $vars['annotation']->id,
+ 'text' => elgg_echo('delete'),
+ 'confirm' => elgg_echo('deleteconfirm'),
+ )) . "</div>";
+ } //end of can edit if statement
+ ?>
+ </div>
+<div class="clearfloat"></div>
+</div><!-- end of messageboard div -->
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 @@ +<?php
+/**
+ * Elgg profile comment wall add
+ */
+?>
+<div id="mb_input_wrapper">
+<form action="<?php echo $vars['url']; ?>action/profile/addcomment" method="post" name="messageboardForm">
+ <!-- textarea for the contents -->
+ <textarea name="message_content" value="" class="commentwall" style="width:500px;height:20px;"></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('profile:commentwall:add'); ?>">
+</form>
+</div>
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 @@ +<?php
+/**
+ * Elgg profile comment wall
+ */
+?>
+<div id="profile_content">
+<?php
+if(isloggedin()){
+ echo elgg_view("profile/commentwall/commentwalladd");
+}
+echo elgg_view("profile/commentwall/commentwall", array('annotation' => $vars['comments']));
+?>
+</div>
\ 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){ <li <?php echo $activity; ?>><a href="<?php echo $url; ?>">Activity</a></li> <li <?php echo $details; ?>><a href="<?php echo $url . 'details'; ?>">Details</a></li> <li <?php echo $friends; ?>><a href="<?php echo $url . 'friends'; ?>">Friends</a></li> + <li <?php echo $commentwall; ?>><a href="<?php echo $url . 'commentwall'; ?>">Comment Wall</a></li> <?php //check to see if the twitter username is set if($vars['entity']->twitter){ @@ -50,4 +55,4 @@ switch($section){ echo elgg_view('profilenav/extend', $profile); ?> </ul> -</div> +</div>
\ No newline at end of file |