aboutsummaryrefslogtreecommitdiff
path: root/views/default
diff options
context:
space:
mode:
authorbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-18 22:11:16 +0000
committerbrettp <brettp@36083f99-b078-4883-b0ff-0f9b5a30f544>2011-02-18 22:11:16 +0000
commit3ae21bb4b8bb1ea13a06e244e2079ceb75431290 (patch)
treea06af9504db24ddbdc35ed0a5c2ad8f64faf4c6e /views/default
parent61a79f7b874a28ec22c40a2c990f5b9b4d4ffa7f (diff)
downloadelgg-3ae21bb4b8bb1ea13a06e244e2079ceb75431290.tar.gz
elgg-3ae21bb4b8bb1ea13a06e244e2079ceb75431290.tar.bz2
Fixes #2953: Like button doesn't show up for logged out users.
git-svn-id: http://code.elgg.org/elgg/trunk@8298 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default')
-rw-r--r--views/default/core/likes/display.php54
1 files changed, 28 insertions, 26 deletions
diff --git a/views/default/core/likes/display.php b/views/default/core/likes/display.php
index d00294d2d..4da140693 100644
--- a/views/default/core/likes/display.php
+++ b/views/default/core/likes/display.php
@@ -14,32 +14,34 @@ if (!isset($vars['entity'])) {
$guid = $vars['entity']->getGUID();
// check to see if the user has already liked this
-if (!elgg_annotation_exists($guid, 'likes')) {
- $url = elgg_get_site_url() . "action/likes/add?guid={$guid}";
- $params = array(
- 'href' => $url,
- 'text' => '<span class="elgg-icon elgg-icon-likes"></span>',
- 'title' => elgg_echo('likes:likethis'),
- 'is_action' => true,
- 'encode_text' => false,
- );
- $likes_button = elgg_view('output/url', $params);
-} else {
- $options = array(
- 'guid' => $guid,
- 'annotation_name' => 'likes',
- 'owner_guid' => get_logged_in_user_guid()
- );
- $likes = elgg_get_annotations($options);
- $url = elgg_get_site_url() . "action/likes/delete?annotation_id={$likes[0]->id}";
- $params = array(
- 'href' => $url,
- 'text' => "<span class=\"elgg-icon elgg-icon-liked\"></span>",
- 'title' => elgg_echo('likes:remove'),
- 'is_action' => true,
- 'encode_text' => false,
- );
- $likes_button = elgg_view('output/url', $params);
+if (elgg_is_logged_in()) {
+ if (!elgg_annotation_exists($guid, 'likes')) {
+ $url = elgg_get_site_url() . "action/likes/add?guid={$guid}";
+ $params = array(
+ 'href' => $url,
+ 'text' => '<span class="elgg-icon elgg-icon-likes"></span>',
+ 'title' => elgg_echo('likes:likethis'),
+ 'is_action' => true,
+ 'encode_text' => false,
+ );
+ $likes_button = elgg_view('output/url', $params);
+ } else {
+ $options = array(
+ 'guid' => $guid,
+ 'annotation_name' => 'likes',
+ 'owner_guid' => get_logged_in_user_guid()
+ );
+ $likes = elgg_get_annotations($options);
+ $url = elgg_get_site_url() . "action/likes/delete?annotation_id={$likes[0]->id}";
+ $params = array(
+ 'href' => $url,
+ 'text' => "<span class=\"elgg-icon elgg-icon-liked\"></span>",
+ 'title' => elgg_echo('likes:remove'),
+ 'is_action' => true,
+ 'encode_text' => false,
+ );
+ $likes_button = elgg_view('output/url', $params);
+ }
}
$list = '';