Skip to content
This repository has been archived by the owner on Jun 2, 2023. It is now read-only.

Commit

Permalink
Fixed deprecated code, and fixed the commentwall
Browse files Browse the repository at this point in the history
  • Loading branch information
jrtilson committed Jan 11, 2012
1 parent 8f136ec commit 3da7bef
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 48 deletions.
14 changes: 7 additions & 7 deletions actions/commentwall/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@
if ($user && !empty($message)) {

// If posting the comment was successful, say so
if ($user->annotate('commentwall', $message, ACCESS_PUBLIC, get_loggedin_userid())) {
if ($user->annotate('commentwall', $message, ACCESS_PUBLIC, elgg_get_logged_in_user_guid())) {

if ($profile_guid != get_loggedin_userid()) {
if ($profile_guid != elgg_get_logged_in_user_guid()) {
notify_user(
$profile_guid,
get_loggedin_userid(),
elgg_get_logged_in_user_guid(),
elgg_echo('profile:comment:subject'),
elgg_echo('profile:comment:body', array(
get_loggedin_user()->name,
elgg_get_logged_in_user_entity()->name,
$message,
$user->getURL(),
get_loggedin_user()->name,
get_loggedin_user()->getURL()
elgg_get_logged_in_user_entity()->name,
elgg_get_logged_in_user_entity()->getURL()
))
);
}
Expand All @@ -33,7 +33,7 @@
add_to_river(
'river/object/profile/commentwall/create',
'commentwall',
get_loggedin_userid(),
elgg_get_logged_in_user_guid(),
$profile_guid);
} else {
register_error(elgg_echo("profile:commentwall:failure"));
Expand Down
4 changes: 2 additions & 2 deletions actions/commentwall/delete.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
* Delete wall comment
*/

$annotation_id = (int) get_input('id');
$annotation_id = (int)get_input('annotation_id');

$comment = get_annotation($annotation_id);
$comment = elgg_get_annotation_from_id($annotation_id);
if ($comment && $comment->canEdit()) {
$comment->delete();
system_message(elgg_echo('profile:commentwall:deleted'));
Expand Down
28 changes: 28 additions & 0 deletions start.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ function tabbed_profile_init() {
elgg_register_action("commentwall/add", "$action_base/add.php");
elgg_register_action("commentwall/delete", "$action_base/delete.php");

// Register a menu handler for commentwall annotations
elgg_register_plugin_hook_handler('register', 'menu:annotation', 'tabbed_profile_annotation_menu_setup');

// allow ECML in parts of the profile
elgg_register_plugin_hook_handler('get_views', 'ecml', 'tabbed_profile_ecml_views_hook');
}
Expand Down Expand Up @@ -135,3 +138,28 @@ function tabbed_profile_ecml_views_hook($hook, $entity_type, $return_value, $par

return $return_value;
}

/**
* Adds a delete link to "commentwall" annotations
* @access private
*/
function tabbed_profile_annotation_menu_setup($hook, $type, $return, $params) {
$annotation = $params['annotation'];

if ($annotation->name == 'commentwall' && $annotation->canEdit()) {
$url = elgg_http_add_url_query_elements('action/commentwall/delete', array(
'annotation_id' => $annotation->id,
));

$options = array(
'name' => 'delete',
'href' => $url,
'text' => "<span class=\"elgg-icon elgg-icon-delete\"></span>",
'confirm' => elgg_echo('deleteconfirm'),
'encode_text' => false
);
$return[] = ElggMenuItem::factory($options);
}

return $return;
}
41 changes: 5 additions & 36 deletions views/default/annotation/commentwall.php
Original file line number Diff line number Diff line change
@@ -1,41 +1,10 @@
<?php
/**
* Comment wall annotation view
* Elgg commentwall annotation view
* - Just outputs the regular generic_comment view for consistency
*
* @uses $vars['annotation']
* @uses $vars['annotation'] ElggAnnotation object
* @uses $vars['full_view'] Display fill view or brief view
*/

$annotation = $vars['annotation'];
$poster = $annotation->getOwnerEntity();
$date = elgg_view_friendly_time($annotation->time_created);

$icon = elgg_view('profile/icon', array(
'entity' => $poster,
'size' => 'tiny',
));

$delete_url = "action/commentwall/delete?id=$annotation->id";
$delete_link = elgg_view('output/confirmlink', array(
'href' => $delete_url,
'text' => '<span class="elgg-icon elgg-icon-delete"></span>',
'title' => elgg_echo('delete'),
'confirm' => elgg_echo('deleteconfirm'),
'text_encode' => false,
));

$metadata = <<<HTML
<ul class="elgg-list-metadata">
<li>$delete_link</li>
</ul>
HTML;

$subtext = "$poster->name $date";
$content = elgg_view('output/longtext', array('value' => $annotation->value));

$body = <<<HTML
$metadata
<p class="elgg-subtext">$subtext</p>
$content
HTML;

echo elgg_view_image_block($icon, $body);
echo elgg_view('annotation/generic_comment', $vars);
4 changes: 2 additions & 2 deletions views/default/forms/commentwall/add.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@

echo '<div class="clearfix">';

echo elgg_view('input/plaintext', array('internalname' => 'message'));
echo elgg_view('input/plaintext', array('name' => 'message'));

echo elgg_view('input/hidden', array(
'internalname' => 'profile_guid',
'name' => 'profile_guid',
'value' => elgg_get_page_owner_guid(),
));

Expand Down
2 changes: 1 addition & 1 deletion views/default/profile/owner_block.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
return TRUE;
}

$icon = elgg_view_entity_icon($user, 'large', array('override' => 'true'));
$icon = elgg_view_entity_icon($user, 'large', array('user_hover' => TRUE));

// grab the actions and admin menu items from user hover
$menu = elgg_trigger_plugin_hook('register', "menu:user_hover", array('entity' => $user), array());
Expand Down

0 comments on commit 3da7bef

Please sign in to comment.