From 839e094117a3645f4611fa86cd73e9fbe7d6a8ce Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Wed, 20 Nov 2002 19:58:15 +0000 Subject: [PATCH] added a hook_deleteaccount --- infolog/inc/class.soinfolog.inc.php | 16 ++++++++++++++++ infolog/inc/hook_deleteaccount.inc.php | 20 ++++++++++++++++++++ infolog/setup/setup.inc.php | 1 + 3 files changed, 37 insertions(+) create mode 100644 infolog/inc/hook_deleteaccount.inc.php diff --git a/infolog/inc/class.soinfolog.inc.php b/infolog/inc/class.soinfolog.inc.php index d0b01bcadf..bdfda337a8 100644 --- a/infolog/inc/class.soinfolog.inc.php +++ b/infolog/inc/class.soinfolog.inc.php @@ -210,6 +210,22 @@ } } + function change_delete_owner($owner,$new_owner=0) // new_owner=0 means delete + { + if (!$new_owner) + { + $sql = "delete FROM phpgw_infolog where info_owner='$owner'"; + $sql2 = "update phpgw_infolog set info_responsible='0' where info_responsible='$owner'"; + } + else + { + $sql = "update phpgw_infolog set info_owner='$new_owner' where info_owner='$owner'"; + $sql2 = "update phpgw_infolog set info_responsible='$new_owner' where info_responsible='$owner'"; + } + $this->db->query($sql,__LINE__,__FILE__); + $this->db->query($sql2,__LINE__,__FILE__); + } + function write($values) // did _not_ ensure ACL { include(PHPGW_SERVER_ROOT.'/infolog/setup/tables_current.inc.php'); diff --git a/infolog/inc/hook_deleteaccount.inc.php b/infolog/inc/hook_deleteaccount.inc.php new file mode 100644 index 0000000000..c142e3b54e --- /dev/null +++ b/infolog/inc/hook_deleteaccount.inc.php @@ -0,0 +1,20 @@ +change_delete_owner(intval($GLOBALS['HTTP_POST_VARS']['account_id']), + intval($GLOBALS['HTTP_POST_VARS']['new_owner'])); + + unset($info); +?> diff --git a/infolog/setup/setup.inc.php b/infolog/setup/setup.inc.php index 72ca1fae5e..304bbfb26b 100755 --- a/infolog/setup/setup.inc.php +++ b/infolog/setup/setup.inc.php @@ -47,6 +47,7 @@ /* The hooks this app includes, needed for hooks registration */ $setup_info['infolog']['hooks'][] = 'preferences'; $setup_info['infolog']['hooks'][] = 'admin'; + $setup_info['infolog']['hooks'][] = 'deleteaccount'; $setup_info['infolog']['hooks'][] = 'about'; $setup_info['infolog']['hooks'][] = 'home'; $setup_info['infolog']['hooks'][] = 'addressbook_view';