<?
/*-------------------------------------------------------------------
admin_list.php Ver. $Revision: 1.2 $ $Date: 2003/05/21 01:53:11 $
*
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.
*
---------------------------------------------------------------------
*/
?>
<?
// change extension 14-May-03
require "global_inc.php";
require "config_inc.php";
require "template.php";
require "user_function_inc.php";
require "output_inc.php";
include $language_pack;
include "user_{$lang_name}.inc";
/*************/
/* 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 = admin_list();
$java = get_file("javascript/user_js.js");
$java = ereg_replace("<BEGIN>SELECT_ONE_USER_ONLY<END>",$SELECT_ONE_ADMIN_ONLY,$java);
$java = ereg_replace("<BEGIN>SELECT_ONE_USER_FIRST<END>",$SELECT_ONE_ADMIN_FIRST,$java);
$html = get_template($template, $template_dir);
$html=ereg_replace("<BEGIN>TITLE<END>",$PAGE_TITLE["ADMINISTRATOR_LIST"],$html);
$html=ereg_replace("<BEGIN>CURRENTLOCATION<END>",$currentlocation,$html);
$html=ereg_replace("<BEGIN>CONTENT<END>",$content,$html);
$html=ereg_replace("<BEGIN>COPYRIGHT<END>",$COPYRIGHT,$html);
$html=ereg_replace("<BEGIN>JAVASCRIPT<END>",$java,$html);
print $html;
/**********************/
/* Function Part */
/**********************/
function admin_list() {
include ("./config_inc.php");
include $language_pack;
include "user_{$lang_name}.inc";
global $fromURL;
global $user_uid_list;
$content ="";
$pattern=",";
$check=split($pattern,$user_uid_list);
$query ="select * from USER where ROLE='adm' order by NAME";
$result = mysql_query($query);
$checked_list = split(",",$user_uid_list);
if (mysql_num_rows($result) > 0) {
if (mysql_num_rows($result) >=$nrows_for_two_links)
$content.=insert_link_line();
$content.=insert_message($USER_MSG["PLEASE_SELECT_ADMIN"]);
$content.="<form name=\"form1\" method=\"post\">";
$content.="<input type=hidden value=\"".basename(__FILE__)."\" name=\"fromURL\">\n";
$content.="<input type=hidden value=\"Adm\" name=\"userrole\">\n";
$content.="<input type=hidden name=\"$USER_UID_LIST\">\n";
$content.="<input type=hidden name=\"uid\">\n";
$content.="\n\t<table width=\"\" border=\"0\" cellspacing=\"4\" cellpadding=\"5\">";
$content.="\n\t\t<tr>";
$content.="\n\t\t\t<td nowrap class=\"tableheading\"></td>";
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$USER_ID</td>";
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$USER_NAME</td>";
$content.="\n\t\t\t<td nowrap class=\"tableheading\">$USER_SEX</td>";
$content.="\n\t\t</tr>";
$i=0;
while ($row = mysql_fetch_array($result))
{
$user_ID = $row["ID"];
$user_Name = $row["NAME"];
//$user_SEX = getSex($row["SEX"]);
$user_SEX = $SEX_NAME[$row["SEX"]];
$user_UID = $row["UID"];
if($i%2==0)
$content.="\n\t\t<tr class=\"tablerowodd\">";
else
$content.="\n\t\t<tr class=\"tableroweven\">";
$content.="\n\t\t\t<td><input type=\"checkbox\" name=\"user_uid\" value=\"$user_UID\"".restore_checked($user_UID,$check)."></td>";
$content.=display_cell($user_ID ,'');
$content.="\n\t\t\t";
$content.=display_cell($user_Name,'');
$content.="\n\t\t\t";
//$course_description = ereg_replace("\n","<br />",$course_description );
$content.=display_cell($user_SEX,'');
$content.="\n\t\t</tr>";
$i++;
}
$content.="\n\t</table>";
$content.=insert_Select_All_Button();
$content.="\n</form>";
$content.=insert_link_line();
}
else {
//Add_New_User
$content.="<form name=\"form1\" method=\"post\">";
$content.="<input type=hidden value=\"".basename(__FILE__)."\" name=\"fromURL\">\n";
$content.="<input type=hidden value=\"Adm\" name=\"userrole\">\n";
$content.="<input type=hidden name=\"$USER_UID_LIST\">\n";
$content.="<input type=hidden name=\"uid\">\n";
$b['NEW'] = "javascript:Add_New_User()";
$b['$BACK_TO_USER_LIST']="user_list.php";
$content.=link_line($b,"");
$content.="\n</form>";
}
return $content;
}
function insert_link_line()
{
$a['VIEW_ADMIN_INFO']="javascript:View_info();";
if (show_if_role(array("Adm"))) {
$a['ADD_NEW_ADMIN']="javascript:AddUser();";
$a['EDIT_ADMIN']="javascript:EditUser();";
$a['DEL_ADMIN']="javascript:DelUser();";
}
$a['BACK_TO_USER_LIST']="user_list.php";
return link_line($a,"");
}
?>