4 // Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 // http://www.codendi.com
9 // Originally written by Laurent Julliard 2001, 2002, Codendi Team, Xerox
14 Function that generates hide/show urls to expand/collapse
15 sections of the personal page
18 $svc : service name to hide/show (sr, bug, pm...)
19 $db_item_id : the item (group, forum, task sub-project,...) from the
20 database that we are curently processing and about to display
21 $item_id : the item_id as given in the URL and on which the show/hide switch
23 $hide = hide param as given in the script URL (-1 means no param was given)
26 $hide_url: URL to use in the page to switch from hide to show or vice versa
27 $count_diff: difference between the number of items in the list between now and
28 the previous last time the section was open (can be negative if items were removed)
29 $hide_flag: true if the section must be hidden, false otherwise
32 function my_hide_url ($svc, $db_item_id, $item_id, $count, $hide) {
36 $pref_name = 'my_hide_'.$svc.$db_item_id;
37 $old_hide = $old_count = $old_pref_value = UserManager::instance()->getCurrentUser()->getPreference($pref_name);
38 if ($old_pref_value) {
39 list($old_hide,$old_count) = explode('|', $old_pref_value);
42 // Make sure they are both 0 if never set before
43 if ($old_count == false) { $old_count = 0; }
44 if ($old_hide == false) { $old_hide = 0; }
46 if ($item_id == $db_item_id) {
48 $pref_value = "$hide|$count";
50 $pref_value = "$old_hide|$count";
55 // if items are hidden keep the old count and keep pref as is
56 $pref_value = $old_pref_value;
58 // only update the item count if the items are visible
59 // if they are hidden keep reporting the old count
60 $pref_value = "$old_hide|$count";
65 // Update pref value if needed
66 if ($old_pref_value != $pref_value) {
67 UserManager::instance()->getCurrentUser()->setPreference($pref_name, $pref_value);
71 $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> ';
74 $hide_url= '<a href="?hide_'.$svc.'=1&hide_item_id='.$db_item_id.'"><img src="../images/pointer_down.png" border="0" title="'._('Collapse').'" alt="'._('Collapse').'"></a> ';
78 return array($hide_now, $count-$old_count, $hide_url);
81 function my_hide($svc, $db_item_id, $item_id, $hide) {
82 $pref_name = 'my_hide_'.$svc.$db_item_id;
83 $old_pref_value = UserManager::instance()->getCurrentUser()->getPreference($pref_name);
84 list($old_hide,$old_count) = explode('|', $old_pref_value);
86 // Make sure they are both 0 if never set before
87 if ($old_hide == false) { $old_hide = 0; }
89 if ($item_id == $db_item_id) {
99 function my_format_as_flag($assigned_to, $submitted_by, $multi_assigned_to=null) {
101 if ($assigned_to == user_getid()) {
103 } else if ($multi_assigned_to) {
104 // For multiple assigned to
105 for ($i=0; $i<count($multi_assigned_to); $i++) {
106 if ($multi_assigned_to[$i]==user_getid()) {
111 if ($submitted_by == user_getid()) {
114 if ($AS_flag) { $AS_flag = '[<b>'.$AS_flag.'</b>]'; }
120 function my_format_as_flag2($assignee, $submitter) {
122 if ($assignee) $AS_flag = 'A';
124 if ($submitter) $AS_flag .= 'S';
126 if ($AS_flag != '') $AS_flag = '[<b>'.$AS_flag.'</b>]';
131 function my_item_count($total, $new) {
133 return '['.$total.($new ? ", <b>".vsprintf(_('%s new items'), array($new))."</b>]" : ']');