"fixed postgres problem reported by Mary Muir <mmuir(at)sjgeophysics.com> on the user list"

This commit is contained in:
Ralf Becker 2008-06-02 05:35:43 +00:00
parent 7eab124b15
commit cdcf216712

View File

@ -7,7 +7,7 @@
* @package timesheet
* @copyright (c) 2005/6 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$
* @version $Id$
*/
require_once(EGW_INCLUDE_ROOT.'/etemplate/inc/class.so_sql.inc.php');
@ -26,7 +26,7 @@ class botimesheet extends so_sql
{
/**
* Timesheets config data
*
*
* @var array
*/
var $config = array();
@ -46,34 +46,34 @@ class botimesheet extends so_sql
var $quantity_sum=false;
/**
* Timestaps that need to be adjusted to user-time on reading or saving
*
*
* @var array
*/
var $timestamps = array(
'ts_start','ts_modified'
);
/**
* Offset in secconds between user and server-time, it need to be add to a server-time to get the user-time
* Offset in secconds between user and server-time, it need to be add to a server-time to get the user-time
* or substracted from a user-time to get the server-time
*
*
* @var int
*/
var $tz_offset_s;
/**
* Current time as timestamp in user-time
*
*
* @var int
*/
var $now;
/**
* Start of today in user-time
*
*
* @var int
*/
var $today;
/**
* Filter for search limiting the date-range
*
*
* @var array
*/
var $date_filters = array( // Start: year,month,day,week, End: year,month,day,week
@ -91,31 +91,31 @@ class botimesheet extends so_sql
);
/**
* Reference to the (bo)link class instanciated at $GLOBALS['egw']->link
*
*
* @var bolink
*/
var $link;
/**
* Grants: $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
*
*
* @var array
*/
*/
var $grants;
/**
* Sums of the last search in keys duration and price
*
*
* @var array
*/
var $summary;
/**
* Array with boolean values in keys 'day', 'week' or 'month', for the sums to return in the search
*
*
* @var array
*/
var $show_sums;
var $customfields=array();
function botimesheet()
{
$this->so_sql(TIMESHEET_APP,'egw_timesheet');
@ -149,10 +149,10 @@ class botimesheet extends so_sql
$GLOBALS['egw']->link =& CreateObject('phpgwapi.bolink');
}
$this->link =& $GLOBALS['egw']->link;
$this->grants = $GLOBALS['egw']->acl->get_grants(TIMESHEET_APP);
}
/**
* get list of specified grants as uid => Username pairs
*
@ -173,7 +173,7 @@ class botimesheet extends so_sql
return $result;
}
/**
* checks if the user has enough rights for a certain operation
*
@ -194,14 +194,14 @@ class botimesheet extends so_sql
$save_data = $this->data;
$data = $this->read($data,true);
$this->data = $save_data;
if (!$data) return null; // entry not found
}
$rights = $this->grants[$data['ts_owner']];
return $data && !!($rights & $required);
}
function date_filter($name,&$start,&$end_param)
{
$end = $end_param;
@ -226,9 +226,9 @@ class botimesheet extends so_sql
$year = (int) date('Y',$this->today);
$month = (int) date('m',$this->today);
$day = (int) date('d',$this->today);
list($syear,$smonth,$sday,$sweek,$eyear,$emonth,$eday,$eweek) = $this->date_filters[$name];
if ($syear || $eyear)
{
$start = mktime(0,0,0,1,1,$syear+$year);
@ -265,7 +265,7 @@ class botimesheet extends so_sql
}
$end_param = $end - 24*60*60;
}
//echo "<p align='right'>date_filter($name,$start,$end) today=".date('l, Y-m-d H:i',$this->today)." ==> ".date('l, Y-m-d H:i:s',$start)." <= date < ".date('l, Y-m-d H:i:s',$end)."</p>\n";
//echo "<p align='right'>date_filter($name,$start,$end) today=".date('l, Y-m-d H:i',$this->today)." ==> ".date('l, Y-m-d H:i:s',$start)." <= date < ".date('l, Y-m-d H:i:s',$end)."</p>\n";
// convert start + end from user to servertime for the filter
return '('.($start-$this->tz_offset_s).' <= ts_start AND ts_start < '.($end-$this->tz_offset_s).')';
}
@ -284,7 +284,7 @@ class botimesheet extends so_sql
* @param string $op='AND' defaults to 'AND', can be set to 'OR' too, then criteria's are OR'ed together
* @param mixed $start=false if != false, return only maxmatch rows begining with start, or array($start,$num)
* @param array $filter=null if set (!=null) col-data pairs, to be and-ed (!) into the query without wildcards
* @param string $join='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
* @param string $join='' sql to do a join, added as is after the table-name, eg. ", table2 WHERE x=y" or
* "LEFT JOIN table2 ON (x=y)", Note: there's no quoting done on $join!
* @param boolean $need_full_no_count=false If true an unlimited query is run to determine the total number of rows, default false
* @param boolean $only_summary=false If true only return the sums as array with keys duration and price, default false
@ -308,7 +308,7 @@ class botimesheet extends so_sql
else
{
if (!is_array($filter['ts_owner'])) $filter['ts_owner'] = array($filter['ts_owner']);
foreach($filter['ts_owner'] as $key => $owner)
{
if (!isset($this->grants[$owner]))
@ -327,7 +327,7 @@ class botimesheet extends so_sql
($this->quantity_sum ? ",SUM(ts_quantity) AS quantity" : ''),
'','',$wildcard,$empty,$op,false,$filter,$join);
$this->summary = $this->summary[0];
if ($only_summary) return $this->summary;
if ($this->show_sums && strpos($order_by,'ts_start') !== false && // sums only make sense if ordered by ts_start
@ -348,7 +348,7 @@ class botimesheet extends so_sql
}
// regular entries
parent::search($criteria,$only_keys,$order_by,$extra_cols,$wildcard,$empty,$op,'UNION',$filter,$join,$need_full_no_count);
$sort = substr($order_by,8);
$union_order = array();
$sum_ts_id = array('year' => -3,'month' => -2,'week' => -1,'day' => 0);
@ -411,7 +411,7 @@ class botimesheet extends so_sql
return $row;
}
/**
* saves a timesheet entry
*
@ -425,7 +425,7 @@ class botimesheet extends so_sql
function save($keys=null,$touch_modified=true,$ignore_acl=false)
{
if ($keys) $this->data_merge($keys);
if (!$ignore_acl && $this->data['ts_id'] && !$this->check_acl(EGW_ACL_EDIT))
{
return true;
@ -481,7 +481,7 @@ class botimesheet extends so_sql
return false;
}
/**
* deletes a timesheet entry identified by $keys or the loaded one, reimplemented to notify the link class (unlink)
*
@ -496,7 +496,7 @@ class botimesheet extends so_sql
$keys = array('ts_id' => (int) $keys);
}
$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
if (!$this->check_acl(EGW_ACL_DELETE,$ts_id))
{
return false;
@ -575,7 +575,7 @@ class botimesheet extends so_sql
}
return $data;
}
/**
* Get the time- and pricesum for the given timesheet entries
*
@ -586,10 +586,10 @@ class botimesheet extends so_sql
{
return $this->search(array('ts_id'=>$ids),true,'','','',false,'AND',false,null,'',false,true);
}
/**
* get title for an timesheet entry identified by $entry
*
*
* Is called as hook to participate in the linking
*
* @param int/array $entry int ts_id or array with timesheet entry
@ -651,19 +651,19 @@ class botimesheet extends so_sql
'menuaction' => TIMESHEET_APP.'.uitimesheet.view',
),
'view_id' => 'ts_id',
'view_popup' => '600x400',
'view_popup' => '600x400',
'add' => array(
'menuaction' => TIMESHEET_APP.'.uitimesheet.edit',
),
'add_app' => 'link_app',
'add_id' => 'link_id',
'add_popup' => '600x400',
'add_id' => 'link_id',
'add_popup' => '600x400',
);
}
/**
* Return the timesheets linked with given project(s) AND with entries of other apps, which are also linked to the same project
*
*
* Projectmanager will cumulate them in the other apps entries.
*
* @param array $param int/array $param['pm_id'] project-id(s)
@ -672,7 +672,7 @@ class botimesheet extends so_sql
function cumulate($param)
{
$links = $this->link->get_3links(TIMESHEET_APP,'projectmanager',$param['pm_id']);
$rows = array();
foreach($links as $link)
{
@ -716,31 +716,31 @@ class botimesheet extends so_sql
*
* @param int $pm_id ID of selected project
* @return array containing link_id and ts_id
*/
*/
function get_ts_links($pm_id=0) {
$tslist = array();
$tslist = array();
if(strlen($pm_id) > 0) {
if(isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) {
if(isset($GLOBALS['egw_info']['user']['apps']['projectmanager'])) {
$bo_pm = CreateObject('projectmanager.boprojectmanager');
$childs = $bo_pm->children($pm_id);
$childs[] = $pm_id;
$pmChilds = implode(",",$childs);
$pmChilds = "'".implode("','",$childs)."'";
$this->db->select( 'egw_links','link_id, link_id1',$query,
__LINE__,__FILE__,False,
'',False,0,
'JOIN egw_pm_projects ON (pm_id = link_id2)
WHERE
WHERE
link_app1 = \'timesheet\' AND
link_app2 = \'projectmanager\' AND
link_id2 IN ('.$pmChilds.')');
while($row = $this->db->row(true)) {
$tslist[$row['link_id']] = $row['link_id1'];
}
}
}
}
return $tslist;
}
}