diff options
Diffstat (limited to 'mod/bookmarks/actions')
-rw-r--r-- | mod/bookmarks/actions/add.php | 49 | ||||
-rw-r--r-- | mod/bookmarks/actions/bookmarks/add.php | 82 | ||||
-rw-r--r-- | mod/bookmarks/actions/bookmarks/delete.php | 29 | ||||
-rw-r--r--[-rwxr-xr-x] | mod/bookmarks/actions/bookmarks/edit.php (renamed from mod/bookmarks/actions/edit.php) | 0 | ||||
-rw-r--r-- | mod/bookmarks/actions/delete.php | 20 | ||||
-rwxr-xr-x | mod/bookmarks/actions/reference.php | 34 | ||||
-rwxr-xr-x | mod/bookmarks/actions/remove.php | 34 |
7 files changed, 111 insertions, 137 deletions
diff --git a/mod/bookmarks/actions/add.php b/mod/bookmarks/actions/add.php deleted file mode 100644 index b17ce76a4..000000000 --- a/mod/bookmarks/actions/add.php +++ /dev/null @@ -1,49 +0,0 @@ -<?php -/** - * Elgg bookmarks add/save action - * - * @package ElggBookmarks - */ - -//set some required variables -$title = strip_tags(get_input('title')); -$address = get_input('address'); -$notes = get_input('notes'); -$access = get_input('access'); -$tags = get_input('tags'); -$tagarray = string_to_tag_array($tags); - -if (!$title || !$address) { - register_error(elgg_echo('bookmarks:save:failed')); - forward(REFERER); -} - -// don't allow malicious code. -// put this in a context of a link so HTMLawed knows how to filter correctly. -$xss_test = "<a href=\"$address\"></a>"; -if ($xss_test != filter_tags($xss_test)) { - register_error(elgg_echo('bookmarks:save:failed')); - forward(REFERER); -} - -//create a new bookmark object -$entity = new ElggObject; -$entity->subtype = "bookmarks"; -$entity->owner_guid = get_loggedin_userid(); -$entity->container_guid = (int)get_input('container_guid', get_loggedin_userid()); -$entity->title = $title; -$entity->description = $notes; -$entity->address = $address; -$entity->access_id = $access; -$entity->link_version = create_wire_url_code();//returns a random code in the form {{L:1hp56}} -$entity->tags = $tagarray; - -if ($entity->save()) { - system_message(elgg_echo('bookmarks:save:success')); - //add to river - add_to_river('river/object/bookmarks/create','create',get_loggedin_userid(),$entity->guid); -} else { - register_error(elgg_echo('bookmarks:save:failed')); -} -$account = get_entity((int)get_input('container_guid', get_loggedin_userid())); -forward("pg/bookmarks/" . $account->username);
\ No newline at end of file diff --git a/mod/bookmarks/actions/bookmarks/add.php b/mod/bookmarks/actions/bookmarks/add.php new file mode 100644 index 000000000..7d8204ca5 --- /dev/null +++ b/mod/bookmarks/actions/bookmarks/add.php @@ -0,0 +1,82 @@ +<?php +/** +* Elgg bookmarks add/save action +* +* @package ElggBookmarks +*/ + +gatekeeper(); + +$title = strip_tags(get_input('title')); +$guid = get_input('bookmark_guid',0); +$description = get_input('description'); +$address = get_input('address'); +$access = get_input('access'); +$shares = get_input('shares',array()); + +if (!$title || !$address) { + register_error(elgg_echo('bookmarks:save:failed')); + forward(REFERER); +} + +// don't allow malicious code. +// put this in a context of a link so HTMLawed knows how to filter correctly. +$xss_test = "<a href=\"$address\"></a>"; +if ($xss_test != filter_tags($xss_test)) { + register_error(elgg_echo('bookmarks:save:failed')); + forward(REFERER); +} + +$tags = get_input('tags'); +$tagarray = string_to_tag_array($tags); + +$new_bookmark = FALSE; +if ($guid == 0) { + $entity = new ElggObject; + $entity->subtype = "bookmarks"; + $entity->owner_guid = $_SESSION['user']->getGUID(); + $entity->container_guid = (int)get_input('container_guid', $_SESSION['user']->getGUID()); + + $new_bookmark = TRUE; + +} else { + + $canedit = false; + if ($entity = get_entity($guid)) { + if ($entity->canEdit()) { + $canedit = true; + } + } + if (!$canedit) { + system_message(elgg_echo('notfound')); + forward("pg/bookmarks"); + } + +} + +$entity->title = $title; +$entity->address = $address; +$entity->description = $description; +$entity->access_id = $access; +$entity->tags = $tagarray; + +if ($entity->save()) { + $entity->clearRelationships(); + $entity->shares = $shares; + + if (is_array($shares) && sizeof($shares) > 0) { + foreach($shares as $share) { + $share = (int) $share; + add_entity_relationship($entity->getGUID(), 'share', $share); + } + } + system_message(elgg_echo('bookmarks:save:success')); + //add to river + if ($new_bookmark) { + add_to_river('river/object/bookmarks/create','create',$_SESSION['user']->guid,$entity->guid); + } + forward($entity->getURL()); +} else { + register_error(elgg_echo('bookmarks:save:failed')); + forward("pg/bookmarks"); +} diff --git a/mod/bookmarks/actions/bookmarks/delete.php b/mod/bookmarks/actions/bookmarks/delete.php new file mode 100644 index 000000000..48b4a2dd8 --- /dev/null +++ b/mod/bookmarks/actions/bookmarks/delete.php @@ -0,0 +1,29 @@ +<?php + + /** + * Elgg bookmarks delete action + * + * @package ElggBookmarks + */ + + $guid = get_input('bookmark_guid',0); + if ($entity = get_entity($guid)) { + + $container = get_entity($entity->container_guid); + if ($entity->canEdit()) { + + if ($entity->delete()) { + + system_message(elgg_echo("bookmarks:delete:success")); + forward("pg/bookmarks/owner/$container->username/"); + + } + + } + + } + + register_error(elgg_echo("bookmarks:delete:failed")); + forward(REFERER); + +?>
\ No newline at end of file diff --git a/mod/bookmarks/actions/edit.php b/mod/bookmarks/actions/bookmarks/edit.php index 87de1c5e2..87de1c5e2 100755..100644 --- a/mod/bookmarks/actions/edit.php +++ b/mod/bookmarks/actions/bookmarks/edit.php diff --git a/mod/bookmarks/actions/delete.php b/mod/bookmarks/actions/delete.php deleted file mode 100644 index 23de80146..000000000 --- a/mod/bookmarks/actions/delete.php +++ /dev/null @@ -1,20 +0,0 @@ -<?php -/** - * Elgg bookmarks delete action - * - * @package ElggBookmarks - */ - -$guid = get_input('bookmark_guid',0); -if ($entity = get_entity($guid)) { - if ($entity->canEdit()) { - $container = get_entity($entity->container_guid); - if ($entity->delete()) { - system_message(elgg_echo("bookmarks:delete:success")); - forward("pg/bookmarks/$container->username/"); - } - } -} - -register_error(elgg_echo("bookmarks:delete:failed")); -forward(REFERER);
\ No newline at end of file diff --git a/mod/bookmarks/actions/reference.php b/mod/bookmarks/actions/reference.php deleted file mode 100755 index 515ac1ed1..000000000 --- a/mod/bookmarks/actions/reference.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -/** - * Elgg bookmarks add as reference - * Guid one is the object, guid two is the bookmark, 'reference' is the relationship name - */ - -//set some variables -$object_guid = get_input('object_guid'); -$bookmark_guid = get_input('reference'); -$object = get_entity($object_guid); -$bookmark = get_entity($bookmark_guid); -//check both the object and bookmark exist -if($bookmark && $object){ - //check the user can add a reference - if($object->canEdit()){ - //create a relationship between the object and bookmark - if(add_entity_relationship($object_guid, "reference", $bookmark_guid)){ - // Success message - system_message(elgg_echo("bookmarks:referenceadded")); - }else{ - // Failure message - system_message(elgg_echo("bookmarks:referenceerror")); - } - }else{ - // Failure message - system_message(elgg_echo("bookmarks:referenceerror")); - } -}else{ - // Failure message - system_message(elgg_echo("bookmarks:referenceerror")); -} - -forward($object->getURL());
\ No newline at end of file diff --git a/mod/bookmarks/actions/remove.php b/mod/bookmarks/actions/remove.php deleted file mode 100755 index f704a5cc3..000000000 --- a/mod/bookmarks/actions/remove.php +++ /dev/null @@ -1,34 +0,0 @@ -<?php - -/** - * Elgg bookmarks remove a reference - * Guid one is the object, guid two is the bookmark, 'reference' is the relationship name - */ - -//set some variables -$object_guid = get_input('object_guid'); -$bookmark_guid = get_input('bookmark'); -$object = get_entity($object_guid); -$bookmark = get_entity($bookmark_guid); -//check both the object and bookmark exist -if($bookmark && $object){ - //check the user can add a reference - if($object->canEdit()){ - //remove the relationship between the object and bookmark - if(remove_entity_relationship($object_guid, "reference", $bookmark_guid)){ - // Success message - system_message(elgg_echo("bookmarks:removed")); - }else{ - // Failure message - system_message(elgg_echo("bookmarks:removederror")); - } - }else{ - // Failure message - system_message(elgg_echo("bookmarks:removederror")); - } -}else{ - // Failure message - system_message(elgg_echo("bookmarks:removederror")); -} - -forward($object->getURL());
\ No newline at end of file |