diff --git a/timesheet/inc/class.timesheet_bo.inc.php b/timesheet/inc/class.timesheet_bo.inc.php index 31a4849a21..86feafcbc7 100644 --- a/timesheet/inc/class.timesheet_bo.inc.php +++ b/timesheet/inc/class.timesheet_bo.inc.php @@ -5,7 +5,7 @@ * @link http://www.egroupware.org * @author Ralf Becker * @package timesheet - * @copyright (c) 2005-11 by Ralf Becker + * @copyright (c) 2005-13 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -695,6 +695,32 @@ class timesheet_bo extends so_sql_cf return $ret; } + /** + * delete / move all timesheets of a given user + * + * @param array $data + * @param int $data['account_id'] owner to change + * @param int $data['new_owner'] new owner or 0 for delete + */ + function deleteaccount($data) + { + $account_id = $data['account_id']; + $new_owner = $data['new_owner']; + + if (!$new_owner) + { + egw_link::unlink(0, TIMESHEET_APP, '', $account_id); + parent::delete(array('ts_owner' => $account_id)); + } + else + { + $this->db->update($this->table_name, array( + 'ts_owner' => $new_owner, + ), array( + 'ts_owner' => $account_id, + ), __LINE__, __FILE__); + } + } /** * set a status for timesheet entry identified by $keys diff --git a/timesheet/setup/setup.inc.php b/timesheet/setup/setup.inc.php index 861ad3b17b..4f0efa20cf 100644 --- a/timesheet/setup/setup.inc.php +++ b/timesheet/setup/setup.inc.php @@ -6,7 +6,7 @@ * @author Ralf Becker * @package timesheet * @subpackage setup - * @copyright (c) 2005-10 by Ralf Becker + * @copyright (c) 2005-13 by Ralf Becker * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @version $Id$ */ @@ -32,7 +32,7 @@ $setup_info[TIMESHEET_APP]['description'] = 'Tracking times and other activities for the Projectmanager.'; $setup_info[TIMESHEET_APP]['note'] = 'The TimeSheet application is sponsored by:'; @@ -43,6 +43,7 @@ $setup_info[TIMESHEET_APP]['hooks']['admin'] = 'timesheet_hooks::all_hooks'; $setup_info[TIMESHEET_APP]['hooks']['sidebox_menu'] = 'timesheet_hooks::all_hooks'; $setup_info[TIMESHEET_APP]['hooks']['search_link'] = 'timesheet_hooks::search_link'; $setup_info[TIMESHEET_APP]['hooks']['pm_cumulate'] = 'timesheet_hooks::cumulate'; +$setup_info[TIMESHEET_APP]['hooks']['deleteaccount'] = 'timesheet.timesheet_bo.deleteaccount'; /* Dependencies for this app to work */ $setup_info[TIMESHEET_APP]['depends'][] = array(