]> gitweb.fluxo.info Git - lorea/elgg.git/commitdiff
simple comment wall added to profiles
authordave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 29 Mar 2010 13:12:24 +0000 (13:12 +0000)
committerdave <dave@36083f99-b078-4883-b0ff-0f9b5a30f544>
Mon, 29 Mar 2010 13:12:24 +0000 (13:12 +0000)
git-svn-id: http://code.elgg.org/elgg/trunk@5537 36083f99-b078-4883-b0ff-0f9b5a30f544

mod/profile/actions/addcomment.php [new file with mode: 0644]
mod/profile/actions/deletecomment.php [new file with mode: 0644]
mod/profile/languages/en.php
mod/profile/profile_lib.php
mod/profile/start.php
mod/profile/views/default/profile/commentwall/commentwall.php [new file with mode: 0644]
mod/profile/views/default/profile/commentwall/commentwall_content.php [new file with mode: 0644]
mod/profile/views/default/profile/commentwall/commentwalladd.php [new file with mode: 0644]
mod/profile/views/default/profile/profile_contents/commentwall.php [new file with mode: 0644]
mod/profile/views/default/profile/profile_navigation.php

diff --git a/mod/profile/actions/addcomment.php b/mod/profile/actions/addcomment.php
new file mode 100644 (file)
index 0000000..b5c5e07
--- /dev/null
@@ -0,0 +1,48 @@
+<?php\r
+/**\r
+ * Elgg profile commentwall: add message action\r
+ */\r
+\r
+// Make sure we're logged in; forward to the front page if not\r
+if (!isloggedin()) forward();\r
+       \r
+// Get input\r
+$message_content = get_input('message_content'); // the actual message\r
+$page_owner = get_input("pageOwner"); // the message board owner\r
+$message_owner = get_input("guid"); // the user posting the message\r
+$user = get_entity($page_owner); // the commentwall owner details\r
+               \r
+// Let's see if we can get a user entity from the specified page_owner\r
+if ($user && !empty($message_content)) {\r
+               \r
+       // If posting the comment was successful, say so\r
+       if ($user->annotate('commentwall',$message_content,$user->access_id, $_SESSION['user']->getGUID())) {\r
+                               \r
+                       global $CONFIG;\r
+                               \r
+                       if ($user->getGUID() != $_SESSION['user']->getGUID())\r
+                       notify_user($user->getGUID(), $_SESSION['user']->getGUID(), elgg_echo('profile:comment:subject'), \r
+                       sprintf(\r
+                                                       elgg_echo('profile:comment:body'),\r
+                                                       $_SESSION['user']->name,\r
+                                                       $message_content,\r
+                                                       $CONFIG->wwwroot . "pg/profile/" . $user->username,\r
+                                                       $_SESSION['user']->name,\r
+                                                       $_SESSION['user']->getURL()\r
+                                               )\r
+                       ); \r
+                                       \r
+                       system_message(elgg_echo("profile:commentwall:posted"));\r
+                       // add to river\r
+                   add_to_river('river/object/profile/commentwall/create','commentwall',$_SESSION['user']->guid,$user->guid);\r
+                               \r
+       } else {\r
+               register_error(elgg_echo("profile:commentwall:failure"));\r
+       }\r
+               \r
+} else {\r
+       register_error(elgg_echo("profile:commentwall:blank"));\r
+}\r
+               \r
+// Forward back to the messageboard\r
+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 (file)
index 0000000..48399af
--- /dev/null
@@ -0,0 +1,29 @@
+<?php\r
+/**\r
+ * Elgg profile commentwall: delete message action\r
+ */\r
+\r
+// Ensure we're logged in\r
+if (!isloggedin()) forward();\r
+               \r
+// Make sure we can get the comment in question\r
+$annotation_id = (int) get_input('annotation_id');\r
+               \r
+//make sure that there is a message on the commentwall matching the passed id\r
+if ($message = get_annotation($annotation_id)) {\r
+       //grab the user or group entity\r
+       $entity = get_entity($message->entity_guid);\r
+   //check to make sure the current user can actually edit the commentwall\r
+       if ($message->canEdit()) {\r
+                       //delete the comment\r
+                       $message->delete();\r
+                       //display message\r
+                       system_message(elgg_echo("profile:commentwall:deleted"));\r
+                       forward($_SERVER['HTTP_REFERER']);\r
+       }\r
+               \r
+} else {\r
+       system_message(elgg_echo("profile:commentwall:notdeleted"));\r
+}\r
+               \r
+forward($_SERVER['HTTP_REFERER']);
\ No newline at end of file
index ee1c20115c659c2667d8ceed3cd18340c304bb66..bb4230070e83e58240c50250bd3707948b36455b 100644 (file)
@@ -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
index 7e092c003fac815b0d2390eb51d3f3e8e78dd65c..993985279559c7244c14c625ca97bbeee31d596d 100644 (file)
@@ -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;
index e66554d08f44f92ca695fe6c9a6336f661181fa0..138de1e357e2196b41397da8d51b7d174d740d06 100644 (file)
@@ -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 (file)
index 0000000..9c1ff3f
--- /dev/null
@@ -0,0 +1,22 @@
+<?php\r
+/**\r
+ * Elgg Commentwall display page\r
+ */\r
+        \r
+// If there is any content to view, view it\r
+if (is_array($vars['annotation']) && sizeof($vars['annotation']) > 0) {\r
+               \r
+       //start the div which will wrap all the message board contents\r
+       echo "<div id=\"messageboard_wrapper\">";\r
+                       \r
+       //loop through all annotations and display\r
+       foreach($vars['annotation'] as $content) {\r
+               echo elgg_view("profile/commentwall/commentwall_content", array('annotation' => $content));\r
+       }\r
+                       \r
+       //close the wrapper div\r
+       echo "</div>";\r
+                       \r
+} else {\r
+       echo "<div class='ContentWrapper'>" . elgg_echo("profile:commentwall:none") . "</div>";\r
+}
\ 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 (file)
index 0000000..d2a313d
--- /dev/null
@@ -0,0 +1,32 @@
+<?php\r
+/**\r
+* Elgg Message board individual item display page\r
+ */\r
+?>\r
+<div class="messageboard"><!-- start of messageboard div -->\r
+    <!-- display the user icon of the user that posted the message -->\r
+    <div class="message_sender">               \r
+        <?php\r
+            echo elgg_view("profile/icon",array('entity' => get_entity($vars['annotation']->owner_guid), 'size' => 'tiny'));\r
+        ?>\r
+    </div>\r
+    <!-- display the user's name who posted and the date/time -->\r
+    <p class="message_item_timestamp">\r
+        <?php echo get_entity($vars['annotation']->owner_guid)->name . " " . friendly_time($vars['annotation']->time_created); ?>\r
+    </p>       \r
+       <!-- output the actual comment -->\r
+       <div class="message"><?php echo elgg_view("output/longtext",array("value" => parse_urls($vars['annotation']->value))); ?></div>\r
+       <div class="message_buttons">  \r
+       <?php\r
+        // if the user looking at the comment can edit, show the delete link\r
+           if ($vars['annotation']->canEdit()) {\r
+                              echo "<div class='delete_message'>" . elgg_view("output/confirmlink",array(\r
+                                                       'href' => $vars['url'] . "action/profile/deletecomment?annotation_id=" . $vars['annotation']->id,\r
+                                                               'text' => elgg_echo('delete'),\r
+                                                               'confirm' => elgg_echo('deleteconfirm'),\r
+                                                       )) . "</div>";\r
+           } //end of can edit if statement\r
+       ?>\r
+       </div>\r
+<div class="clearfloat"></div>\r
+</div><!-- end of messageboard div -->\r
diff --git a/mod/profile/views/default/profile/commentwall/commentwalladd.php b/mod/profile/views/default/profile/commentwall/commentwalladd.php
new file mode 100644 (file)
index 0000000..0d696b9
--- /dev/null
@@ -0,0 +1,18 @@
+<?php\r
+/**\r
+ * Elgg profile comment wall add\r
+ */ \r
+?>\r
+<div id="mb_input_wrapper">\r
+<form action="<?php echo $vars['url']; ?>action/profile/addcomment" method="post" name="messageboardForm">\r
+    <!-- textarea for the contents -->\r
+    <textarea name="message_content" value="" class="commentwall" style="width:500px;height:20px;"></textarea><br />\r
+    <!-- the person posting an item on the message board -->\r
+    <input type="hidden" name="guid" value="<?php echo $_SESSION['guid']; ?>"  />\r
+    <!-- the page owner, this will be the profile owner -->\r
+    <input type="hidden" name="pageOwner" value="<?php echo page_owner(); ?>"  />\r
+    <?php echo elgg_view('input/securitytoken'); ?>\r
+    <!-- submit messages input -->\r
+    <input type="submit" id="postit" value="<?php echo elgg_echo('profile:commentwall:add'); ?>">\r
+</form>\r
+</div>\r
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 (file)
index 0000000..c13c163
--- /dev/null
@@ -0,0 +1,13 @@
+<?php\r
+/**\r
+ * Elgg profile comment wall\r
+ */\r
+?>\r
+<div id="profile_content">\r
+<?php\r
+if(isloggedin()){\r
+       echo elgg_view("profile/commentwall/commentwalladd");\r
+}\r
+echo elgg_view("profile/commentwall/commentwall", array('annotation' => $vars['comments']));\r
+?>\r
+</div>
\ No newline at end of file
index c6ba3054a9120af705013b9840a00fca695212eb..1c2c782c7467e678359e81aa100710d2b09769e0 100755 (executable)
@@ -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