]> git.pld-linux.org Git - packages/eventum.git/blob - eventum-order.patch
- remove junk
[packages/eventum.git] / eventum-order.patch
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
3 @@ -0,0 +1,72 @@
4 +<?
5 +require_once(dirname(__FILE__) . '/../init.php');
6 +require_once(APP_INC_PATH . "class.auth.php");
7 +require_once(APP_INC_PATH . "class.issue.php");
8 +
9 +// check login
10 +if (!Auth::hasValidCookie(APP_COOKIE)) {
11 +       exit;
12 +}
13 +
14 +
15 +
16 +if (!isset($_POST['before']) || !isset($_POST['after'])) {
17 +       exit;
18 +}
19 +
20 +parse_str($_POST['before'], $before);
21 +parse_str($_POST['after'], $after);
22 +
23 +$before = $before['issue_list_table'];
24 +$after = $after['issue_list_table'];
25 +
26 +
27 +$before = array_slice($before, 2, count($before)-3);
28 +$after = array_slice($after, 2, count($after)-3);
29 +
30 +if (count($before) != count($after) or count($before) < 1) {
31 +       exit;
32 +}
33 +
34 +$usr_id = Auth::getUserID();
35 +
36 +$order = Issue::getIssueOrderByUser($usr_id);
37 +
38 +if (!count($order)) {
39 +    // no prev order list
40 +    exit;
41 +}
42 +
43 +$after_filterd = array();
44 +$before_filterd = array();
45 +
46 +// remove issues that are not assigned to me
47 +foreach ($after as $id) {
48 +    if (isset($order[$id])) {
49 +        $after_filterd[] = $id;
50 +    }
51 +}
52 +foreach ($before as $id) {
53 +    if (isset($order[$id])) {
54 +        $before_filterd[] = $id;
55 +    }
56 +}
57 +
58 +foreach ($after_filterd as $key => $nID) {
59 +    if ($nID != $before_filterd[$key]) {
60 +        if ($nID) {
61 +            $stmt = "UPDATE
62 +                        " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
63 +                     SET
64 +                        isu_order = " . $order[$before_filterd[$key]] . "
65 +                     WHERE
66 +                        isu_iss_id = $nID AND
67 +                        isu_usr_id = $usr_id";
68 +            $res = DB_Helper::getInstance()->query($stmt);
69 +            if (PEAR::isError($res)) {
70 +                Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
71 +                die('update failed');
72 +            }
73 +        }
74 +    }
75 +}
76 --- eventum-2.2/htdocs/ajax/update.php  1970-01-01 02:00:00.000000000 +0200
77 +++ eventum-2.2-order/htdocs/ajax/update.php    2009-10-12 22:10:36.439185157 +0300
78 @@ -0,0 +1,38 @@
79 +<?
80 +require_once(dirname(__FILE__) . '/../init.php');
81 +require_once(APP_INC_PATH . "class.auth.php");
82 +require_once(APP_INC_PATH . "class.issue.php");
83 +
84 +// check login
85 +if (!Auth::hasValidCookie(APP_COOKIE)) {
86 +    exit;
87 +}
88 +
89 +if (!is_numeric($_POST['issueID'])) {
90 +    exit;
91 +}
92 +
93 +switch ($_POST['fieldName']) {
94 +  case 'expected_resolution_date':
95 +    $day = (int)$_POST['day'];
96 +    $month = (int)$_POST['month'];
97 +       $year = (int)$_POST['year'];
98 +       if ($day == 0 && $month == 1 && $year == 0) {
99 +               // clear button
100 +               $date = null;
101 +       } else {
102 +               $date = sprintf('%04d-%02d-%02d', $year, $month, $day);
103 +       }
104 +       if (Issue::updateField($_POST['issueID'], $_POST['fieldName'], $date) !== -1) {
105 +               if (!is_null($date)) {
106 +            echo Date_Helper::getSimpleDate(sprintf('%04d-%02d-%02d', $year, $month, $day), false);
107 +               }
108 +    } else {
109 +        echo 'update failed';
110 +    }
111 +    exit;
112 +  break;
113 +  default:
114 +      die('object type not supported');
115 +  break;
116 +}
117 --- eventum-2.2/htdocs/css/style.css    2009-09-14 18:07:55.000000000 +0300
118 +++ eventum-2.2-order/htdocs/css/style.css      2009-10-12 22:10:36.439185157 +0300
119 @@ -172,4 +172,22 @@
120      font-size: 70%;
121      font-family: Verdana, Arial, Helvetica, sans-serif;
122      padding: 10px;
123 -}
124 \ No newline at end of file
125 +}
126 +.tDnD_whileDrag td {
127 +    background-color: #ffffdd;
128 +}
129 +.tDnD_whileDrag td {
130 +    border: 1px solid red;
131 +}
132 +.inline_date_pick {
133 +    cursor: pointer;
134 +}
135 +.custom_field {
136 +    cursor: pointer;
137 +}
138 +.showDragHandle {
139 +    cursor: move;
140 +       background-image: url(../images/updown2.gif);
141 +    background-repeat: no-repeat;
142 +    background-position: center center;
143 +}
144 --- eventum-2.2/htdocs/js/global.js     2009-09-14 18:07:55.000000000 +0300
145 +++ eventum-2.2-order/htdocs/js/global.js       2009-10-12 22:10:36.439185157 +0300
146 @@ -798,4 +798,44 @@
147          firstDay: user_prefs.week_firstday
148      });
149  });
150 +
151 +$(document).ready(function() {
152 +    // dialog type calender isn't working in Konqueror beacuse it's not a supported browser for either jQuery or jQuery UI
153 +    // http://groups.google.com/group/jquery-ui/browse_thread/thread/ea61238c34cb5f33/046837b02fb90b5c
154 +    if (navigator.appName != 'Konqueror') {
155 +        $(".inline_date_pick").click(function() {
156 +        var masterObj = this;
157 +        var masterObjPos = $(masterObj).offset();
158 +        // offset gives uses top and left but datepicker needs pageX and pageY
159 +        var masterObjPos = {pageX: masterObjPos.left, pageY: masterObjPos.top};
160 +        $(this).datepicker(
161 +            // we use dialog type calender so we won't haveto have a hidden element on the page
162 +            'dialog',
163 +            // selected date
164 +            masterObj.innerHTML,
165 +            // onclick handler
166 +            function (date, dteObj) {
167 +                fieldName = masterObj.id.substr(0,masterObj.id.indexOf('|'));
168 +                issueID = masterObj.id.substr(masterObj.id.indexOf('|')+1);
169 +                               if (date == '') {
170 +                                       // clear button
171 +                                       dteObj.selectedDay = 0;
172 +                                       dteObj.selectedMonth = 0;
173 +                                       dteObj.selectedYear = 0;
174 +                               }
175 +                               //alertProperties(date);
176 +                $.post("/ajax/update.php", {fieldName: fieldName, issueID: issueID, day: dteObj.selectedDay, month: (dteObj.selectedMonth+1), year: dteObj.selectedYear}, function(data) {
177 +                    masterObj.innerHTML = data;
178 +                }, "text");
179 +            },
180 +            // config
181 +            {dateFormat: 'dd M yy', duration: ""},
182 +            // position of the datepicker calender - taken from div's offset
183 +            masterObjPos
184 +        );
185 +        return false;
186 +        });
187 +    }
188 +});
189 +
190  //-->
191 --- eventum-2.2/htdocs/js/jquery/jquery.tablednd.js     1970-01-01 02:00:00.000000000 +0200
192 +++ eventum-2.2-order/htdocs/js/jquery/jquery.tablednd.js       2009-10-12 22:10:36.435851675 +0300
193 @@ -0,0 +1,382 @@
194 +/**
195 + * TableDnD plug-in for JQuery, allows you to drag and drop table rows
196 + * You can set up various options to control how the system will work
197 + * Copyright (c) Denis Howlett <denish@isocra.com>
198 + * Licensed like jQuery, see http://docs.jquery.com/License.
199 + *
200 + * Configuration options:
201 + * 
202 + * onDragStyle
203 + *     This is the style that is assigned to the row during drag. There are limitations to the styles that can be
204 + *     associated with a row (such as you can't assign a border--well you can, but it won't be
205 + *     displayed). (So instead consider using onDragClass.) The CSS style to apply is specified as
206 + *     a map (as used in the jQuery css(...) function).
207 + * onDropStyle
208 + *     This is the style that is assigned to the row when it is dropped. As for onDragStyle, there are limitations
209 + *     to what you can do. Also this replaces the original style, so again consider using onDragClass which
210 + *     is simply added and then removed on drop.
211 + * onDragClass
212 + *     This class is added for the duration of the drag and then removed when the row is dropped. It is more
213 + *     flexible than using onDragStyle since it can be inherited by the row cells and other content. The default
214 + *     is class is tDnD_whileDrag. So to use the default, simply customise this CSS class in your
215 + *     stylesheet.
216 + * onDrop
217 + *     Pass a function that will be called when the row is dropped. The function takes 2 parameters: the table
218 + *     and the row that was dropped. You can work out the new order of the rows by using
219 + *     table.rows.
220 + * onDragStart
221 + *     Pass a function that will be called when the user starts dragging. The function takes 2 parameters: the
222 + *     table and the row which the user has started to drag.
223 + * onAllowDrop
224 + *     Pass a function that will be called as a row is over another row. If the function returns true, allow 
225 + *     dropping on that row, otherwise not. The function takes 2 parameters: the dragged row and the row under
226 + *     the cursor. It returns a boolean: true allows the drop, false doesn't allow it.
227 + * scrollAmount
228 + *     This is the number of pixels to scroll if the user moves the mouse cursor to the top or bottom of the
229 + *     window. The page should automatically scroll up or down as appropriate (tested in IE6, IE7, Safari, FF2,
230 + *     FF3 beta
231 + * dragHandle
232 + *     This is the name of a class that you assign to one or more cells in each row that is draggable. If you
233 + *     specify this class, then you are responsible for setting cursor: move in the CSS and only these cells
234 + *     will have the drag behaviour. If you do not specify a dragHandle, then you get the old behaviour where
235 + *     the whole row is draggable.
236 + * 
237 + * Other ways to control behaviour:
238 + *
239 + * Add class="nodrop" to any rows for which you don't want to allow dropping, and class="nodrag" to any rows
240 + * that you don't want to be draggable.
241 + *
242 + * Inside the onDrop method you can also call $.tableDnD.serialize() this returns a string of the form
243 + * <tableID>[]=<rowID1>&<tableID>[]=<rowID2> so that you can send this back to the server. The table must have
244 + * an ID as must all the rows.
245 + *
246 + * Other methods:
247 + *
248 + * $("...").tableDnDUpdate() 
249 + * Will update all the matching tables, that is it will reapply the mousedown method to the rows (or handle cells).
250 + * This is useful if you have updated the table rows using Ajax and you want to make the table draggable again.
251 + * The table maintains the original configuration (so you don't have to specify it again).
252 + *
253 + * $("...").tableDnDSerialize()
254 + * Will serialize and return the serialized string as above, but for each of the matching tables--so it can be
255 + * called from anywhere and isn't dependent on the currentTable being set up correctly before calling
256 + *
257 + * Known problems:
258 + * - Auto-scoll has some problems with IE7  (it scrolls even when it shouldn't), work-around: set scrollAmount to 0
259 + * 
260 + * Version 0.2: 2008-02-20 First public version
261 + * Version 0.3: 2008-02-07 Added onDragStart option
262 + *                         Made the scroll amount configurable (default is 5 as before)
263 + * Version 0.4: 2008-03-15 Changed the noDrag/noDrop attributes to nodrag/nodrop classes
264 + *                         Added onAllowDrop to control dropping
265 + *                         Fixed a bug which meant that you couldn't set the scroll amount in both directions
266 + *                         Added serialize method
267 + * Version 0.5: 2008-05-16 Changed so that if you specify a dragHandle class it doesn't make the whole row
268 + *                         draggable
269 + *                         Improved the serialize method to use a default (and settable) regular expression.
270 + *                         Added tableDnDupate() and tableDnDSerialize() to be called when you are outside the table
271 + */
272 +jQuery.tableDnD = {
273 +    /** Keep hold of the current table being dragged */
274 +    currentTable : null,
275 +    /** Keep hold of the current drag object if any */
276 +    dragObject: null,
277 +    /** The current mouse offset */
278 +    mouseOffset: null,
279 +    /** Remember the old value of Y so that we don't do too much processing */
280 +    oldY: 0,
281 +
282 +    /** Actually build the structure */
283 +    build: function(options) {
284 +        // Set up the defaults if any
285 +
286 +        this.each(function() {
287 +            // This is bound to each matching table, set up the defaults and override with user options
288 +            this.tableDnDConfig = jQuery.extend({
289 +                onDragStyle: null,
290 +                onDropStyle: null,
291 +                               // Add in the default class for whileDragging
292 +                               onDragClass: "tDnD_whileDrag",
293 +                onDrop: null,
294 +                onDragStart: null,
295 +                scrollAmount: 5,
296 +                               serializeRegexp: /[^\-]*$/, // The regular expression to use to trim row IDs
297 +                               serializeParamName: null, // If you want to specify another parameter name instead of the table ID
298 +                dragHandle: null // If you give the name of a class here, then only Cells with this class will be draggable
299 +            }, options || {});
300 +            // Now make the rows draggable
301 +            jQuery.tableDnD.makeDraggable(this);
302 +        });
303 +
304 +        // Now we need to capture the mouse up and mouse move event
305 +        // We can use bind so that we don't interfere with other event handlers
306 +        jQuery(document)
307 +            .bind('mousemove', jQuery.tableDnD.mousemove)
308 +            .bind('mouseup', jQuery.tableDnD.mouseup);
309 +
310 +        // Don't break the chain
311 +        return this;
312 +    },
313 +
314 +    /** This function makes all the rows on the table draggable apart from those marked as "NoDrag" */
315 +    makeDraggable: function(table) {
316 +        var config = table.tableDnDConfig;
317 +               if (table.tableDnDConfig.dragHandle) {
318 +                       // We only need to add the event to the specified cells
319 +                       var cells = jQuery("td."+table.tableDnDConfig.dragHandle, table);
320 +                       cells.each(function() {
321 +                               // The cell is bound to "this"
322 +                jQuery(this).mousedown(function(ev) {
323 +                    jQuery.tableDnD.dragObject = this.parentNode;
324 +                    jQuery.tableDnD.currentTable = table;
325 +                    jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
326 +                    if (config.onDragStart) {
327 +                        // Call the onDrop method if there is one
328 +                        config.onDragStart(table, this);
329 +                    }
330 +                    return false;
331 +                });
332 +                       })
333 +               } else {
334 +                       // For backwards compatibility, we add the event to the whole row
335 +               var rows = jQuery("tr", table); // get all the rows as a wrapped set
336 +               rows.each(function() {
337 +                               // Iterate through each row, the row is bound to "this"
338 +                               var row = jQuery(this);
339 +                               if (! row.hasClass("nodrag")) {
340 +                       row.mousedown(function(ev) {
341 +                           if (ev.target.tagName == "TD") {
342 +                               jQuery.tableDnD.dragObject = this;
343 +                               jQuery.tableDnD.currentTable = table;
344 +                               jQuery.tableDnD.mouseOffset = jQuery.tableDnD.getMouseOffset(this, ev);
345 +                               if (config.onDragStart) {
346 +                                   // Call the onDrop method if there is one
347 +                                   config.onDragStart(table, this);
348 +                               }
349 +                               return false;
350 +                           }
351 +                       }).css("cursor", "move"); // Store the tableDnD object
352 +                               }
353 +                       });
354 +               }
355 +       },
356 +
357 +       updateTables: function() {
358 +               this.each(function() {
359 +                       // this is now bound to each matching table
360 +                       if (this.tableDnDConfig) {
361 +                               jQuery.tableDnD.makeDraggable(this);
362 +                       }
363 +               })
364 +       },
365 +
366 +    /** Get the mouse coordinates from the event (allowing for browser differences) */
367 +    mouseCoords: function(ev){
368 +        if(ev.pageX || ev.pageY){
369 +            return {x:ev.pageX, y:ev.pageY};
370 +        }
371 +        return {
372 +            x:ev.clientX + document.body.scrollLeft - document.body.clientLeft,
373 +            y:ev.clientY + document.body.scrollTop  - document.body.clientTop
374 +        };
375 +    },
376 +
377 +    /** Given a target element and a mouse event, get the mouse offset from that element.
378 +        To do this we need the element's position and the mouse position */
379 +    getMouseOffset: function(target, ev) {
380 +        ev = ev || window.event;
381 +
382 +        var docPos    = this.getPosition(target);
383 +        var mousePos  = this.mouseCoords(ev);
384 +        return {x:mousePos.x - docPos.x, y:mousePos.y - docPos.y};
385 +    },
386 +
387 +    /** Get the position of an element by going up the DOM tree and adding up all the offsets */
388 +    getPosition: function(e){
389 +        var left = 0;
390 +        var top  = 0;
391 +        /** Safari fix -- thanks to Luis Chato for this! */
392 +        if (e.offsetHeight == 0) {
393 +            /** Safari 2 doesn't correctly grab the offsetTop of a table row
394 +            this is detailed here:
395 +            http://jacob.peargrove.com/blog/2006/technical/table-row-offsettop-bug-in-safari/
396 +            the solution is likewise noted there, grab the offset of a table cell in the row - the firstChild.
397 +            note that firefox will return a text node as a first child, so designing a more thorough
398 +            solution may need to take that into account, for now this seems to work in firefox, safari, ie */
399 +            e = e.firstChild; // a table cell
400 +        }
401 +
402 +        while (e.offsetParent){
403 +            left += e.offsetLeft;
404 +            top  += e.offsetTop;
405 +            e     = e.offsetParent;
406 +        }
407 +
408 +        left += e.offsetLeft;
409 +        top  += e.offsetTop;
410 +
411 +        return {x:left, y:top};
412 +    },
413 +
414 +    mousemove: function(ev) {
415 +        if (jQuery.tableDnD.dragObject == null) {
416 +            return;
417 +        }
418 +
419 +        var dragObj = jQuery(jQuery.tableDnD.dragObject);
420 +        var config = jQuery.tableDnD.currentTable.tableDnDConfig;
421 +        var mousePos = jQuery.tableDnD.mouseCoords(ev);
422 +        var y = mousePos.y - jQuery.tableDnD.mouseOffset.y;
423 +        //auto scroll the window
424 +           var yOffset = window.pageYOffset;
425 +               if (document.all) {
426 +               // Windows version
427 +               //yOffset=document.body.scrollTop;
428 +               if (typeof document.compatMode != 'undefined' &&
429 +                    document.compatMode != 'BackCompat') {
430 +                  yOffset = document.documentElement.scrollTop;
431 +               }
432 +               else if (typeof document.body != 'undefined') {
433 +                  yOffset=document.body.scrollTop;
434 +               }
435 +
436 +           }
437 +                   
438 +               if (mousePos.y-yOffset < config.scrollAmount) {
439 +               window.scrollBy(0, -config.scrollAmount);
440 +           } else {
441 +            var windowHeight = window.innerHeight ? window.innerHeight
442 +                    : document.documentElement.clientHeight ? document.documentElement.clientHeight : document.body.clientHeight;
443 +            if (windowHeight-(mousePos.y-yOffset) < config.scrollAmount) {
444 +                window.scrollBy(0, config.scrollAmount);
445 +            }
446 +        }
447 +
448 +
449 +        if (y != jQuery.tableDnD.oldY) {
450 +            // work out if we're going up or down...
451 +            var movingDown = y > jQuery.tableDnD.oldY;
452 +            // update the old value
453 +            jQuery.tableDnD.oldY = y;
454 +            // update the style to show we're dragging
455 +                       if (config.onDragClass) {
456 +                               dragObj.addClass(config.onDragClass);
457 +                       } else {
458 +                   dragObj.css(config.onDragStyle);
459 +                       }
460 +            // If we're over a row then move the dragged row to there so that the user sees the
461 +            // effect dynamically
462 +            var currentRow = jQuery.tableDnD.findDropTargetRow(dragObj, y);
463 +            if (currentRow) {
464 +                // TODO worry about what happens when there are multiple TBODIES
465 +                if (movingDown && jQuery.tableDnD.dragObject != currentRow) {
466 +                    jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow.nextSibling);
467 +                } else if (! movingDown && jQuery.tableDnD.dragObject != currentRow) {
468 +                    jQuery.tableDnD.dragObject.parentNode.insertBefore(jQuery.tableDnD.dragObject, currentRow);
469 +                }
470 +            }
471 +        }
472 +
473 +        return false;
474 +    },
475 +
476 +    /** We're only worried about the y position really, because we can only move rows up and down */
477 +    findDropTargetRow: function(draggedRow, y) {
478 +        var rows = jQuery.tableDnD.currentTable.rows;
479 +        for (var i=0; i<rows.length; i++) {
480 +            var row = rows[i];
481 +            var rowY    = this.getPosition(row).y;
482 +            var rowHeight = parseInt(row.offsetHeight)/2;
483 +            if (row.offsetHeight == 0) {
484 +                rowY = this.getPosition(row.firstChild).y;
485 +                rowHeight = parseInt(row.firstChild.offsetHeight)/2;
486 +            }
487 +            // Because we always have to insert before, we need to offset the height a bit
488 +            if ((y > rowY - rowHeight) && (y < (rowY + rowHeight))) {
489 +                // that's the row we're over
490 +                               // If it's the same as the current row, ignore it
491 +                               if (row == draggedRow) {return null;}
492 +                var config = jQuery.tableDnD.currentTable.tableDnDConfig;
493 +                if (config.onAllowDrop) {
494 +                    if (config.onAllowDrop(draggedRow, row)) {
495 +                        return row;
496 +                    } else {
497 +                        return null;
498 +                    }
499 +                } else {
500 +                                       // If a row has nodrop class, then don't allow dropping (inspired by John Tarr and Famic)
501 +                    var nodrop = jQuery(row).hasClass("nodrop");
502 +                    if (! nodrop) {
503 +                        return row;
504 +                    } else {
505 +                        return null;
506 +                    }
507 +                }
508 +                return row;
509 +            }
510 +        }
511 +        return null;
512 +    },
513 +
514 +    mouseup: function(e) {
515 +        if (jQuery.tableDnD.currentTable && jQuery.tableDnD.dragObject) {
516 +            var droppedRow = jQuery.tableDnD.dragObject;
517 +            var config = jQuery.tableDnD.currentTable.tableDnDConfig;
518 +            // If we have a dragObject, then we need to release it,
519 +            // The row will already have been moved to the right place so we just reset stuff
520 +                       if (config.onDragClass) {
521 +                   jQuery(droppedRow).removeClass(config.onDragClass);
522 +                       } else {
523 +                   jQuery(droppedRow).css(config.onDropStyle);
524 +                       }
525 +            jQuery.tableDnD.dragObject   = null;
526 +            if (config.onDrop) {
527 +                // Call the onDrop method if there is one
528 +                config.onDrop(jQuery.tableDnD.currentTable, droppedRow);
529 +            }
530 +            jQuery.tableDnD.currentTable = null; // let go of the table too
531 +        }
532 +    },
533 +
534 +    serialize: function() {
535 +        if (jQuery.tableDnD.currentTable) {
536 +            return jQuery.tableDnD.serializeTable(jQuery.tableDnD.currentTable);
537 +        } else {
538 +            return "Error: No Table id set, you need to set an id on your table and every row";
539 +        }
540 +    },
541 +
542 +       serializeTable: function(table) {
543 +        var result = "";
544 +        var tableId = table.id;
545 +        var rows = table.rows;
546 +        for (var i=0; i<rows.length; i++) {
547 +            if (result.length > 0) result += "&";
548 +            var rowId = rows[i].id;
549 +            if (rowId && rowId && table.tableDnDConfig && table.tableDnDConfig.serializeRegexp) {
550 +                rowId = rowId.match(table.tableDnDConfig.serializeRegexp)[0];
551 +            }
552 +
553 +            result += tableId + '[]=' + rowId;
554 +        }
555 +        return result;
556 +       },
557 +
558 +       serializeTables: function() {
559 +        var result = "";
560 +        this.each(function() {
561 +                       // this is now bound to each matching table
562 +                       result += jQuery.tableDnD.serializeTable(this);
563 +               });
564 +        return result;
565 +    }
566 +
567 +}
568 +
569 +jQuery.fn.extend(
570 +       {
571 +               tableDnD : jQuery.tableDnD.build,
572 +               tableDnDUpdate : jQuery.tableDnD.updateTables,
573 +               tableDnDSerialize: jQuery.tableDnD.serializeTables
574 +       }
575 +);
576 \ No newline at end of file
577 --- eventum-2.2/htdocs/list.php 2009-09-14 18:07:55.000000000 +0300
578 +++ eventum-2.2-order/htdocs/list.php   2009-10-12 22:10:36.435851675 +0300
579 @@ -53,6 +53,11 @@
580              $profile['sort_by'] . "&sort_order=" . $profile['sort_order']);
581  }
582  
583 +@$reorder_usr_id = $_REQUEST["reorder_user"];
584 +@$reorder_issue_id = $_REQUEST["reorder_source"];
585 +@$reorder_neworder = $_REQUEST["reorder_neworder"];
586 +Issue::reorderUserIssues($reorder_usr_id, $reorder_issue_id, $reorder_neworder);
587 +
588  $options = Issue::saveSearchParams();
589  $tpl->assign("options", $options);
590  $tpl->assign("sorting", Issue::getSortingInfo($options));
591 @@ -78,6 +83,21 @@
592  }
593  $assign_options += $users;
594  
595 +// get the isu_order (assignated users) ordering user
596 +if (!empty($options["users"])) {
597 +    if ($options["users"] == -2) {
598 +        $isu_order_user = $usr_id;
599 +    } else
600 +    if ($options["users"] > 0) {
601 +        $isu_order_user = $options["users"];
602 +    } else {
603 +        unset($isu_order_user);
604 +    }
605 +} else {
606 +    unset($isu_order_user);
607 +}
608 +$tpl->assign("isu_order_user", $isu_order_user);
609 +
610  $list = Issue::getListing($prj_id, $options, $pagerRow, $rows);
611  $tpl->assign("list", $list["list"]);
612  $tpl->assign("list_info", $list["info"]);
613 --- eventum-2.2/lib/eventum/class.display_column.php    2009-09-14 18:07:55.000000000 +0300
614 +++ eventum-2.2-order/lib/eventum/class.display_column.php      2009-10-12 22:10:36.429185594 +0300
615 @@ -230,7 +230,10 @@
616                  ),
617                  "iss_expected_resolution_date"  =>  array(
618                      "title" =>  ev_gettext("Expected Resolution Date")
619 -                )
620 +                ),
621 +                "isu_order" => array(
622 +                    "title" => ev_gettext("Order")
623 +                ),
624              )
625          );
626          return $columns[$page];
627 --- eventum-2.2/lib/eventum/class.issue.php     2009-09-14 18:07:55.000000000 +0300
628 +++ eventum-2.2-order/lib/eventum/class.issue.php       2009-10-12 22:10:36.445851670 +0300
629 @@ -1333,6 +1333,7 @@
630              Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
631              return -1;
632          } else {
633 +            self::moveOrderForAllUsers($issue_id, 1000);
634              $prj_id = self::getProjectID($issue_id);
635  
636              // record the change
637 @@ -1636,6 +1637,180 @@
638          }
639      }
640  
641 +    /**
642 +     * Method used to update the a single detail field of a specific issue.
643 +     *
644 +     * @param integer $issue_id
645 +     * @param string $field_name
646 +     * @param string $field_value
647 +     * @param string $field_type string or integer (for escape)
648 +     * @return integer 1 on success, -1 otherwise
649 +     */
650 +    function updateField($issue_id, $field_name, $filed_value) {
651 +
652 +        $issue_id = Misc::escapeInteger($issue_id);
653 +
654 +        $usr_id = Auth::getUserID();
655 +        $prj_id = self::getProjectID($issue_id);
656 +
657 +        // get all of the 'current' information of this issue
658 +        $current = self::getDetails($issue_id);
659 +
660 +        $stmt = "UPDATE
661 +                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue
662 +                 SET
663 +                    iss_updated_date='" . Date_Helper::getCurrentDateGMT() . "',
664 +                    iss_last_public_action_date='" . Date_Helper::getCurrentDateGMT() . "',
665 +                    iss_last_public_action_type='updated'";
666 +
667 +        switch ($field_name) {
668 +            case 'category':
669 +                $stmt .= ", iss_prc_id = " . Misc::escapeInteger($filed_value);
670 +            break;
671 +            case 'release':
672 +                $stmt .= ", iss_pre_id = " . Misc::escapeInteger($filed_value);
673 +            break;
674 +            case 'expected_resolution_date':
675 +                if (is_null($filed_value)) {
676 +                    $stmt .= ", iss_expected_resolution_date = null";
677 +                } else {
678 +                    $stmt .= ", iss_expected_resolution_date = '" . Misc::escapeString($filed_value) . "'";
679 +                }
680 +            break;
681 +            case 'release':
682 +                $stmt .= ", iss_pre_id = " . Misc::escapeInteger($filed_value);
683 +            break;
684 +            case 'priority':
685 +                $stmt .= ", iss_pri_id = " . Misc::escapeInteger($filed_value);
686 +            break;
687 +            case 'status':
688 +                $stmt .= ", iss_sta_id = " . Misc::escapeInteger($filed_value);
689 +            break;
690 +            case 'resolution':
691 +                $stmt .= ", iss_res_id = " . Misc::escapeInteger($filed_value);
692 +            break;
693 +            case 'summary':
694 +                $stmt .= ", iss_summary = '" . Misc::escapeString($filed_value) . "'";
695 +            break;
696 +            case 'description':
697 +                $stmt .= ", iss_description = '" . Misc::escapeString($filed_value) . "'";
698 +            break;
699 +            case 'estimated_dev_time':
700 +                $stmt .= ", iss_dev_time = '" . Misc::escapeString($filed_value) . "'";
701 +            break;
702 +            case 'percent_complete':
703 +                $stmt .= ", iss_percent_complete = '" . Misc::escapeString($filed_value) . "'";
704 +            break;
705 +            case 'trigger_reminders':
706 +                $stmt .= ", iss_trigger_reminders = " . Misc::escapeInteger($filed_value);
707 +            break;
708 +            case 'group':
709 +                $stmt .= ", iss_grp_id = " . Misc::escapeInteger($filed_value);
710 +            break;
711 +            case 'private':
712 +                $stmt .= ", iss_private = " . Misc::escapeInteger($filed_value);
713 +            break;
714 +            default:
715 +                Error_Handler::logError("Unknown field name $field_name", __FILE__, __LINE__);
716 +                return -1;
717 +            break;
718 +        }
719 +
720 +        $stmt .= "
721 +                 WHERE
722 +                    iss_id=$issue_id";
723 +
724 +        $res = DB_Helper::getInstance()->query($stmt);
725 +        if (PEAR::isError($res)) {
726 +            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
727 +            return -1;
728 +        } else {
729 +            $new = array(
730 +                'category' => $current['iss_prc_id'],
731 +                'release' => $current['iss_pre_id'],
732 +                'expected_resolution_date' => $current['iss_expected_resolution_date'],
733 +                'release' => $current['iss_pre_id'],
734 +                'priority' => $current['iss_pri_id'],
735 +                'status' => $current['iss_sta_id'],
736 +                'resolution' => $current['iss_res_id'],
737 +                'summary' => $current['iss_summary'],
738 +                'description' => $current['iss_description'],
739 +                'estimated_dev_time' => $current['iss_dev_time'],
740 +                'percent_complete' => $current['iss_percent_complete'],
741 +                'trigger_reminders' => $current['iss_trigger_reminders'],
742 +                'group' => $current['iss_grp_id'],
743 +                'iss_private' => $current['private']
744 +            );
745 +            $new[$field_name] = $filed_value;
746 +
747 +            // add change to the history (only for changes on specific fields?)
748 +            $updated_fields = array();
749 +            if ($field_name == 'expected_resolution_date' && $current["iss_expected_resolution_date"] != $filed_value) {
750 +                $updated_fields["Expected Resolution Date"] = History::formatChanges($current["iss_expected_resolution_date"], $filed_value);
751 +            }
752 +            if ($field_name == 'category' && $current["iss_prc_id"] != $filed_value) {
753 +                $updated_fields["Category"] = History::formatChanges(Category::getTitle($current["iss_prc_id"]), Category::getTitle($filed_value));
754 +            }
755 +            if ($field_name == 'release' && $current["iss_pre_id"] != $filed_value) {
756 +                $updated_fields["Release"] = History::formatChanges(Release::getTitle($current["iss_pre_id"]), Release::getTitle($filed_value));
757 +            }
758 +            if ($field_name == 'priority' && $current["iss_pri_id"] != $filed_value) {
759 +                $updated_fields["Priority"] = History::formatChanges(Priority::getTitle($current["iss_pri_id"]), Priority::getTitle($filed_value));
760 +                Workflow::handlePriorityChange($prj_id, $issue_id, $usr_id, $current, $new);
761 +            }
762 +            if ($field_name == 'status' && $current["iss_sta_id"] != $filed_value) {
763 +                // clear out the last-triggered-reminder flag when changing the status of an issue
764 +                Reminder_Action::clearLastTriggered($issue_id);
765 +
766 +                // if old status was closed and new status is not, clear closed data from issue.
767 +                $old_status_details = Status::getDetails($current['iss_sta_id']);
768 +                if ($old_status_details['sta_is_closed'] == 1) {
769 +                    $new_status_details = Status::getDetails($filed_value);
770 +                    if ($new_status_details['sta_is_closed'] != 1) {
771 +                        self::clearClosed($issue_id);
772 +                    }
773 +                }
774 +                $updated_fields["Status"] = History::formatChanges(Status::getStatusTitle($current["iss_sta_id"]), Status::getStatusTitle($filed_value));
775 +            }
776 +            if ($field_name == 'resolution' && $current["iss_res_id"] != $filed_value) {
777 +                $updated_fields["Resolution"] = History::formatChanges(Resolution::getTitle($current["iss_res_id"]), Resolution::getTitle($filed_value));
778 +            }
779 +            if ($field_name == 'estimated_dev_time' && $current["iss_dev_time"] != $filed_value) {
780 +                $updated_fields["Estimated Dev. Time"] = History::formatChanges(Misc::getFormattedTime(($current["iss_dev_time"]*60)), Misc::getFormattedTime(($filed_value*60)));
781 +            }
782 +            if ($field_name == 'summary' && $current["iss_summary"] != $filed_value) {
783 +                $updated_fields["Summary"] = '';
784 +            }
785 +            if ($field_name == 'description' && $current["iss_description"] != $filed_value) {
786 +                $updated_fields["Description"] = '';
787 +            }
788 +            if ($field_name == 'private' && ($filed_value != $current['iss_private'])) {
789 +                $updated_fields["Private"] = History::formatChanges(Misc::getBooleanDisplayValue($current['iss_private']), Misc::getBooleanDisplayValue($filed_value));
790 +            }
791 +            if (count($updated_fields) > 0) {
792 +                // log the changes
793 +                $changes = '';
794 +                $i = 0;
795 +                foreach ($updated_fields as $key => $value) {
796 +                    if ($i > 0) {
797 +                        $changes .= "; ";
798 +                    }
799 +                    if (($key != "Summary") && ($key != "Description")) {
800 +                        $changes .= "$key: $value";
801 +                    } else {
802 +                        $changes .= "$key";
803 +                    }
804 +                    $i++;
805 +                }
806 +
807 +                History::add($issue_id, $usr_id, History::getTypeID('issue_updated'), "Issue updated ($changes) by " . User::getFullName($usr_id));
808 +                // send notifications for the issue being updated
809 +                Notification::notifyIssueUpdated($issue_id, $current, $new);
810 +            }
811 +        }
812 +        return 1;
813 +    }
814 +
815  
816      /**
817       * Move the issue to a new project
818 @@ -1800,16 +1975,33 @@
819      {
820          $issue_id = Misc::escapeInteger($issue_id);
821          $assignee_usr_id = Misc::escapeInteger($assignee_usr_id);
822 +        $order = 1;
823 +        // move all orders down to free "order space" for this new association
824 +        $stmt = "UPDATE 
825 +                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
826 +                 SET
827 +                    isu_order = isu_order + 1
828 +                 WHERE
829 +                    isu_usr_id = $assignee_usr_id AND
830 +                    isu_order >= $order";
831 +        $res = DB_Helper::getInstance()->query($stmt);
832 +        if (PEAR::isError($res)) {
833 +            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
834 +            return -1;
835 +        }
836 +        // insert the new association
837          $stmt = "INSERT INTO
838                      " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
839                   (
840                      isu_iss_id,
841                      isu_usr_id,
842 -                    isu_assigned_date
843 +                    isu_assigned_date,
844 +                    isu_order
845                   ) VALUES (
846                      $issue_id,
847                      $assignee_usr_id,
848 -                    '" . Date_Helper::getCurrentDateGMT() . "'
849 +                    '" . Date_Helper::getCurrentDateGMT() . "',
850 +                    $order
851                   )";
852          $res = DB_Helper::getInstance()->query($stmt);
853          if (PEAR::isError($res)) {
854 @@ -1824,6 +2016,78 @@
855          }
856      }
857  
858 +    /**
859 +     * Method used to get the order list to be rearranged
860 +     * 
861 +     * @access  private
862 +     * @param   string $issue_id The issue ID or a comma seperated list of IDs already prepared for giving to mysql
863 +     * @param   string $usr_id The user to remove. When not specified, all users are taken as to be removed for that issue
864 +     * @return  mixed delete order list to be rearranged. Used as a parameter to the method of rearranging the order.
865 +     */
866 +    function getDeleteUserAssociationOrderList($issue_id, $usr_id = "")
867 +    {
868 +        // find all affected associantion orders
869 +        $stmt = "SELECT isu_usr_id, isu_order FROM
870 +                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
871 +                 WHERE
872 +                 isu_iss_id IN ($issue_id)";
873 +        if (!empty($usr_id)) {
874 +            $stmt.= " AND isu_usr_id IN ($usr_id)";
875 +        }
876 +        $stmt.= "ORDER BY isu_order";
877 +        $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
878 +        if (PEAR::isError($res)) {
879 +            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
880 +            return -1;
881 +        } else {
882 +            $deleted_orders = array();
883 +            foreach ($res as $row) {
884 +                if (empty($deleted_orders[$row['isu_usr_id']])) {
885 +                    $deleted_orders[$row['isu_usr_id']] = array();
886 +                }
887 +                $deleted_orders[$row['isu_usr_id']] [] = $row['isu_order'];
888 +            }
889 +            return $deleted_orders;
890 +        }
891 +    }
892 +
893 +    /**
894 +     *
895 +     * Method used to rearrange order list in the db according to known deleted records
896 +     *
897 +     * @access  private
898 +     * @param   mixed  deleteorder list
899 +     * @return void
900 +     */
901 +    function rearrangeDeleteUserAssociationOrderList($delete_order_list)
902 +    {
903 +        if (empty($delete_order_list) || (!is_array($delete_order_list))) {
904 +            return -1;
905 +        }
906 +        foreach ($delete_order_list as $isu_usr_id => $orders) {
907 +            for ($i = 0; $i < count($orders); $i++) { // traverse all deleted orders
908 +                // move the orders after them up to take the "order space" of the deleted records
909 +                $stmt = "UPDATE
910 +                            " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
911 +                         SET
912 +                            isu_order = isu_order - " . ($i+1) . "
913 +                         WHERE
914 +                            isu_usr_id = $isu_usr_id AND
915 +                            isu_order > " . $orders[$i];
916 +                if ($i < count($orders) - 1) {
917 +                    $stmt.=  " AND
918 +                            isu_order < " . $orders[$i+1];
919 +                }
920 +                $res = DB_Helper::getInstance()->query($stmt);
921 +                if (PEAR::isError($res)) {
922 +                    Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
923 +                    return -1;
924 +                }
925 +            }
926 +        }
927 +        return 1;
928 +    }
929 +
930  
931      /**
932       * Method used to delete all user assignments for a specific issue.
933 @@ -1839,6 +2103,7 @@
934          if (is_array($issue_id)) {
935              $issue_id = implode(", ", $issue_id);
936          }
937 +        $deleted_order_list = self::getDeleteUserAssociationOrderList($issue_id);
938          $stmt = "DELETE FROM
939                      " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
940                   WHERE
941 @@ -1869,6 +2134,7 @@
942      {
943          $issue_id = Misc::escapeInteger($issue_id);
944          $usr_id = Misc::escapeInteger($usr_id);
945 +        $delete_order_list = self::getDeleteUserAssociationOrderList($issue_id, $usr_id);
946          $stmt = "DELETE FROM
947                      " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
948                   WHERE
949 @@ -1883,6 +2149,7 @@
950                  History::add($issue_id, Auth::getUserID(), History::getTypeID('user_unassociated'),
951                      User::getFullName($usr_id) . ' removed from issue by ' . User::getFullName(Auth::getUserID()));
952              }
953 +            self::rearrangeDeleteUserAssociationOrderList($delete_order_list);
954              return 1;
955          }
956      }
957 @@ -2342,6 +2609,11 @@
958      {
959          $sort_by = self::getParam('sort_by');
960          $sort_order = self::getParam('sort_order');
961 +        $users = self::getParam('users');
962 +        if (empty($users) && ($sort_by == 'isu_order')) { // Sorting by isu_order is impossible when no user specified
963 +            unset($sort_by);
964 +            unset($sort_order);
965 +        }
966          $rows = self::getParam('rows');
967          $hide_closed = self::getParam('hide_closed');
968          if ($hide_closed === '') {
969 @@ -2448,6 +2720,7 @@
970              "iss_expected_resolution_date" => "desc",
971              "pre_title" => "asc",
972              "assigned" => "asc",
973 +            "isu_order" => "desc",
974          );
975  
976          foreach ($custom_fields as $fld_id => $fld_name) {
977 @@ -3253,6 +3526,8 @@
978          $ids = implode(", ", $ids);
979          $stmt = "SELECT
980                      isu_iss_id,
981 +                    isu_order,
982 +                    isu_usr_id,
983                      usr_full_name
984                   FROM
985                      " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,
986 @@ -3264,6 +3539,7 @@
987          if (PEAR::isError($res)) {
988              Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
989          } else {
990 +            // gather names of the users assigned to each issue
991              $t = array();
992              for ($i = 0; $i < count($res); $i++) {
993                  if (!empty($t[$res[$i]['isu_iss_id']])) {
994 @@ -3272,9 +3548,18 @@
995                      $t[$res[$i]['isu_iss_id']] = $res[$i]['usr_full_name'];
996                  }
997              }
998 +            // gather orders
999 +            $o = array();
1000 +            for ($i = 0; $i < count($res); $i++) {
1001 +                if (empty($o[$res[$i]['isu_iss_id']])) {
1002 +                    $o[$res[$i]['isu_iss_id']] = array();
1003 +                }
1004 +                $o[$res[$i]['isu_iss_id']][$res[$i]['isu_usr_id']] = $res[$i]['isu_order'];
1005 +            }
1006              // now populate the $result variable again
1007              for ($i = 0; $i < count($result); $i++) {
1008                  @$result[$i]['assigned_users'] = $t[$result[$i]['iss_id']];
1009 +                @$result[$i]['assigned_users_order'] = $o[$result[$i]['iss_id']];
1010              }
1011          }
1012      }
1013 @@ -4247,6 +4532,7 @@
1014              Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
1015              return -1;
1016          }
1017 +        self::moveOrderForAllUsers($issue_id, 1);
1018      }
1019  
1020  
1021 @@ -4346,4 +4632,120 @@
1022          History::add($issue_id, Auth::getUserID(), History::getTypeID('user_associated'),
1023                          "Issue assignment to changed (" . History::formatChanges(join(', ', $old_assignee_names), join(', ', $assignee_names)) . ") by " . User::getFullName(Auth::getUserID()));
1024      }
1025 +
1026 +    /**
1027 +     * Reorders user's issues as requested by user
1028 +     * @access public
1029 +     * @param $usr_id User to be reordered
1030 +     * @param $issue_id Issue or array of issues to be moved
1031 +     * @param $neworder The new order of the issues
1032 +     * @return void
1033 +     */
1034 +    function reorderUserIssues($usr_id, $issue_id, $neworder)
1035 +    {
1036 +        if (!isset($usr_id) || !isset($issue_id) || !isset($neworder)) {
1037 +            return false;
1038 +        }
1039 +        if (!is_numeric($usr_id) || !is_numeric($neworder)) {
1040 +            return false;
1041 +        }
1042 +        $usr_id = Misc::escapeInteger($usr_id);
1043 +        $issue_id = Misc::escapeInteger($issue_id);
1044 +        $neworder = Misc::escapeInteger($neworder);
1045 +        if (is_array($issue_id)) {
1046 +            $issue_count = count($issue_id);
1047 +            $issue_id_str = implode(", ", $issue_id);
1048 +        } else {
1049 +            $issue_count = 1;
1050 +            $issue_id_str = $issue_id;
1051 +            $issue_id = array($issue_id);
1052 +        }
1053 +        // do a nasty pretending to be deleting stuff so that reordering happens as if these elements were deleted
1054 +        $orderlist = self::getDeleteUserAssociationOrderList($issue_id_str, $usr_id);
1055 +        self::rearrangeDeleteUserAssociationOrderList($orderlist);
1056 +        // move down the orders to free the "order space" needed
1057 +        $stmt = "UPDATE 
1058 +                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
1059 +                 SET
1060 +                    isu_order = isu_order + $issue_count
1061 +                 WHERE
1062 +                    isu_usr_id = $usr_id AND
1063 +                    isu_order >= $neworder";
1064 +        $res = DB_Helper::getInstance()->query($stmt);
1065 +        if (PEAR::isError($res)) {
1066 +            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
1067 +            return -1;
1068 +        }
1069 +        //update the order for the issues being moved
1070 +        $i = 0;
1071 +        foreach ($issue_id as $iss_id) {
1072 +            $stmt = "UPDATE
1073 +                        " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
1074 +                     SET
1075 +                        isu_order = " . ($neworder + $i) . "
1076 +                     WHERE
1077 +                        isu_usr_id = $usr_id AND
1078 +                        isu_iss_id = $iss_id";
1079 +            $res = DB_Helper::getInstance()->query($stmt);
1080 +            if (PEAR::isError($res)) {
1081 +                Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
1082 +                return -1;
1083 +            }
1084 +            $i++;
1085 +        }
1086 +    }
1087 +
1088 +
1089 +    /**
1090 +     * Get users issue order list
1091 +     * @access public
1092 +     * @param $user_id User
1093 +     * @param $order_list Order of the issues
1094 +     * @return void
1095 +     */
1096 +    function getIssueOrderByUser($usr_id) {
1097 +
1098 +        if (!is_numeric($usr_id)) {
1099 +            return false;
1100 +        }
1101 +
1102 +        $stmt = "SELECT
1103 +                    isu_iss_id, isu_order
1104 +                FROM
1105 +                    " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
1106 +                WHERE
1107 +                    isu_usr_id = " . $usr_id ;
1108 +
1109 +        $order_list = array();
1110 +
1111 +        $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
1112 +
1113 +        if (PEAR::isError($res)) {
1114 +            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
1115 +            return array();
1116 +        } else {
1117 +            foreach ($res as $row) {
1118 +                $order_list[$row["isu_iss_id"]] = $row["isu_order"];
1119 +            }
1120 +        }
1121 +        return $order_list;
1122 +    }
1123 +
1124 +    function moveOrderForAllUsers($issue_id, $neworder)
1125 +    {
1126 +        // Move the issue to the top priority for the ppl it's assigned to
1127 +        $stmt = "SELECT isu_usr_id FROM
1128 +                    "  . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
1129 +                 WHERE
1130 +                    isu_iss_id = " . Misc::escapeInteger($issue_id);
1131 +        $res = DB_Helper::getInstance()->getAll($stmt, DB_FETCHMODE_ASSOC);
1132 +        if (PEAR::isError($res)) {
1133 +            Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
1134 +            return -1;
1135 +        }
1136 +        foreach ($res as $row) {
1137 +            self::reorderUserIssues($row["isu_usr_id"], $issue_id, $neworder);
1138 +        }
1139 +    }
1140 +    
1141  }
1142 --- eventum-2.2/templates/header.tpl.html       2009-09-14 18:07:55.000000000 +0300
1143 +++ eventum-2.2-order/templates/header.tpl.html 2009-10-12 22:10:36.435851675 +0300
1144 @@ -8,6 +8,7 @@
1145  <script type="text/javascript" src="{$rel_url}js/jquery/form.js?c=9984"></script>
1146  <script type="text/javascript" src="{$rel_url}js/jquery/blockui.js?c=eb13"></script>
1147  <script type="text/javascript" src="{$rel_url}js/jquery/ui.datepicker.js?c=a911"></script>
1148 +<script type="text/javascript" src="{$rel_url}js/jquery/jquery.tablednd.js"></script>
1149  <link rel="stylesheet" href="{$rel_url}js/jquery/ui.datepicker.css?c=5096">
1150  <script type="text/javascript">
1151  <!--
1152 --- eventum-2.2/templates/list.tpl.html 2009-09-14 18:07:55.000000000 +0300
1153 +++ eventum-2.2-order/templates/list.tpl.html   2009-10-12 22:10:36.439185157 +0300
1154 @@ -92,6 +92,28 @@
1155      f.target = '_popup';
1156      f.submit();
1157  }
1158 +function reorderBulk(order_user, neworder)
1159 +{
1160 +    url = page_url + "?";
1161 +    url += "reorder_user=" + order_user;
1162 +
1163 +    items = document.getElementsByName("item[]");
1164 +    checkedcount = 0;
1165 +    for (var i = 0; i < items.length; i++) {
1166 +      if (items[i].checked) {
1167 +        url += "&reorder_source[" + checkedcount + "]=" + items[i].value;
1168 +        checkedcount++;
1169 +      }
1170 +    }
1171 +    if (checkedcount == 0) {
1172 +        alert('{/literal}{t escape=js}Please choose which issues to move to the new place.{/t}{literal}');
1173 +        return false;
1174 +    }
1175 +
1176 +    url += "&reorder_neworder=" + neworder;
1177 +    
1178 +    window.location.href = url;
1179 +}
1180  function hideClosed(f)
1181  {
1182      if (f.hide_closed.checked) {
1183 @@ -153,6 +175,13 @@
1184          f.go.disabled = true;
1185      }
1186  }
1187 +function updateCustomFields(issue_id)
1188 +{
1189 +    var features = 'width=560,height=460,top=30,left=30,resizable=yes,scrollbars=yes,toolbar=no,location=no,menubar=no,status=no';
1190 +    var customWin = window.open('custom_fields.php?issue_id=' + issue_id, '_custom_fields', features);
1191 +    customWin.focus();
1192 +    return false;
1193 +}
1194  //-->
1195  </script>
1196  {/literal}
1197 @@ -169,11 +198,11 @@
1198    <input type="hidden" name="cat" value="bulk_update">
1199    <tr>
1200      <td>
1201 -      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0">
1202 -        <tr>
1203 +      <table bgcolor="#FFFFFF" width="100%" cellspacing="1" cellpadding="2" border="0" id="issue_list_table">
1204 +        <tr class="nodrag">
1205            <td colspan="{$col_count}" class="default">
1206              <table width="100%" cellspacing="0" cellpadding="0" border="0">
1207 -              <tr>
1208 +              <tr class="nodrag">
1209                  <td class="default">
1210                    <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>
1211                    {include file="help_link.tpl.html" topic="list"}
1212 @@ -193,7 +222,7 @@
1213              </table>
1214            </td>
1215          </tr>
1216 -        <tr bgcolor="{$cell_color}">
1217 +        <tr bgcolor="{$cell_color}" class="nodrag">
1218            {if $current_role > $roles.developer}
1219            <td width="1%">
1220              <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'item[]');toggleBulkUpdate();">
1221 @@ -208,7 +237,7 @@
1222                    {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}
1223                  </td>
1224                {/foreach}
1225 -          {else}
1226 +          {elseif $field_name != 'isu_order' || $isu_order_user}
1227            <td align="{$column.align|default:'center'}" class="default_white" nowrap {if $column.width != ''}width="{$column.width}"{/if}>
1228              {if $field_name == 'iss_summary'}
1229              <table cellspacing="0" cellpadding="1" width="100%">
1230 @@ -232,20 +261,21 @@
1231            {/if}
1232            {/foreach}
1233          </tr>
1234 +        <tbody>
1235          {section name="i" loop=$list}
1236 -        <tr {if $current_role >= $roles.developer AND $list[i].iqu_status > 0}style="text-decoration: line-through;"{/if}>
1237 +        <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}>
1238            {if $current_role > $roles.developer}
1239            <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>
1240            {/if}
1241            {foreach from=$columns item=column key=field_name}
1242            {if $field_name == 'custom_fields'}
1243              {foreach from=$list[i].custom_field key=fld_id item=fld_value}
1244 -                <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default">
1245 -                  {$fld_value|formatCustomValue:$fld_id:$list[i].iss_id}
1246 +                <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default custom_field" onclick="return updateCustomFields({$list[i].iss_id});">
1247 +                    {$fld_value|formatCustomValue:$fld_id:$list[i].iss_id}
1248                  </td>
1249                {/foreach}
1250 -          {else}
1251 -          <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default">
1252 +          {elseif $field_name != 'isu_order' || $isu_order_user}
1253 +          <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default{if $field_name == 'isu_order'} dragHandle{/if}">
1254              {if $field_name == 'iss_id'}
1255                <a href="view.php?id={$list[i].iss_id}" class="link" title="{t}view issue details{/t}">{$list[i].iss_id}</a>
1256              {elseif $field_name == 'pri_rank'}
1257 @@ -279,7 +309,7 @@
1258              {elseif $field_name == 'iss_percent_complete'}
1259                {$list[i].iss_percent_complete|escape:"html"}%
1260              {elseif $field_name == 'iss_expected_resolution_date'}
1261 -              {$list[i].iss_expected_resolution_date|escape:"html"}
1262 +              <div class="inline_date_pick" id="expected_resolution_date|{$list[i].iss_id}">{$list[i].iss_expected_resolution_date|escape:"html"}&nbsp;</div>
1263              {elseif $field_name == 'iss_summary'}
1264                <a href="view.php?id={$list[i].iss_id}" class="link" title="{t}view issue details{/t}">{$list[i].iss_summary|escape:"html"}</a>
1265                {if $list[i].redeemed}
1266 @@ -288,6 +318,8 @@
1267                {if $list[i].iss_private == 1}
1268                    <b>[Private]</b>
1269                {/if}
1270 +            {elseif $field_name == 'isu_order'}
1271 +              {if $options.sort_by == "isu_order" and $current_user_id == $isu_order_user}&nbsp;{/if}
1272              {/if}
1273            </td>
1274            {/if}
1275 @@ -300,10 +332,11 @@
1276            </td>
1277          </tr>
1278          {/section}
1279 -        <tr bgcolor="{$cell_color}">
1280 +        </tbody>
1281 +        <tr bgcolor="{$cell_color}" class="nodrag">
1282            <td colspan="{$col_count}">
1283              <table width="100%" cellspacing="0" cellpadding="0">
1284 -              <tr>
1285 +              <tr class="nodrag">
1286                  <td width="30%" nowrap>
1287                    {if $current_role > $roles.developer}
1288                    <input type="button" value="{t}All{/t}" class="shortcut" onClick="javascript:toggleSelectAll(this.form, 'item[]');">
1289 @@ -355,6 +388,35 @@
1290    </form>
1291  </table>
1292  <br />
1293 -
1294 +<script type="text/javascript">
1295 +{*
1296 + * Order issues by drag and drop:
1297 + * only if sorted by order and viewing your own issues
1298 + *}
1299 +{if $options.sort_by == "isu_order" and $current_user_id == $isu_order_user}
1300 +{literal}
1301 +var before = ''; // make it global variable
1302 +$('#issue_list_table').tableDnD({
1303 +    onDragClass: "tDnD_whileDrag",
1304 +    onDragStart: function(table, row) {
1305 +        before = $.tableDnD.serialize('id');
1306 +    },
1307 +    onDrop: function(table, row) {
1308 +        $.post("/ajax/order.php", {before: before, after: $.tableDnD.serialize('id')}, function(data) {
1309 +                if (data.length > 0) {
1310 +                alert(data);
1311 +            }
1312 +        }, "text");
1313 +    },
1314 +       dragHandle: "dragHandle"
1315 +});
1316 +$("#issue_list_table tr").hover(function() {
1317 +    $('#' + this.id + ' .dragHandle').addClass('showDragHandle');
1318 +}, function() {
1319 +    $('#' + this.id + ' .dragHandle').removeClass('showDragHandle');
1320 +});
1321 +{/literal}
1322 +{/if}
1323 +</script>
1324  {include file="app_info.tpl.html"}
1325  {include file="footer.tpl.html"}
1326 --- eventum-2.2/upgrade/patches/04_isu_order.php        1970-01-01 02:00:00.000000000 +0200
1327 +++ eventum-2.2-order/upgrade/patches/04_isu_order.php  2009-10-12 22:10:36.439185157 +0300
1328 @@ -0,0 +1,15 @@
1329 +<?php
1330 +
1331 +function db_patch_4() {
1332 +       $stmts = array();
1333 +
1334 +       $columns = db_getCol('DESC %TABLE_PREFIX%issue_user');
1335 +       if (in_array('isu_order', $columns)) {
1336 +               return $stmts;
1337 +       }
1338 +
1339 +       $stmts[] = "ALTER TABLE %TABLE_PREFIX%issue_user ADD isu_order int(11) NOT NULL DEFAULT '0' AFTER isu_assigned_date, ADD INDEX isu_order (isu_order)";
1340 +       $stmts[] = "UPDATE %TABLE_PREFIX%issue_user set isu_order=isu_iss_id";
1341 +
1342 +       return $stmts;
1343 +}
1344 --- eventum-2.2/upgrade/update-database.php     2009-09-14 18:07:55.000000000 +0300
1345 +++ eventum-2.2-order/upgrade/update-database.php       2009-10-12 22:10:36.439185157 +0300
1346 @@ -73,6 +73,7 @@
1347                 1 => '01_notes.php',
1348                 2 => '02_usr_alias.php',
1349                 3 => '03_prj_mail_aliases.php',
1350 +               4 => '04_isu_order.php',
1351         );
1352  
1353         // sanity check. check that the version table exists.
This page took 0.290746 seconds and 4 git commands to generate.