diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 14:58:59 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-03-15 14:58:59 -0300 |
commit | 792f381882a59615e0a7c1c0ee5d1c63d59cb358 (patch) | |
tree | ed9487afb1639d02de7320797d3dc0bfc8651f6e /mod/elgg-favorites/actions | |
parent | 323fdcc59e467e6437aad244c475ed0184c7a020 (diff) | |
parent | 31354451ce2c236c9c963064652c39fe54be4afd (diff) | |
download | elgg-792f381882a59615e0a7c1c0ee5d1c63d59cb358.tar.gz elgg-792f381882a59615e0a7c1c0ee5d1c63d59cb358.tar.bz2 |
Merge commit '31354451ce2c236c9c963064652c39fe54be4afd' as 'mod/elgg-favorites'
Diffstat (limited to 'mod/elgg-favorites/actions')
-rw-r--r-- | mod/elgg-favorites/actions/favorites/add.php | 17 | ||||
-rw-r--r-- | mod/elgg-favorites/actions/favorites/remove.php | 17 |
2 files changed, 34 insertions, 0 deletions
diff --git a/mod/elgg-favorites/actions/favorites/add.php b/mod/elgg-favorites/actions/favorites/add.php new file mode 100644 index 000000000..bee00c291 --- /dev/null +++ b/mod/elgg-favorites/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/mod/elgg-favorites/actions/favorites/remove.php b/mod/elgg-favorites/actions/favorites/remove.php new file mode 100644 index 000000000..1dd771650 --- /dev/null +++ b/mod/elgg-favorites/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']); + } |