mirror of
https://github.com/owncloud/bookmarks.git
synced 2024-12-02 06:24:11 +01:00
Bookmarks: Move delete code to Bookmarks class, also change to use id
This commit is contained in:
parent
7bfe6a7c89
commit
f23ff751b2
@ -30,33 +30,10 @@ $RUNTIME_NOSETUPFS=true;
|
|||||||
OCP\JSON::checkLoggedIn();
|
OCP\JSON::checkLoggedIn();
|
||||||
OCP\JSON::checkAppEnabled('bookmarks');
|
OCP\JSON::checkAppEnabled('bookmarks');
|
||||||
|
|
||||||
$params=array(
|
$id = $_GET['id'];
|
||||||
htmlspecialchars_decode($_GET["url"]),
|
if (!OC_Bookmarks_Bookmarks::deleteUrl($id)){
|
||||||
OCP\USER::getUser()
|
OC_JSON::error();
|
||||||
);
|
exit();
|
||||||
|
}
|
||||||
|
|
||||||
$query = OCP\DB::prepare("
|
OCP\JSON::success();
|
||||||
SELECT id FROM *PREFIX*bookmarks
|
|
||||||
WHERE url LIKE ?
|
|
||||||
AND user_id = ?
|
|
||||||
");
|
|
||||||
|
|
||||||
$id = $query->execute($params)->fetchOne();
|
|
||||||
|
|
||||||
$query = OCP\DB::prepare("
|
|
||||||
DELETE FROM *PREFIX*bookmarks
|
|
||||||
WHERE id = $id
|
|
||||||
");
|
|
||||||
|
|
||||||
$result = $query->execute();
|
|
||||||
|
|
||||||
|
|
||||||
$query = OCP\DB::prepare("
|
|
||||||
DELETE FROM *PREFIX*bookmarks_tags
|
|
||||||
WHERE bookmark_id = $id
|
|
||||||
");
|
|
||||||
|
|
||||||
$result = $query->execute();
|
|
||||||
// var_dump($params);
|
|
||||||
|
|
||||||
OCP\JSON::success(array('data' => array()));
|
|
||||||
|
@ -93,11 +93,13 @@ function delBookmark(event) {
|
|||||||
var record = $(this).parent().parent();
|
var record = $(this).parent().parent();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: OC.filePath('bookmarks', 'ajax', 'delBookmark.php'),
|
url: OC.filePath('bookmarks', 'ajax', 'delBookmark.php'),
|
||||||
data: 'url=' + encodeURIComponent($(this).parent().parent().children('.bookmark_url:first').text()),
|
data: 'id=' + record.data('id'),
|
||||||
success: function(data){
|
success: function(data){
|
||||||
record.remove();
|
if (data.status == 'success') {
|
||||||
if($('.bookmarks_list').is(':empty')) {
|
record.remove();
|
||||||
$("#firstrun").show();
|
if($('.bookmarks_list').is(':empty')) {
|
||||||
|
$("#firstrun").show();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -113,5 +113,37 @@ class OC_Bookmarks_Bookmarks{
|
|||||||
$bookmarks = $query->execute($params)->fetchAll();
|
$bookmarks = $query->execute($params)->fetchAll();
|
||||||
return $bookmarks;
|
return $bookmarks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function deleteUrl($id)
|
||||||
|
{
|
||||||
|
$user = OCP\USER::getUser();
|
||||||
|
|
||||||
|
$query = OCP\DB::prepare("
|
||||||
|
SELECT id FROM *PREFIX*bookmarks
|
||||||
|
WHERE id = ?
|
||||||
|
AND user_id = ?
|
||||||
|
");
|
||||||
|
|
||||||
|
$result = $query->execute(array($id, $user));
|
||||||
|
$id = $result->fetchOne();
|
||||||
|
if ($id === false) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$query = OCP\DB::prepare("
|
||||||
|
DELETE FROM *PREFIX*bookmarks
|
||||||
|
WHERE id = $id
|
||||||
|
");
|
||||||
|
|
||||||
|
$result = $query->execute();
|
||||||
|
|
||||||
|
$query = OCP\DB::prepare("
|
||||||
|
DELETE FROM *PREFIX*bookmarks_tags
|
||||||
|
WHERE bookmark_id = $id
|
||||||
|
");
|
||||||
|
|
||||||
|
$result = $query->execute();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
Loading…
Reference in New Issue
Block a user