egroupware_official/admin/deletegroup.php

96 lines
4.0 KiB
PHP
Raw Normal View History

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. *
\**************************************************************************/
/* $Id$ */
$phpgw_info = array();
2001-02-09 18:57:43 +01:00
$phpgw_info['flags'] = array('noheader' => True, 'nonavbar' => True, 'currentapp' => 'admin');
2000-08-18 05:24:22 +02:00
2001-01-21 03:05:45 +01:00
if (! $group_id) {
2001-02-09 18:57:43 +01:00
Header('Location: ' . $phpgw->link('groups.php'));
2001-01-21 03:05:45 +01:00
}
2001-02-09 18:57:43 +01:00
include('../header.inc.php');
2001-02-01 05:02:01 +01:00
$p = CreateObject('phpgwapi.Template',$phpgw->common->get_tpl_dir('admin'));
2001-02-09 18:57:43 +01:00
$p->set_file(array('body' => 'delete_common.tpl',
'message_row' => 'message_row.tpl'));
if ((($group_id) && ($confirm)) || $removeusers) {
if ($removeusers) {
2001-02-09 18:57:43 +01:00
$old_group_list = $phpgw->acl->get_ids_for_location(intval($group_id),1,'phpgw_group');
2001-02-01 05:02:01 +01:00
@reset($old_group_list);
while($old_group_list && $id = each($old_group_list)) {
2001-02-09 18:57:43 +01:00
$phpgw->acl->delete_repository('phpgw_group',$group_id,intval($id[1]));
}
}
2001-02-09 18:57:43 +01:00
$group_name = $phpgw->accounts->id2name($group_id);
2000-08-18 05:24:22 +02:00
2001-02-09 18:57:43 +01:00
$old_group_list = $phpgw->acl->get_ids_for_location(intval($group_id),1,'phpgw_group');
2001-02-01 05:02:01 +01:00
if ($old_group_list) {
$phpgw->common->phpgw_header();
echo parse_navbar();
2001-02-09 18:57:43 +01:00
$p->set_var('message_display','<tr><td>'
. lang('Sorry, the follow users are still a member of the group x',$group_name)
. '<br>' . lang('They must be removed before you can continue') . '</td></td>');
$p->parse('messages','message_row',True);
$p->set_var('message_display','<tr><td><table border="0">');
$p->parse('messages','message_row',True);
2000-08-18 05:24:22 +02:00
2001-02-01 05:02:01 +01:00
while (list(,$id) = each($old_group_list)) {
2001-02-09 18:57:43 +01:00
$p->set_var('message_display','<tr><td><a href="' . $phpgw->link('editaccount.php','account_=' . $id) . '">' . $phpgw->common->grab_owner_name($id) . '</a></tr></td>');
$p->parse('messages','message_row',True);
2000-08-18 05:24:22 +02:00
}
2001-02-09 18:57:43 +01:00
$p->set_var('message_display','</table></center></td></tr><tr><td>'
. '<a href="' . $phpgw->link('deletegroup.php','group_id=' . $group_id . '&removeusers=True')
. '">' . lang('Remove all users from this group') . '</a></td></tr>');
$p->parse('messages','message_row',True);
$p->set_var('yes','');
$p->set_var('no','');
$p->pparse('out','body');
$phpgw->common->phpgw_exit();
2000-08-18 05:24:22 +02:00
}
if ($confirm) {
2001-02-09 18:57:43 +01:00
$phpgw->db->lock(array('phpgw_accounts','phpgw_acl'));
$phpgw->db->query('DELETE FROM phpgw_accounts WHERE account_id='.$group_id,__LINE__,__FILE__);
$phpgw->acl->delete_repository('%%','run',intval($group_id));
$basedir = $phpgw_info['server']['files_dir'] . SEP . 'groups' . SEP;
if (! @rmdir($basedir . $group_name)) {
2001-02-09 18:57:43 +01:00
$cd = 38;
} else {
$cd = 32;
}
2001-02-09 18:57:43 +01:00
$phpgw->db->unlock();
Header('Location: ' . $phpgw->link('groups.php','cd='.$cd));
2001-02-01 05:02:01 +01:00
$phpgw->common->phpgw_exit();
}
2001-02-01 05:02:01 +01:00
} else {
2001-02-01 05:02:01 +01:00
$phpgw->common->phpgw_header();
echo parse_navbar();
2001-01-21 03:05:45 +01:00
2001-02-09 18:57:43 +01:00
$p->set_var('message_display',lang('Are you sure you want to delete this group ?'));
$p->parse('messages','message_row');
$p->set_var('yes','<a href="' . $phpgw->link('deletegroup.php',"group_id=$group_id&confirm=true") . '">' . lang('Yes') . '</a>');
$p->set_var('no','<a href="' . $phpgw->link('groups.php') . '">' . lang('No') . '</a>');
2001-01-21 03:05:45 +01:00
2001-02-09 18:57:43 +01:00
$p->pparse('out','body');
2001-01-21 03:05:45 +01:00
2001-02-01 05:02:01 +01:00
$phpgw->common->phpgw_footer();
}
2000-09-28 01:17:36 +02:00
?>