fix not updated infolog in list, when timesheet is booked on it: added "row_mod" as maximum of info_modified, link_lastmod (incl. deleted ones) and timesheet_bo::sum() max_modified

This commit is contained in:
Ralf Becker 2014-05-24 10:59:03 +00:00
parent 30ffb38bd6
commit c04f0ccc8f
4 changed files with 43 additions and 20 deletions

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package infolog * @package infolog
* @copyright (c) 2003-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2003-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -206,14 +206,22 @@ class infolog_ui
if ($info['info_id_parent']) $info['class'] .= 'infolog_rowHasParent '; if ($info['info_id_parent']) $info['class'] .= 'infolog_rowHasParent ';
if ($info['info_anz_subs'] > 0) $info['class'] .= 'infolog_rowHasSubs '; if ($info['info_anz_subs'] > 0) $info['class'] .= 'infolog_rowHasSubs ';
$info['row_mod'] = $info['info_modified'];
if (!$show_links) $show_links = $this->prefs['show_links']; if (!$show_links) $show_links = $this->prefs['show_links'];
if (($show_links != 'none' && $show_links != 'no_describtion' || if (($show_links != 'none' && $show_links != 'no_describtion' ||
$this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) && $this->prefs['show_times'] || isset($GLOBALS['egw_info']['user']['apps']['timesheet'])) &&
(isset($info['links']) || ($info['links'] = egw_link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true)))) (isset($info['links']) || ($info['links'] = egw_link::get_links('infolog',$info['info_id'],'','link_lastmod DESC',true,true))))
{ {
$timesheets = array(); $timesheets = array();
foreach ($info['links'] as $link) foreach ($info['links'] as $link)
{ {
// incl. link modification time into row_mod (link's lastmod is always in server-time!)
$link_mod = egw_time::server2user($link['lastmod']);
if ($info['row_mod'] < $link_mod) $info['row_mod'] = $link_mod;
if ($link['deleted']) continue; // skip deleted links, but incl. them in row_mod!
if ($show_links != 'none' && $show_links != 'no_describtion' && if ($show_links != 'none' && $show_links != 'no_describtion' &&
$link['link_id'] != $info['info_link_id'] && $link['link_id'] != $info['info_link_id'] &&
($link['app'] != $action || $link['id'] != $action_id) && ($link['app'] != $action || $link['id'] != $action_id) &&
@ -231,6 +239,8 @@ class infolog_ui
{ {
$sum = ExecMethod('timesheet.timesheet_bo.sum',$timesheets); $sum = ExecMethod('timesheet.timesheet_bo.sum',$timesheets);
$info['info_sum_timesheets'] = $sum['duration']; $info['info_sum_timesheets'] = $sum['duration'];
// incl. max timesheet modification in row_mod
if ($info['row_mod'] < $sum['max_modified']) $info['row_mod'] = $sum['max_modified'];
} }
} }
$info['info_type_label'] = $this->bo->enums['type'][$info['info_type']]; $info['info_type_label'] = $this->bo->enums['type'][$info['info_type']];
@ -279,7 +289,7 @@ class infolog_ui
} }
$query['actions'] = $this->get_actions($query); $query['actions'] = $this->get_actions($query);
$query['row_id'] = 'info_id'; $query['row_id'] = 'info_id';
$query['row_modified'] = 'info_datemodified'; $query['row_modified'] = 'row_mod';
$query['parent_id'] = 'info_id_parent'; $query['parent_id'] = 'info_id_parent';
$query['is_parent'] = 'info_anz_subs'; $query['is_parent'] = 'info_anz_subs';
$query['action_var'] = 'multi_action'; // as 'action' is already used in infolog $query['action_var'] = 'multi_action'; // as 'action' is already used in infolog
@ -398,7 +408,7 @@ class infolog_ui
// query all links and sub counts in one go // query all links and sub counts in one go
if ($infos && (!$query['csv_export'] || !is_array($query['csv_export']))) if ($infos && (!$query['csv_export'] || !is_array($query['csv_export'])))
{ {
$links = egw_link::get_links_multiple('infolog',array_keys($infos),true); $links = egw_link::get_links_multiple('infolog',array_keys($infos),true,'','link_lastmod DESC',true); // true=incl. deleted
$anzSubs = $this->bo->anzSubs(array_keys($infos)); $anzSubs = $this->bo->anzSubs(array_keys($infos));
} }
$rows = array(); $rows = array();

View File

@ -8,7 +8,7 @@
* *
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright 2001-2013 by RalfBecker@outdoor-training.de * @copyright 2001-2014 by RalfBecker@outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api * @package api
* @subpackage link * @subpackage link
@ -16,7 +16,7 @@
*/ */
/** /**
* Generalized linking between entries of eGroupware apps * Generalized linking between entries of EGroupware apps
* *
* Please note: this class can NOT and does not need to be initialised, all methods are static * Please note: this class can NOT and does not need to be initialised, all methods are static
* *
@ -99,6 +99,9 @@
* Attached files are stored under $vfs_basedir='/infolog' in the vfs! * Attached files are stored under $vfs_basedir='/infolog' in the vfs!
* 3) It manages the link-registry, in which apps can register themselfs by implementing some hooks * 3) It manages the link-registry, in which apps can register themselfs by implementing some hooks
* 4) It notifies apps, who registered for that service, about changes in the links their entries * 4) It notifies apps, who registered for that service, about changes in the links their entries
*
* Modification times in links (and deleted timestamp) are always in server-time!
* (We dont convert them here, as most apps ignore them anyway)
*/ */
class egw_link extends solink class egw_link extends solink
{ {

View File

@ -8,7 +8,7 @@
* *
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @copyright 2001-2013 by RalfBecker@outdoor-training.de * @copyright 2001-2014 by RalfBecker@outdoor-training.de
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package api * @package api
* @subpackage link * @subpackage link
@ -53,10 +53,9 @@ class solink
* @param string $remark='' Remark to be saved with the link (defaults to '') * @param string $remark='' Remark to be saved with the link (defaults to '')
* @param int $owner=0 Owner of the link (defaults to user) * @param int $owner=0 Owner of the link (defaults to user)
* @param int $lastmod=0 timestamp of last modification (defaults to now=time()) * @param int $lastmod=0 timestamp of last modification (defaults to now=time())
* @param int $no_notify=0 &1 dont notify $app1, &2 dont notify $app2
* @return int/boolean False (for db or param-error) or on success link_id (Please not the return-value of $id1) * @return int/boolean False (for db or param-error) or on success link_id (Please not the return-value of $id1)
*/ */
static function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0,$lastmod=0,$no_notify=0 ) static function link( $app1,&$id1,$app2,$id2='',$remark='',$owner=0,$lastmod=0 )
{ {
if (self::DEBUG) if (self::DEBUG)
{ {
@ -67,7 +66,7 @@ class solink
{ {
return False; // dont link to self or other nosense return False; // dont link to self or other nosense
} }
if ($link = self::get_link($app1,$id1,$app2,$id2)) if (($link = self::get_link($app1,$id1,$app2,$id2)))
{ {
if ($link['link_remark'] != $remark) if ($link['link_remark'] != $remark)
{ {
@ -186,6 +185,7 @@ class solink
'owner' => $row['link_owner'], 'owner' => $row['link_owner'],
'lastmod' => $row['link_lastmod'], 'lastmod' => $row['link_lastmod'],
'link_id' => $row['link_id'], 'link_id' => $row['link_id'],
'deleted' => $row['deleted'],
); );
} }
@ -303,7 +303,10 @@ class solink
} }
if($hold_for_purge) if($hold_for_purge)
{ {
self::$db->update(self::TABLE,array('deleted'=> time()), $where, __LINE__,__FILE__); self::$db->update(self::TABLE,array(
'deleted' => time(),
'link_lastmod' => time(),
), $where, __LINE__,__FILE__);
} }
else else
{ {

View File

@ -5,7 +5,7 @@
* @link http://www.egroupware.org * @link http://www.egroupware.org
* @author Ralf Becker <RalfBecker-AT-outdoor-training.de> * @author Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @package timesheet * @package timesheet
* @copyright (c) 2005-13 by Ralf Becker <RalfBecker-AT-outdoor-training.de> * @copyright (c) 2005-14 by Ralf Becker <RalfBecker-AT-outdoor-training.de>
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @version $Id$ * @version $Id$
*/ */
@ -518,16 +518,21 @@ class timesheet_bo extends so_sql_cf
return array(); return array();
} }
unset($criteria); unset($criteria);
foreach ($ids as $r =>$v) $id_filter[] = $v['id']; foreach ($ids as $v)
{
$id_filter[] = $v['id'];
}
$filter = array('ts_id'=>$id_filter); $filter = array('ts_id'=>$id_filter);
} }
// if we only want to return the summary (sum of duration and sum of price) we have to take care that the customfield table // if we only want to return the summary (sum of duration and sum of price) we have to take care that the customfield table
// is not joined, as the join causes a multiplication of the sum per customfield found // is not joined, as the join causes a multiplication of the sum per customfield found
// joining of the cutomfield table is triggered by criteria being set with either a string or an array // joining of the cutomfield table is triggered by criteria being set with either a string or an array
$this->summary = parent::search(($only_summary?false:$criteria),"SUM(ts_duration) AS duration,SUM($total_sql) AS price". $this->summary = parent::search(($only_summary?false:$criteria),
"SUM(ts_duration) AS duration,SUM($total_sql) AS price,MAX(ts_modified) AS max_modified".
($this->quantity_sum ? ",SUM(ts_quantity) AS quantity" : ''), ($this->quantity_sum ? ",SUM(ts_quantity) AS quantity" : ''),
'','',$wildcard,$empty,$op,false,($only_summary&&is_array($criteria)&&is_array($filter)?array_merge($criteria,$filter):$filter),($only_summary?'':$join)); '','',$wildcard,$empty,$op,false,($only_summary&&is_array($criteria)&&is_array($filter)?array_merge($criteria,$filter):$filter),($only_summary?'':$join));
$this->summary = $this->summary[0]; $this->summary = $this->summary[0];
$this->summary['max_modified'] = egw_time::server2user($this->summary['max_modified']);
if ($only_summary) return $this->summary; if ($only_summary) return $this->summary;
@ -676,7 +681,7 @@ class timesheet_bo extends so_sql_cf
} }
$ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id']; $ts_id = is_null($keys) ? $this->data['ts_id'] : $keys['ts_id'];
if (!$this->check_acl(EGW_ACL_DELETE,$ts_id) || !($old = $this->read($ts_id))) if (!$ignore_acl && !$this->check_acl(EGW_ACL_DELETE,$ts_id) || !($old = $this->read($ts_id)))
{ {
return false; return false;
} }
@ -727,11 +732,11 @@ class timesheet_bo extends so_sql_cf
/** /**
* set a status for timesheet entry identified by $keys * set a status for timesheet entry identified by $keys
* *
* @param array $keys if given array with col => value pairs to characterise the rows to delete * @param array $keys=null if given array with col => value pairs to characterise single timesheet or null for $this->data
* @param boolean $status * @param int $status=0
* @return int affected rows, should be 1 if ok, 0 if an error * @return int affected rows, should be 1 if ok, 0 if an error
*/ */
function set_status($keys=null,$status) function set_status($keys=null, $status=0)
{ {
$ret = true; $ret = true;
if (!is_array($keys) && (int) $keys) if (!is_array($keys) && (int) $keys)
@ -752,10 +757,10 @@ class timesheet_bo extends so_sql_cf
} }
/** /**
* Get the time- and pricesum for the given timesheet entries * Get the time-, price-, quantity-sum and max. modification date for the given timesheet entries
* *
* @param array $ids array of timesheet id's * @param array $ids array of timesheet id's
* @return array with keys time and price * @return array with values for keys "duration", "price", "max_modified" and "quantity"
*/ */
function sum($ids) function sum($ids)
{ {
@ -854,6 +859,8 @@ class timesheet_bo extends so_sql_cf
*/ */
function file_access($id,$check,$rel_path=null,$user=null) function file_access($id,$check,$rel_path=null,$user=null)
{ {
unset($rel_path); // not used, but required by function signature
return $this->check_acl($check,$id,$user); return $this->check_acl($check,$id,$user);
} }