1 --- eventum-2.2/htdocs/ajax/order.php 1970-01-01 02:00:00.000000000 +0200
2 +++ eventum-2.2-order/htdocs/ajax/order.php 2009-10-12 22:10:36.429185594 +0300
5 +require_once dirname(__FILE__) . '/../../init.php';
8 +if (!Auth::hasValidCookie(APP_COOKIE)) {
13 +if (!isset($_POST['before']) || !isset($_POST['after'])) {
17 +parse_str($_POST['before'], $before);
18 +parse_str($_POST['after'], $after);
20 +$before = $before['issue_list_table'];
21 +$after = $after['issue_list_table'];
24 +$before = array_slice($before, 2, count($before)-3);
25 +$after = array_slice($after, 2, count($after)-3);
27 +if (count($before) != count($after) or count($before) < 1) {
31 +$usr_id = Auth::getUserID();
33 +$order = Issue::getIssueOrderByUser($usr_id);
35 +if (!count($order)) {
36 + // no prev order list
40 +$after_filterd = array();
41 +$before_filterd = array();
43 +// remove issues that are not assigned to me
44 +foreach ($after as $id) {
45 + if (isset($order[$id])) {
46 + $after_filterd[] = $id;
49 +foreach ($before as $id) {
50 + if (isset($order[$id])) {
51 + $before_filterd[] = $id;
55 +foreach ($after_filterd as $key => $nID) {
56 + if ($nID != $before_filterd[$key]) {
59 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
61 + isu_order = " . $order[$before_filterd[$key]] . "
63 + isu_iss_id = $nID AND
64 + isu_usr_id = $usr_id";
65 + $res = DB_Helper::getInstance()->query($stmt);
66 + if (PEAR::isError($res)) {
67 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
68 + die('update failed');
73 --- eventum-2.2/htdocs/css/style.css~ 2009-10-12 22:27:13.000000000 +0300
74 +++ eventum-2.2/htdocs/css/style.css 2009-10-12 22:28:31.402712101 +0300
81 + background-color: #ffffdd;
84 + border: 1px solid red;
94 + background-image: url(../images/updown2.gif);
95 + background-repeat: no-repeat;
96 + background-position: center center;
98 --- eventum-2.2/htdocs/js/jquery/jquery.tablednd.js 1970-01-01 02:00:00.000000000 +0200
99 +++ eventum-2.2-order/htdocs/js/jquery/jquery.tablednd.js 2009-10-12 22:10:36.435851675 +0300
102 + * TableDnD plug-in for JQuery, allows you to drag and drop table rows
103 + * You can set up various options to control how the system will work
104 + * Copyright (c) Denis Howlett <denish@isocra.com>
105 + * Licensed like jQuery, see http://docs.jquery.com/License.
107 + * Configuration options:
110 + * This is the style that is assigned to the row during drag. There are limitations to the styles that can be
111 + * associated with a row (such as you can't assign a border--well you can, but it won't be
112 + * displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
113 + * a map (as used in the jQuery css(...) function).
115 + * This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
116 + * to what you can do. Also this replaces the original style, so again consider using onDragClass which
117 + * is simply added and then removed on drop.
119 + * This class is added for the duration of the drag and then removed when the row is dropped. It is more
120 + * flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
121 + * is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
124 + * Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
125 + * and the row that was dropped. You can work out the new order of the rows by using
128 + * Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
129 + * table and the row which the user has started to drag.
131 + * Pass a function that will be called as a row is over another row. If the function returns true, allow
132 + * dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
133 + * the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
135 + * This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
136 + * window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
139 + * This is the name of a class that you assign to one or more cells in each row that is draggable. If you
140 + * specify this class, then you are responsible for setting cursor: move in the CSS and only these cells
141 + * will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where
142 + * the whole row is draggable.
144 + * Other ways to control behaviour:
146 + * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
147 + * that you don't want to be draggable.
149 + * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
150 + * <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
151 + * an ID as must all the rows.
155 + * $("...").tableDnDUpdate()
156 + * Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells).
157 + * This is useful if you have updated the table rows using Ajax and you want to make the table draggable again.
158 + * The table maintains the original configuration (so you don't have to specify it again).
160 + * $("...").tableDnDSerialize()
161 + * Will serialize and return the serialized string as above, but for each of the matching tables--so it can be
162 + * called from anywhere and isn't dependent on the currentTable being set up correctly before calling
165 + * - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
167 + * Version 0.2: 2008-02-20 First public version
168 + * Version 0.3: 2008-02-07 Added onDragStart option
169 + * Made the scroll amount configurable (default is 5 as before)
170 + * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
171 + * Added onAllowDrop to control dropping
172 + * Fixed a bug which meant that you couldn't set the scroll amount in both directions
173 + * Added serialize method
174 + * Version 0.5: 2008-05-16 Changed so that if you specify a dragHandle class it doesn't make the whole row
176 + * Improved the serialize method to use a default (and settable) regular expression.
177 + * Added tableDnDupate() and tableDnDSerialize() to be called when you are outside the table
180 + /** Keep hold of the current table being dragged */
181 + currentTable : null,
182 + /** Keep hold of the current drag object if any */
184 + /** The current mouse offset */
186 + /** Remember the old value of Y so that we don't do too much processing */
189 + /** Actually build the structure */
190 + build: function(options) {
191 + // Set up the defaults if any
193 + this.each(function() {
194 + // This is bound to each matching table, set up the defaults and override with user options
195 + this.tableDnDConfig = jQuery.extend({
198 + // Add in the default class for whileDragging
199 + onDragClass: "tDnD_whileDrag",
203 + serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
204 + serializeParamName: null, // If you want to specify another parameter name instead of the table ID
205 + dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
207 + // Now make the rows draggable
208 + jQuery.tableDnD.makeDraggable(this);
211 + // Now we need to capture the mouse up and mouse move event
212 + // We can use bind so that we don't interfere with other event handlers
214 + .bind('mousemove', jQuery.tableDnD.mousemove)
215 + .bind('mouseup', jQuery.tableDnD.mouseup);
217 + // Don't break the chain
221 + /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
222 + makeDraggable: function(table) {
223 + var config = table.tableDnDConfig;
224 + if (table.tableDnDConfig.dragHandle) {
225 + // We only need to add the event to the specified cells
226 + var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
227 + cells.each(function() {
228 + // The cell is bound to "this"
229 + jQuery(this).mousedown(function(ev) {
230 + jQuery.tableDnD.dragObject = this.parentNode;
231 + jQuery.tableDnD.currentTable = table;
232 + jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
233 + if (config.onDragStart) {
234 + // Call the onDrop method if there is one
235 + config.onDragStart(table, this);
241 + // For backwards compatibility, we add the event to the whole row
242 + var rows = jQuery("tr", table); // get all the rows as a wrapped set
243 + rows.each(function() {
244 + // Iterate through each row, the row is bound to "this"
245 + var row = jQuery(this);
246 + if (! row.hasClass("nodrag")) {
247 + row.mousedown(function(ev) {
248 + if (ev.target.tagName == "TD") {
249 + jQuery.tableDnD.dragObject = this;
250 + jQuery.tableDnD.currentTable = table;
251 + jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
252 + if (config.onDragStart) {
253 + // Call the onDrop method if there is one
254 + config.onDragStart(table, this);
258 + }).css("cursor", "move"); // Store the tableDnD object
264 + updateTables: function() {
265 + this.each(function() {
266 + // this is now bound to each matching table
267 + if (this.tableDnDConfig) {
268 + jQuery.tableDnD.makeDraggable(this);
273 + /** Get the mouse coordinates from the event (allowing for browser differences) */
274 + mouseCoords: function(ev){
275 + if(ev.pageX || ev.pageY){
276 + return {x:ev.pageX, y:ev.pageY};
279 + x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
280 + y:ev.clientY + document.body.scrollTop - document.body.clientTop
284 + /** Given a target element and a mouse event, get the mouse offset from that element.
285 + To do this we need the element's position and the mouse position */
286 + getMouseOffset: function(target, ev) {
287 + ev = ev || window.event;
289 + var docPos = this.getPosition(target);
290 + var mousePos = this.mouseCoords(ev);
291 + return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
294 + /** Get the position of an element by going up the DOM tree and adding up all the offsets */
295 + getPosition: function(e){
298 + /** Safari fix -- thanks to Luis Chato for this! */
299 + if (e.offsetHeight == 0) {
300 + /** Safari 2 doesn't correctly grab the offsetTop of a table row
301 + this is detailed here:
302 + http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
303 + the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
304 + note that firefox will return a text node as a first child, so designing a more thorough
305 + solution may need to take that into account, for now this seems to work in firefox, safari, ie */
306 + e = e.firstChild; // a table cell
309 + while (e.offsetParent){
310 + left += e.offsetLeft;
311 + top += e.offsetTop;
312 + e = e.offsetParent;
315 + left += e.offsetLeft;
316 + top += e.offsetTop;
318 + return {x:left, y:top};
321 + mousemove: function(ev) {
322 + if (jQuery.tableDnD.dragObject == null) {
326 + var dragObj = jQuery(jQuery.tableDnD.dragObject);
327 + var config = jQuery.tableDnD.currentTable.tableDnDConfig;
328 + var mousePos = jQuery.tableDnD.mouseCoords(ev);
329 + var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
330 + //auto scroll the window
331 + var yOffset = window.pageYOffset;
332 + if (document.all) {
334 + //yOffset=document.body.scrollTop;
335 + if (typeof document.compatMode != 'undefined' &&
336 + document.compatMode != 'BackCompat') {
337 + yOffset = document.documentElement.scrollTop;
339 + else if (typeof document.body != 'undefined') {
340 + yOffset=document.body.scrollTop;
345 + if (mousePos.y-yOffset < config.scrollAmount) {
346 + window.scrollBy(0, -config.scrollAmount);
348 + var windowHeight = window.innerHeight ? window.innerHeight
349 + : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
350 + if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
351 + window.scrollBy(0, config.scrollAmount);
356 + if (y != jQuery.tableDnD.oldY) {
357 + // work out if we're going up or down...
358 + var movingDown = y > jQuery.tableDnD.oldY;
359 + // update the old value
360 + jQuery.tableDnD.oldY = y;
361 + // update the style to show we're dragging
362 + if (config.onDragClass) {
363 + dragObj.addClass(config.onDragClass);
365 + dragObj.css(config.onDragStyle);
367 + // If we're over a row then move the dragged row to there so that the user sees the
368 + // effect dynamically
369 + var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
371 + // TODO worry about what happens when there are multiple TBODIES
372 + if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
373 + jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
374 + } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
375 + jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
383 + /** We're only worried about the y position really, because we can only move rows up and down */
384 + findDropTargetRow: function(draggedRow, y) {
385 + var rows = jQuery.tableDnD.currentTable.rows;
386 + for (var i=0; i<rows.length; i++) {
388 + var rowY = this.getPosition(row).y;
389 + var rowHeight = parseInt(row.offsetHeight)/2;
390 + if (row.offsetHeight == 0) {
391 + rowY = this.getPosition(row.firstChild).y;
392 + rowHeight = parseInt(row.firstChild.offsetHeight)/2;
394 + // Because we always have to insert before, we need to offset the height a bit
395 + if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
396 + // that's the row we're over
397 + // If it's the same as the current row, ignore it
398 + if (row == draggedRow) {return null;}
399 + var config = jQuery.tableDnD.currentTable.tableDnDConfig;
400 + if (config.onAllowDrop) {
401 + if (config.onAllowDrop(draggedRow, row)) {
407 + // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
408 + var nodrop = jQuery(row).hasClass("nodrop");
421 + mouseup: function(e) {
422 + if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
423 + var droppedRow = jQuery.tableDnD.dragObject;
424 + var config = jQuery.tableDnD.currentTable.tableDnDConfig;
425 + // If we have a dragObject, then we need to release it,
426 + // The row will already have been moved to the right place so we just reset stuff
427 + if (config.onDragClass) {
428 + jQuery(droppedRow).removeClass(config.onDragClass);
430 + jQuery(droppedRow).css(config.onDropStyle);
432 + jQuery.tableDnD.dragObject = null;
433 + if (config.onDrop) {
434 + // Call the onDrop method if there is one
435 + config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
437 + jQuery.tableDnD.currentTable = null; // let go of the table too
441 + serialize: function() {
442 + if (jQuery.tableDnD.currentTable) {
443 + return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);
445 + return "Error: No Table id set, you need to set an id on your table and every row";
449 + serializeTable: function(table) {
451 + var tableId = table.id;
452 + var rows = table.rows;
453 + for (var i=0; i<rows.length; i++) {
454 + if (result.length > 0) result += "&";
455 + var rowId = rows[i].id;
456 + if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) {
457 + rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0];
460 + result += tableId + '[]=' + rowId;
465 + serializeTables: function() {
467 + this.each(function() {
468 + // this is now bound to each matching table
469 + result += jQuery.tableDnD.serializeTable(this);
478 + tableDnD : jQuery.tableDnD.build,
479 + tableDnDUpdate : jQuery.tableDnD.updateTables,
480 + tableDnDSerialize: jQuery.tableDnD.serializeTables
483 \ No newline at end of file
484 --- eventum-2.3.1/htdocs/list.php~ 2011-04-20 17:37:25.000000000 +0300
485 +++ eventum-2.3.1/htdocs/list.php 2011-04-20 17:40:51.675898467 +0300
490 +@$reorder_usr_id = $_REQUEST["reorder_user"];
491 +@$reorder_issue_id = $_REQUEST["reorder_source"];
492 +@$reorder_neworder = $_REQUEST["reorder_neworder"];
493 +Issue::reorderUserIssues($reorder_usr_id, $reorder_issue_id, $reorder_neworder);
495 $options = Search::saveSearchParams();
496 $tpl->assign("options", $options);
497 $tpl->assign("sorting", Search::getSortingInfo($options));
500 $assign_options += $users;
502 +// get the isu_order (assigned users) ordering user
503 +if (!empty($options["users"])) {
504 + if ($options["users"] == -2) {
505 + $isu_order_user = $usr_id;
507 + if ($options["users"] > 0) {
508 + $isu_order_user = $options["users"];
510 + unset($isu_order_user);
513 + unset($isu_order_user);
516 +if (isset($isu_order_user)) {
517 + $tpl->assign("isu_order_user", $isu_order_user);
520 $list = Search::getListing($prj_id, $options, $pagerRow, $rows);
521 $tpl->assign("list", $list["list"]);
522 $tpl->assign("list_info", $list["info"]);
523 --- eventum-2.2/lib/eventum/class.display_column.php 2009-09-14 18:07:55.000000000 +0300
524 +++ eventum-2.2-order/lib/eventum/class.display_column.php 2009-10-12 22:10:36.429185594 +0300
527 "iss_expected_resolution_date" => array(
528 "title" => ev_gettext("Expected Resolution Date")
531 + "isu_order" => array(
532 + "title" => ev_gettext("Order")
536 return $columns[$page];
537 --- eventum-2.2/lib/eventum/class.issue.php 2009-09-14 18:07:55.000000000 +0300
538 +++ eventum-2.2-order/lib/eventum/class.issue.php 2009-10-12 22:10:36.445851670 +0300
539 @@ -1333,6 +1333,7 @@
540 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
543 + self::moveOrderForAllUsers($issue_id, 1000);
544 $prj_id = self::getProjectID($issue_id);
547 @@ -1800,16 +1801,33 @@
549 $issue_id = Misc::escapeInteger($issue_id);
550 $assignee_usr_id = Misc::escapeInteger($assignee_usr_id);
552 + // move all orders down to free "order space" for this new association
554 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
556 + isu_order = isu_order + 1
558 + isu_usr_id = $assignee_usr_id AND
559 + isu_order >= $order";
560 + $res = DB_Helper::getInstance()->query($stmt);
561 + if (PEAR::isError($res)) {
562 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
565 + // insert the new association
567 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
577 - '" . Date_Helper::getCurrentDateGMT() . "'
578 + '" . Date_Helper::getCurrentDateGMT() . "',
581 $res = DB_Helper::getInstance()->query($stmt);
582 if (PEAR::isError($res)) {
583 @@ -1824,6 +1842,78 @@
588 + * Method used to get the order list to be rearranged
591 + * @param string $issue_id The issue ID or a comma seperated list of IDs already prepared for giving to mysql
592 + * @param string $usr_id The user to remove. When not specified, all users are taken as to be removed for that issue
593 + * @return mixed delete order list to be rearranged. Used as a parameter to the method of rearranging the order.
595 + function getDeleteUserAssociationOrderList($issue_id, $usr_id = "")
597 + // find all affected associantion orders
598 + $stmt = "SELECT isu_usr_id, isu_order FROM
599 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
601 + isu_iss_id IN ($issue_id)";
602 + if (!empty($usr_id)) {
603 + $stmt.= " AND isu_usr_id IN ($usr_id)";
605 + $stmt.= "ORDER BY isu_order";
606 + $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
607 + if (PEAR::isError($res)) {
608 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
611 + $deleted_orders = array();
612 + foreach ($res as $row) {
613 + if (empty($deleted_orders[$row['isu_usr_id']])) {
614 + $deleted_orders[$row['isu_usr_id']] = array();
616 + $deleted_orders[$row['isu_usr_id']] [] = $row['isu_order'];
618 + return $deleted_orders;
624 + * Method used to rearrange order list in the db according to known deleted records
627 + * @param mixed deleteorder list
630 + function rearrangeDeleteUserAssociationOrderList($delete_order_list)
632 + if (empty($delete_order_list) || (!is_array($delete_order_list))) {
635 + foreach ($delete_order_list as $isu_usr_id => $orders) {
636 + for ($i = 0; $i < count($orders); $i++) { // traverse all deleted orders
637 + // move the orders after them up to take the "order space" of the deleted records
639 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
641 + isu_order = isu_order - " . ($i+1) . "
643 + isu_usr_id = $isu_usr_id AND
644 + isu_order > " . $orders[$i];
645 + if ($i < count($orders) - 1) {
647 + isu_order < " . $orders[$i+1];
649 + $res = DB_Helper::getInstance()->query($stmt);
650 + if (PEAR::isError($res)) {
651 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
661 * Method used to delete all user assignments for a specific issue.
662 @@ -1839,6 +1929,7 @@
663 if (is_array($issue_id)) {
664 $issue_id = implode(", ", $issue_id);
666 + $deleted_order_list = self::getDeleteUserAssociationOrderList($issue_id);
668 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
670 @@ -1869,6 +1960,7 @@
672 $issue_id = Misc::escapeInteger($issue_id);
673 $usr_id = Misc::escapeInteger($usr_id);
674 + $delete_order_list = self::getDeleteUserAssociationOrderList($issue_id, $usr_id);
676 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
678 @@ -1883,6 +1975,7 @@
679 History::add($issue_id, Auth::getUserID(), History::getTypeID('user_unassociated'),
680 User::getFullName($usr_id) . ' removed from issue by ' . User::getFullName(Auth::getUserID()));
682 + self::rearrangeDeleteUserAssociationOrderList($delete_order_list);
686 @@ -3253,6 +3352,8 @@
687 $ids = implode(", ", $ids);
694 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,
695 @@ -3264,6 +3365,7 @@
696 if (PEAR::isError($res)) {
697 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
699 + // gather names of the users assigned to each issue
701 for ($i = 0; $i < count($res); $i++) {
702 if (!empty($t[$res[$i]['isu_iss_id']])) {
703 @@ -3272,9 +3374,18 @@
704 $t[$res[$i]['isu_iss_id']] = $res[$i]['usr_full_name'];
709 + for ($i = 0; $i < count($res); $i++) {
710 + if (empty($o[$res[$i]['isu_iss_id']])) {
711 + $o[$res[$i]['isu_iss_id']] = array();
713 + $o[$res[$i]['isu_iss_id']][$res[$i]['isu_usr_id']] = $res[$i]['isu_order'];
715 // now populate the $result variable again
716 for ($i = 0; $i < count($result); $i++) {
717 @$result[$i]['assigned_users'] = $t[$result[$i]['iss_id']];
718 + @$result[$i]['assigned_users_order'] = $o[$result[$i]['iss_id']];
722 @@ -4247,6 +4358,7 @@
723 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
726 + self::moveOrderForAllUsers($issue_id, 1);
730 @@ -4346,4 +4458,120 @@
731 History::add($issue_id, Auth::getUserID(), History::getTypeID('user_associated'),
732 "Issue assignment to changed (" . History::formatChanges(join(', ', $old_assignee_names), join(', ', $assignee_names)) . ") by " . User::getFullName(Auth::getUserID()));
736 + * Reorders user's issues as requested by user
738 + * @param $usr_id User to be reordered
739 + * @param $issue_id Issue or array of issues to be moved
740 + * @param $neworder The new order of the issues
743 + function reorderUserIssues($usr_id, $issue_id, $neworder)
745 + if (!isset($usr_id) || !isset($issue_id) || !isset($neworder)) {
748 + if (!is_numeric($usr_id) || !is_numeric($neworder)) {
751 + $usr_id = Misc::escapeInteger($usr_id);
752 + $issue_id = Misc::escapeInteger($issue_id);
753 + $neworder = Misc::escapeInteger($neworder);
754 + if (is_array($issue_id)) {
755 + $issue_count = count($issue_id);
756 + $issue_id_str = implode(", ", $issue_id);
759 + $issue_id_str = $issue_id;
760 + $issue_id = array($issue_id);
762 + // do a nasty pretending to be deleting stuff so that reordering happens as if these elements were deleted
763 + $orderlist = self::getDeleteUserAssociationOrderList($issue_id_str, $usr_id);
764 + self::rearrangeDeleteUserAssociationOrderList($orderlist);
765 + // move down the orders to free the "order space" needed
767 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
769 + isu_order = isu_order + $issue_count
771 + isu_usr_id = $usr_id AND
772 + isu_order >= $neworder";
773 + $res = DB_Helper::getInstance()->query($stmt);
774 + if (PEAR::isError($res)) {
775 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
778 + //update the order for the issues being moved
780 + foreach ($issue_id as $iss_id) {
782 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
784 + isu_order = " . ($neworder + $i) . "
786 + isu_usr_id = $usr_id AND
787 + isu_iss_id = $iss_id";
788 + $res = DB_Helper::getInstance()->query($stmt);
789 + if (PEAR::isError($res)) {
790 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
799 + * Get users issue order list
801 + * @param $user_id User
802 + * @param $order_list Order of the issues
805 + function getIssueOrderByUser($usr_id) {
807 + if (!is_numeric($usr_id)) {
812 + isu_iss_id, isu_order
814 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
816 + isu_usr_id = " . $usr_id ;
818 + $order_list = array();
820 + $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
822 + if (PEAR::isError($res)) {
823 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
826 + foreach ($res as $row) {
827 + $order_list[$row["isu_iss_id"]] = $row["isu_order"];
830 + return $order_list;
833 + function moveOrderForAllUsers($issue_id, $neworder)
835 + // Move the issue to the top priority for the ppl it's assigned to
836 + $stmt = "SELECT isu_usr_id FROM
837 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
839 + isu_iss_id = " . Misc::escapeInteger($issue_id);
840 + $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
841 + if (PEAR::isError($res)) {
842 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
845 + foreach ($res as $row) {
846 + self::reorderUserIssues($row["isu_usr_id"], $issue_id, $neworder);
851 --- eventum-2.3.1/lib/eventum/class.search.php~ 2011-04-20 17:22:15.000000000 +0300
852 +++ eventum-2.3.1/lib/eventum/class.search.php 2011-04-20 17:44:34.498519260 +0300
855 $sort_by = self::getParam('sort_by');
856 $sort_order = self::getParam('sort_order');
857 + $users = self::getParam('users');
858 + if (empty($users) && $sort_by === 'isu_order') {
859 + // Sorting by isu_order is impossible when no user specified
861 + unset($sort_order);
863 $rows = self::getParam('rows');
864 $hide_closed = self::getParam('hide_closed');
865 if ($hide_closed === '') {
867 "iss_expected_resolution_date" => "desc",
868 "pre_title" => "asc",
870 + "isu_order" => "desc",
873 foreach ($custom_fields as $fld_id => $fld_name) {
874 --- eventum-2.3/templates/header.tpl.html~ 2010-09-27 18:12:42.000000000 +0300
875 +++ eventum-2.3/templates/header.tpl.html 2010-09-27 18:13:08.884494665 +0300
877 <script type="text/javascript" src="{$rel_url}js/jquery/form.js?c=9984"></script>
878 <script type="text/javascript" src="{$rel_url}js/jquery/blockui.js?c=eb13"></script>
879 <script type="text/javascript" src="{$rel_url}js/jquery/ui.datepicker.js?c=a911"></script>
880 +<script type="text/javascript" src="{$rel_url}js/jquery/jquery.tablednd.js"></script>
881 <script type="text/javascript" src="{$rel_url}js/validation.js?c=9775"></script>
882 <script type="text/javascript" src="{$rel_url}js/browserSniffer.js?c=c046"></script>
883 <script type="text/javascript" src="{$rel_url}js/global.js?c=5297"></script>
884 --- eventum-2.2/templates/list.tpl.html 2009-09-14 18:07:55.000000000 +0300
885 +++ eventum-2.2-order/templates/list.tpl.html 2009-10-12 22:10:36.439185157 +0300
890 +function reorderBulk(order_user, neworder)
892 + url = page_url + "?";
893 + url += "reorder_user=" + order_user;
895 + items = document.getElementsByName("item[]");
897 + for (var i = 0; i < items.length; i++) {
898 + if (items[i].checked) {
899 + url += "&reorder_source[" + checkedcount + "]=" + items[i].value;
903 + if (checkedcount == 0) {
904 + alert('{/literal}{t escape=js}Please choose which issues to move to the new place.{/t}{literal}');
908 + url += "&reorder_neworder=" + neworder;
910 + window.location.href = url;
912 function hideClosed(f)
914 if (f.hide_closed.checked) {
916 f.go.disabled = true;
919 +function updateCustomFields(issue_id)
921 + var features = 'width=560,height=460,top=30,left=30,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,status=no';
922 + var customWin = window.open('custom_fields.php?issue_id=' + issue_id, '_custom_fields', features);
929 @@ -169,11 +198,11 @@
930 <input type="hidden" name="cat" value="bulk_update">
933 - <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
935 + <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0" id="issue_list_table">
936 + <tr class="nodrag">
937 <td colspan="{$col_count}" class="default">
938 <table width="100%" cellspacing="0" cellpadding="0" border="0">
940 + <tr class="nodrag">
942 <b>{t}Search Results{/t} ({$list_info.total_rows} {t}issues found{/t}{if $list_info.end_offset > 0}, {math equation="x + 1" x=$list_info.start_offset} - {$list_info.end_offset} {t}shown{/t}{/if})</b>
943 {include file="help_link.tpl.html" topic="list"}
948 - <tr bgcolor="{$cell_color}">
949 + <tr bgcolor="{$cell_color}" class="nodrag">
950 {if $current_role > $roles.developer}
952 <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'item[]');toggleBulkUpdate();">
954 {if $sorting.images[$fld_name_id] != ""}<a title="{t}sort by{/t} {$fld_title|escape:"html"}" href="{$sorting.links[$fld_name_id]}" class="white_link"><img border="0" src="{$sorting.images[$fld_name_id]}"></a>{/if}
958 + {elseif $field_name != 'isu_order' || $isu_order_user}
959 <td align="{$column.align|default:'center'}" class="default_white" nowrap {if $column.width != ''}width="{$column.width}"{/if}>
960 {if $field_name == 'iss_summary'}
961 <table cellspacing="0" cellpadding="1" width="100%">
967 {section name="i" loop=$list}
968 - <tr {if $current_role >= $roles.developer AND $list[i].iqu_status > 0}style="text-decoration: line-through;"{/if}>
969 + <tr {if $current_role >= $roles.developer AND $list[i].iqu_status > 0}style="text-decoration: line-through;"{/if} id="{$list[i].iss_id}" {if !$list[i].assigned_users_order[$current_user_id]}class="nodrag"{/if}>
970 {if $current_role > $roles.developer}
971 <td bgcolor="{$list[i].status_color}" width="1%" class="default" align="center"><input type="checkbox" name="item[]" value="{$list[i].iss_id}" onchange="toggleBulkUpdate();"></td>
974 {$fld_value|formatCustomValue:$fld_id:$list[i].iss_id}
978 - <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default">
979 + {elseif $field_name != 'isu_order' || $isu_order_user}
980 + <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default{if $field_name == 'isu_order'} dragHandle{/if}">
981 {if $field_name == 'iss_id'}
982 <a href="view.php?id={$list[i].iss_id}" class="link" title="{t}view issue details{/t}">{$list[i].iss_id}</a>
983 {elseif $field_name == 'pri_rank'}
985 {if $list[i].iss_private == 1}
988 + {elseif $field_name == 'isu_order'}
989 + {if $options.sort_by == "isu_order" and $current_user_id == $isu_order_user} {/if}
993 @@ -300,10 +332,11 @@
997 - <tr bgcolor="{$cell_color}">
999 + <tr bgcolor="{$cell_color}" class="nodrag">
1000 <td colspan="{$col_count}">
1001 <table width="100%" cellspacing="0" cellpadding="0">
1003 + <tr class="nodrag">
1004 <td width="30%" nowrap>
1005 {if $current_role > $roles.developer}
1006 <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'item[]');">
1007 @@ -355,6 +388,35 @@
1012 +<script type="text/javascript">
1014 + * Order issues by drag and drop:
1015 + * only if sorted by order and viewing your own issues
1017 +{if $options.sort_by == "isu_order" and $current_user_id == $isu_order_user}
1019 +var before = ''; // make it global variable
1020 +$('#issue_list_table').tableDnD({
1021 + onDragClass: "tDnD_whileDrag",
1022 + onDragStart: function(table, row) {
1023 + before = $.tableDnD.serialize('id');
1025 + onDrop: function(table, row) {
1026 + $.post("/ajax/order.php", {before: before, after: $.tableDnD.serialize('id')}, function(data) {
1027 + if (data.length > 0) {
1032 + dragHandle: "dragHandle"
1034 +$("#issue_list_table tr").hover(function() {
1035 + $('#' + this.id + ' .dragHandle').addClass('showDragHandle');
1037 + $('#' + this.id + ' .dragHandle').removeClass('showDragHandle');
1042 {include file="app_info.tpl.html"}
1043 {include file="footer.tpl.html"}