From 196cd13771d3906ce595d56a8f4120f24c65b20e Mon Sep 17 00:00:00 2001 From: nathangray Date: Mon, 22 Jul 2019 15:10:43 -0600 Subject: [PATCH] Importexport - support deleteaccount hook --- .../class.importexport_definitions_bo.inc.php | 31 +++++++++++++++++-- importexport/setup/setup.inc.php | 1 + 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/importexport/inc/class.importexport_definitions_bo.inc.php b/importexport/inc/class.importexport_definitions_bo.inc.php index 6b68ec8f66..2707070e95 100644 --- a/importexport/inc/class.importexport_definitions_bo.inc.php +++ b/importexport/inc/class.importexport_definitions_bo.inc.php @@ -60,7 +60,7 @@ class importexport_definitions_bo { $sql .= ') OR owner = '.$GLOBALS['egw_info']['user']['account_id']; $query['col_filter'][] = $sql; } - + // Handle allowed filter if($query['col_filter']['allowed_users']) { @@ -77,7 +77,7 @@ class importexport_definitions_bo { $query['col_filter'][] = '('.implode(' OR ', $allowed) . ')'; } } - + $total = $this->so_sql->get_rows($query, $rows, $readonlys); $ro_count = 0; foreach($rows as &$row) { @@ -328,5 +328,32 @@ class importexport_definitions_bo { return $export; } + /** + * + * changes or deletes entries with a specified owner (for deleteaccount hook) + * + * @param array $args hook arguments + * @param int $args['account_id'] account to delete + * @param int $args['new_owner']=0 new owner + * @todo test deleting an owner with replace and without + */ + function change_delete_owner(array $args) // new_owner=0 means delete + { + if (!(int) $args['new_owner']) + { + $this->so_sql->delete(array('owner'=>$args['account_id'])); + } + else + { + $GLOBALS['egw']->db->update( + self::_defintion_table, + array('owner'=>$args['new_owner']), + array('owner'=>$args['account_id']), + __LINE__,__FILE__,'importexport' + ); + } + } + + } diff --git a/importexport/setup/setup.inc.php b/importexport/setup/setup.inc.php index ff98ab548b..5ea9a8f2b7 100644 --- a/importexport/setup/setup.inc.php +++ b/importexport/setup/setup.inc.php @@ -34,6 +34,7 @@ $setup_info['importexport']['hooks']['sidebox_all'] = 'importexport_admin_prefs_ $setup_info['importexport']['hooks']['etemplate2_register_widgets'] = 'importexport_admin_prefs_sidebox_hooks::widgets'; $setup_info['importexport']['hooks']['config'] = 'importexport_admin_prefs_sidebox_hooks::config'; $setup_info['importexport']['hooks']['config_after_save'] = 'importexport_admin_prefs_sidebox_hooks::config_after_save'; +$setup_info['importexport']['hooks']['deleteaccount'] = 'importexport.importexport_definitions_bo.change_delete_owner'; /* Dependencies for this app to work */ $setup_info['importexport']['depends'][] = array(