File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -295,4 +295,37 @@ function getUsers($options) {
295295 }
296296 return $ user_list ;
297297 }
298+
299+ // checkBehalfId checks whether behalf_id is appropriate.
300+ // On behalf user must be active and have lower rank.
301+ function checkBehalfId () {
302+ $ options = array ('status ' =>ACTIVE ,'max_rank ' =>$ this ->rank -1 );
303+ $ users = $ this ->getUsers ($ options );
304+ foreach ($ users as $ one_user ) {
305+ if ($ one_user ['id ' ] == $ this ->behalf_id )
306+ return true ;
307+ }
308+
309+ return false ;
310+ }
311+
312+ // adjustBehalfId attempts to adjust behalf_id and behalf_name to a first found
313+ // aapropriate user.
314+ //
315+ // Needed for situations when use does not have do_own_something right.
316+ // Example: has view_charts but does not have view_own_charts.
317+ // In this case we still allow access to charts, but set behalf_id to someone else.
318+ function adjustBehalfId () {
319+ $ options = array ('status ' =>ACTIVE ,'max_rank ' =>$ this ->rank -1 );
320+ $ users = $ this ->getUsers ($ options );
321+ foreach ($ users as $ one_user ) {
322+ // Fake loop to access first element.
323+ $ this ->behalf_id = $ one_user ['id ' ];
324+ $ this ->behalf_name = $ one_user ['name ' ];
325+ $ _SESSION ['behalf_id ' ] = $ this ->behalf_id ;
326+ $ _SESSION ['behalf_name ' ] = $ this ->behalf_name ;
327+ return true ;
328+ }
329+ return false ;
330+ }
298331}
Original file line number Diff line number Diff line change 1212 <br >
1313 <table cellspacing =" 0" cellpadding =" 4" width =" 100%" border =" 0" >
1414 <tr >
15- <td align =" center" >  ; Anuko Time Tracker 1.17.71.4163 | Copyright © ; <a href =" https://www.anuko.com/lp/tt_3.htm" target =" _blank" >Anuko</a > |
15+ <td align =" center" >  ; Anuko Time Tracker 1.17.71.4164 | Copyright © ; <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 >
Original file line number Diff line number Diff line change 4646 header ('Location: feature_disabled.php ' );
4747 exit ();
4848}
49+ if ($ user ->behalf_id && (!$ user ->can ('view_charts ' ) || !$ user ->checkBehalfId ())) {
50+ header ('Location: access_denied.php ' ); // Trying on behalf, but no right or wrong user.
51+ exit ();
52+ }
53+ if (!$ user ->behalf_id && !$ user ->can ('view_own_charts ' ) && !$ user ->adjustBehalfId ()) {
54+ header ('Location: access_denied.php ' ); // Trying as self, but no right for self, and noone to view on behalf.
55+ exit ();
56+ }
4957
5058// Initialize and store date in session.
5159$ cl_date = $ request ->getParameter ('date ' , @$ _SESSION ['date ' ]);
You can’t perform that action at this time.
0 commit comments