diff --git a/admin/schools.php b/admin/schools.php index a8f15f5..3fade4c 100644 --- a/admin/schools.php +++ b/admin/schools.php @@ -56,7 +56,7 @@ /* Load existing entry if it exists, else make an entry if * there is data, else, do nothing */ if($i['principal_uid'] > 0) - $pl = user_load_by_uid($i['principal_uid']); + $pl = user_load_($i['principal_uid']); else if($first != '' && $last != '') { $pl = user_create('principal', "*$first$last".user_generate_password()); $principal_update = "principal_uid='{$pl['uid']}',"; @@ -85,7 +85,7 @@ * to insert */ $sh = false; if($i['sciencehead_uid'] > 0) { - $sh = user_load_by_uid($i['sciencehead_uid']); + $sh = user_load($i['sciencehead_uid']); /* It's possile for sh to be false now, happens when the user is * deleted outside the school editor, this condition needs to be * fixed. If we let it go, the saving the teacher info will @@ -167,21 +167,55 @@ mysql_query("UPDATE schools SET include_olympics = TRUE WHERE id IN $olympicString"); mysql_query("UPDATE schools SET include_olympics = FALSE WHERE id NOT IN $olympicString"); } + else if($_POST['action']=="copy") { + $oldConfId=intval($_POST['copyconference']); + $newConfId=intval($conference['id']); + if($oldConfId && $newConfId) { - if($_GET['action']=="delete" && $_GET['delete']) - { + $q=mysql_query("SELECT * FROM schools WHERE conferences_id=$oldConfId"); + + while($r=mysql_fetch_object($q)) { + $puid = ($r->principal_uid == null) ? 'NULL' : ("'".intval($r->principal_uid)."'"); + $shuid = ($r->sciencehead_uid == null) ? 'NULL' : ("'".intval($r->sciencehead_uid)."'"); + + mysql_query("INSERT INTO schools (school,schoollang,schoollevel,board,district,phone,fax,address,city,province_code,postalcode,principal_uid,schoolemail,sciencehead_uid,accesscode,lastlogin,junior,intermediate,senior,registration_password,projectlimit,projectlimitper,conferences_id) VALUES ( + '".mysql_real_escape_string($r->school)."', + '".mysql_real_escape_string($r->schoollang)."', + '".mysql_real_escape_string($r->schoollevel)."', + '".mysql_real_escape_string($r->board)."', + '".mysql_real_escape_string($r->district)."', + '".mysql_real_escape_string($r->phone)."', + '".mysql_real_escape_string($r->fax)."', + '".mysql_real_escape_string($r->address)."', + '".mysql_real_escape_string($r->city)."', + '".mysql_real_escape_string($r->province_code)."', + '".mysql_real_escape_string($r->postalcode)."',$puid, + '".mysql_real_escape_string($r->schoolemail)."',$shuid, + '".mysql_real_escape_string($r->accesscode)."', + NULL, + '".mysql_real_escape_string($r->junior)."', + '".mysql_real_escape_string($r->intermediate)."', + '".mysql_real_escape_string($r->senior)."', + '".mysql_real_escape_string($r->registration_password)."', + '".mysql_real_escape_string($r->projectlimit)."', + '".mysql_real_escape_string($r->projectlimitper)."', + '".mysql_real_escape_string($newConfId)."')"); + } + $notice="copied"; + } + } + + if($_GET['action']=="delete" && $_GET['delete']) { mysql_query("DELETE FROM schools WHERE id='".$_GET['delete']."'"); $notice = 'deleted'; } - if($_GET['action']=="clearaccesscodes") - { + if($_GET['action']=="clearaccesscodes") { mysql_query("UPDATE schools SET accesscode=NULL WHERE conferences_id='{$conference['id']}'"); $notice = 'clearaccess'; } - if($_GET['action']=="makeaccesscodes") - { + if($_GET['action']=="makeaccesscodes") { $q=mysql_query("SELECT id FROM schools WHERE conferences_id='{$conference['id']}' AND (accesscode IS NULL OR accesscode='')"); while($r=mysql_fetch_object($q)) { @@ -192,9 +226,7 @@ $notice = 'makeaccess'; } - if($_GET['action']=="edit" || $_GET['action']=="add") - { - + if($_GET['action']=="edit" || $_GET['action']=="add") { send_header(($_GET['action']=='edit') ? "Edit School" : "Add New School", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php', @@ -255,7 +287,7 @@ echo "