forked from extern/egroupware
* ProjectManager/Timesheet: automatic change a changed project-title in Timesheet too
This commit is contained in:
parent
802d4c5282
commit
ef07aebbd4
@ -1336,20 +1336,29 @@ class egw_link extends solink
|
|||||||
return str_replace(array('&','"','<','>'),array('&','"','<','>'),$str);
|
return str_replace(array('&','"','<','>'),array('&','"','<','>'),$str);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Key for old link title in $data param to egw_link::notify
|
||||||
|
*/
|
||||||
|
const OLD_LINK_TITLE = 'old_link_title';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* notify other apps about changed content in $app,$id
|
* notify other apps about changed content in $app,$id
|
||||||
*
|
*
|
||||||
|
* To give other apps the possebility to update a title, you can also specify
|
||||||
|
* a changed old link-title in $data[egw_link::OLD_LINK_TITLE].
|
||||||
|
*
|
||||||
* @param string $app name of app in which the updated happend
|
* @param string $app name of app in which the updated happend
|
||||||
* @param string $id id in $app of the updated entry
|
* @param string $id id in $app of the updated entry
|
||||||
* @param array $data=null updated data of changed entry, as the read-method of the BO-layer would supply it
|
* @param array $data=null updated data of changed entry, as the read-method of the BO-layer would supply it
|
||||||
*/
|
*/
|
||||||
static function notify_update($app,$id,$data=null)
|
static function notify_update($app,$id,$data=null)
|
||||||
{
|
{
|
||||||
|
self::delete_cache($app,$id);
|
||||||
|
//error_log(__METHOD__."('$app', $id, $data)");
|
||||||
foreach(self::get_links($app,$id,'!'.self::VFS_APPNAME) as $link_id => $link)
|
foreach(self::get_links($app,$id,'!'.self::VFS_APPNAME) as $link_id => $link)
|
||||||
{
|
{
|
||||||
self::notify('update',$link['app'],$link['id'],$app,$id,$link_id,$data);
|
self::notify('update',$link['app'],$link['id'],$app,$id,$link_id,$data);
|
||||||
}
|
}
|
||||||
self::delete_cache($app,$id);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1374,6 +1383,7 @@ class egw_link extends solink
|
|||||||
*/
|
*/
|
||||||
static private function notify($type,$notify_app,$notify_id,$target_app,$target_id,$link_id,$data=null)
|
static private function notify($type,$notify_app,$notify_id,$target_app,$target_id,$link_id,$data=null)
|
||||||
{
|
{
|
||||||
|
//error_log(__METHOD__."('$type', '$notify_app', $notify_id, '$target_app', $target_id, $link_id, $data)");
|
||||||
if ($link_id && isset(self::$app_register[$notify_app]) && isset(self::$app_register[$notify_app]['notify']))
|
if ($link_id && isset(self::$app_register[$notify_app]) && isset(self::$app_register[$notify_app]['notify']))
|
||||||
{
|
{
|
||||||
if (!self::$notifies)
|
if (!self::$notifies)
|
||||||
|
@ -920,13 +920,20 @@ class timesheet_bo extends so_sql_cf
|
|||||||
|
|
||||||
if ($data['target_app'] == 'projectmanager' && $this->read($data['id']))
|
if ($data['target_app'] == 'projectmanager' && $this->read($data['id']))
|
||||||
{
|
{
|
||||||
|
$old_title = isset($data['data']) ? $data['data'][egw_link::OLD_LINK_TITLE] : null;
|
||||||
switch($data['type'])
|
switch($data['type'])
|
||||||
{
|
{
|
||||||
case 'link':
|
case 'link':
|
||||||
case 'update':
|
case 'update':
|
||||||
if (empty($this->data['ts_project'])) // timesheet has not yet project set --> set just linked one
|
if (empty($this->data['ts_project']) || // timesheet has not yet project set --> set just linked one
|
||||||
|
isset($old_title) && $this->data['ts_project'] === $old_title)
|
||||||
{
|
{
|
||||||
$pm_id = $data['target_id'];
|
$pm_id = $data['target_id'];
|
||||||
|
$update['ts_project'] = egw_link::title('projectmanager', $pm_id);
|
||||||
|
if (isset($old_title) && $this->data['ts_title'] === $old_title)
|
||||||
|
{
|
||||||
|
$update['ts_title'] = $update['ts_project'];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -934,14 +941,16 @@ class timesheet_bo extends so_sql_cf
|
|||||||
if ($this->data['ts_project'] == projectmanager_bo::link_title($data['target_id']))
|
if ($this->data['ts_project'] == projectmanager_bo::link_title($data['target_id']))
|
||||||
{
|
{
|
||||||
$pm_id = 0;
|
$pm_id = 0;
|
||||||
|
$update['ts_project'] = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (isset($pm_id))
|
if (isset($update))
|
||||||
{
|
{
|
||||||
$ts_project = $pm_id ? egw_link::title('projectmanager', $pm_id) : null;
|
$this->update($update);
|
||||||
$this->update(array('ts_project' => $ts_project));
|
egw_link::notify_update(TIMESHEET_APP, $this->data['ts_id'],$this->data);
|
||||||
//error_log(__METHOD__."() setting pm_id=$pm_id --> ts_project=".array2string($ts_project));
|
//error_log(__METHOD__."() setting pm_id=$pm_id --> ".array2string($update));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ($backup) $this->data = $backup;
|
if ($backup) $this->data = $backup;
|
||||||
|
Loading…
Reference in New Issue
Block a user