From: Andrew Dolgov Date: Sun, 31 Mar 2013 13:15:23 +0000 (+0400) Subject: implement filter drag and drop sorting X-Git-Tag: 1.7.6~97 X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=a86ba0a67a83547e83335a619b1c2b5bf3355093;p=tt-rss.git implement filter drag and drop sorting --- diff --git a/classes/pref/filters.php b/classes/pref/filters.php index a64333f7..6ccff51d 100644 --- a/classes/pref/filters.php +++ b/classes/pref/filters.php @@ -3,11 +3,47 @@ class Pref_Filters extends Handler_Protected { function csrf_ignore($method) { $csrf_ignored = array("index", "getfiltertree", "edit", "newfilter", "newrule", - "newaction"); + "newaction", "savefilterorder"); return array_search($method, $csrf_ignored) !== false; } + function filtersortreset() { + db_query($this->link, "UPDATE ttrss_filters2 + SET order_id = 0 WHERE owner_uid = " . $_SESSION["uid"]); + return; + } + + function savefilterorder() { + $data = json_decode($_POST['payload'], true); + + #file_put_contents("/tmp/saveorder.json", $_POST['payload']); + #$data = json_decode(file_get_contents("/tmp/saveorder.json"), true); + + if (!is_array($data['items'])) + $data['items'] = json_decode($data['items'], true); + + $index = 0; + + if (is_array($data) && is_array($data['items'])) { + foreach ($data['items'][0]['items'] as $item) { + $filter_id = (int) str_replace("FILTER:", "", $item['_reference']); + + if ($filter_id > 0) { + + db_query($this->link, "UPDATE ttrss_filters2 SET + order_id = $index WHERE id = '$filter_id' AND + owner_uid = " .$_SESSION["uid"]); + + ++$index; + } + } + } + + return; + } + + function testFilter() { $filter = array(); @@ -623,6 +659,10 @@ class Pref_Filters extends Handler_Protected { print " "; + print " "; + + print " "; @@ -639,14 +679,16 @@ class Pref_Filters extends Handler_Protected { ". __("Loading, please wait...").""; - print "