1 --- eventum-1.7.0.orig/include/class.display_column.php 2005-12-29 21:27:24.000000000 +0200
2 +++ eventum-1.7.0/include/class.display_column.php 2006-04-10 13:42:27.939037416 +0300
5 "iss_expected_resolution_date" => array(
6 "title" => "Expected Resolution Date"
8 + "isu_order" => array(
13 diff -u eventum-1.7.0/include/class.issue.php eventum-1.7.1/include/class.issue.php
14 --- eventum-1.7.0/include/class.issue.php 2006-04-10 13:42:27.949037639 +0300
15 +++ eventum-1.7.1/include/class.issue.php 2006-04-10 13:49:39.038651201 +0300
17 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
20 + Issue::moveOrderForAllUsers($issue_id, 1000);
21 $prj_id = Issue::getProjectID($issue_id);
23 // add note with the reason to close the issue
24 @@ -1595,16 +1596,33 @@
26 $issue_id = Misc::escapeInteger($issue_id);
27 $assignee_usr_id = Misc::escapeInteger($assignee_usr_id);
29 + // move all orders down to free "order space" for this new association
31 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
33 + isu_order = isu_order + 1
35 + isu_usr_id = $assignee_usr_id AND
36 + isu_order >= $order";
37 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
38 + if (PEAR::isError($res)) {
39 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
42 + // insert the new association
44 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
54 - '" . Date_API::getCurrentDateGMT() . "'
55 + '" . Date_API::getCurrentDateGMT() . "',
58 $res = $GLOBALS["db_api"]->dbh->query($stmt);
59 if (PEAR::isError($res)) {
60 @@ -1619,6 +1637,78 @@
65 + * Method used to get the order list to be rearranged
68 + * @param string $issue_id The issue ID or a comma seperated list of IDs already prepared for giving to mysql
69 + * @param string $usr_id The user to remove. When not specified, all users are taken as to be removed for that issue
70 + * @return mixed delete order list to be rearranged. Used as a parameter to the method of rearranging the order.
72 + function getDeleteUserAssociationOrderList($issue_id, $usr_id = "")
74 + // find all affected associantion orders
75 + $stmt = "SELECT isu_usr_id, isu_order FROM
76 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
78 + isu_iss_id IN ($issue_id)";
79 + if ($usr_id !== FALSE) {
80 + $stmt.= " AND isu_usr_id IN ($usr_id)";
82 + $stmt.= "ORDER BY isu_order";
83 + $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
84 + if (PEAR::isError($res)) {
85 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
88 + $deleted_orders = array();
89 + foreach ($res as $row) {
90 + if (empty($deleted_orders[$row['isu_usr_id']])) {
91 + $deleted_orders[$row['isu_usr_id']] = array();
93 + $deleted_orders[$row['isu_usr_id']] [] = $row['isu_order'];
95 + return $deleted_orders;
101 + * Method used to rearrange order list in the db according to known deleted records
104 + * @param mixed deleteorder list
107 + function rearrangeDeleteUserAssociationOrderList($delete_order_list)
109 + if (empty($delete_order_list) || (!is_array($delete_order_list))) {
112 + foreach ($delete_order_list as $isu_usr_id => $orders) {
113 + for ($i = 0; $i < count($orders); $i++) { // traverse all deleted orders
114 + // move the orders after them up to take the "order space" of the deleted records
116 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
118 + isu_order = isu_order - " . ($i+1) . "
120 + isu_usr_id = $isu_usr_id AND
121 + isu_order > " . $orders[$i];
122 + if ($i < count($orders) - 1) {
124 + isu_order < " . $orders[$i+1];
126 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
127 + if (PEAR::isError($res)) {
128 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
138 * Method used to delete all user assignments for a specific issue.
139 @@ -1634,6 +1724,7 @@
140 if (is_array($issue_id)) {
141 $issue_id = implode(", ", $issue_id);
143 + $deleted_order_list = Issue::getDeleteUserAssociationOrderList($issue_id);
145 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
147 @@ -1646,6 +1737,7 @@
149 History::add($issue_id, $usr_id, History::getTypeID('user_all_unassociated'), 'Issue assignments removed by ' . User::getFullName($usr_id));
151 + Issue::rearrangeDeleteUserAsssociationOrderList($deleted_order_list);
155 @@ -1664,6 +1756,7 @@
157 $issue_id = Misc::escapeInteger($issue_id);
158 $usr_id = Misc::escapeInteger($usr_id);
159 + $delete_order_list = Issue::getDeleteUserAssociationOrderList($issue_id, $usr_id);
161 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
163 @@ -1678,6 +1771,7 @@
164 History::add($issue_id, Auth::getUserID(), History::getTypeID('user_unassociated'),
165 User::getFullName($usr_id) . ' removed from issue by ' . User::getFullName(Auth::getUserID()));
167 + Issue::rearrangeDeleteUserAssociationOrderList($delete_order_list);
171 @@ -2160,6 +2246,11 @@
173 $sort_by = Issue::getParam('sort_by');
174 $sort_order = Issue::getParam('sort_order');
175 + $users = Issue::getParam('users');
176 + if (empty($users) && ($sort_by == 'isu_order')) { // Sorting by isu_order is impossible when no user specified
178 + unset($sort_order);
180 $rows = Issue::getParam('rows');
181 $hide_closed = Issue::getParam('hide_closed');
182 if ($hide_closed === '') {
183 @@ -2293,6 +2385,7 @@
184 "last_action_date" => "desc",
185 "usr_full_name" => "asc",
186 "iss_expected_resolution_date" => "desc",
187 + "isu_order" => "desc",
190 foreach ($custom_fields as $fld_id => $fld_name) {
191 @@ -2974,6 +3067,8 @@
192 $ids = implode(", ", $ids);
199 " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user,
200 @@ -2985,6 +3080,7 @@
201 if (PEAR::isError($res)) {
202 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
204 + // gather names of the users assigned to each issue
206 for ($i = 0; $i < count($res); $i++) {
207 if (!empty($t[$res[$i]['isu_iss_id']])) {
208 @@ -2993,9 +3089,18 @@
209 $t[$res[$i]['isu_iss_id']] = $res[$i]['usr_full_name'];
214 + for ($i = 0; $i < count($res); $i++) {
215 + if (empty($o[$res[$i]['isu_iss_id']])) {
216 + $o[$res[$i]['isu_iss_id']] = array();
218 + $o[$res[$i]['isu_iss_id']][$res[$i]['isu_usr_id']] = $res[$i]['isu_order'];
220 // now populate the $result variable again
221 for ($i = 0; $i < count($result); $i++) {
222 @$result[$i]['assigned_users'] = $t[$result[$i]['iss_id']];
223 + @$result[$i]['assigned_users_order'] = $o[$result[$i]['iss_id']];
227 @@ -3962,6 +4067,7 @@
228 Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
231 + Issue::moveOrderForAllUsers($issue_id, 1);
235 @@ -4020,8 +4126,91 @@
237 return $returns[$msg_id];
241 + * Reorders user's issues as requested by user
243 + * @param $usr_id User to be reordered
244 + * @param $issue_id Issue or array of issues to be moved
245 + * @param $neworder The new order of the issues
248 + function reorderUserIssues($usr_id, $issue_id, $neworder)
250 + if (!isset($usr_id) || !isset($issue_id) || !isset($neworder)) {
253 + if (!is_numeric($usr_id) || !is_numeric($neworder)) {
256 + $usr_id = Misc::escapeInteger($usr_id);
257 + $issue_id = Misc::escapeInteger($issue_id);
258 + $neworder = Misc::escapeInteger($neworder);
259 + if (is_array($issue_id)) {
260 + $issue_count = count($issue_id);
261 + $issue_id_str = implode(", ", $issue_id);
264 + $issue_id_str = $issue_id;
265 + $issue_id = array($issue_id);
267 + // do a nasty pretending to be deleting stuff so that reordering happens as if these elements were deleted
268 + $orderlist = Issue::getDeleteUserAssociationOrderList($issue_id_str, $usr_id);
269 + Issue::rearrangeDeleteUserAssociationOrderList($orderlist);
270 + // move down the orders to free the "order space" needed
272 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
274 + isu_order = isu_order + $issue_count
276 + isu_usr_id = $usr_id AND
277 + isu_order >= $neworder";
278 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
279 + if (PEAR::isError($res)) {
280 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
283 + //update the order for the issues being moved
285 + foreach ($issue_id as $iss_id) {
287 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
289 + isu_order = " . ($neworder + $i) . "
291 + isu_usr_id = $usr_id AND
292 + isu_iss_id = $iss_id";
293 + $res = $GLOBALS["db_api"]->dbh->query($stmt);
294 + if (PEAR::isError($res)) {
295 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
302 + function moveOrderForAllUsers($issue_id, $neworder)
304 + // Move the issue to the top priority for the ppl it's assigned to
305 + $stmt = "SELECT isu_usr_id FROM
306 + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user
308 + isu_iss_id = " . Misc::escapeInteger($issue_id);
309 + $res = $GLOBALS["db_api"]->dbh->getAll($stmt, DB_FETCHMODE_ASSOC);
310 + if (PEAR::isError($res)) {
311 + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__);
314 + foreach ($res as $row) {
315 + Issue::reorderUserIssues($row["isu_usr_id"], $issue_id, $neworder);
324 // benchmarking the included file (aka setup time)
326 $GLOBALS['bench']->setMarker('Included Issue Class');
327 --- eventum-1.7.0.orig/templates/en/list.tpl.html 2005-12-29 21:27:24.000000000 +0200
328 +++ eventum-1.7.0/templates/en/list.tpl.html 2006-04-10 13:42:27.949037639 +0300
333 +function reorderBulk(order_user, neworder)
335 + url = page_url + "?";
336 + url += "reorder_user=" + order_user;
338 + items = document.getElementsByName("item[]");
340 + for (var i = 0; i < items.length; i++) {
341 + if (items[i].checked) {
342 + url += "&reorder_source[" + checkedcount + "]=" + items[i].value;
346 + if (checkedcount == 0) {
347 + alert('Please choose which issues to move to the new palce.');
351 + url += "&reorder_neworder=" + neworder;
353 + window.location.href = url;
355 function hideClosed(f)
357 if (f.hide_closed.checked) {
359 <td align="{$column.align|default:'center'}" class="default_white" nowrap>
360 {$fld_title|escape:"html"}
365 + {elseif $field_name != 'isu_order' || $isu_order_user}
366 <td align="{$column.align|default:'center'}" class="default_white" nowrap {if $column.width != ''}width="{$column.width}"{/if}>
367 {if $field_name == 'iss_summary'}
368 <table cellspacing="0" cellpadding="1" width="100%">
372 {elseif $sorting.links[$field_name] != ''}
373 - <a title="sort by {$column.title}" href="{$sorting.links[$field_name]}" class="white_link">{$column.title}</a>
374 - {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}
375 + <a title="sort by {$column.title}" href="{$sorting.links[$field_name]}" class="white_link">{$column.title}</a>
376 + {if $field_name == 'isu_order'}
377 + <br>{$users[$isu_order_user]}
379 + {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}
384 {$fld_value|formatCustomValue:$fld_id:$list[i].iss_id}
388 + {elseif $field_name != 'isu_order' || $isu_order_user}
389 <td bgcolor="{$list[i].status_color}" align="{$column.align|default:'center'}" class="default">
390 {if $field_name == 'iss_id'}
391 <a href="view.php?id={$list[i].iss_id}" class="link" title="view issue details">{$list[i].iss_id}</a>
394 {if $list[i].iss_private == 1}
398 + {elseif $field_name == 'isu_order'}
399 + {if $isu_order_user}
400 + {assign var="order" value=$list[i].assigned_users_order[$isu_order_user]}
402 + <a class="link" title="hide / show reordering options" href="javascript:void(null);" onClick="javascript:toggleVisibility('order{$list[i].iss_id}_');">{$order}</a>
403 + <div id="order{$list[i].iss_id}_1" style="display: none">
406 + <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>
407 + <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>
410 + <td class="default"><a class="link" title="move here" href="javascript:void(null);" onClick="javascript:reorderBulk({$isu_order_user}, {$order})">Move here</a></td>