2000-08-18 05:24:22 +02:00
|
|
|
<?php
|
|
|
|
/**************************************************************************\
|
|
|
|
* phpGroupWare - administration *
|
|
|
|
* http://www.phpgroupware.org *
|
|
|
|
* -------------------------------------------- *
|
|
|
|
* This program is free software; you can redistribute it and/or modify it *
|
|
|
|
* under the terms of the GNU General Public License as published by the *
|
|
|
|
* Free Software Foundation; either version 2 of the License, or (at your *
|
|
|
|
* option) any later version. *
|
|
|
|
\**************************************************************************/
|
|
|
|
|
2001-03-30 06:58:33 +02:00
|
|
|
/* $Id$ */
|
2000-08-18 05:24:22 +02:00
|
|
|
|
2001-03-30 06:58:33 +02:00
|
|
|
$phpgw_info = array();
|
2000-11-21 01:41:31 +01:00
|
|
|
|
2001-05-16 15:34:13 +02:00
|
|
|
if ($delete_account || $cancel || !$account_id )
|
2001-03-30 06:58:33 +02:00
|
|
|
{
|
2001-05-10 13:21:06 +02:00
|
|
|
$phpgw_info['flags'] = array(
|
|
|
|
'noheader' => True,
|
|
|
|
'nonavbar' => True
|
|
|
|
);
|
2001-03-30 06:58:33 +02:00
|
|
|
}
|
2001-03-23 04:14:09 +01:00
|
|
|
|
2001-05-10 13:21:06 +02:00
|
|
|
$phpgw_info['flags']['currentapp'] = 'admin';
|
|
|
|
include('../header.inc.php');
|
2001-03-30 06:58:33 +02:00
|
|
|
// Make sure they are not attempting to delete their own account, or they have cancelled.
|
|
|
|
// If they are, they should not reach this point anyway.
|
2001-04-17 17:30:08 +02:00
|
|
|
if($cancel || $phpgw_info['user']['account_id'] == $account_id)
|
2001-03-30 06:58:33 +02:00
|
|
|
{
|
|
|
|
Header('Location: '.$phpgw->link('/admin/accounts.php'));
|
|
|
|
$phpgw->common->phpgw_exit();
|
|
|
|
}
|
|
|
|
|
2001-04-17 17:30:08 +02:00
|
|
|
if ($account_id && !$delete_account)
|
2001-03-30 06:58:33 +02:00
|
|
|
{
|
2001-05-10 13:21:06 +02:00
|
|
|
$phpgw->template->set_file(array('form' => 'delete_account.tpl'));
|
2001-03-30 06:58:33 +02:00
|
|
|
|
|
|
|
$phpgw->template->set_var('form_action',$phpgw->link('/admin/deleteaccount.php'));
|
|
|
|
$phpgw->template->set_var('account_id',$account_id);
|
|
|
|
// the account can have special chars/white spaces, if it is a ldap dn
|
|
|
|
$account_id = rawurlencode($account_id);
|
|
|
|
|
|
|
|
// Find out who the new owner is of the deleted users records...
|
2001-03-30 13:44:33 +02:00
|
|
|
$str = '<select name="new_owner" size="5">'."\n";
|
2001-03-30 06:58:33 +02:00
|
|
|
$users = $phpgw->accounts->get_list('accounts');
|
|
|
|
$c_users = count($users);
|
2001-05-09 05:05:22 +02:00
|
|
|
$str .= '<option value=0>'.lang('Delete All Records').'</option>'."\n";
|
2001-03-30 06:58:33 +02:00
|
|
|
for($i=0;$i<$c_users;$i++)
|
|
|
|
{
|
2001-05-09 05:05:22 +02:00
|
|
|
$str .= '<option value='.$users[$i]['account_id'].'>'.$phpgw->common->display_fullname($users[$i]['account_lid'],$users[$i]['account_firstname'],$users[$i]['account_lastname']).'</option>'."\n";
|
2001-03-30 06:58:33 +02:00
|
|
|
}
|
|
|
|
$str .= '</select>'."\n";
|
|
|
|
$phpgw->template->set_var('lang_new_owner',lang('Who would you like to transfer ALL records owned by the deleted user to?'));
|
|
|
|
$phpgw->template->set_var('new_owner_select',$str);
|
|
|
|
$phpgw->template->set_var('cancel',lang('cancel'));
|
|
|
|
$phpgw->template->set_var('delete',lang('delete'));
|
2001-05-10 13:21:06 +02:00
|
|
|
$phpgw->template->pparse('out','form');
|
2001-03-30 06:58:33 +02:00
|
|
|
|
|
|
|
$phpgw->common->phpgw_footer();
|
|
|
|
}
|
2001-04-17 17:30:08 +02:00
|
|
|
if($delete_account)
|
2001-03-30 06:58:33 +02:00
|
|
|
{
|
2001-03-31 14:03:38 +02:00
|
|
|
$accountid = $account_id;
|
2001-03-30 06:58:33 +02:00
|
|
|
settype($account_id,'integer');
|
|
|
|
$account_id = get_account_id($accountid);
|
|
|
|
$lid = $phpgw->accounts->id2name($account_id);
|
2001-05-09 05:05:22 +02:00
|
|
|
$db = $phpgw->db;
|
|
|
|
$db->query('SELECT app_name,app_order FROM phpgw_applications WHERE app_enabled!=0 ORDER BY app_order',__LINE__,__FILE__);
|
|
|
|
if($db->num_rows())
|
2001-03-30 06:58:33 +02:00
|
|
|
{
|
2001-05-09 05:05:22 +02:00
|
|
|
while($db->next_record())
|
2001-03-30 06:58:33 +02:00
|
|
|
{
|
2001-05-09 05:05:22 +02:00
|
|
|
$appname = $db->f('app_name');
|
|
|
|
|
2001-03-30 06:58:33 +02:00
|
|
|
if($appname <> 'admin')
|
|
|
|
{
|
|
|
|
$phpgw->common->hook_single('deleteaccount', $appname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$phpgw->common->hook_single('deleteaccount','preferences');
|
|
|
|
$phpgw->common->hook_single('deleteaccount','admin');
|
|
|
|
|
2001-03-30 13:44:33 +02:00
|
|
|
$basedir = $phpgw_info['server']['files_dir'] . SEP . 'users' . SEP;
|
2001-03-23 04:14:09 +01:00
|
|
|
|
|
|
|
if (! @rmdir($basedir . $lid))
|
|
|
|
{
|
|
|
|
$cd = 34;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$cd = 29;
|
|
|
|
}
|
|
|
|
|
2001-05-10 13:21:06 +02:00
|
|
|
Header("Location: " . $phpgw->link('/admin/accounts.php',"cd=$cd"));
|
2001-03-30 13:44:33 +02:00
|
|
|
$phpgw->common->phpgw_exit();
|
2001-03-23 04:14:09 +01:00
|
|
|
}
|
2000-09-25 22:47:40 +02:00
|
|
|
?>
|