diff options
author | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-07-16 09:36:07 +0000 |
---|---|---|
committer | marcus <marcus@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2008-07-16 09:36:07 +0000 |
commit | d8d9ce784ba2a05776f194b7923dafd02ccd6391 (patch) | |
tree | 0e345377b99d7a57e8a536d2deb091c064419483 | |
parent | 0ad7f6660c247e1eead0e651f4da73db762e2d2a (diff) | |
download | elgg-d8d9ce784ba2a05776f194b7923dafd02ccd6391.tar.gz elgg-d8d9ce784ba2a05776f194b7923dafd02ccd6391.tar.bz2 |
Closes #116: Groups join clears invite flags
http://trac.elgg.org/elgg/ticket/116
git-svn-id: https://code.elgg.org/elgg/trunk@1434 36083f99-b078-4883-b0ff-0f9b5a30f544
-rw-r--r-- | engine/lib/metadata.php | 17 | ||||
-rw-r--r-- | mod/groups/actions/join.php | 4 |
2 files changed, 16 insertions, 5 deletions
diff --git a/engine/lib/metadata.php b/engine/lib/metadata.php index 1a8c58a2e..52c01c5e8 100644 --- a/engine/lib/metadata.php +++ b/engine/lib/metadata.php @@ -150,18 +150,25 @@ } /**
- * Removes metadata on an entity with a particular name
+ * Removes metadata on an entity with a particular name, optionally with a given value.
*
* @param int $entity_guid The entity GUID
- * @param string $name The name of the entity
+ * @param string $name The name of the metadata + * @param string $value The optional value of the item (useful for removing a single item in a multiple set)
* @return true|false Depending on success
*/
- function remove_metadata($entity_guid, $name) {
+ function remove_metadata($entity_guid, $name, $value = "") {
global $CONFIG;
$entity_guid = (int) $entity_guid;
- $name = sanitise_string(trim($name));
- if ($existing = get_data("SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_guid = $entity_guid and name_id=" . add_metastring($name))) {
+ $name = sanitise_string($name); + $value = sanitise_string($value); + + $query = "SELECT * from {$CONFIG->dbprefix}metadata WHERE entity_guid = $entity_guid and name_id=" . add_metastring($name); + if ($value!="") + $query .= " and value_id=" . add_metastring($value); +
+ if ($existing = get_data($query)) {
foreach($existing as $ex)
delete_metadata($ex->id);
return true;
diff --git a/mod/groups/actions/join.php b/mod/groups/actions/join.php index 639ed14da..bf6e95482 100644 --- a/mod/groups/actions/join.php +++ b/mod/groups/actions/join.php @@ -32,6 +32,10 @@ { system_message(elgg_echo("groups:joined")); + // Remove any invite or join request flags + remove_metadata($user->guid, 'group_invite', $group->guid); + remove_metadata($user->guid, 'group_join_request', $group->guid); + forward($group->getURL()); exit; } |