mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-22 16:03:47 +01:00
deleteaccount.php now is done by hooks (hook_{appname}_deleteaccount.inc.php). It can now change ownership of records before deleting the user from the system.
This commit is contained in:
parent
0224d6d9da
commit
2ede16ef3a
@ -9,84 +9,74 @@
|
||||
* option) any later version. *
|
||||
\**************************************************************************/
|
||||
|
||||
/* $Id$ */
|
||||
/* $Id$ */
|
||||
|
||||
$phpgw_info = array();
|
||||
$phpgw_info = array();
|
||||
|
||||
if ($confirm || ! $account_id) {
|
||||
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
|
||||
}
|
||||
if ($submit || !$account_id)
|
||||
{
|
||||
$phpgw_info["flags"] = array("noheader" => True, "nonavbar" => True);
|
||||
}
|
||||
|
||||
$phpgw_info["flags"]["currentapp"] = "admin";
|
||||
include("../header.inc.php");
|
||||
$phpgw->template->set_file(array("body" => "delete_common.tpl"));
|
||||
|
||||
// I didn't active this code until all tables are up to date using the owner field
|
||||
// The calendar isn't update to date. (jengo)
|
||||
// NOTE: This is so I don't forget, add a double explode() to the app_tables field
|
||||
// to say what the name of the owner field is.
|
||||
function delete_users_records($account_id, $permissions)
|
||||
{
|
||||
global $phpgw;
|
||||
|
||||
$db2 = $phpgw->db;
|
||||
|
||||
while ($permission = each($permissions)) {
|
||||
$db2->query("select app_tables from applications where app_name='$permission[0]'");
|
||||
$db2->next_record();
|
||||
|
||||
if ($db2->f("app_tables")) {
|
||||
$tables = explode(",",$db2->f("app_tables"));
|
||||
while (list($null,$table) = each($tables)) {
|
||||
$db2->query("delete from $table where owner='$account_id'");
|
||||
}
|
||||
}
|
||||
} // end while
|
||||
} // end function
|
||||
|
||||
|
||||
|
||||
// Make sure they are not attempting to delete there own account.
|
||||
// If they are, they should not reach this point anyway.
|
||||
if ($phpgw_info["user"]["account_id"] == $account_id) {
|
||||
Header('Location: ' . $phpgw->link('/admin/accounts.php'));
|
||||
$phpgw->common->phpgw_exit();
|
||||
}
|
||||
|
||||
if (($account_id) && (! $confirm)) {
|
||||
// the account can have special chars/white spaces, if it is a ldap dn
|
||||
$account_id = rawurlencode($account_id);
|
||||
$phpgw->template->set_var("messages",lang("Are you sure you want to delete this account ?") . "<br>"
|
||||
. "<font color=\"red\"><blink>" . lang("All records and account information will be lost!") . "</blink></font>");
|
||||
$phpgw->template->set_var("yes",'<a href="' . $phpgw->link("/admin/deleteaccount.php","account_id=$account_id&confirm=true")
|
||||
. '">' . lang("Yes") . '</a>');
|
||||
$phpgw->template->set_var("no",'<a href="' . $phpgw->link("/admin/accounts.php")
|
||||
. '">' . lang("No") . '</a>');
|
||||
$phpgw->template->pparse("out","body");
|
||||
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
|
||||
if ($confirm) {
|
||||
$accountid = get_account_id($account_id);
|
||||
$lid = $phpgw->accounts->id2name($accountid);
|
||||
$table_locks = array('phpgw_preferences','todo','phpgw_addressbook','phpgw_accounts');
|
||||
|
||||
$cal = CreateObject('calendar.calendar');
|
||||
$cal_stream = $cal->open('INBOX',$accountid,'');
|
||||
|
||||
$cal->delete_calendar($cal_stream,$accountid);
|
||||
|
||||
$phpgw->db->lock($table_locks);
|
||||
// This really needs to fall back on the app authors job to write the delete routines for their apps.
|
||||
// I need to get with Milosch and have him write a small hook for deleting ALL records for an owner.
|
||||
$phpgw->db->query('delete from todo where todo_owner='.$accountid);
|
||||
$phpgw->db->query('delete from phpgw_addressbook where owner='.$accountid);
|
||||
$phpgw->db->query('delete from phpgw_preferences where preference_owner='.$accountid);
|
||||
|
||||
$phpgw->accounts->delete($accountid);
|
||||
$phpgw->db->unlock();
|
||||
$phpgw_info["flags"]["currentapp"] = "admin";
|
||||
include("../header.inc.php");
|
||||
// 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.
|
||||
if($submit=='Cancel' || $phpgw_info['user']['account_id'] == $account_id)
|
||||
{
|
||||
Header('Location: '.$phpgw->link('/admin/accounts.php'));
|
||||
$phpgw->common->phpgw_exit();
|
||||
}
|
||||
|
||||
if (($account_id) && ($submit<>'Delete'))
|
||||
{
|
||||
$phpgw->template->set_file(array("form" => "delete_account.tpl"));
|
||||
|
||||
$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...
|
||||
$str = '<select name="new_owner" size="5">'."\n";;
|
||||
$users = $phpgw->accounts->get_list('accounts');
|
||||
$c_users = count($users);
|
||||
$str .= '<option value="0">Delete All Records</option>'."\n";
|
||||
for($i=0;$i<$c_users;$i++)
|
||||
{
|
||||
$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";
|
||||
}
|
||||
$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'));
|
||||
$phpgw->template->pparse("out","form");
|
||||
|
||||
$phpgw->common->phpgw_footer();
|
||||
}
|
||||
if($submit=='Delete')
|
||||
{
|
||||
$accountid = $account_id
|
||||
settype($account_id,'integer');
|
||||
$account_id = get_account_id($accountid);
|
||||
$lid = $phpgw->accounts->id2name($account_id);
|
||||
$phpgw->db->query('SELECT app_name FROM phpgw_applications WHERE app_enabled=1',__LINE__,__FILE__);
|
||||
if($phpgw->db->num_rows())
|
||||
{
|
||||
while($phpgw->db->next_record())
|
||||
{
|
||||
$appname = $phpgw->db->f('app_name');
|
||||
if($appname <> 'admin')
|
||||
{
|
||||
$phpgw->common->hook_single('deleteaccount', $appname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$phpgw->common->hook_single('deleteaccount','preferences');
|
||||
$phpgw->common->hook_single('deleteaccount','admin');
|
||||
|
||||
$sep = $phpgw->common->filesystem_separator();
|
||||
|
||||
$basedir = $phpgw_info['server']['files_dir'] . $sep . 'users' . $sep;
|
||||
|
19
admin/templates/default/delete_account.tpl
Executable file
19
admin/templates/default/delete_account.tpl
Executable file
@ -0,0 +1,19 @@
|
||||
<!-- BEGIN form -->
|
||||
<form method="POST" action="{form_action}">
|
||||
<input type="hidden" name="account_id" value="{account_id}">
|
||||
<center>
|
||||
<table border=0 width=85%>
|
||||
<tr>
|
||||
<td align="center">{lang_new_owner}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">{new_owner_select}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><input type="submit" name="submit" value="{cancel}"> <input type="submit" name="submit" value="{delete}"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
</form>
|
||||
<!-- END form -->
|
||||
|
19
admin/templates/verdilak/delete_account.tpl
Executable file
19
admin/templates/verdilak/delete_account.tpl
Executable file
@ -0,0 +1,19 @@
|
||||
<!-- BEGIN form -->
|
||||
<form method="POST" action="{form_action}">
|
||||
<input type="hidden" name="account_id" value="{account_id}">
|
||||
<center>
|
||||
<table border=0 width=85%>
|
||||
<tr>
|
||||
<td align="center">{lang_new_owner}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center">{new_owner_select}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><input type="submit" name="submit" value="{cancel}"> <input type="submit" name="submit" value="{delete}"></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
</form>
|
||||
<!-- END form -->
|
||||
|
Loading…
Reference in New Issue
Block a user