# R35504 - in /trunk/timesheet/inc: class.timesheet\_bo.inc.php class.timesheet\_hooks.inc.php

**URL:** <https://help.egroupware.org/t/r35504-in-trunk-timesheet-inc-class-timesheet-bo-inc-php-class-timesheet-hooks-inc-php/48152>\
**Category:** eGW-svn\
**Created:** [June 26, 2011, 2:29pm UTC](https://help.egroupware.org/t/r35504-in-trunk-timesheet-inc-class-timesheet-bo-inc-php-class-timesheet-hooks-inc-php/48152 "2011-06-26T14:29:35Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ralfbecker\_sf](https://help.egroupware.org/letter_avatar_proxy/v4/letter/r/b2d939/32.png) [@ralfbecker\_sf](https://help.egroupware.org/u/ralfbecker_sf)\
**Post date:** [June 26, 2011, 2:29pm UTC](https://help.egroupware.org/t/r35504-in-trunk-timesheet-inc-class-timesheet-bo-inc-php-class-timesheet-hooks-inc-php/48152/1 "2011-06-26T14:29:35Z")

</div>

Author: ralfbecker  
New Revision: 35504

URL: [http://svn.stylite.de/viewvc/egroupware?rev=35504&view=rev](http://svn.stylite.de/viewvc/egroupware?rev=35504&view=rev)  
Log:  
file\_access\_user implementation for timesheet

Modified:  
trunk/timesheet/inc/class.timesheet\_bo.inc.php  
trunk/timesheet/inc/class.timesheet\_hooks.inc.php

# Modified: trunk/timesheet/inc/class.timesheet\_bo.inc.php URL: [http://svn.stylite.de/viewvc/egroupware/trunk/timesheet/inc/class.timesheet\_bo.inc.php?rev=35504&r1=35503&r2=35504&view=diff](http://svn.stylite.de/viewvc/egroupware/trunk/timesheet/inc/class.timesheet_bo.inc.php?rev=35504&r1=35503&r2=35504&view=diff)

— trunk/timesheet/inc/class.timesheet\_bo.inc.php (original)  
+++ trunk/timesheet/inc/class.timesheet\_bo.inc.php Sun Jun 26 16:29:35 2011  
@@ -5,7 +5,7 @@

- @link [http://www.egroupware.org](http://www.egroupware.org)
- @author Ralf Becker \<[RalfBecker-AT-outdoor-training.de](http://RalfBecker-AT-outdoor-training.de)\>
- @package timesheet

- 
  - @copyright © 2005-9 by Ralf Becker \<[RalfBecker-AT-outdoor-training.de](http://RalfBecker-AT-outdoor-training.de)\>

- 
  - @copyright © 2005-11 by Ralf Becker \<[RalfBecker-AT-outdoor-training.de](http://RalfBecker-AT-outdoor-training.de)\>
  - @license [http://opensource.org/licenses/gpl-license.php](http://opensource.org/licenses/gpl-license.php) GPL - GNU General Public License
  - @version $Id$  
\*/  
@@ -19,8 +19,6 @@
  - Business object of the TimeSheet
  - 
  - Uses eTemplate’s so\_sql as storage object (Table: egw\_timesheet).

- 
  - 

- 
  - @todo Implement sorting&filtering by and searching of custom fields  
_/  
class timesheet\_bo extends so\_sql\_cf  
{  
@@ -37,15 +35,15 @@  
 /  
var $quantity\_sum=false;  
/_

- 
  - current user

- 
  - 

- 
  - @var int

- \*/
- var $user;
- /\*\*
  - Timestaps that need to be adjusted to user-time on reading or saving
  - 
  - @var array

- \*/
- var $user;
- /\*\*
- 
  - current user

- 
  - 

- 
  - @var int  
\*/  
var $timestamps = array(  
‘ts\_start’,‘ts\_modified’  
@@ -175,7 +173,7 @@  
{  
$this-\>status\_labels =& $this-\>config\_data[‘status\_labels’];  
if (!is\_array($this-\>status\_labels)) $this-\>status\_labels= array($this-\>status\_labels);

- 

- 

```
  foreach ($this->status_labels as $status_id => $label)
  {
  	if (!is_array($label))

```

@@ -267,12 +265,12 @@  
\* Rights are given via owner grants or role based acl  
\*  
\* @param int $required EGW\_ACL\_READ, EGW\_ACL\_WRITE, EGW\_ACL\_ADD, EGW\_ACL\_DELETE, EGW\_ACL\_BUDGET, EGW\_ACL\_EDIT\_BUDGET

- 
  - @param array/int $data=null project or project-id to use, default the project in $this-\>data

- 
  - @param array|int $data=null project or project-id to use, default the project in $this-\>data

- 
  - @param int $user=null for which user to check, default current user
  - @return boolean true if the rights are ok, null if not found, false if no rights  
\*/

- function check\_acl($required,$data=null)
- {
- 

```
  //error_log( __METHOD__."($required,".array2string($data).")");

```

- function check\_acl($required,$data=null,$user=null)

- {  
if (is\_null($data) || (int)$data == $this-\>data[‘ts\_id’])  
{  
$data =& $this-\>data;  
@@ -285,9 +283,19 @@

- 

```
  $rights = $this->grants[$data['ts_owner']];

```

- 
- 

```
  return $data && !!($rights & $required);

```

- 

```
  if (!$user) $user = $this->user;

```

- 

```
  if ($user == $this->user)

```

- 

```
  {

```

- 

```
  	$grants = $this->grants;

```

- 

```
  }

```

- 

```
  else

```

- 

```
  {

```

- 

```
  	$grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP,true,$user);

```

- 

```
  }

```

- 

```
  $ret = $data && !!($grants[$data['ts_owner']] & $required);

```

- 
- 

```
  //error_log( __METHOD__."($required,$data[ts_id],$user) returning ".array2string($ret));

```

- 

```
  return $ret;

```

}

/\*\*  
@@ -371,7 +379,7 @@  
\*

  - reimplemented to limit result to users we have grants from
  - 

- 
  - @param array/string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)

- 
  - @param array|string $criteria array of key and data cols, OR a SQL query (content for WHERE), fully quoted (!)
  - @param boolean/string $only\_keys=true True returns only keys, False returns all cols. comma seperated list of keys to return
  - @param string $order\_by=’’ fieldnames + {ASC|DESC} separated by colons ‘,’, can also contain a GROUP BY (if it contains ORDER BY)
  - @param string/array $extra\_cols=’’ string or array of strings to be added to the SELECT, eg. “count(\*) as num”  
@@ -474,7 +482,7 @@
  - 
  - @param int $ts\_id
  - @param boolean $ignore\_acl=false should the acl be checked

- 
  - @return array/boolean array with timesheet entry, null if timesheet not found or false if no rights

- 
  - @return array|boolean array with timesheet entry, null if timesheet not found or false if no rights  
\*/  
function read($ts\_id,$ignore\_acl=false)  
{  
@@ -700,15 +708,17 @@  
}

```
/**

```

- 
  - Check access to the projects file store

- 
  - 

- 
  - @param int $id id of entry

- 
  - Check access to the file store

- 
  - 

- 
  - @param int|array $id id of entry or entry array
  - @param int $check EGW\_ACL\_READ for read and EGW\_ACL\_EDIT for write or delete access

- 
  - @param string $rel\_path=null currently not used in InfoLog

- 
  - @param int $user=null for which user to check, default current user
  - @return boolean true if access is granted or false otherwise  
\*/

- function file\_access($id,$check,$rel\_path)
- {
- 

```
  return $this->check_acl($check,$id);

```

- function file\_access($id,$check,$rel\_path=null,$user=null)

- {

- 

```
  return $this->check_acl($check,$id,$user);

```

}

/\*\*

# Modified: trunk/timesheet/inc/class.timesheet\_hooks.inc.php URL: [http://svn.stylite.de/viewvc/egroupware/trunk/timesheet/inc/class.timesheet\_hooks.inc.php?rev=35504&r1=35503&r2=35504&view=diff](http://svn.stylite.de/viewvc/egroupware/trunk/timesheet/inc/class.timesheet_hooks.inc.php?rev=35504&r1=35503&r2=35504&view=diff)

— trunk/timesheet/inc/class.timesheet\_hooks.inc.php (original)  
+++ trunk/timesheet/inc/class.timesheet\_hooks.inc.php Sun Jun 26 16:29:35 2011  
@@ -5,7 +5,7 @@

- @link [http://www.egroupware.org](http://www.egroupware.org)
- @author Ralf Becker \<[RalfBecker-AT-outdoor-training.de](http://RalfBecker-AT-outdoor-training.de)\>
- @package timesheet

- 
  - @copyright © 2005-9 by Ralf Becker \<[RalfBecker-AT-outdoor-training.de](http://RalfBecker-AT-outdoor-training.de)\>

- 
  - @copyright © 2005-11 by Ralf Becker \<[RalfBecker-AT-outdoor-training.de](http://RalfBecker-AT-outdoor-training.de)\>
  - @license [http://opensource.org/licenses/gpl-license.php](http://opensource.org/licenses/gpl-license.php) GPL - GNU General Public License
  - @version $Id$  
\*/  
@@ -55,6 +55,7 @@  
‘add\_id’ =\> ‘link\_id’,  
‘add\_popup’ =\> ‘600x425’,  
‘file\_access’=\> TIMESHEET\_APP.’.timesheet\_bo.file\_access’,

- 

```
  	'file_access_user' => true,	// file_access supports 4th parameter $user
  );

```

}

* * *

All of the data generated in your IT infrastructure is seriously valuable.  
Why? It contains a definitive record of application performance, security  
threats, fraudulent activity, and more. Splunk takes this data and makes  
sense of it. IT sense. And common sense.  
[http://p.sf.net/sfu/splunk-d2d-c2](http://p.sf.net/sfu/splunk-d2d-c2)

* * *

eGroupWare-cvs mailing list  
[eGroupWare-cvs@lists.sourceforge.net](mailto:eGroupWare-cvs@lists.sourceforge.net)  
[https://lists.sourceforge.net/lists/listinfo/egroupware-cvs](https://lists.sourceforge.net/lists/listinfo/egroupware-cvs)
