1 --- eventum-r3721/include/class.display_column.php~ 2008-09-09 22:45:13.000000000 +0300
2 +++ eventum-r3721/include/class.display_column.php 2008-09-09 22:46:04.000000000 +0300
5 "iss_expected_resolution_date" => array(
6 "title" => ev_gettext("Expected Resolution Date")
9 + "isu_order" => array(
10 + "title" => ev_gettext("Issue Order")
14 return $columns[$page];
15 --- eventum-1.7.0/include/class.issue.php 2005-12-29 21:27:25.000000000 +0200
16 +++ eventum/include/class.issue.php 2006-03-27 15:33:02.000000000 +0300
18 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
21 + Issue::moveOrderForAllUsers($issue_id, 1000);
22 $prj_id = Issue::getProjectID($issue_id);
24 // add note with the reason to close the issue
25 @@ -1596,16 +1596,33 @@
27 $issue_id = Misc::escapeInteger($issue_id);
28 $assignee_usr_id = Misc::escapeInteger($assignee_usr_id);
30 + // move all orders down to free "order space" for this new association
32 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
34 + isu_order = isu_order + 1
36 + isu_usr_id = $assignee_usr_id AND
37 + isu_order >= $order";
38 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
39 + if (PEAR::isError($res)) {
40 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
43 + // insert the new association
45 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
55 - '" . Date_API::getCurrentDateGMT() . "'
56 + '" . Date_API::getCurrentDateGMT() . "',
59 $res = $GLOBALS["db_api"]->dbh->query($stmt);
60 if (PEAR::isError($res)) {
61 @@ -1620,6 +1637,78 @@
66 + * Method used to get the order list to be rearranged
69 + * @param string $issue_id The issue ID or a comma seperated list of IDs already prepared for giving to mysql
70 + * @param string $usr_id The user to remove. When not specified, all users are taken as to be removed for that issue
71 + * @return mixed delete order list to be rearranged. Used as a parameter to the method of rearranging the order.
73 + function getDeleteUserAssociationOrderList($issue_id, $usr_id = "")
75 + // find all affected associantion orders
76 + $stmt = "SELECT isu_usr_id, isu_order FROM
77 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
79 + isu_iss_id IN ($issue_id)";
80 + if ($usr_id !== FALSE) {
81 + $stmt.= " AND isu_usr_id IN ($usr_id)";
83 + $stmt.= "ORDER BY isu_order";
84 + $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
85 + if (PEAR::isError($res)) {
86 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
89 + $deleted_orders = array();
90 + foreach ($res as $row) {
91 + if (empty($deleted_orders[$row['isu_usr_id']])) {
92 + $deleted_orders[$row['isu_usr_id']] = array();
94 + $deleted_orders[$row['isu_usr_id']] [] = $row['isu_order'];
96 + return $deleted_orders;
102 + * Method used to rearrange order list in the db according to known deleted records
105 + * @param mixed deleteorder list
108 + function rearrangeDeleteUserAssociationOrderList($delete_order_list)
110 + if (empty($delete_order_list) || (!is_array($delete_order_list))) {
113 + foreach ($delete_order_list as $isu_usr_id => $orders) {
114 + for ($i = 0; $i < count($orders); $i++) { // traverse all deleted orders
115 + // move the orders after them up to take the "order space" of the deleted records
117 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
119 + isu_order = isu_order - " . ($i+1) . "
121 + isu_usr_id = $isu_usr_id AND
122 + isu_order > " . $orders[$i];
123 + if ($i < count($orders) - 1) {
125 + isu_order < " . $orders[$i+1];
127 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
128 + if (PEAR::isError($res)) {
129 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
139 * Method used to delete all user assignments for a specific issue.
140 @@ -1635,6 +1724,7 @@
141 if (is_array($issue_id)) {
142 $issue_id = implode(", ", $issue_id);
144 + $deleted_order_list = Issue::getDeleteUserAssociationOrderList($issue_id);
146 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
148 @@ -1647,6 +1737,7 @@
150 History::add($issue_id, $usr_id, History::getTypeID('user_all_unassociated'), 'Issue assignments removed by ' . User::getFullName($usr_id));
152 + Issue::rearrangeDeleteUserAsssociationOrderList($deleted_order_list);
156 @@ -1665,6 +1756,7 @@
158 $issue_id = Misc::escapeInteger($issue_id);
159 $usr_id = Misc::escapeInteger($usr_id);
160 + $delete_order_list = Issue::getDeleteUserAssociationOrderList($issue_id, $usr_id);
162 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
164 @@ -1679,6 +1771,7 @@
165 History::add($issue_id, Auth::getUserID(), History::getTypeID('user_unassociated'),
166 User::getFullName($usr_id) . ' removed from issue by ' . User::getFullName(Auth::getUserID()));
168 + Issue::rearrangeDeleteUserAssociationOrderList($delete_order_list);
172 @@ -2161,6 +2246,11 @@
174 $sort_by = Issue::getParam('sort_by');
175 $sort_order = Issue::getParam('sort_order');
176 + $users = Issue::getParam('users');
177 + if (empty($users) && ($sort_by == 'isu_order')) { // Sorting by isu_order is impossible when no user specified
179 + unset($sort_order);
181 $rows = Issue::getParam('rows');
182 $hide_closed = Issue::getParam('hide_closed');
183 if ($hide_closed === '') {
184 @@ -2582,6 +2582,7 @@
185 "last_action_date" => "desc",
186 "usr_full_name" => "asc",
187 "iss_expected_resolution_date" => "desc",
188 + "isu_order" => "desc",
191 foreach ($custom_fields as $fld_id => $fld_name) {
192 @@ -2975,6 +3066,8 @@
193 $ids = implode(", ", $ids);
200 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,
201 @@ -2986,6 +3079,7 @@
202 if (PEAR::isError($res)) {
203 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
205 + // gather names of the users assigned to each issue
207 for ($i = 0; $i < count($res); $i++) {
208 if (!empty($t[$res[$i]['isu_iss_id']])) {
209 @@ -2994,9 +3088,18 @@
210 $t[$res[$i]['isu_iss_id']] = $res[$i]['usr_full_name'];
215 + for ($i = 0; $i < count($res); $i++) {
216 + if (empty($o[$res[$i]['isu_iss_id']])) {
217 + $o[$res[$i]['isu_iss_id']] = array();
219 + $o[$res[$i]['isu_iss_id']][$res[$i]['isu_usr_id']] = $res[$i]['isu_order'];
221 // now populate the $result variable again
222 for ($i = 0; $i < count($result); $i++) {
223 @$result[$i]['assigned_users'] = $t[$result[$i]['iss_id']];
224 + @$result[$i]['assigned_users_order'] = $o[$result[$i]['iss_id']];
228 @@ -3963,6 +4066,7 @@
229 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
232 + Issue::moveOrderForAllUsers($issue_id, 1);
236 @@ -4021,8 +4125,91 @@
238 return $returns[$msg_id];
242 + * Reorders user's issues as requested by user
244 + * @param $usr_id User to be reordered
245 + * @param $issue_id Issue or array of issues to be moved
246 + * @param $neworder The new order of the issues
249 + function reorderUserIssues($usr_id, $issue_id, $neworder)
251 + if (!isset($usr_id) || !isset($issue_id) || !isset($neworder)) {
254 + if (!is_numeric($usr_id) || !is_numeric($neworder)) {
257 + $usr_id = Misc::escapeInteger($usr_id);
258 + $issue_id = Misc::escapeInteger($issue_id);
259 + $neworder = Misc::escapeInteger($neworder);
260 + if (is_array($issue_id)) {
261 + $issue_count = count($issue_id);
262 + $issue_id_str = implode(", ", $issue_id);
265 + $issue_id_str = $issue_id;
266 + $issue_id = array($issue_id);
268 + // do a nasty pretending to be deleting stuff so that reordering happens as if these elements were deleted
269 + $orderlist = Issue::getDeleteUserAssociationOrderList($issue_id_str, $usr_id);
270 + Issue::rearrangeDeleteUserAssociationOrderList($orderlist);
271 + // move down the orders to free the "order space" needed
273 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
275 + isu_order = isu_order + $issue_count
277 + isu_usr_id = $usr_id AND
278 + isu_order >= $neworder";
279 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
280 + if (PEAR::isError($res)) {
281 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
284 + //update the order for the issues being moved
286 + foreach ($issue_id as $iss_id) {
288 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
290 + isu_order = " . ($neworder + $i) . "
292 + isu_usr_id = $usr_id AND
293 + isu_iss_id = $iss_id";
294 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
295 + if (PEAR::isError($res)) {
296 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
303 + function moveOrderForAllUsers($issue_id, $neworder)
305 + // Move the issue to the top priority for the ppl it's assigned to
306 + $stmt = "SELECT isu_usr_id FROM
307 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
309 + isu_iss_id = " . Misc::escapeInteger($issue_id);
310 + $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
311 + if (PEAR::isError($res)) {
312 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
315 + foreach ($res as $row) {
316 + Issue::reorderUserIssues($row["isu_usr_id"], $issue_id, $neworder);
325 // benchmarking the included file (aka setup time)
327 $GLOBALS['bench']->setMarker('Included Issue Class');
328 diff -ru eventum-1.7.0/list.php eventum/list.php
329 --- eventum-1.7.0/list.php 2005-12-29 21:27:24.000000000 +0200
330 +++ eventum/list.php 2006-03-30 14:57:06.000000000 +0300
332 $profile['sort_by'] . "&sort_order=" . $profile['sort_order']);
335 +@$reorder_usr_id = $_REQUEST["reorder_user"];
336 +@$reorder_issue_id = $_REQUEST["reorder_source"];
337 +@$reorder_neworder = $_REQUEST["reorder_neworder"];
338 +Issue::reorderUserIssues($reorder_usr_id, $reorder_issue_id, $reorder_neworder);
340 $options = Issue::saveSearchParams();
341 $tpl->assign("options", $options);
342 $tpl->assign("sorting", Issue::getSortingInfo($options));
347 +// get the isu_order (assignated users) ordering user
348 +if (!empty($options["users"])) {
349 + if ($options["users"] == -2) {
350 + $isu_order_user = $usr_id;
352 + if ($options["users"] > 0) {
353 + $isu_order_user = $options["users"];
355 + unset($isu_order_user);
358 + unset($isu_order_user);
360 +$tpl->assign("isu_order_user", $isu_order_user);
362 $list = Issue::getListing($prj_id, $options, $pagerRow, $rows);
363 $tpl->assign("list", $list["list"]);
364 $tpl->assign("list_info", $list["info"]);
365 --- eventum-1.7.0/templates/list.tpl.html 2005-12-29 21:27:24.000000000 +0200
366 +++ eventum/templates/list.tpl.html 2006-03-23 16:28:30.000000000 +0200
371 +function reorderBulk(order_user, neworder)
373 + url = page_url + "?";
374 + url += "reorder_user=" + order_user;
376 + items = document.getElementsByName("item[]");
378 + for (var i = 0; i < items.length; i++) {
379 + if (items[i].checked) {
380 + url += "&reorder_source[" + checkedcount + "]=" + items[i].value;
384 + if (checkedcount == 0) {
385 + alert('{/literal}{t escape=js}Please choose which issues to move to the new place.{/t}{literal}');
389 + url += "&reorder_neworder=" + neworder;
391 + window.location.href = url;
393 function hideClosed(f)
395 if (f.hide_closed.checked) {
397 <td align="{$column.align|default:'center'}" class="default_white" nowrap>
398 {$fld_title|escape:"html"}
403 + {elseif $field_name != 'isu_order' || $isu_order_user}
404 <td align="{$column.align|default:'center'}" class="default_white" nowrap {if $column.width != ''}width="{$column.width}"{/if}>
405 {if $field_name == 'iss_summary'}
406 <table cellspacing="0" cellpadding="1" width="100%">
410 {elseif $sorting.links[$field_name] != ''}
411 - <a title="{t}sort by{/t} {$column.title}" href="{$sorting.links[$field_name]}" class="white_link">{$column.title}</a>
412 - {if $sorting.images[$field_name] != ""}<a title="{t}sort by{/t} {$column.title}" href="{$sorting.links[$field_name]}" class="white_link"><img border="0" src="{$sorting.images[$field_name]}"></a>{/if}
413 + <a title="{t}sort by{/t} {$column.title}" href="{$sorting.links[$field_name]}" class="white_link">{$column.title}</a>
414 + {if $field_name == 'isu_order'}
415 + <br>{$users[$isu_order_user]}
417 + {if $sorting.images[$field_name] != ""}<a title="{t}sort by{/t} {$column.title}" href="{$sorting.links[$field_name]}" class="white_link"><img border="0" src="{$sorting.images[$field_name]}"></a>{/if}
422 {$fld_value|formatCustomValue:$fld_id:$list[i].iss_id}
426 + {elseif $field_name != 'isu_order' || $isu_order_user}
427 <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default">
428 {if $field_name == 'iss_id'}
429 <a href="view.php?id={$list[i].iss_id}" class="link" title="view issue details">{$list[i].iss_id}</a>
432 {if $list[i].iss_private == 1}
436 + {elseif $field_name == 'isu_order'}
437 + {if $isu_order_user}
438 + {assign var="order" value=$list[i].assigned_users_order[$isu_order_user]}
440 + <a class="link" title="{t}hide / show reordering options{/t}" href="javascript:void(null);" onClick="javascript:toggleVisibility('order{$list[i].iss_id}_');">{$order}</a>
441 + <div id="order{$list[i].iss_id}_1" style="display: none">
444 + <td class="default">{if $order > 1}<a class="link" title="{t}move up{/t}" href="list.php?reorder_user={$isu_order_user}&reorder_source[0]={$list[i].iss_id}&reorder_neworder={math equation="x - 1" x=$order}">{t}Up{/t}</a>{/if}</td>
445 + <td class="default"><a class="link" title="{t}move up{/t}" href="list.php?reorder_user={$isu_order_user}&reorder_source[0]={$list[i].iss_id}&reorder_neworder={math equation="x + 1" x=$order}">{t}Down{/t}</a></td>
448 + <td class="default"><a class="link" title="{t}move here{/t}" href="javascript:void(null);" onClick="javascript:reorderBulk({$isu_order_user}, {$order})">{t}Move here{/t}</a></td>
456 --- /dev/null 2006-03-28 14:00:37.000000000 +0300
457 +++ ./order_patch-patch.sql 2008-08-27 17:16:21.444016830 +0300
459 +ALTER TABLE eventum_issue_user
460 + ADD isu_order int(11) NOT NULL DEFAULT '0' AFTER isu_assigned_date,
461 + ADD INDEX isu_order (isu_order);