diff --git a/docs/CHANGES.txt b/docs/CHANGES.txt index ecd1cee8..75aafd58 100644 --- a/docs/CHANGES.txt +++ b/docs/CHANGES.txt @@ -1,5 +1,8 @@ CHANGELOG +2013-08-08 by Squiffy +Drag and Drop ordering on the Do Not Upload page in toolbox + 2013-08-05 by Ajax Search email blacklist diff --git a/gazelle.sql b/gazelle.sql index 121003bd..1db66f73 100644 --- a/gazelle.sql +++ b/gazelle.sql @@ -252,6 +252,7 @@ CREATE TABLE `do_not_upload` ( `Comment` varchar(255) COLLATE utf8_bin NOT NULL, `UserID` int(10) NOT NULL, `Time` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `Sequence` mediumint(8) NOT NULL, PRIMARY KEY (`ID`), KEY `Time` (`Time`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin; diff --git a/sections/tools/managers/dnu_alter.php b/sections/tools/managers/dnu_alter.php index b3eb4d92..31eb0b87 100644 --- a/sections/tools/managers/dnu_alter.php +++ b/sections/tools/managers/dnu_alter.php @@ -5,7 +5,14 @@ authorize(); -if ($_POST['submit'] == 'Delete') { //Delete +if($_POST['submit'] == 'Reorder') { // Reorder + foreach ($_POST['item'] as $Position => $Item) { + $Position = db_string($Position); + $Item = db_string($Item); + $DB->query('UPDATE `do_not_upload` SET `Sequence` = ' . $Position . ' WHERE `id` = '. $Item); + } + +} else if ($_POST['submit'] == 'Delete') { //Delete if (!is_number($_POST['id']) || $_POST['id'] == '') { error(0); } @@ -38,9 +45,9 @@ } else { //Create $DB->query(" INSERT INTO do_not_upload - (Name, Comment, UserID, Time) + (Name, Comment, UserID, Time, Sequence) VALUES - ('$P[name]','$P[comment]','$LoggedUser[ID]','".sqltime()."')"); + ('$P[name]','$P[comment]','$LoggedUser[ID]','".sqltime()."', 9999)"); } } diff --git a/sections/tools/managers/dnu_list.php b/sections/tools/managers/dnu_list.php index 5e642a78..6464e4fa 100644 --- a/sections/tools/managers/dnu_list.php +++ b/sections/tools/managers/dnu_list.php @@ -4,68 +4,71 @@ } $Title = 'Manage the "Do Not Upload" list'; -View::show_header($Title); +View::show_header($Title, 'jquery-ui,dnu_list'); $DB->query(" - SELECT - d.ID, - d.Name, - d.Comment, - d.UserID, - d.Time - FROM do_not_upload as d - LEFT JOIN users_main AS um ON um.ID=d.UserID - ORDER BY d.Time DESC"); -?> -
-

-
- - - - - - - - - - - - - - - - - - - -next_record()) { ?> - - - + + + + + + + + + + + + next_record()) { ?> + + + + + + + + + + +
Add an entry to the "Do Not Upload" list
- - - - - -
NameCommentAddedSubmit
+ SELECT + d.ID, + d.Name, + d.Comment, + d.UserID, + d.Time + FROM do_not_upload as d + LEFT JOIN users_main AS um ON um.ID=d.UserID + ORDER BY d.Sequence"); + ?> +
+

+

Drag and drop table rows to reorder.

+
+ + + + + + - - - - - - - - - -
Add an entry to the "Do Not Upload" list
- - -
- -
- - -
- +
+ + + + + +
NameCommentAddedSubmit
+ + + + + + + +
+ +
+ + +
+ diff --git a/sections/upload/upload.php b/sections/upload/upload.php index f4078d9a..1a28c9e3 100644 --- a/sections/upload/upload.php +++ b/sections/upload/upload.php @@ -99,7 +99,7 @@ d.Comment, d.Time FROM do_not_upload as d - ORDER BY d.Time DESC'); + ORDER BY d.Sequence'); $DNU = $DB->to_array(); list($Name, $Comment, $Updated) = reset($DNU); reset($DNU); diff --git a/static/functions/dnu_list.js b/static/functions/dnu_list.js new file mode 100644 index 00000000..32dc6245 --- /dev/null +++ b/static/functions/dnu_list.js @@ -0,0 +1,25 @@ +jQuery(document).ready(function ($) { + // Helper function to preserve table cell dimentions + var fixDimentions = function (unused, elements) { + // Iterate through each table cell and correct width + elements.children().each(function () { + $(this).width($(this).width()); + }); + return elements; + }; + // Make table sortable + $('#dnu tbody').sortable({ + helper: fixDimentions, + cancel: 'input, .colhead, .rowa', + update: function (event, ui) { + var post = $(this).sortable('serialize'); + request = $.ajax({ + url: 'tools.php', + type: "post", + data: 'action=dnu_alter&auth=' + authkey + '&' + post + '&submit=Reorder' + }); + request.done(function (response, textStatus, jqXHR) { + }); + } + }); +}); \ No newline at end of file