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.3.1/htdocs/css/style.css~ 2011-09-15 09:36:55.000000000 +0300
74 +++ eventum-2.3.1/htdocs/css/style.css 2011-09-15 09:38:23.668223576 +0300
80 + background-color: #ffffdd;
83 + border: 1px solid red;
93 + background-image: url(../images/updown2.gif);
94 + background-repeat: no-repeat;
95 + background-position: center center;
102 list-style-type: none;
105 \ No newline at end of file
107 --- eventum-2.2/htdocs/js/jquery/jquery.tablednd.js 1970-01-01 02:00:00.000000000 +0200
108 +++ eventum-2.2-order/htdocs/js/jquery/jquery.tablednd.js 2009-10-12 22:10:36.435851675 +0300
111 + * TableDnD plug-in for JQuery, allows you to drag and drop table rows
112 + * You can set up various options to control how the system will work
113 + * Copyright (c) Denis Howlett <denish@isocra.com>
114 + * Licensed like jQuery, see http://docs.jquery.com/License.
116 + * Configuration options:
119 + * This is the style that is assigned to the row during drag. There are limitations to the styles that can be
120 + * associated with a row (such as you can't assign a border--well you can, but it won't be
121 + * displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
122 + * a map (as used in the jQuery css(...) function).
124 + * This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
125 + * to what you can do. Also this replaces the original style, so again consider using onDragClass which
126 + * is simply added and then removed on drop.
128 + * This class is added for the duration of the drag and then removed when the row is dropped. It is more
129 + * flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
130 + * is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
133 + * Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
134 + * and the row that was dropped. You can work out the new order of the rows by using
137 + * Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
138 + * table and the row which the user has started to drag.
140 + * Pass a function that will be called as a row is over another row. If the function returns true, allow
141 + * dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
142 + * the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
144 + * This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
145 + * window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
148 + * This is the name of a class that you assign to one or more cells in each row that is draggable. If you
149 + * specify this class, then you are responsible for setting cursor: move in the CSS and only these cells
150 + * will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where
151 + * the whole row is draggable.
153 + * Other ways to control behaviour:
155 + * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
156 + * that you don't want to be draggable.
158 + * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
159 + * <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
160 + * an ID as must all the rows.
164 + * $("...").tableDnDUpdate()
165 + * Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells).
166 + * This is useful if you have updated the table rows using Ajax and you want to make the table draggable again.
167 + * The table maintains the original configuration (so you don't have to specify it again).
169 + * $("...").tableDnDSerialize()
170 + * Will serialize and return the serialized string as above, but for each of the matching tables--so it can be
171 + * called from anywhere and isn't dependent on the currentTable being set up correctly before calling
174 + * - Auto-scoll has some problems with IE7 (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
176 + * Version 0.2: 2008-02-20 First public version
177 + * Version 0.3: 2008-02-07 Added onDragStart option
178 + * Made the scroll amount configurable (default is 5 as before)
179 + * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
180 + * Added onAllowDrop to control dropping
181 + * Fixed a bug which meant that you couldn't set the scroll amount in both directions
182 + * Added serialize method
183 + * Version 0.5: 2008-05-16 Changed so that if you specify a dragHandle class it doesn't make the whole row
185 + * Improved the serialize method to use a default (and settable) regular expression.
186 + * Added tableDnDupate() and tableDnDSerialize() to be called when you are outside the table
189 + /** Keep hold of the current table being dragged */
190 + currentTable : null,
191 + /** Keep hold of the current drag object if any */
193 + /** The current mouse offset */
195 + /** Remember the old value of Y so that we don't do too much processing */
198 + /** Actually build the structure */
199 + build: function(options) {
200 + // Set up the defaults if any
202 + this.each(function() {
203 + // This is bound to each matching table, set up the defaults and override with user options
204 + this.tableDnDConfig = jQuery.extend({
207 + // Add in the default class for whileDragging
208 + onDragClass: "tDnD_whileDrag",
212 + serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
213 + serializeParamName: null, // If you want to specify another parameter name instead of the table ID
214 + dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
216 + // Now make the rows draggable
217 + jQuery.tableDnD.makeDraggable(this);
220 + // Now we need to capture the mouse up and mouse move event
221 + // We can use bind so that we don't interfere with other event handlers
223 + .bind('mousemove', jQuery.tableDnD.mousemove)
224 + .bind('mouseup', jQuery.tableDnD.mouseup);
226 + // Don't break the chain
230 + /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
231 + makeDraggable: function(table) {
232 + var config = table.tableDnDConfig;
233 + if (table.tableDnDConfig.dragHandle) {
234 + // We only need to add the event to the specified cells
235 + var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
236 + cells.each(function() {
237 + // The cell is bound to "this"
238 + jQuery(this).mousedown(function(ev) {
239 + jQuery.tableDnD.dragObject = this.parentNode;
240 + jQuery.tableDnD.currentTable = table;
241 + jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
242 + if (config.onDragStart) {
243 + // Call the onDrop method if there is one
244 + config.onDragStart(table, this);
250 + // For backwards compatibility, we add the event to the whole row
251 + var rows = jQuery("tr", table); // get all the rows as a wrapped set
252 + rows.each(function() {
253 + // Iterate through each row, the row is bound to "this"
254 + var row = jQuery(this);
255 + if (! row.hasClass("nodrag")) {
256 + row.mousedown(function(ev) {
257 + if (ev.target.tagName == "TD") {
258 + jQuery.tableDnD.dragObject = this;
259 + jQuery.tableDnD.currentTable = table;
260 + jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
261 + if (config.onDragStart) {
262 + // Call the onDrop method if there is one
263 + config.onDragStart(table, this);
267 + }).css("cursor", "move"); // Store the tableDnD object
273 + updateTables: function() {
274 + this.each(function() {
275 + // this is now bound to each matching table
276 + if (this.tableDnDConfig) {
277 + jQuery.tableDnD.makeDraggable(this);
282 + /** Get the mouse coordinates from the event (allowing for browser differences) */
283 + mouseCoords: function(ev){
284 + if(ev.pageX || ev.pageY){
285 + return {x:ev.pageX, y:ev.pageY};
288 + x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
289 + y:ev.clientY + document.body.scrollTop - document.body.clientTop
293 + /** Given a target element and a mouse event, get the mouse offset from that element.
294 + To do this we need the element's position and the mouse position */
295 + getMouseOffset: function(target, ev) {
296 + ev = ev || window.event;
298 + var docPos = this.getPosition(target);
299 + var mousePos = this.mouseCoords(ev);
300 + return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
303 + /** Get the position of an element by going up the DOM tree and adding up all the offsets */
304 + getPosition: function(e){
307 + /** Safari fix -- thanks to Luis Chato for this! */
308 + if (e.offsetHeight == 0) {
309 + /** Safari 2 doesn't correctly grab the offsetTop of a table row
310 + this is detailed here:
311 + http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
312 + the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
313 + note that firefox will return a text node as a first child, so designing a more thorough
314 + solution may need to take that into account, for now this seems to work in firefox, safari, ie */
315 + e = e.firstChild; // a table cell
318 + while (e.offsetParent){
319 + left += e.offsetLeft;
320 + top += e.offsetTop;
321 + e = e.offsetParent;
324 + left += e.offsetLeft;
325 + top += e.offsetTop;
327 + return {x:left, y:top};
330 + mousemove: function(ev) {
331 + if (jQuery.tableDnD.dragObject == null) {
335 + var dragObj = jQuery(jQuery.tableDnD.dragObject);
336 + var config = jQuery.tableDnD.currentTable.tableDnDConfig;
337 + var mousePos = jQuery.tableDnD.mouseCoords(ev);
338 + var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
339 + //auto scroll the window
340 + var yOffset = window.pageYOffset;
341 + if (document.all) {
343 + //yOffset=document.body.scrollTop;
344 + if (typeof document.compatMode != 'undefined' &&
345 + document.compatMode != 'BackCompat') {
346 + yOffset = document.documentElement.scrollTop;
348 + else if (typeof document.body != 'undefined') {
349 + yOffset=document.body.scrollTop;
354 + if (mousePos.y-yOffset < config.scrollAmount) {
355 + window.scrollBy(0, -config.scrollAmount);
357 + var windowHeight = window.innerHeight ? window.innerHeight
358 + : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
359 + if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
360 + window.scrollBy(0, config.scrollAmount);
365 + if (y != jQuery.tableDnD.oldY) {
366 + // work out if we're going up or down...
367 + var movingDown = y > jQuery.tableDnD.oldY;
368 + // update the old value
369 + jQuery.tableDnD.oldY = y;
370 + // update the style to show we're dragging
371 + if (config.onDragClass) {
372 + dragObj.addClass(config.onDragClass);
374 + dragObj.css(config.onDragStyle);
376 + // If we're over a row then move the dragged row to there so that the user sees the
377 + // effect dynamically
378 + var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
380 + // TODO worry about what happens when there are multiple TBODIES
381 + if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
382 + jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
383 + } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
384 + jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
392 + /** We're only worried about the y position really, because we can only move rows up and down */
393 + findDropTargetRow: function(draggedRow, y) {
394 + var rows = jQuery.tableDnD.currentTable.rows;
395 + for (var i=0; i<rows.length; i++) {
397 + var rowY = this.getPosition(row).y;
398 + var rowHeight = parseInt(row.offsetHeight)/2;
399 + if (row.offsetHeight == 0) {
400 + rowY = this.getPosition(row.firstChild).y;
401 + rowHeight = parseInt(row.firstChild.offsetHeight)/2;
403 + // Because we always have to insert before, we need to offset the height a bit
404 + if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
405 + // that's the row we're over
406 + // If it's the same as the current row, ignore it
407 + if (row == draggedRow) {return null;}
408 + var config = jQuery.tableDnD.currentTable.tableDnDConfig;
409 + if (config.onAllowDrop) {
410 + if (config.onAllowDrop(draggedRow, row)) {
416 + // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
417 + var nodrop = jQuery(row).hasClass("nodrop");
430 + mouseup: function(e) {
431 + if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
432 + var droppedRow = jQuery.tableDnD.dragObject;
433 + var config = jQuery.tableDnD.currentTable.tableDnDConfig;
434 + // If we have a dragObject, then we need to release it,
435 + // The row will already have been moved to the right place so we just reset stuff
436 + if (config.onDragClass) {
437 + jQuery(droppedRow).removeClass(config.onDragClass);
439 + jQuery(droppedRow).css(config.onDropStyle);
441 + jQuery.tableDnD.dragObject = null;
442 + if (config.onDrop) {
443 + // Call the onDrop method if there is one
444 + config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
446 + jQuery.tableDnD.currentTable = null; // let go of the table too
450 + serialize: function() {
451 + if (jQuery.tableDnD.currentTable) {
452 + return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);
454 + return "Error: No Table id set, you need to set an id on your table and every row";
458 + serializeTable: function(table) {
460 + var tableId = table.id;
461 + var rows = table.rows;
462 + for (var i=0; i<rows.length; i++) {
463 + if (result.length > 0) result += "&";
464 + var rowId = rows[i].id;
465 + if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) {
466 + rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0];
469 + result += tableId + '[]=' + rowId;
474 + serializeTables: function() {
476 + this.each(function() {
477 + // this is now bound to each matching table
478 + result += jQuery.tableDnD.serializeTable(this);
487 + tableDnD : jQuery.tableDnD.build,
488 + tableDnDUpdate : jQuery.tableDnD.updateTables,
489 + tableDnDSerialize: jQuery.tableDnD.serializeTables
492 \ No newline at end of file
493 --- eventum-2.3.2/htdocs/list.php~ 2012-03-09 18:19:56.000000000 +0200
494 +++ eventum-2.3.2/htdocs/list.php 2012-03-09 18:32:43.998284397 +0200
499 +@$reorder_usr_id = $_REQUEST["reorder_user"];
500 +@$reorder_issue_id = $_REQUEST["reorder_source"];
501 +@$reorder_neworder = $_REQUEST["reorder_neworder"];
502 +Issue::reorderUserIssues($reorder_usr_id, $reorder_issue_id, $reorder_neworder);
504 if (!empty($_REQUEST['nosave'])) {
505 $options = Search::saveSearchParams(false);
509 $assign_options += $users;
511 +// get the isu_order (assigned users) ordering user
512 +if (!empty($options["users"])) {
513 + if ($options["users"] == -2) {
514 + $isu_order_user = $usr_id;
516 + if ($options["users"] > 0) {
517 + $isu_order_user = $options["users"];
519 + unset($isu_order_user);
522 + unset($isu_order_user);
525 +if (isset($isu_order_user)) {
526 + $tpl->assign("isu_order_user", $isu_order_user);
529 $list = Search::getListing($prj_id, $options, $pagerRow, $rows);
530 $tpl->assign("list", $list["list"]);
531 $tpl->assign("list_info", $list["info"]);
532 --- eventum-2.2/lib/eventum/class.display_column.php 2009-09-14 18:07:55.000000000 +0300
533 +++ eventum-2.2-order/lib/eventum/class.display_column.php 2009-10-12 22:10:36.429185594 +0300
536 "iss_expected_resolution_date" => array(
537 "title" => ev_gettext("Expected Resolution Date")
540 + "isu_order" => array(
541 + "title" => ev_gettext("Order")
545 return $columns[$page];
546 --- eventum-2.3.1/lib/eventum/class.issue.php~ 2011-09-15 09:36:55.000000000 +0300
547 +++ eventum-2.3.1/lib/eventum/class.issue.php 2011-09-15 09:42:02.844032474 +0300
548 @@ -1374,6 +1374,7 @@
552 + self::moveOrderForAllUsers($issue_id, 1000);
553 $prj_id = self::getProjectID($issue_id);
556 @@ -1800,16 +1801,33 @@
558 $issue_id = Misc::escapeInteger($issue_id);
559 $assignee_usr_id = Misc::escapeInteger($assignee_usr_id);
561 + // move all orders down to free "order space" for this new association
563 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
565 + isu_order = isu_order + 1
567 + isu_usr_id = $assignee_usr_id AND
568 + isu_order >= $order";
569 + $res = DB_Helper::getInstance()->query($stmt);
570 + if (PEAR::isError($res)) {
571 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
574 + // insert the new association
576 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
586 - '" . Date_Helper::getCurrentDateGMT() . "'
587 + '" . Date_Helper::getCurrentDateGMT() . "',
590 $res = DB_Helper::getInstance()->query($stmt);
591 if (PEAR::isError($res)) {
592 @@ -1824,6 +1842,78 @@
597 + * Method used to get the order list to be rearranged
600 + * @param string $issue_id The issue ID or a comma seperated list of IDs already prepared for giving to mysql
601 + * @param string $usr_id The user to remove. When not specified, all users are taken as to be removed for that issue
602 + * @return mixed delete order list to be rearranged. Used as a parameter to the method of rearranging the order.
604 + function getDeleteUserAssociationOrderList($issue_id, $usr_id = "")
606 + // find all affected associantion orders
607 + $stmt = "SELECT isu_usr_id, isu_order FROM
608 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
610 + isu_iss_id IN ($issue_id)";
611 + if (!empty($usr_id)) {
612 + $stmt.= " AND isu_usr_id IN ($usr_id)";
614 + $stmt.= "ORDER BY isu_order";
615 + $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
616 + if (PEAR::isError($res)) {
617 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
620 + $deleted_orders = array();
621 + foreach ($res as $row) {
622 + if (empty($deleted_orders[$row['isu_usr_id']])) {
623 + $deleted_orders[$row['isu_usr_id']] = array();
625 + $deleted_orders[$row['isu_usr_id']] [] = $row['isu_order'];
627 + return $deleted_orders;
633 + * Method used to rearrange order list in the db according to known deleted records
636 + * @param mixed deleteorder list
639 + function rearrangeDeleteUserAssociationOrderList($delete_order_list)
641 + if (empty($delete_order_list) || (!is_array($delete_order_list))) {
644 + foreach ($delete_order_list as $isu_usr_id => $orders) {
645 + for ($i = 0; $i < count($orders); $i++) { // traverse all deleted orders
646 + // move the orders after them up to take the "order space" of the deleted records
648 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
650 + isu_order = isu_order - " . ($i+1) . "
652 + isu_usr_id = $isu_usr_id AND
653 + isu_order > " . $orders[$i];
654 + if ($i < count($orders) - 1) {
656 + isu_order < " . $orders[$i+1];
658 + $res = DB_Helper::getInstance()->query($stmt);
659 + if (PEAR::isError($res)) {
660 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
670 * Method used to delete all user assignments for a specific issue.
671 @@ -1839,6 +1929,7 @@
672 if (is_array($issue_id)) {
673 $issue_id = implode(", ", $issue_id);
675 + $deleted_order_list = self::getDeleteUserAssociationOrderList($issue_id);
677 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
679 @@ -1869,6 +1960,7 @@
681 $issue_id = Misc::escapeInteger($issue_id);
682 $usr_id = Misc::escapeInteger($usr_id);
683 + $delete_order_list = self::getDeleteUserAssociationOrderList($issue_id, $usr_id);
685 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
687 @@ -2020,6 +2021,7 @@
688 History::add($issue_id, Auth::getUserID(), History::getTypeID('user_unassociated'),
689 User::getFullName($usr_id) . ' removed from issue by ' . User::getFullName(Auth::getUserID()));
691 + self::rearrangeDeleteUserAssociationOrderList($delete_order_list);
695 @@ -3253,6 +3352,8 @@
696 $ids = implode(", ", $ids);
703 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,
704 @@ -3264,6 +3365,7 @@
705 if (PEAR::isError($res)) {
706 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
708 + // gather names of the users assigned to each issue
710 for ($i = 0; $i < count($res); $i++) {
711 if (!empty($t[$res[$i]['isu_iss_id']])) {
712 @@ -3272,9 +3374,18 @@
713 $t[$res[$i]['isu_iss_id']] = $res[$i]['usr_full_name'];
718 + for ($i = 0; $i < count($res); $i++) {
719 + if (empty($o[$res[$i]['isu_iss_id']])) {
720 + $o[$res[$i]['isu_iss_id']] = array();
722 + $o[$res[$i]['isu_iss_id']][$res[$i]['isu_usr_id']] = $res[$i]['isu_order'];
724 // now populate the $result variable again
725 for ($i = 0; $i < count($result); $i++) {
726 @$result[$i]['assigned_users'] = $t[$result[$i]['iss_id']];
727 + @$result[$i]['assigned_users_order'] = $o[$result[$i]['iss_id']];
731 @@ -4247,6 +4358,7 @@
732 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
735 + self::moveOrderForAllUsers($issue_id, 1);
739 @@ -4346,4 +4458,120 @@
740 History::add($issue_id, Auth::getUserID(), History::getTypeID('user_associated'),
741 "Issue assignment to changed (" . History::formatChanges(join(', ', $old_assignee_names), join(', ', $assignee_names)) . ") by " . User::getFullName(Auth::getUserID()));
745 + * Reorders user's issues as requested by user
747 + * @param $usr_id User to be reordered
748 + * @param $issue_id Issue or array of issues to be moved
749 + * @param $neworder The new order of the issues
752 + function reorderUserIssues($usr_id, $issue_id, $neworder)
754 + if (!isset($usr_id) || !isset($issue_id) || !isset($neworder)) {
757 + if (!is_numeric($usr_id) || !is_numeric($neworder)) {
760 + $usr_id = Misc::escapeInteger($usr_id);
761 + $issue_id = Misc::escapeInteger($issue_id);
762 + $neworder = Misc::escapeInteger($neworder);
763 + if (is_array($issue_id)) {
764 + $issue_count = count($issue_id);
765 + $issue_id_str = implode(", ", $issue_id);
768 + $issue_id_str = $issue_id;
769 + $issue_id = array($issue_id);
771 + // do a nasty pretending to be deleting stuff so that reordering happens as if these elements were deleted
772 + $orderlist = self::getDeleteUserAssociationOrderList($issue_id_str, $usr_id);
773 + self::rearrangeDeleteUserAssociationOrderList($orderlist);
774 + // move down the orders to free the "order space" needed
776 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
778 + isu_order = isu_order + $issue_count
780 + isu_usr_id = $usr_id AND
781 + isu_order >= $neworder";
782 + $res = DB_Helper::getInstance()->query($stmt);
783 + if (PEAR::isError($res)) {
784 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
787 + //update the order for the issues being moved
789 + foreach ($issue_id as $iss_id) {
791 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
793 + isu_order = " . ($neworder + $i) . "
795 + isu_usr_id = $usr_id AND
796 + isu_iss_id = $iss_id";
797 + $res = DB_Helper::getInstance()->query($stmt);
798 + if (PEAR::isError($res)) {
799 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
808 + * Get users issue order list
810 + * @param $user_id User
811 + * @param $order_list Order of the issues
814 + function getIssueOrderByUser($usr_id) {
816 + if (!is_numeric($usr_id)) {
821 + isu_iss_id, isu_order
823 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
825 + isu_usr_id = " . $usr_id ;
827 + $order_list = array();
829 + $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
831 + if (PEAR::isError($res)) {
832 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
835 + foreach ($res as $row) {
836 + $order_list[$row["isu_iss_id"]] = $row["isu_order"];
839 + return $order_list;
842 + function moveOrderForAllUsers($issue_id, $neworder)
844 + // Move the issue to the top priority for the ppl it's assigned to
845 + $stmt = "SELECT isu_usr_id FROM
846 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
848 + isu_iss_id = " . Misc::escapeInteger($issue_id);
849 + $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
850 + if (PEAR::isError($res)) {
851 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
854 + foreach ($res as $row) {
855 + self::reorderUserIssues($row["isu_usr_id"], $issue_id, $neworder);
860 --- eventum-2.3.1/lib/eventum/class.search.php~ 2011-04-20 17:22:15.000000000 +0300
861 +++ eventum-2.3.1/lib/eventum/class.search.php 2011-04-20 17:44:34.498519260 +0300
864 $sort_by = self::getParam('sort_by');
865 $sort_order = self::getParam('sort_order');
866 + $users = self::getParam('users');
867 + if (empty($users) && $sort_by === 'isu_order') {
868 + // Sorting by isu_order is impossible when no user specified
870 + unset($sort_order);
872 $rows = self::getParam('rows');
873 $hide_closed = self::getParam('hide_closed');
874 if ($hide_closed === '') {
876 "iss_expected_resolution_date" => "desc",
877 "pre_title" => "asc",
879 + "isu_order" => "desc",
882 foreach ($custom_fields as $fld_id => $fld_name) {
883 --- eventum-2.3.1/templates/header.tpl.html~ 2011-09-15 09:36:55.000000000 +0300
884 +++ eventum-2.3.1/templates/header.tpl.html 2011-09-15 09:43:49.318473817 +0300
886 <script type="text/javascript" src="{$rel_url}js/jquery/form.js?c=9984"></script>
887 <script type="text/javascript" src="{$rel_url}js/jquery/blockui.js?c=eb13"></script>
888 <script type="text/javascript" src="{$rel_url}js/jquery/ui.datepicker.js?c=a911"></script>
889 +<script type="text/javascript" src="{$rel_url}js/jquery/jquery.tablednd.js"></script>
890 <script type="text/javascript" src="{$rel_url}js/validation.js?c=ad33"></script>
891 <script type="text/javascript" src="{$rel_url}js/browserSniffer.js?c=c046"></script>
892 <script type="text/javascript" src="{$rel_url}js/global.js?c=50d6"></script>
893 --- eventum-2.2/templates/list.tpl.html 2009-09-14 18:07:55.000000000 +0300
894 +++ eventum-2.2-order/templates/list.tpl.html 2009-10-12 22:10:36.439185157 +0300
899 +function reorderBulk(order_user, neworder)
901 + url = page_url + "?";
902 + url += "reorder_user=" + order_user;
904 + items = document.getElementsByName("item[]");
906 + for (var i = 0; i < items.length; i++) {
907 + if (items[i].checked) {
908 + url += "&reorder_source[" + checkedcount + "]=" + items[i].value;
912 + if (checkedcount == 0) {
913 + alert('{/literal}{t escape=js}Please choose which issues to move to the new place.{/t}{literal}');
917 + url += "&reorder_neworder=" + neworder;
919 + window.location.href = url;
921 function hideClosed(f)
923 if (f.hide_closed.checked) {
925 f.go.disabled = true;
928 +function updateCustomFields(issue_id)
930 + var features = 'width=560,height=460,top=30,left=30,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,status=no';
931 + var customWin = window.open('custom_fields.php?issue_id=' + issue_id, '_custom_fields', features);
938 @@ -169,11 +198,11 @@
939 <input type="hidden" name="cat" value="bulk_update">
942 - <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
944 + <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0" id="issue_list_table">
945 + <tr class="nodrag">
946 <td colspan="{$col_count}" class="default">
947 <table width="100%" cellspacing="0" cellpadding="0" border="0">
949 + <tr class="nodrag">
951 <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>
952 {include file="help_link.tpl.html" topic="list"}
957 - <tr bgcolor="{$cell_color}">
958 + <tr bgcolor="{$cell_color}" class="nodrag">
959 {if $current_role > $roles.developer}
961 <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'item[]');toggleBulkUpdate();">
963 {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}
967 + {elseif $field_name != 'isu_order' || $isu_order_user}
968 <td align="{$column.align|default:'center'}" class="default_white" nowrap {if $column.width != ''}width="{$column.width}"{/if}>
969 {if $field_name == 'iss_summary'}
970 <table cellspacing="0" cellpadding="1" width="100%">
976 {section name="i" loop=$list}
977 - <tr {if $current_role >= $roles.developer AND $list[i].iqu_status > 0}style="text-decoration: line-through;"{/if}>
978 + <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}>
979 {if $current_role > $roles.developer}
980 <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>
983 {$fld_value|formatCustomValue:$fld_id:$list[i].iss_id}
987 - <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default">
988 + {elseif $field_name != 'isu_order' || $isu_order_user}
989 + <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default{if $field_name == 'isu_order'} dragHandle{/if}">
990 {if $field_name == 'iss_id'}
991 <a href="view.php?id={$list[i].iss_id}" class="link" title="{t}view issue details{/t}">{$list[i].iss_id}</a>
992 {elseif $field_name == 'pri_rank'}
994 {if $list[i].iss_private == 1}
997 + {elseif $field_name == 'isu_order'}
998 + {if $options.sort_by == "isu_order" and $current_user_id == $isu_order_user} {/if}
1002 @@ -300,10 +332,11 @@
1006 - <tr bgcolor="{$cell_color}">
1008 + <tr bgcolor="{$cell_color}" class="nodrag">
1009 <td colspan="{$col_count}">
1010 <table width="100%" cellspacing="0" cellpadding="0">
1012 + <tr class="nodrag">
1013 <td width="30%" nowrap>
1014 {if $current_role > $roles.developer}
1015 <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'item[]');">
1016 @@ -355,6 +388,35 @@
1021 +<script type="text/javascript">
1023 + * Order issues by drag and drop:
1024 + * only if sorted by order and viewing your own issues
1026 +{if $options.sort_by == "isu_order" and $current_user_id == $isu_order_user}
1028 +var before = ''; // make it global variable
1029 +$('#issue_list_table').tableDnD({
1030 + onDragClass: "tDnD_whileDrag",
1031 + onDragStart: function(table, row) {
1032 + before = $.tableDnD.serialize('id');
1034 + onDrop: function(table, row) {
1035 + $.post("/ajax/order.php", {before: before, after: $.tableDnD.serialize('id')}, function(data) {
1036 + if (data.length > 0) {
1041 + dragHandle: "dragHandle"
1043 +$("#issue_list_table tr").hover(function() {
1044 + $('#' + this.id + ' .dragHandle').addClass('showDragHandle');
1046 + $('#' + this.id + ' .dragHandle').removeClass('showDragHandle');
1051 {include file="app_info.tpl.html"}
1052 {include file="footer.tpl.html"}