aboutsummaryrefslogtreecommitdiff
path: root/views/default/favorites/button.php
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-15 14:58:59 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-15 14:58:59 -0300
commit31354451ce2c236c9c963064652c39fe54be4afd (patch)
tree6203d2ba3f7e29518291e2e3999d9fa89892b417 /views/default/favorites/button.php
downloadelgg-31354451ce2c236c9c963064652c39fe54be4afd.tar.gz
elgg-31354451ce2c236c9c963064652c39fe54be4afd.tar.bz2
Squashed 'mod/elgg-favorites/' content from commit d96e69b
git-subtree-dir: mod/elgg-favorites git-subtree-split: d96e69bd1365c3e3c4d998e72d9941ea1ea2278b
Diffstat (limited to 'views/default/favorites/button.php')
-rw-r--r--views/default/favorites/button.php46
1 files changed, 46 insertions, 0 deletions
diff --git a/views/default/favorites/button.php b/views/default/favorites/button.php
new file mode 100644
index 000000000..bc355d595
--- /dev/null
+++ b/views/default/favorites/button.php
@@ -0,0 +1,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;