1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
<?php
/**
* Elgg Lorea Favorites Plugin
*
* @package ElggFavorites
*/
if (!isset($vars['entity'])) {
return true;
}
if (!elgg_is_logged_in()) {
return true;
}
$fav_entity_guid = $vars['entity']->getGUID();
$fav_user_guid = elgg_get_logged_in_user_guid();
if (!check_entity_relationship($fav_user_guid ,'flags_content', $fav_entity_guid)) {
$fav_url = elgg_get_site_url() . "action/favorites/add/?guid={$fav_entity_guid}";
$fav_params = array(
'href' => $fav_url,
'text' => elgg_view_icon('star-empty'),
'title' => elgg_echo('favorites:add'),
'class' => 'favorites-add',
'is_action' => true,
'is_trusted' => true,
);
$fav_button = elgg_view('output/url', $fav_params);
} else {
$fav_url = elgg_get_site_url() . "action/favorites/remove/?guid={$fav_entity_guid}";
$fav_params = array(
'href' => $fav_url,
'text' => elgg_view_icon('star'),
'title' => elgg_echo('favorites:remove'),
'class' => 'favorites-remove',
'is_action' => true,
'is_trusted' => true,
);
$fav_button = elgg_view('output/url', $fav_params);
}
echo $fav_button;
|