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.2/htdocs/list.php 2009-09-14 18:07:55.000000000 +0300
485 +++ eventum-2.2-order/htdocs/list.php 2009-10-12 22:10:36.435851675 +0300
487 $profile['sort_by'] . "&sort_order=" . $profile['sort_order']);
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 = Issue::saveSearchParams();
496 $tpl->assign("options", $options);
497 $tpl->assign("sorting", Issue::getSortingInfo($options));
500 $assign_options += $users;
502 +// get the isu_order (assignated 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);
515 +$tpl->assign("isu_order_user", $isu_order_user);
517 $list = Issue::getListing($prj_id, $options, $pagerRow, $rows);
518 $tpl->assign("list", $list["list"]);
519 $tpl->assign("list_info", $list["info"]);
520 --- eventum-2.2/lib/eventum/class.display_column.php 2009-09-14 18:07:55.000000000 +0300
521 +++ eventum-2.2-order/lib/eventum/class.display_column.php 2009-10-12 22:10:36.429185594 +0300
524 "iss_expected_resolution_date" => array(
525 "title" => ev_gettext("Expected Resolution Date")
528 + "isu_order" => array(
529 + "title" => ev_gettext("Order")
533 return $columns[$page];
534 --- eventum-2.2/lib/eventum/class.issue.php 2009-09-14 18:07:55.000000000 +0300
535 +++ eventum-2.2-order/lib/eventum/class.issue.php 2009-10-12 22:10:36.445851670 +0300
536 @@ -1333,6 +1333,7 @@
537 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
540 + self::moveOrderForAllUsers($issue_id, 1000);
541 $prj_id = self::getProjectID($issue_id);
544 @@ -1800,16 +1801,33 @@
546 $issue_id = Misc::escapeInteger($issue_id);
547 $assignee_usr_id = Misc::escapeInteger($assignee_usr_id);
549 + // move all orders down to free "order space" for this new association
551 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
553 + isu_order = isu_order + 1
555 + isu_usr_id = $assignee_usr_id AND
556 + isu_order >= $order";
557 + $res = DB_Helper::getInstance()->query($stmt);
558 + if (PEAR::isError($res)) {
559 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
562 + // insert the new association
564 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
574 - '" . Date_Helper::getCurrentDateGMT() . "'
575 + '" . Date_Helper::getCurrentDateGMT() . "',
578 $res = DB_Helper::getInstance()->query($stmt);
579 if (PEAR::isError($res)) {
580 @@ -1824,6 +1842,78 @@
585 + * Method used to get the order list to be rearranged
588 + * @param string $issue_id The issue ID or a comma seperated list of IDs already prepared for giving to mysql
589 + * @param string $usr_id The user to remove. When not specified, all users are taken as to be removed for that issue
590 + * @return mixed delete order list to be rearranged. Used as a parameter to the method of rearranging the order.
592 + function getDeleteUserAssociationOrderList($issue_id, $usr_id = "")
594 + // find all affected associantion orders
595 + $stmt = "SELECT isu_usr_id, isu_order FROM
596 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
598 + isu_iss_id IN ($issue_id)";
599 + if (!empty($usr_id)) {
600 + $stmt.= " AND isu_usr_id IN ($usr_id)";
602 + $stmt.= "ORDER BY isu_order";
603 + $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
604 + if (PEAR::isError($res)) {
605 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
608 + $deleted_orders = array();
609 + foreach ($res as $row) {
610 + if (empty($deleted_orders[$row['isu_usr_id']])) {
611 + $deleted_orders[$row['isu_usr_id']] = array();
613 + $deleted_orders[$row['isu_usr_id']] [] = $row['isu_order'];
615 + return $deleted_orders;
621 + * Method used to rearrange order list in the db according to known deleted records
624 + * @param mixed deleteorder list
627 + function rearrangeDeleteUserAssociationOrderList($delete_order_list)
629 + if (empty($delete_order_list) || (!is_array($delete_order_list))) {
632 + foreach ($delete_order_list as $isu_usr_id => $orders) {
633 + for ($i = 0; $i < count($orders); $i++) { // traverse all deleted orders
634 + // move the orders after them up to take the "order space" of the deleted records
636 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
638 + isu_order = isu_order - " . ($i+1) . "
640 + isu_usr_id = $isu_usr_id AND
641 + isu_order > " . $orders[$i];
642 + if ($i < count($orders) - 1) {
644 + isu_order < " . $orders[$i+1];
646 + $res = DB_Helper::getInstance()->query($stmt);
647 + if (PEAR::isError($res)) {
648 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
658 * Method used to delete all user assignments for a specific issue.
659 @@ -1839,6 +1929,7 @@
660 if (is_array($issue_id)) {
661 $issue_id = implode(", ", $issue_id);
663 + $deleted_order_list = self::getDeleteUserAssociationOrderList($issue_id);
665 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
667 @@ -1869,6 +1960,7 @@
669 $issue_id = Misc::escapeInteger($issue_id);
670 $usr_id = Misc::escapeInteger($usr_id);
671 + $delete_order_list = self::getDeleteUserAssociationOrderList($issue_id, $usr_id);
673 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
675 @@ -1883,6 +1975,7 @@
676 History::add($issue_id, Auth::getUserID(), History::getTypeID('user_unassociated'),
677 User::getFullName($usr_id) . ' removed from issue by ' . User::getFullName(Auth::getUserID()));
679 + self::rearrangeDeleteUserAssociationOrderList($delete_order_list);
683 @@ -2342,6 +2435,11 @@
685 $sort_by = self::getParam('sort_by');
686 $sort_order = self::getParam('sort_order');
687 + $users = self::getParam('users');
688 + if (empty($users) && ($sort_by == 'isu_order')) { // Sorting by isu_order is impossible when no user specified
690 + unset($sort_order);
692 $rows = self::getParam('rows');
693 $hide_closed = self::getParam('hide_closed');
694 if ($hide_closed === '') {
695 @@ -2448,6 +2546,7 @@
696 "iss_expected_resolution_date" => "desc",
697 "pre_title" => "asc",
699 + "isu_order" => "desc",
702 foreach ($custom_fields as $fld_id => $fld_name) {
703 @@ -3253,6 +3352,8 @@
704 $ids = implode(", ", $ids);
711 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,
712 @@ -3264,6 +3365,7 @@
713 if (PEAR::isError($res)) {
714 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
716 + // gather names of the users assigned to each issue
718 for ($i = 0; $i < count($res); $i++) {
719 if (!empty($t[$res[$i]['isu_iss_id']])) {
720 @@ -3272,9 +3374,18 @@
721 $t[$res[$i]['isu_iss_id']] = $res[$i]['usr_full_name'];
726 + for ($i = 0; $i < count($res); $i++) {
727 + if (empty($o[$res[$i]['isu_iss_id']])) {
728 + $o[$res[$i]['isu_iss_id']] = array();
730 + $o[$res[$i]['isu_iss_id']][$res[$i]['isu_usr_id']] = $res[$i]['isu_order'];
732 // now populate the $result variable again
733 for ($i = 0; $i < count($result); $i++) {
734 @$result[$i]['assigned_users'] = $t[$result[$i]['iss_id']];
735 + @$result[$i]['assigned_users_order'] = $o[$result[$i]['iss_id']];
739 @@ -4247,6 +4358,7 @@
740 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
743 + self::moveOrderForAllUsers($issue_id, 1);
747 @@ -4346,4 +4458,120 @@
748 History::add($issue_id, Auth::getUserID(), History::getTypeID('user_associated'),
749 "Issue assignment to changed (" . History::formatChanges(join(', ', $old_assignee_names), join(', ', $assignee_names)) . ") by " . User::getFullName(Auth::getUserID()));
753 + * Reorders user's issues as requested by user
755 + * @param $usr_id User to be reordered
756 + * @param $issue_id Issue or array of issues to be moved
757 + * @param $neworder The new order of the issues
760 + function reorderUserIssues($usr_id, $issue_id, $neworder)
762 + if (!isset($usr_id) || !isset($issue_id) || !isset($neworder)) {
765 + if (!is_numeric($usr_id) || !is_numeric($neworder)) {
768 + $usr_id = Misc::escapeInteger($usr_id);
769 + $issue_id = Misc::escapeInteger($issue_id);
770 + $neworder = Misc::escapeInteger($neworder);
771 + if (is_array($issue_id)) {
772 + $issue_count = count($issue_id);
773 + $issue_id_str = implode(", ", $issue_id);
776 + $issue_id_str = $issue_id;
777 + $issue_id = array($issue_id);
779 + // do a nasty pretending to be deleting stuff so that reordering happens as if these elements were deleted
780 + $orderlist = self::getDeleteUserAssociationOrderList($issue_id_str, $usr_id);
781 + self::rearrangeDeleteUserAssociationOrderList($orderlist);
782 + // move down the orders to free the "order space" needed
784 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
786 + isu_order = isu_order + $issue_count
788 + isu_usr_id = $usr_id AND
789 + isu_order >= $neworder";
790 + $res = DB_Helper::getInstance()->query($stmt);
791 + if (PEAR::isError($res)) {
792 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
795 + //update the order for the issues being moved
797 + foreach ($issue_id as $iss_id) {
799 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
801 + isu_order = " . ($neworder + $i) . "
803 + isu_usr_id = $usr_id AND
804 + isu_iss_id = $iss_id";
805 + $res = DB_Helper::getInstance()->query($stmt);
806 + if (PEAR::isError($res)) {
807 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
816 + * Get users issue order list
818 + * @param $user_id User
819 + * @param $order_list Order of the issues
822 + function getIssueOrderByUser($usr_id) {
824 + if (!is_numeric($usr_id)) {
829 + isu_iss_id, isu_order
831 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
833 + isu_usr_id = " . $usr_id ;
835 + $order_list = array();
837 + $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
839 + if (PEAR::isError($res)) {
840 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
843 + foreach ($res as $row) {
844 + $order_list[$row["isu_iss_id"]] = $row["isu_order"];
847 + return $order_list;
850 + function moveOrderForAllUsers($issue_id, $neworder)
852 + // Move the issue to the top priority for the ppl it's assigned to
853 + $stmt = "SELECT isu_usr_id FROM
854 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
856 + isu_iss_id = " . Misc::escapeInteger($issue_id);
857 + $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
858 + if (PEAR::isError($res)) {
859 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
862 + foreach ($res as $row) {
863 + self::reorderUserIssues($row["isu_usr_id"], $issue_id, $neworder);
868 --- eventum-2.2/templates/header.tpl.html 2009-09-14 18:07:55.000000000 +0300
869 +++ eventum-2.2-order/templates/header.tpl.html 2009-10-12 22:10:36.435851675 +0300
871 <script type="text/javascript" src="{$rel_url}js/jquery/form.js?c=9984"></script>
872 <script type="text/javascript" src="{$rel_url}js/jquery/blockui.js?c=eb13"></script>
873 <script type="text/javascript" src="{$rel_url}js/jquery/ui.datepicker.js?c=a911"></script>
874 +<script type="text/javascript" src="{$rel_url}js/jquery/jquery.tablednd.js"></script>
875 <link rel="stylesheet" href="{$rel_url}js/jquery/ui.datepicker.css?c=5096">
876 <script type="text/javascript">
878 --- eventum-2.2/templates/list.tpl.html 2009-09-14 18:07:55.000000000 +0300
879 +++ eventum-2.2-order/templates/list.tpl.html 2009-10-12 22:10:36.439185157 +0300
884 +function reorderBulk(order_user, neworder)
886 + url = page_url + "?";
887 + url += "reorder_user=" + order_user;
889 + items = document.getElementsByName("item[]");
891 + for (var i = 0; i < items.length; i++) {
892 + if (items[i].checked) {
893 + url += "&reorder_source[" + checkedcount + "]=" + items[i].value;
897 + if (checkedcount == 0) {
898 + alert('{/literal}{t escape=js}Please choose which issues to move to the new place.{/t}{literal}');
902 + url += "&reorder_neworder=" + neworder;
904 + window.location.href = url;
906 function hideClosed(f)
908 if (f.hide_closed.checked) {
910 f.go.disabled = true;
913 +function updateCustomFields(issue_id)
915 + var features = 'width=560,height=460,top=30,left=30,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,status=no';
916 + var customWin = window.open('custom_fields.php?issue_id=' + issue_id, '_custom_fields', features);
923 @@ -169,11 +198,11 @@
924 <input type="hidden" name="cat" value="bulk_update">
927 - <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
929 + <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0" id="issue_list_table">
930 + <tr class="nodrag">
931 <td colspan="{$col_count}" class="default">
932 <table width="100%" cellspacing="0" cellpadding="0" border="0">
934 + <tr class="nodrag">
936 <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>
937 {include file="help_link.tpl.html" topic="list"}
942 - <tr bgcolor="{$cell_color}">
943 + <tr bgcolor="{$cell_color}" class="nodrag">
944 {if $current_role > $roles.developer}
946 <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'item[]');toggleBulkUpdate();">
948 {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}
952 + {elseif $field_name != 'isu_order' || $isu_order_user}
953 <td align="{$column.align|default:'center'}" class="default_white" nowrap {if $column.width != ''}width="{$column.width}"{/if}>
954 {if $field_name == 'iss_summary'}
955 <table cellspacing="0" cellpadding="1" width="100%">
961 {section name="i" loop=$list}
962 - <tr {if $current_role >= $roles.developer AND $list[i].iqu_status > 0}style="text-decoration: line-through;"{/if}>
963 + <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}>
964 {if $current_role > $roles.developer}
965 <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>
968 {$fld_value|formatCustomValue:$fld_id:$list[i].iss_id}
972 - <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default">
973 + {elseif $field_name != 'isu_order' || $isu_order_user}
974 + <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default{if $field_name == 'isu_order'} dragHandle{/if}">
975 {if $field_name == 'iss_id'}
976 <a href="view.php?id={$list[i].iss_id}" class="link" title="{t}view issue details{/t}">{$list[i].iss_id}</a>
977 {elseif $field_name == 'pri_rank'}
979 {if $list[i].iss_private == 1}
982 + {elseif $field_name == 'isu_order'}
983 + {if $options.sort_by == "isu_order" and $current_user_id == $isu_order_user} {/if}
987 @@ -300,10 +332,11 @@
991 - <tr bgcolor="{$cell_color}">
993 + <tr bgcolor="{$cell_color}" class="nodrag">
994 <td colspan="{$col_count}">
995 <table width="100%" cellspacing="0" cellpadding="0">
997 + <tr class="nodrag">
998 <td width="30%" nowrap>
999 {if $current_role > $roles.developer}
1000 <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'item[]');">
1001 @@ -355,6 +388,35 @@
1006 +<script type="text/javascript">
1008 + * Order issues by drag and drop:
1009 + * only if sorted by order and viewing your own issues
1011 +{if $options.sort_by == "isu_order" and $current_user_id == $isu_order_user}
1013 +var before = ''; // make it global variable
1014 +$('#issue_list_table').tableDnD({
1015 + onDragClass: "tDnD_whileDrag",
1016 + onDragStart: function(table, row) {
1017 + before = $.tableDnD.serialize('id');
1019 + onDrop: function(table, row) {
1020 + $.post("/ajax/order.php", {before: before, after: $.tableDnD.serialize('id')}, function(data) {
1021 + if (data.length > 0) {
1026 + dragHandle: "dragHandle"
1028 +$("#issue_list_table tr").hover(function() {
1029 + $('#' + this.id + ' .dragHandle').addClass('showDragHandle');
1031 + $('#' + this.id + ' .dragHandle').removeClass('showDragHandle');
1036 {include file="app_info.tpl.html"}
1037 {include file="footer.tpl.html"}