Skip to content

Commit 047bc80

Browse files
committed
Replaced all calls to canManageTeam() with rights checks.
1 parent 7638ca2 commit 047bc80

4 files changed

Lines changed: 19 additions & 27 deletions

File tree

WEB-INF/lib/ttUser.class.php

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,14 +155,6 @@ function isClient() {
155155
return $this->is_client;
156156
}
157157

158-
// canManageTeam - determines whether current user is manager or co-manager.
159-
// This is a legacy function that we are getting rid of by replacing with rights check.
160-
function canManageTeam() {
161-
return $this->can('manage_users'); // By default this is assigned to co-managers (an managers).
162-
// Which is sufficient for now until we refactor all calls
163-
// to this function and then remove it.
164-
}
165-
166158
// isPluginEnabled checks whether a plugin is enabled for user.
167159
function isPluginEnabled($plugin)
168160
{

WEB-INF/templates/footer.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
<br>
1313
<table cellspacing="0" cellpadding="4" width="100%" border="0">
1414
<tr>
15-
<td align="center">&nbsp;Anuko Time Tracker 1.17.88.4268 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
15+
<td align="center">&nbsp;Anuko Time Tracker 1.17.89.4269 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
1616
<a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
1717
<a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
1818
<a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>

tofile.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
}
9898
if ($bean->getAttribute('chcost')) {
9999
print "\t<cost><![CDATA[";
100-
if ($user->canManageTeam() || $user->isClient())
100+
if ($user->can('manage_invoices') || $user->isClient())
101101
print $subtotal['cost'];
102102
else
103103
print $subtotal['expenses'];
@@ -111,7 +111,7 @@
111111
print "<row>\n";
112112

113113
print "\t<date><![CDATA[".$item['date']."]]></date>\n";
114-
if ($user->canManageTeam() || $user->isClient()) print "\t<user><![CDATA[".$item['user']."]]></user>\n";
114+
if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) print "\t<user><![CDATA[".$item['user']."]]></user>\n";
115115
if ($bean->getAttribute('chclient')) print "\t<client><![CDATA[".$item['client']."]]></client>\n";
116116
if ($bean->getAttribute('chproject')) print "\t<project><![CDATA[".$item['project']."]]></project>\n";
117117
if ($bean->getAttribute('chtask')) print "\t<task><![CDATA[".$item['task']."]]></task>\n";
@@ -127,7 +127,7 @@
127127
if ($bean->getAttribute('chnote')) print "\t<note><![CDATA[".$item['note']."]]></note>\n";
128128
if ($bean->getAttribute('chcost')) {
129129
print "\t<cost><![CDATA[";
130-
if ($user->canManageTeam() || $user->isClient())
130+
if ($user->can('manage_invoices') || $user->isClient())
131131
print $item['cost'];
132132
else
133133
print $item['expense'];
@@ -184,7 +184,7 @@
184184
print ',"'.$val.'"';
185185
}
186186
if ($bean->getAttribute('chcost')) {
187-
if ($user->canManageTeam() || $user->isClient())
187+
if ($user->can('manage_invoices') || $user->isClient())
188188
print ',"'.$subtotal['cost'].'"';
189189
else
190190
print ',"'.$subtotal['expenses'].'"';
@@ -194,7 +194,7 @@
194194
} else {
195195
// Normal report. Print headers.
196196
print '"'.$i18n->get('label.date').'"';
197-
if ($user->canManageTeam() || $user->isClient()) print ',"'.$i18n->get('label.user').'"';
197+
if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) print ',"'.$i18n->get('label.user').'"';
198198
if ($bean->getAttribute('chclient')) print ',"'.$i18n->get('label.client').'"';
199199
if ($bean->getAttribute('chproject')) print ',"'.$i18n->get('label.project').'"';
200200
if ($bean->getAttribute('chtask')) print ',"'.$i18n->get('label.task').'"';
@@ -212,7 +212,7 @@
212212
// Print items.
213213
foreach ($items as $item) {
214214
print '"'.$item['date'].'"';
215-
if ($user->canManageTeam() || $user->isClient()) print ',"'.str_replace('"','""',$item['user']).'"';
215+
if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) print ',"'.str_replace('"','""',$item['user']).'"';
216216
if ($bean->getAttribute('chclient')) print ',"'.str_replace('"','""',$item['client']).'"';
217217
if ($bean->getAttribute('chproject')) print ',"'.str_replace('"','""',$item['project']).'"';
218218
if ($bean->getAttribute('chtask')) print ',"'.str_replace('"','""',$item['task']).'"';
@@ -227,7 +227,7 @@
227227
}
228228
if ($bean->getAttribute('chnote')) print ',"'.str_replace('"','""',$item['note']).'"';
229229
if ($bean->getAttribute('chcost')) {
230-
if ($user->canManageTeam() || $user->isClient())
230+
if ($user->can('manage_invoices') || $user->isClient())
231231
print ',"'.$item['cost'].'"';
232232
else
233233
print ',"'.$item['expense'].'"';

topdf.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@
119119
if ($bean->getAttribute('chduration')) $html .= "<td $styleRightAligned>".$subtotal['time'].'</td>';
120120
if ($bean->getAttribute('chcost')) {
121121
$html .= "<td $styleRightAligned>";
122-
if ($user->canManageTeam() || $user->isClient())
122+
if ($user->can('manage_invoices') || $user->isClient())
123123
$html .= $subtotal['cost'];
124124
else
125125
$html .= $subtotal['expenses'];
@@ -135,7 +135,7 @@
135135
if ($bean->getAttribute('chcost')) {
136136
$html .= "<td $styleRightAligned>";
137137
$html .= htmlspecialchars($user->currency).' ';
138-
if ($user->canManageTeam() || $user->isClient())
138+
if ($user->can('manage_invoices') || $user->isClient())
139139
$html .= $totals['cost'];
140140
else
141141
$html .= $totals['expenses'];
@@ -150,7 +150,7 @@
150150
$html .= '<thead>';
151151
$html .= "<tr $styleHeader>";
152152
$html .= '<td>'.$i18n->get('label.date').'</td>';
153-
if ($user->canManageTeam() || $user->isClient()) { $colspan++; $html .= '<td>'.$i18n->get('label.user').'</td>'; }
153+
if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) { $colspan++; $html .= '<td>'.$i18n->get('label.user').'</td>'; }
154154
if ($bean->getAttribute('chclient')) { $colspan++; $html .= '<td>'.$i18n->get('label.client').'</td>'; }
155155
if ($bean->getAttribute('chproject')) { $colspan++; $html .= '<td>'.$i18n->get('label.project').'</td>'; }
156156
if ($bean->getAttribute('chtask')) { $colspan++; $html .= '<td>'.$i18n->get('label.task').'</td>'; }
@@ -174,7 +174,7 @@
174174
if ($cur_grouped_by != $prev_grouped_by && !$first_pass) {
175175
$html .= '<tr style="background-color:#e0e0e0;">';
176176
$html .= '<td>'.$i18n->get('label.subtotal').'</td>';
177-
if ($user->canManageTeam() || $user->isClient()) {
177+
if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) {
178178
$html .= '<td>';
179179
if ($group_by == 'user') $html .= htmlspecialchars($subtotals[$prev_grouped_by]['name']);
180180
$html .= '</td>';
@@ -205,7 +205,7 @@
205205
if ($bean->getAttribute('chnote')) $html .= '<td></td>';
206206
if ($bean->getAttribute('chcost')) {
207207
$html .= "<td $styleRightAligned>";
208-
if ($user->canManageTeam() || $user->isClient())
208+
if ($user->can('manage_invoices') || $user->isClient())
209209
$html .= $subtotals[$prev_grouped_by]['cost'];
210210
else
211211
$html .= $subtotals[$prev_grouped_by]['expenses'];
@@ -223,7 +223,7 @@
223223
// Print a regular row.
224224
$html .= '<tr>';
225225
$html .= '<td>'.$item['date'].'</td>';
226-
if ($user->canManageTeam() || $user->isClient()) $html .= '<td>'.htmlspecialchars($item['user']).'</td>';
226+
if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) $html .= '<td>'.htmlspecialchars($item['user']).'</td>';
227227
if ($bean->getAttribute('chclient')) $html .= '<td>'.htmlspecialchars($item['client']).'</td>';
228228
if ($bean->getAttribute('chproject')) $html .= '<td>'.htmlspecialchars($item['project']).'</td>';
229229
if ($bean->getAttribute('chtask')) $html .= '<td>'.htmlspecialchars($item['task']).'</td>';
@@ -234,7 +234,7 @@
234234
if ($bean->getAttribute('chnote')) $html .= '<td>'.htmlspecialchars($item['note']).'</td>';
235235
if ($bean->getAttribute('chcost')) {
236236
$html .= "<td $styleRightAligned>";
237-
if ($user->canManageTeam() || $user->isClient())
237+
if ($user->can('manage_invoices') || $user->isClient())
238238
$html .= $item['cost'];
239239
else
240240
$html .= $item['expense'];
@@ -261,7 +261,7 @@
261261
if ($print_subtotals) {
262262
$html .= '<tr style="background-color:#e0e0e0;">';
263263
$html .= '<td>'.$i18n->get('label.subtotal').'</td>';
264-
if ($user->canManageTeam() || $user->isClient()) {
264+
if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) {
265265
$html .= '<td>';
266266
if ($group_by == 'user') $html .= htmlspecialchars($subtotals[$prev_grouped_by]['name']);
267267
$html .= '</td>';
@@ -292,7 +292,7 @@
292292
if ($bean->getAttribute('chnote')) $html .= '<td></td>';
293293
if ($bean->getAttribute('chcost')) {
294294
$html .= "<td $styleRightAligned>";
295-
if ($user->canManageTeam() || $user->isClient())
295+
if ($user->can('manage_invoices') || $user->isClient())
296296
$html .= $subtotals[$prev_grouped_by]['cost'];
297297
else
298298
$html .= $subtotals[$prev_grouped_by]['expenses'];
@@ -308,7 +308,7 @@
308308
$html .= '<tr><td colspan="'.$colspan.'">&nbsp;</td></tr>';
309309
$html .= '<tr style="background-color:#e0e0e0;">';
310310
$html .= '<td>'.$i18n->get('label.total').'</td>';
311-
if ($user->canManageTeam() || $user->isClient()) $html .= '<td></td>';
311+
if ($user->can('view_reports') || $user->can('view_all_reports') || $user->isClient()) $html .= '<td></td>';
312312
if ($bean->getAttribute('chclient')) $html .= '<td></td>';
313313
if ($bean->getAttribute('chproject')) $html .= '<td></td>';
314314
if ($bean->getAttribute('chtask')) $html .= '<td></td>';
@@ -319,7 +319,7 @@
319319
if ($bean->getAttribute('chnote')) $html .= '<td></td>';
320320
if ($bean->getAttribute('chcost')) {
321321
$html .= "<td $styleRightAligned>".htmlspecialchars($user->currency).' ';
322-
if ($user->canManageTeam() || $user->isClient())
322+
if ($user->can('manage_invoices') || $user->isClient())
323323
$html .= $totals['cost'];
324324
else
325325
$html .= $totals['expenses'];

0 commit comments

Comments
 (0)