4 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 * Originally written by Laurent Julliard 2001, 2002, Codendi Team, Xerox
6 * http://www.codendi.com
9 * http://fusionforge.org
11 * This file is part of FusionForge. FusionForge is free software;
12 * you can redistribute it and/or modify it under the terms of the
13 * GNU General Public License as published by the Free Software
14 * Foundation; either version 2 of the Licence, or (at your option)
17 * FusionForge is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
22 * You should have received a copy of the GNU General Public License along
23 * with FusionForge; if not, write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
28 Function that generates hide/show urls to expand/collapse
29 sections of the personal page
32 $svc : service name to hide/show (sr, bug, pm...)
33 $db_item_id : the item (group, forum, task sub-project,...) from the
34 database that we are curently processing and about to display
35 $item_id : the item_id as given in the URL and on which the show/hide switch
37 $hide = hide param as given in the script URL (-1 means no param was given)
40 $hide_url: URL to use in the page to switch from hide to show or vice versa
41 $count_diff: difference between the number of items in the list between now and
42 the previous last time the section was open (can be negative if items were removed)
43 $hide_flag: true if the section must be hidden, false otherwise
47 function my_hide_url ($svc, $db_item_id, $item_id, $count, $hide) {
49 $pref_name = 'my_hide_'.$svc.$db_item_id;
50 $old_hide = $old_count = $old_pref_value = UserManager::instance()->getCurrentUser()->getPreference($pref_name);
51 if ($old_pref_value) {
52 list($old_hide,$old_count) = explode('|', $old_pref_value);
55 // Make sure they are both 0 if never set before
56 if ($old_count == false) { $old_count = 0; }
57 if ($old_hide == false) { $old_hide = 0; }
59 if ($item_id == $db_item_id) {
61 $pref_value = "$hide|$count";
63 $pref_value = "$old_hide|$count";
68 // if items are hidden keep the old count and keep pref as is
69 $pref_value = $old_pref_value;
71 // only update the item count if the items are visible
72 // if they are hidden keep reporting the old count
73 $pref_value = "$old_hide|$count";
78 // Update pref value if needed
79 if ($old_pref_value != $pref_value) {
80 UserManager::instance()->getCurrentUser()->setPreference($pref_name, $pref_value);
84 $hide_url= '<a href="?hide_'.$svc.'=0&hide_item_id='.$db_item_id.'"><img src="../images/pointer_right.png" border="0" title="'._('Expand').'" alt="'._('Expand').'" /></a> ';
87 $hide_url= '<a href="?hide_'.$svc.'=1&hide_item_id='.$db_item_id.'"><img src="../images/pointer_down.png" title="'._('Collapse').'" alt="'._('Collapse').'" /></a> ';
91 return array($hide_now, $count-$old_count, $hide_url);
94 function my_hide($svc, $db_item_id, $item_id, $hide) {
95 $pref_name = 'my_hide_'.$svc.$db_item_id;
96 $old_pref_value = UserManager::instance()->getCurrentUser()->getPreference($pref_name);
98 list($old_hide, $old_count) = explode('|', $old_pref_value);
100 if (!isset($old_hide))
103 // Make sure they are both 0 if never set before
104 if ($old_hide == false) { $old_hide = 0; }
106 if ($item_id == $db_item_id) {
116 function my_format_as_flag($assigned_to, $submitted_by, $multi_assigned_to=null) {
118 if ($assigned_to == user_getid()) {
120 } else if ($multi_assigned_to) {
121 // For multiple assigned to
122 for ($i=0; $i<count($multi_assigned_to); $i++) {
123 if ($multi_assigned_to[$i]==user_getid()) {
128 if ($submitted_by == user_getid()) {
131 if ($AS_flag) { $AS_flag = '[<b>'.$AS_flag.'</b>]'; }
137 function my_format_as_flag2($assignee, $submitter) {
139 if ($assignee) $AS_flag = 'A';
141 if ($submitter) $AS_flag .= 'S';
143 if ($AS_flag != '') $AS_flag = '[<b>'.$AS_flag.'</b>]';
148 function my_item_count($total, $new) {
149 return '['.$total.($new ? ", <b>".vsprintf(_('%s new items'), array($new))."</b>]" : ']');