]>
Commit | Line | Data |
---|---|---|
b75ef820 ER |
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 | |
3 | @@ -223,6 +223,9 @@ | |
4 | ), | |
5 | "iss_expected_resolution_date" => array( | |
6 | "title" => "Expected Resolution Date" | |
7 | + ), | |
8 | + "isu_order" => array( | |
9 | + "title" => "Order" | |
10 | ) | |
11 | ) | |
12 | ); | |
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 | |
16 | @@ -1245,6 +1245,7 @@ | |
17 | Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); | |
18 | return -1; | |
19 | } else { | |
20 | + Issue::moveOrderForAllUsers($issue_id, 1000); | |
21 | $prj_id = Issue::getProjectID($issue_id); | |
22 | ||
23 | // add note with the reason to close the issue | |
24 | @@ -1595,16 +1596,33 @@ | |
25 | { | |
26 | $issue_id = Misc::escapeInteger($issue_id); | |
27 | $assignee_usr_id = Misc::escapeInteger($assignee_usr_id); | |
28 | + $order = 1; | |
29 | + // move all orders down to free "order space" for this new association | |
30 | + $stmt = "UPDATE | |
31 | + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user | |
32 | + SET | |
33 | + isu_order = isu_order + 1 | |
34 | + WHERE | |
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__); | |
40 | + return -1; | |
41 | + } | |
42 | + // insert the new association | |
43 | $stmt = "INSERT INTO | |
44 | " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user | |
45 | ( | |
46 | isu_iss_id, | |
47 | isu_usr_id, | |
48 | - isu_assigned_date | |
49 | + isu_assigned_date, | |
50 | + isu_order | |
51 | ) VALUES ( | |
52 | $issue_id, | |
53 | $assignee_usr_id, | |
54 | - '" . Date_API::getCurrentDateGMT() . "' | |
55 | + '" . Date_API::getCurrentDateGMT() . "', | |
56 | + $order | |
57 | )"; | |
58 | $res = $GLOBALS["db_api"]->dbh->query($stmt); | |
59 | if (PEAR::isError($res)) { | |
60 | @@ -1619,6 +1637,78 @@ | |
61 | } | |
62 | } | |
63 | ||
64 | + /** | |
65 | + * Method used to get the order list to be rearranged | |
66 | + * | |
67 | + * @access private | |
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. | |
71 | + */ | |
72 | + function getDeleteUserAssociationOrderList($issue_id, $usr_id = "") | |
73 | + { | |
74 | + // find all affected associantion orders | |
75 | + $stmt = "SELECT isu_usr_id, isu_order FROM | |
76 | + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user | |
77 | + WHERE | |
78 | + isu_iss_id IN ($issue_id)"; | |
79 | + if ($usr_id !== FALSE) { | |
80 | + $stmt.= " AND isu_usr_id IN ($usr_id)"; | |
81 | + } | |
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__); | |
86 | + return -1; | |
87 | + } else { | |
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(); | |
92 | + } | |
93 | + $deleted_orders[$row['isu_usr_id']] [] = $row['isu_order']; | |
94 | + } | |
95 | + return $deleted_orders; | |
96 | + } | |
97 | + } | |
98 | + | |
99 | + /** | |
100 | + * | |
101 | + * Method used to rearrange order list in the db according to known deleted records | |
102 | + * | |
103 | + * @access private | |
104 | + * @param mixed deleteorder list | |
105 | + * @return void | |
106 | + */ | |
107 | + function rearrangeDeleteUserAssociationOrderList($delete_order_list) | |
108 | + { | |
109 | + if (empty($delete_order_list) || (!is_array($delete_order_list))) { | |
110 | + return -1; | |
111 | + } | |
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 | |
115 | + $stmt = "UPDATE | |
116 | + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user | |
117 | + SET | |
118 | + isu_order = isu_order - " . ($i+1) . " | |
119 | + WHERE | |
120 | + isu_usr_id = $isu_usr_id AND | |
121 | + isu_order > " . $orders[$i]; | |
122 | + if ($i < count($orders) - 1) { | |
123 | + $stmt.= " AND | |
124 | + isu_order < " . $orders[$i+1]; | |
125 | + } | |
126 | + $res = $GLOBALS["db_api"]->dbh->query($stmt); | |
127 | + if (PEAR::isError($res)) { | |
128 | + Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); | |
129 | + return -1; | |
130 | + } | |
131 | + } | |
132 | + } | |
133 | + return 1; | |
134 | + } | |
135 | + | |
136 | ||
137 | /** | |
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); | |
142 | } | |
143 | + $deleted_order_list = Issue::getDeleteUserAssociationOrderList($issue_id); | |
144 | $stmt = "DELETE FROM | |
145 | " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user | |
146 | WHERE | |
147 | @@ -1646,6 +1737,7 @@ | |
148 | if ($usr_id) { | |
149 | History::add($issue_id, $usr_id, History::getTypeID('user_all_unassociated'), 'Issue assignments removed by ' . User::getFullName($usr_id)); | |
150 | } | |
151 | + Issue::rearrangeDeleteUserAsssociationOrderList($deleted_order_list); | |
152 | return 1; | |
153 | } | |
154 | } | |
155 | @@ -1664,6 +1756,7 @@ | |
156 | { | |
157 | $issue_id = Misc::escapeInteger($issue_id); | |
158 | $usr_id = Misc::escapeInteger($usr_id); | |
159 | + $delete_order_list = Issue::getDeleteUserAssociationOrderList($issue_id, $usr_id); | |
160 | $stmt = "DELETE FROM | |
161 | " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user | |
162 | WHERE | |
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())); | |
166 | } | |
167 | + Issue::rearrangeDeleteUserAssociationOrderList($delete_order_list); | |
168 | return 1; | |
169 | } | |
170 | } | |
171 | @@ -2160,6 +2246,11 @@ | |
172 | { | |
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 | |
177 | + unset($sort_by); | |
178 | + unset($sort_order); | |
179 | + } | |
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", | |
188 | ); | |
189 | ||
190 | foreach ($custom_fields as $fld_id => $fld_name) { | |
191 | @@ -2974,6 +3067,8 @@ | |
192 | $ids = implode(", ", $ids); | |
193 | $stmt = "SELECT | |
194 | isu_iss_id, | |
195 | + isu_order, | |
196 | + isu_usr_id, | |
197 | usr_full_name | |
198 | FROM | |
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__); | |
203 | } else { | |
204 | + // gather names of the users assigned to each issue | |
205 | $t = array(); | |
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']; | |
210 | } | |
211 | } | |
212 | + // gather orders | |
213 | + $o = array(); | |
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(); | |
217 | + } | |
218 | + $o[$res[$i]['isu_iss_id']][$res[$i]['isu_usr_id']] = $res[$i]['isu_order']; | |
219 | + } | |
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']]; | |
224 | } | |
225 | } | |
226 | } | |
227 | @@ -3962,6 +4067,7 @@ | |
228 | Error_Handler::logError(array($res->getMessage(), $res->getDebugInfo()), __FILE__, __LINE__); | |
229 | return -1; | |
230 | } | |
231 | + Issue::moveOrderForAllUsers($issue_id, 1); | |
232 | } | |
233 | ||
234 | ||
235 | @@ -4020,8 +4126,91 @@ | |
236 | } | |
237 | return $returns[$msg_id]; | |
238 | } | |
239 | + | |
240 | + /** | |
241 | + * Reorders user's issues as requested by user | |
242 | + * @access public | |
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 | |
246 | + * @return void | |
247 | + */ | |
248 | + function reorderUserIssues($usr_id, $issue_id, $neworder) | |
249 | + { | |
250 | + if (!isset($usr_id) || !isset($issue_id) || !isset($neworder)) { | |
251 | + return false; | |
252 | + } | |
253 | + if (!is_numeric($usr_id) || !is_numeric($neworder)) { | |
254 | + return false; | |
255 | + } | |
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); | |
262 | + } else { | |
263 | + $issue_count = 1; | |
264 | + $issue_id_str = $issue_id; | |
265 | + $issue_id = array($issue_id); | |
266 | + } | |
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 | |
271 | + $stmt = "UPDATE | |
272 | + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user | |
273 | + SET | |
274 | + isu_order = isu_order + $issue_count | |
275 | + WHERE | |
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__); | |
281 | + return -1; | |
282 | + } | |
283 | + //update the order for the issues being moved | |
284 | + $i = 0; | |
285 | + foreach ($issue_id as $iss_id) { | |
286 | + $stmt = "UPDATE | |
287 | + " . APP_DEFAULT_DB . "." . APP_TABLE_PREFIX . "issue_user | |
288 | + SET | |
289 | + isu_order = " . ($neworder + $i) . " | |
290 | + WHERE | |
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__); | |
296 | + return -1; | |
297 | + } | |
298 | + $i++; | |
299 | + } | |
300 | + } | |
301 | + | |
302 | + function moveOrderForAllUsers($issue_id, $neworder) | |
303 | + { | |
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 | |
307 | + WHERE | |
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__); | |
312 | + return -1; | |
313 | + } | |
314 | + foreach ($res as $row) { | |
315 | + Issue::reorderUserIssues($row["isu_usr_id"], $issue_id, $neworder); | |
316 | + } | |
317 | + } | |
318 | + | |
319 | } | |
320 | ||
321 | + | |
322 | + | |
323 | + | |
324 | // benchmarking the included file (aka setup time) | |
325 | if (APP_BENCHMARK) { | |
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 | |
329 | @@ -89,6 +89,28 @@ | |
330 | f.target = '_popup'; | |
331 | f.submit(); | |
332 | } | |
333 | +function reorderBulk(order_user, neworder) | |
334 | +{ | |
335 | + url = page_url + "?"; | |
336 | + url += "reorder_user=" + order_user; | |
337 | + | |
338 | + items = document.getElementsByName("item[]"); | |
339 | + checkedcount = 0; | |
340 | + for (var i = 0; i < items.length; i++) { | |
341 | + if (items[i].checked) { | |
342 | + url += "&reorder_source[" + checkedcount + "]=" + items[i].value; | |
343 | + checkedcount++; | |
344 | + } | |
345 | + } | |
346 | + if (checkedcount == 0) { | |
347 | + alert('Please choose which issues to move to the new palce.'); | |
348 | + return false; | |
349 | + } | |
350 | + | |
351 | + url += "&reorder_neworder=" + neworder; | |
352 | + | |
353 | + window.location.href = url; | |
354 | +} | |
355 | function hideClosed(f) | |
356 | { | |
357 | if (f.hide_closed.checked) { | |
358 | @@ -202,8 +224,8 @@ | |
359 | <td align="{$column.align|default:'center'}" class="default_white" nowrap> | |
360 | {$fld_title|escape:"html"} | |
361 | </td> | |
362 | - {/foreach} | |
363 | - {else} | |
364 | + {/foreach} | |
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%"> | |
369 | @@ -218,8 +240,11 @@ | |
370 | </tr> | |
371 | </table> | |
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]} | |
378 | + {/if} | |
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} | |
380 | {else} | |
381 | {$column.title} | |
382 | {/if} | |
383 | @@ -239,7 +264,7 @@ | |
384 | {$fld_value|formatCustomValue:$fld_id:$list[i].iss_id} | |
385 | </td> | |
386 | {/foreach} | |
387 | - {else} | |
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> | |
392 | @@ -278,7 +303,24 @@ | |
393 | {/if} | |
394 | {if $list[i].iss_private == 1} | |
395 | <b>[Private]</b> | |
396 | - {/if} | |
397 | + {/if} | |
398 | + {elseif $field_name == 'isu_order'} | |
399 | + {if $isu_order_user} | |
400 | + {assign var="order" value=$list[i].assigned_users_order[$isu_order_user]} | |
401 | + {if $order} | |
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"> | |
404 | + <table> | |
405 | + <tr> | |
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> | |
408 | + </tr> | |
409 | + <tr> | |
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> | |
411 | + </tr> | |
412 | + </table> | |
413 | + {/if} | |
414 | + {/if} | |
415 | {/if} | |
416 | </td> | |
417 | {/if} |