aboutsummaryrefslogtreecommitdiff
path: root/actions/favorites
diff options
context:
space:
mode:
Diffstat (limited to 'actions/favorites')
-rw-r--r--actions/favorites/add.php17
-rw-r--r--actions/favorites/remove.php17
2 files changed, 34 insertions, 0 deletions
diff --git a/actions/favorites/add.php b/actions/favorites/add.php
new file mode 100644
index 000000000..bee00c291
--- /dev/null
+++ b/actions/favorites/add.php
@@ -0,0 +1,17 @@
+<?php
+ $entity_guid = (int) get_input('guid');
+ $user_guid = elgg_get_logged_in_user_guid();
+ if (($entity_guid > 0) &&
+ ($user_guid > 0) &&
+ !check_entity_relationship($user_guid ,'flags_content', $entity_guid)) {
+ if (add_entity_relationship($user_guid ,'flags_content', $entity_guid)) {
+ // elgg_dump("Notice: Added flag relationship between $user_guid and $entity_guid. ", FALSE, 'NOTICE');
+ system_message(elgg_echo('favorites:added'));
+ } else {
+ // elgg_dump("Could not add flag / fav relation between $user_guid and $entity_guid.", FALSE, 'WARN');
+ register_error(elgg_echo('favorites:addfailed'));
+ }
+ }
+ if (!elgg_is_xhr()) {
+ forward($_SERVER['HTTP_REFERER']);
+ }
diff --git a/actions/favorites/remove.php b/actions/favorites/remove.php
new file mode 100644
index 000000000..1dd771650
--- /dev/null
+++ b/actions/favorites/remove.php
@@ -0,0 +1,17 @@
+<?php
+ $entity_guid = (int) get_input('guid');
+ $user_guid = elgg_get_logged_in_user_guid();
+ if (($entity_guid > 0) &&
+ ($user_guid > 0) &&
+ check_entity_relationship($user_guid ,'flags_content', $entity_guid)) {
+ if (remove_entity_relationship($user_guid ,'flags_content', $entity_guid)) {
+ // elgg_dump("Notice: Removed flag relationship between $user_guid and $entity_guid. ", FALSE, 'NOTICE');
+ system_message(elgg_echo('favorites:removed'));
+ } else {
+ // elgg_dump("Could not add flag / fav relation between $user_guid and $entity_guid.", FALSE, 'WARN');
+ register_error(elgg_echo('favorites:removefailed'));
+ }
+ }
+ if (!elgg_is_xhr()) {
+ forward($_SERVER['HTTP_REFERER']);
+ }