<?
/*-------------------------------------------------------------------
group_delete.php Ver. $Revision: 1.2 $ $Date: 2003/05/21 01:58:49 $
*
Copyright (C) 2000 Hong Kong Baptist University
*
This file is part of the Quadrille system.
* This program is free software; it is distributed under the terms of
the GNU General Public License, either version 2, or (at your option)
* any later version.
* This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*
---------------------------------------------------------------------
*/
?>
<?
require "global_inc.php";
require "config_inc.php";
require "template.php";
include $language_pack;
include "user_{$lang_name}.inc";
require "user_function_inc.php";
require "output_inc.php";
/*************/
/* Main Part */
/*************/
check_expire();
$temp_cookie[user_uid] = $cookie[user_uid];
$temp_cookie[password] = $cookie[password];
$temp_cookie[db_index] = $cookie[db_index];
$temp_cookie[course_uid] = $cookie[course_uid];
$temp_cookie[unit_uid] = $cookie[unit_uid];
set_cookie($temp_cookie);
$AcceptRole=array("Adm","Tea");
restrict_access($AcceptRole);
insert_header();
$currentlocation = insert_current_location($cookie["course_uid"],$cookie["unit_uid"],$cookie["paper_uid"]);//
$content = delete_group();
$html = get_template($template, $template_dir);
$html=ereg_replace("<BEGIN>TITLE<END>",$DEL_GROUP,$html);
$html=ereg_replace("<BEGIN>CONTENT<END>",$content,$html);
$html=ereg_replace("<BEGIN>CURRENTLOCATION<END>",$currentlocation,$html);
$html=ereg_replace("<BEGIN>COPYRIGHT<END>",$COPYRIGHT,$html);
$html=ereg_replace("<BEGIN>JAVASCRIPT<END>",$java,$html);
print $html;
/***********************/
/* Function Part */
/**********************/
function group_empty($group_uid) {
//user_in_group
$query="select * from USER_IN_GROUP where GROUP_UID = $group_uid";
$result = mysql_query($query);
return (mysql_num_rows($result)<=0);
}
function delete_group() {
global $uid;
include ("./config_inc.php");
include $language_pack;
include "user_{$lang_name}.inc";
global $group_uid;
global $Confirmed;
global $fromURL;
$query = "select * from GROUP_INFO where UID = $group_uid";
$row = "";
if (isset($Confirmed)) {
//$content.=insert_link($BACK,$fromURL,0);
//$content.="<input type=button value=\"$BACK\" onclick=\"javascript:document.location='$fromURL';\">\n";
$query="delete from LEARN where USER_TYPE = 'Group' and USER_UID = $group_uid";
$result = mysql_query($query);
$query="delete from USER_IN_GROUP where GROUP_UID = $group_uid";
$result = mysql_query($query);
$query="delete from GROUP_INFO where UID = $group_uid";
$result = mysql_query($query);
unset($Confirmed);
header("location:$fromURL");
}
$result = mysql_query($query);
if (mysql_num_rows($result) >0 ) {
$row = mysql_fetch_array($result);
global $fromURL;
global $Confirmed;
$content="";
$errorStr="";
if (!group_empty($group_uid)) {
$errorStr=$GROUP_NOT_EMPTY;
}
$content.="<table width=\"\" border=0 cellspacing=4 cellpadding=5 >";
$content.=display_field($GROUP_ID,$row["ID"],'readonly',1);
$content.=display_field($GROUP_NAME,$row["NAME"],'readonly',1);
$content.=display_field($GROUP_DESC,$row["DESCRIPTION"],'readonly',1);
$content.="</table>\n"."<br />";
$content.="<form name=\"form1\" method=\"post\" action=\"group_delete.php\">";
$content.="<input type=\"hidden\" name=\"fromURL\" value = \"$fromURL\">";
$content.="<input type=\"hidden\" name=\"group_uid\" value = \"$group_uid\">";
$content.="<input type=\"hidden\" name=\"Confirmed\" value = \"1\">";
$content.=insert_warning($errorStr)."<br />";
if (isset($Confirmed) && ($errorStr=="") ) {
$content.=$DELETE_GROUP_CONFIRM."<br />";
}
$content.="<br />";
$content.="<input type=button value=\"$OK\" onclick=\"javascript:document.form1.submit();\">\n";
$content.="<input type=button value=\"$CANCEL\" onclick=\"javascript:document.location='$fromURL';\">\n";
$content.="\n</form>";
}
return $content;
}
?>