require_once('initialize.php');
import('form.Form');
+import('ttAdmin');
// Access checks.
if (!ttAccessAllowed('delete_group')) {
header('Location: access_denied.php');
exit();
}
-// End of access checks.
-
-// TODO: refactor this... and the template.
$group_id = (int)$request->getParameter('id');
+if ($user->group_id != $group_id) {
+ header('Location: access_denied.php');
+ exit();
+}
+// End of access checks.
+// Note: reuse ttAdmin class here because deleting a group is a complicated task.
+// This creates an issue of using the class for not intended purpose.
+// However, otherwise we have to duplicate code, so reuse it is, for now.
$admin = new ttAdmin();
$group_details = $admin->getGroupDetails($group_id);
$group_name = $group_details['group_name'];
if ($request->isPost()) {
if ($request->getParameter('btn_delete')) {
- $result = $admin->markGroupDeleted($group_id);
- if ($result) {
- header('Location: admin_groups.php');
+ if ($admin->markGroupDeleted($group_id)) {
+ $auth->doLogout();
+ session_unset();
+ header('Location: login.php');
exit();
} else
$err->add($i18n->get('error.db'));
}
if ($request->getParameter('btn_cancel')) {
- header('Location: admin_groups.php');
+ header('Location: group_edit.php');
exit();
}
} // isPost
$smarty->assign('group_to_delete', $group_name);
$smarty->assign('forms', array($form->getName()=>$form->toArray()));
$smarty->assign('title', $i18n->get('title.delete_group'));
-$smarty->assign('content_page_name', 'admin_group_delete.tpl');
+$smarty->assign('content_page_name', 'group_delete.tpl');
$smarty->display('index.tpl');