1 --- eventum-1.7.0/include/class.display_column.php 2005-12-29 21:27:24.000000000 +0200
2 +++ eventum/include/class.display_column.php 2006-03-22 18:03:06.000000000 +0200
5 "iss_expected_resolution_date" => array(
6 "title" => "Expected Resolution Date"
8 + "isu_order" => array(
13 --- eventum-1.7.0/include/class.issue.php 2005-12-29 21:27:25.000000000 +0200
14 +++ eventum/include/class.issue.php 2006-03-27 15:33:02.000000000 +0300
16 Reminder_Action::clearLastTriggered($issue_id);
18 // if old status was closed and new status is not, clear closed data from issue.
19 - if ($old_details['sta_is_closed'] == 1) {
20 + if (@$old_details['sta_is_closed'] == 1) {
21 $new_details = Status::getDetails($status_id);
22 if ($new_details['sta_is_closed'] != 1) {
23 Issue::clearClosed($issue_id);
25 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
28 + Issue::moveOrderForAllUsers($issue_id, 1000);
29 $prj_id = Issue::getProjectID($issue_id);
31 // add note with the reason to close the issue
33 $assignment_notifications[] = $assignee;
34 $assignments_changed = true;
36 - $assignments_changed = true;
38 if (count($assignment_notifications) > 0) {
39 Notification::notifyNewAssignment($assignment_notifications, $issue_id);
40 @@ -1596,16 +1596,33 @@
42 $issue_id = Misc::escapeInteger($issue_id);
43 $assignee_usr_id = Misc::escapeInteger($assignee_usr_id);
45 + // move all orders down to free "order space" for this new association
47 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
49 + isu_order = isu_order + 1
51 + isu_usr_id = $assignee_usr_id AND
52 + isu_order >= $order";
53 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
54 + if (PEAR::isError($res)) {
55 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
58 + // insert the new association
60 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
70 - '" . Date_API::getCurrentDateGMT() . "'
71 + '" . Date_API::getCurrentDateGMT() . "',
74 $res = $GLOBALS["db_api"]->dbh->query($stmt);
75 if (PEAR::isError($res)) {
76 @@ -1620,6 +1637,78 @@
81 + * Method used to get the order list to be rearranged
84 + * @param string $issue_id The issue ID or a comma seperated list of IDs already prepared for giving to mysql
85 + * @param string $usr_id The user to remove. When not specified, all users are taken as to be removed for that issue
86 + * @return mixed delete order list to be rearranged. Used as a parameter to the method of rearranging the order.
88 + function getDeleteUserAssociationOrderList($issue_id, $usr_id = "")
90 + // find all affected associantion orders
91 + $stmt = "SELECT isu_usr_id, isu_order FROM
92 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
94 + isu_iss_id IN ($issue_id)";
95 + if ($usr_id !== FALSE) {
96 + $stmt.= " AND isu_usr_id IN ($usr_id)";
98 + $stmt.= "ORDER BY isu_order";
99 + $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
100 + if (PEAR::isError($res)) {
101 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
104 + $deleted_orders = array();
105 + foreach ($res as $row) {
106 + if (empty($deleted_orders[$row['isu_usr_id']])) {
107 + $deleted_orders[$row['isu_usr_id']] = array();
109 + $deleted_orders[$row['isu_usr_id']] [] = $row['isu_order'];
111 + return $deleted_orders;
117 + * Method used to rearrange order list in the db according to known deleted records
120 + * @param mixed deleteorder list
123 + function rearrangeDeleteUserAssociationOrderList($delete_order_list)
125 + if (empty($delete_order_list) || (!is_array($delete_order_list))) {
128 + foreach ($delete_order_list as $isu_usr_id => $orders) {
129 + for ($i = 0; $i < count($orders); $i++) { // traverse all deleted orders
130 + // move the orders after them up to take the "order space" of the deleted records
132 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
134 + isu_order = isu_order - " . ($i+1) . "
136 + isu_usr_id = $isu_usr_id AND
137 + isu_order > " . $orders[$i];
138 + if ($i < count($orders) - 1) {
140 + isu_order < " . $orders[$i+1];
142 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
143 + if (PEAR::isError($res)) {
144 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
154 * Method used to delete all user assignments for a specific issue.
155 @@ -1635,6 +1724,7 @@
156 if (is_array($issue_id)) {
157 $issue_id = implode(", ", $issue_id);
159 + $deleted_order_list = Issue::getDeleteUserAssociationOrderList($issue_id);
161 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
163 @@ -1647,6 +1737,7 @@
165 History::add($issue_id, $usr_id, History::getTypeID('user_all_unassociated'), 'Issue assignments removed by ' . User::getFullName($usr_id));
167 + Issue::rearrangeDeleteUserAsssociationOrderList($deleted_order_list);
171 @@ -1665,6 +1756,7 @@
173 $issue_id = Misc::escapeInteger($issue_id);
174 $usr_id = Misc::escapeInteger($usr_id);
175 + $delete_order_list = Issue::getDeleteUserAssociationOrderList($issue_id, $usr_id);
177 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
179 @@ -1679,6 +1771,7 @@
180 History::add($issue_id, Auth::getUserID(), History::getTypeID('user_unassociated'),
181 User::getFullName($usr_id) . ' removed from issue by ' . User::getFullName(Auth::getUserID()));
183 + Issue::rearrangeDeleteUserAssociationOrderList($delete_order_list);
187 @@ -2047,14 +2140,6 @@
191 - if (count($users) > 0) {
192 - // automatically change the status to 'Assigned'
193 - Issue::setStatus($new_issue_id, Status::getStatusID('Assigned'), FALSE);
195 - // set this special variable to false, to avoid triggering
196 - // another status update on the workflow class
197 - $has_assignee = false;
200 // now process any files being uploaded
202 @@ -2161,6 +2246,11 @@
204 $sort_by = Issue::getParam('sort_by');
205 $sort_order = Issue::getParam('sort_order');
206 + $users = Issue::getParam('users');
207 + if (empty($users) && ($sort_by == 'isu_order')) { // Sorting by isu_order is impossible when no user specified
209 + unset($sort_order);
211 $rows = Issue::getParam('rows');
212 $hide_closed = Issue::getParam('hide_closed');
213 if ($hide_closed === '') {
214 @@ -2261,7 +2351,8 @@
218 - "iss_expected_resolution_date"
219 + "iss_expected_resolution_date",
224 @@ -2975,6 +3066,8 @@
225 $ids = implode(", ", $ids);
232 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,
233 @@ -2986,6 +3079,7 @@
234 if (PEAR::isError($res)) {
235 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
237 + // gather names of the users assigned to each issue
239 for ($i = 0; $i < count($res); $i++) {
240 if (!empty($t[$res[$i]['isu_iss_id']])) {
241 @@ -2994,9 +3088,18 @@
242 $t[$res[$i]['isu_iss_id']] = $res[$i]['usr_full_name'];
247 + for ($i = 0; $i < count($res); $i++) {
248 + if (empty($o[$res[$i]['isu_iss_id']])) {
249 + $o[$res[$i]['isu_iss_id']] = array();
251 + $o[$res[$i]['isu_iss_id']][$res[$i]['isu_usr_id']] = $res[$i]['isu_order'];
253 // now populate the $result variable again
254 for ($i = 0; $i < count($result); $i++) {
255 @$result[$i]['assigned_users'] = $t[$result[$i]['iss_id']];
256 + @$result[$i]['assigned_users_order'] = $o[$result[$i]['iss_id']];
260 @@ -3963,6 +4066,7 @@
261 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
264 + Issue::moveOrderForAllUsers($issue_id, 1);
268 @@ -4021,8 +4125,91 @@
270 return $returns[$msg_id];
274 + * Reorders user's issues as requested by user
276 + * @param $usr_id User to be reordered
277 + * @param $issue_id Issue or array of issues to be moved
278 + * @param $neworder The new order of the issues
281 + function reorderUserIssues($usr_id, $issue_id, $neworder)
283 + if (!isset($usr_id) || !isset($issue_id) || !isset($neworder)) {
286 + if (!is_numeric($usr_id) || !is_numeric($neworder)) {
289 + $usr_id = Misc::escapeInteger($usr_id);
290 + $issue_id = Misc::escapeInteger($issue_id);
291 + $neworder = Misc::escapeInteger($neworder);
292 + if (is_array($issue_id)) {
293 + $issue_count = count($issue_id);
294 + $issue_id_str = implode(", ", $issue_id);
297 + $issue_id_str = $issue_id;
298 + $issue_id = array($issue_id);
300 + // do a nasty pretending to be deleting stuff so that reordering happens as if these elements were deleted
301 + $orderlist = Issue::getDeleteUserAssociationOrderList($issue_id_str, $usr_id);
302 + Issue::rearrangeDeleteUserAssociationOrderList($orderlist);
303 + // move down the orders to free the "order space" needed
305 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
307 + isu_order = isu_order + $issue_count
309 + isu_usr_id = $usr_id AND
310 + isu_order >= $neworder";
311 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
312 + if (PEAR::isError($res)) {
313 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
316 + //update the order for the issues being moved
318 + foreach ($issue_id as $iss_id) {
320 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
322 + isu_order = " . ($neworder + $i) . "
324 + isu_usr_id = $usr_id AND
325 + isu_iss_id = $iss_id";
326 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
327 + if (PEAR::isError($res)) {
328 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
335 + function moveOrderForAllUsers($issue_id, $neworder)
337 + // Move the issue to the top priority for the ppl it's assigned to
338 + $stmt = "SELECT isu_usr_id FROM
339 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
341 + isu_iss_id = " . Misc::escapeInteger($issue_id);
342 + $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
343 + if (PEAR::isError($res)) {
344 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
347 + foreach ($res as $row) {
348 + Issue::reorderUserIssues($row["isu_usr_id"], $issue_id, $neworder);
357 // benchmarking the included file (aka setup time)
359 $GLOBALS['bench']->setMarker('Included Issue Class');
360 diff -ru eventum-1.7.0/list.php eventum/list.php
361 --- eventum-1.7.0/list.php 2005-12-29 21:27:24.000000000 +0200
362 +++ eventum/list.php 2006-03-30 14:57:06.000000000 +0300
364 $profile['sort_by'] . "&sort_order=" . $profile['sort_order']);
367 +@$reorder_usr_id = $_REQUEST["reorder_user"];
368 +@$reorder_issue_id = $_REQUEST["reorder_source"];
369 +@$reorder_neworder = $_REQUEST["reorder_neworder"];
370 +Issue::reorderUserIssues($reorder_usr_id, $reorder_issue_id, $reorder_neworder);
372 $options = Issue::saveSearchParams();
373 $tpl->assign("options", $options);
374 $tpl->assign("sorting", Issue::getSortingInfo($options));
379 +// get the isu_order (assignated users) ordering user
380 +if (!empty($options["users"])) {
381 + if ($options["users"] == -2) {
382 + $isu_order_user = $usr_id;
384 + if ($options["users"] > 0) {
385 + $isu_order_user = $options["users"];
387 + unset($isu_order_user);
390 + unset($isu_order_user);
392 +$tpl->assign("isu_order_user", $isu_order_user);
394 $list = Issue::getListing($prj_id, $options, $pagerRow, $rows);
395 $tpl->assign("list", $list["list"]);
396 $tpl->assign("list_info", $list["info"]);
398 $tpl->assign("refresh_page", "list.php");
400 $tpl->displayTemplate();
402 \ No newline at end of file
404 diff -ru eventum-1.7.0/templates/en/list.tpl.html eventum/templates/en/list.tpl.html
405 --- eventum-1.7.0/templates/en/list.tpl.html 2005-12-29 21:27:24.000000000 +0200
406 +++ eventum/templates/en/list.tpl.html 2006-03-23 16:28:30.000000000 +0200
411 +function reorderBulk(order_user, neworder)
413 + url = page_url + "?";
414 + url += "reorder_user=" + order_user;
416 + items = document.getElementsByName("item[]");
418 + for (var i = 0; i < items.length; i++) {
419 + if (items[i].checked) {
420 + url += "&reorder_source[" + checkedcount + "]=" + items[i].value;
424 + if (checkedcount == 0) {
425 + alert('Please choose which issues to move to the new palce.');
429 + url += "&reorder_neworder=" + neworder;
431 + window.location.href = url;
433 function hideClosed(f)
435 if (f.hide_closed.checked) {
437 <td align="{$column.align|default:'center'}" class="default_white" nowrap>
438 {$fld_title|escape:"html"}
443 + {elseif $field_name != 'isu_order' || $isu_order_user}
444 <td align="{$column.align|default:'center'}" class="default_white" nowrap {if $column.width != ''}width="{$column.width}"{/if}>
445 {if $field_name == 'iss_summary'}
446 <table cellspacing="0" cellpadding="1" width="100%">
450 {elseif $sorting.links[$field_name] != ''}
451 - <a title="sort by {$column.title}" href="{$sorting.links[$field_name]}" class="white_link">{$column.title}</a>
452 - {if $sorting.images[$field_name] != ""}<a title="sort by {$column.title}" href="{$sorting.links[$field_name]}" class="white_link"><img border="0" src="{$sorting.images[$field_name]}"></a>{/if}
453 + <a title="sort by {$column.title}" href="{$sorting.links[$field_name]}" class="white_link">{$column.title}</a>
454 + {if $field_name == 'isu_order'}
455 + <br>{$users[$isu_order_user]}
457 + {if $sorting.images[$field_name] != ""}<a title="sort by {$column.title}" href="{$sorting.links[$field_name]}" class="white_link"><img border="0" src="{$sorting.images[$field_name]}"></a>{/if}
462 {$fld_value|formatCustomValue:$fld_id:$list[i].iss_id}
466 + {elseif $field_name != 'isu_order' || $isu_order_user}
467 <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default">
468 {if $field_name == 'iss_id'}
469 <a href="view.php?id={$list[i].iss_id}" class="link" title="view issue details">{$list[i].iss_id}</a>
472 {if $list[i].iss_private == 1}
476 + {elseif $field_name == 'isu_order'}
477 + {if $isu_order_user}
478 + {assign var="order" value=$list[i].assigned_users_order[$isu_order_user]}
480 + <a class="link" title="hide / show reordering options" href="javascript:void(null);" onClick="javascript:toggleVisibility('order{$list[i].iss_id}_');">{$order}</a>
481 + <div id="order{$list[i].iss_id}_1" style="display: none">
484 + <td class="default">{if $order > 1}<a class="link" title="move up" href="list.php?reorder_user={$isu_order_user}&reorder_source[0]={$list[i].iss_id}&reorder_neworder={math equation="x - 1" x=$order}">Up</a>{/if}</td>
485 + <td class="default"><a class="link" title="move up" href="list.php?reorder_user={$isu_order_user}&reorder_source[0]={$list[i].iss_id}&reorder_neworder={math equation="x + 1" x=$order}">Down</a></td>
488 + <td class="default"><a class="link" title="move here" href="javascript:void(null);" onClick="javascript:reorderBulk({$isu_order_user}, {$order})">Move here</a></td>
499 {include file="app_info.tpl.html"}
500 -{include file="footer.tpl.html"}
501 \ No newline at end of file
502 +{include file="footer.tpl.html"}
505 --- /dev/null 2006-03-28 14:00:37.000000000 +0300
506 +++ ./order_patch-patch.sql 2008-08-27 17:16:21.444016830 +0300
508 +ALTER TABLE eventum_issue_user
509 + ADD isu_order int(11) NOT NULL DEFAULT '0' AFTER isu_assigned_date,
510 + ADD INDEX isu_order (isu_order);