2005-05-13 17:36:01 +00:00
< ?
/*
This file is part of the 'Science Fair In A Box' project
SFIAB Website : http :// www . sfiab . ca
Copyright ( C ) 2005 Sci - Tech Ontario Inc < info @ scitechontario . org >
Copyright ( C ) 2005 James Grant < james @ lightbox . 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 , version 2.
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 .
You should have received a copy of the GNU General Public License
along with this program ; see the file COPYING . If not , write to
the Free Software Foundation , Inc . , 59 Temple Place - Suite 330 ,
Boston , MA 02111 - 1307 , USA .
*/
?>
< ?
require ( " ../common.inc.php " );
2007-11-21 17:02:09 +00:00
require_once ( " ../user.inc.php " );
2010-07-13 03:30:17 +00:00
user_auth_required ( 'admin' );
2005-05-13 17:36:01 +00:00
2011-02-23 16:45:00 +00:00
function output_user_summary ( $userid ) {
$user = user_load ( $userid );
$account = account_load ( $user [ 'accounts_id' ]);
if ( ! $user || ! $account ) {
echo " Invalid User ID ( $userid ) " ;
return ;
}
echo i18n ( " Account " ) . " : " ;
if ( $account [ 'username' ] == $account [ 'email' ]) {
echo $account [ 'username' ];
} else {
echo $account [ 'username' ];
if ( $account [ 'email' ]) echo " / " . $account [ 'email' ];
}
echo " <br /> " ;
echo i18n ( " Name " ) . " : " ;
echo $user [ 'firstname' ] . " " . $user [ 'lastname' ] . " <br /> " ;
if ( $user [ 'phonework' ] || $user [ 'phonehome' ] || $user [ 'phonecell' ]) {
echo i18n ( " Phone " ) . " : " ;
if ( $user [ 'phonework' ]) echo " (W) " . $user [ 'phonework' ] . " " ;
if ( $user [ 'phonehome' ]) echo " (H) " . $user [ 'phonehome' ] . " " ;
if ( $user [ 'phonecell' ]) echo " (C) " . $user [ 'phonecell' ] . " " ;
echo " <br /> " ;
}
}
2005-05-13 17:36:01 +00:00
2011-02-23 16:45:00 +00:00
if ( $_POST [ 'action' ] == " removeuser " ) {
$schoolid = intval ( $_POST [ 'schoolid' ]);
if ( $_POST [ 'role' ] == " principal " ) {
$f = " principal_uid " ;
} else if ( $_POST [ 'role' ] == " teacher " ) {
$f = " sciencehead_uid " ;
}
if ( $f ) {
mysql_query ( " UPDATE schools SET $f =NULL WHERE id=' $schoolid ' " );
}
echo " ok " ;
exit ;
}
2011-02-23 21:57:33 +00:00
else if ( $_POST [ 'action' ] == " adduser " ) {
/* we have the following to work with :
accounts_id , conferenceid , field , role , username , users_id
*/
//if accounts_id is 0, it means its a new user
$accounts_id = intval ( $_POST [ 'accounts_id' ]);
$conferenceid = intval ( $_POST [ 'conferenceid' ]);
$schoolid = intval ( $_POST [ 'schoolid' ]);
if ( $accounts_id == 0 ) {
$a = account_create ( $_POST [ 'username' ]);
if ( isEmailAddress ( $_POST [ 'username' ]))
account_set_email ( $a [ 'id' ], $_POST [ 'username' ]);
//and load it again, just so we have the most up-to-date
$a = account_load ( $a [ 'id' ]);
}
else
$a = account_load ( $accounts_id );
//now lets add the role -- this fails gracefully if they already have the role, or if its added, in both cases it returns 'ok'
$ret = account_add_role ( $a [ 'id' ], $_POST [ 'role' ], $conferenceid );
//we still need the user id
$u = user_load_by_accounts_id ( $a [ 'id' ]);
if ( $ret == 'ok' && $u [ 'id' ]) {
mysql_query ( " UPDATE schools SET ` " . mysql_real_escape_string ( $_POST [ 'field' ]) . " `=' { $u [ 'id' ] } ' WHERE id=' $schoolid ' " );
echo mysql_error ();
//and update the users schools_id, yes, maybe we should use the user object and user_save() but the single query here is easier and probably waaaaaay faster
mysql_query ( " UPDATE users SET schools_id=' $schoolid ' WHERE id=' { $u [ 'id' ] } ' " );
echo mysql_error ();
echo " ok " ;
}
else {
echo " error \n " ;
echo " ret= $ret\n " ;
echo " u= " ; print_r ( $u );
//error ?
}
exit ;
}
2011-02-23 16:45:00 +00:00
if ( $_GET [ 'action' ] == 'loaduser' ) {
$schoolid = intval ( $_GET [ 'schoolid' ]);
$role = $_GET [ 'role' ];
if ( $role == " principal " ) {
$f = " principal_uid " ;
} else if ( $role == " teacher " ) {
$f = " sciencehead_uid " ;
}
$q = mysql_query ( " SELECT $f AS userid FROM schools WHERE id=' $schoolid ' " );
$r = mysql_fetch_object ( $q );
if ( $r -> userid > 0 ) {
//we already have one, so just display teh details, with the option to remove or edit
echo " <td align= \" right \" > " ;
2011-02-23 21:57:33 +00:00
echo " <a onclick= \" return openeditor( $r->userid ); return false; \" href= \" # \" ><img border= \" 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/edit. " . $config [ 'icon_extension' ] . " \" ></a> " ;
2011-02-23 16:45:00 +00:00
echo " " ;
echo " <a onclick= \" return removeUserFromSchool(' $role ', $schoolid ) \"
href = \ " # \" ><img border=0 src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/button_cancel. " . $config [ 'icon_extension' ] . " \" ></a> " ;
echo " </td><td> " ;
output_user_summary ( $r -> userid );
echo " </td> " ;
echo " </tr> " ;
}
else {
2011-03-01 16:21:29 +00:00
echo " <td align= \" right \" > " . i18n ( " Email/username " ) . " </td> " ;
2011-02-23 16:45:00 +00:00
echo " <td> " ;
emit_user_selector ( $f , $conference [ 'id' ], $role );
echo " </td> " ;
}
exit ;
}
2011-02-23 21:57:33 +00:00
2011-02-23 16:45:00 +00:00
function emit_user_selector ( $name , $conferenceid , $role , $allowcreate = true ) {
echo " <!--begin emit_user_selector ( $name , $conferenceid , $role , $allowcreate )--> \n " ;
echo " <input type= \" hidden \" id= \" { $name } _role \" name= \" { $name } _role \" value= \" $role\ " > " ;
echo " <input type= \" hidden \" id= \" { $name } _conferenceid \" name= \" { $name } _conferenceid \" value= \" $conferenceid\ " > " ;
2011-02-23 21:57:33 +00:00
echo " <input type= \" text \" class= \" user_select_autocomplete \" size= \" 45 \" id= \" { $name } \" name= \" { $name } \" > " ;
2011-02-23 16:45:00 +00:00
echo " <!--end emit_user_selector--> \n " ;
}
if ( $_POST [ 'save' ] == " edit " || $_POST [ 'save' ] == " add " ) {
if ( $_POST [ 'save' ] == " add " ) {
2010-11-01 17:14:42 +00:00
$q = mysql_query ( " INSERT INTO schools (conferences_id) VALUES (' " . $conference [ 'id' ] . " ') " );
2005-05-13 17:36:01 +00:00
$id = mysql_insert_id ();
}
else
2009-10-11 03:32:14 +00:00
$id = intval ( $_POST [ 'id' ]);
2005-05-13 17:36:01 +00:00
2009-09-09 00:26:12 +00:00
$atrisk = $_POST [ 'atrisk' ] == 'yes' ? 'yes' : 'no' ;
2005-05-13 17:36:01 +00:00
$exec = " UPDATE schools SET " .
2006-10-15 17:11:56 +00:00
" school=' " . mysql_escape_string ( stripslashes ( $_POST [ 'school' ])) . " ', " .
" schoollang=' " . mysql_escape_string ( stripslashes ( $_POST [ 'schoollang' ])) . " ', " .
2009-09-09 00:26:12 +00:00
" designate=' " . mysql_escape_string ( stripslashes ( $_POST [ 'schooldesignate' ])) . " ', " .
2006-10-15 17:11:56 +00:00
" schoollevel=' " . mysql_escape_string ( stripslashes ( $_POST [ 'schoollevel' ])) . " ', " .
2005-05-13 17:36:01 +00:00
" school=' " . mysql_escape_string ( stripslashes ( $_POST [ 'school' ])) . " ', " .
2006-01-27 18:36:53 +00:00
" board=' " . mysql_escape_string ( stripslashes ( $_POST [ 'board' ])) . " ', " .
" district=' " . mysql_escape_string ( stripslashes ( $_POST [ 'district' ])) . " ', " .
2005-05-13 17:36:01 +00:00
" address=' " . mysql_escape_string ( stripslashes ( $_POST [ 'address' ])) . " ', " .
" city=' " . mysql_escape_string ( stripslashes ( $_POST [ 'city' ])) . " ', " .
" province_code=' " . mysql_escape_string ( stripslashes ( $_POST [ 'province_code' ])) . " ', " .
" postalcode=' " . mysql_escape_string ( stripslashes ( $_POST [ 'postalcode' ])) . " ', " .
2006-10-15 17:11:56 +00:00
" schoolemail=' " . mysql_escape_string ( stripslashes ( $_POST [ 'schoolemail' ])) . " ', " .
2005-05-13 17:36:01 +00:00
" phone=' " . mysql_escape_string ( stripslashes ( $_POST [ 'phone' ])) . " ', " .
" fax=' " . mysql_escape_string ( stripslashes ( $_POST [ 'fax' ])) . " ', " .
2005-11-24 20:21:55 +00:00
" registration_password=' " . mysql_escape_string ( stripslashes ( $_POST [ 'registration_password' ])) . " ', " .
2006-01-18 05:22:58 +00:00
" projectlimit=' " . mysql_escape_string ( stripslashes ( $_POST [ 'projectlimit' ])) . " ', " .
" projectlimitper=' " . mysql_escape_string ( stripslashes ( $_POST [ 'projectlimitper' ])) . " ', " .
2009-09-09 00:26:12 +00:00
" accesscode=' " . mysql_escape_string ( stripslashes ( $_POST [ 'accesscode' ])) . " ', " .
" atrisk=' $atrisk ' " .
2005-05-13 17:36:01 +00:00
" WHERE id=' $id ' " ;
mysql_query ( $exec );
echo mysql_error ();
if ( $_POST [ 'save' ] == " add " )
2007-11-18 23:50:23 +00:00
$notice = 'added' ;
2005-05-13 17:36:01 +00:00
else
2007-11-18 23:50:23 +00:00
$notice = 'saved' ;
2005-05-13 17:36:01 +00:00
}
2011-02-23 21:57:33 +00:00
else if ( $_POST [ 'action' ] == " save_participation " ) {
2010-06-11 14:48:29 +00:00
// update the schools' participation in fairs an olympics to reflect the settings submitted
$olympicSet = array ();
$fairSet = array ();
foreach ( $_POST as $idx => $value ){
if ( preg_match ( '/_olympics$/' , $idx )){
$parts = explode ( '_' , $idx );
$olympicSet [] = $parts [ 0 ];
} else if ( preg_match ( '/_fairs$/' , $idx )){
$parts = explode ( '_' , $idx );
$fairSet [] = $parts [ 0 ];
}
}
$fairString = '(' . implode ( ',' , $fairSet ) . ')' ;
$olympicString = '(' . implode ( ',' , $olympicSet ) . ')' ;
mysql_query ( " UPDATE schools SET include_fairs = TRUE WHERE id IN $fairString " );
mysql_query ( " UPDATE schools SET include_fairs = FALSE WHERE id NOT IN $fairString " );
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 " );
2010-06-10 22:10:20 +00:00
}
2011-01-11 20:10:51 +00:00
else if ( $_POST [ 'action' ] == " copy " ) {
$oldConfId = intval ( $_POST [ 'copyconference' ]);
$newConfId = intval ( $conference [ 'id' ]);
if ( $oldConfId && $newConfId ) {
$q = mysql_query ( " SELECT * FROM schools WHERE conferences_id= $oldConfId " );
while ( $r = mysql_fetch_object ( $q )) {
2011-02-23 21:57:33 +00:00
//FIXME: we need to roll the userid's to new ones for the new conference, if we use the same ones its not gonna work
//nobody should be copying for now, so we should be safe for a few months
//2011-02-22
2011-01-11 20:10:51 +00:00
$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 " ;
}
}
2005-05-13 17:36:01 +00:00
2011-01-11 20:10:51 +00:00
if ( $_GET [ 'action' ] == " delete " && $_GET [ 'delete' ]) {
2005-05-13 17:36:01 +00:00
mysql_query ( " DELETE FROM schools WHERE id=' " . $_GET [ 'delete' ] . " ' " );
2007-11-18 23:50:23 +00:00
$notice = 'deleted' ;
2005-05-13 17:36:01 +00:00
}
2011-01-11 20:10:51 +00:00
if ( $_GET [ 'action' ] == " clearaccesscodes " ) {
2010-11-01 17:14:42 +00:00
mysql_query ( " UPDATE schools SET accesscode=NULL WHERE conferences_id=' { $conference [ 'id' ] } ' " );
2007-11-18 23:50:23 +00:00
$notice = 'clearaccess' ;
2006-12-06 19:24:09 +00:00
}
2011-01-11 20:10:51 +00:00
if ( $_GET [ 'action' ] == " makeaccesscodes " ) {
2010-11-01 17:14:42 +00:00
$q = mysql_query ( " SELECT id FROM schools WHERE conferences_id=' { $conference [ 'id' ] } ' AND (accesscode IS NULL OR accesscode='') " );
2011-02-23 21:57:33 +00:00
while ( $r = mysql_fetch_object ( $q )) {
2006-12-06 19:24:09 +00:00
$ac = generatePassword ( 5 );
2010-11-01 17:14:42 +00:00
mysql_query ( " UPDATE schools SET accesscode=' $ac ' WHERE id=' $r->id ' AND conferences_id=' { $conference [ 'id' ] } ' " );
2006-12-06 19:24:09 +00:00
}
2007-11-18 23:50:23 +00:00
$notice = 'makeaccess' ;
2006-12-06 19:24:09 +00:00
}
2011-01-11 20:10:51 +00:00
if ( $_GET [ 'action' ] == " edit " || $_GET [ 'action' ] == " add " ) {
2007-11-18 23:50:23 +00:00
send_header (( $_GET [ 'action' ] == 'edit' ) ? " Edit School " : " Add New School " ,
2011-02-23 16:45:00 +00:00
2007-11-18 23:50:23 +00:00
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ,
2008-08-22 20:50:38 +00:00
'School Management' => 'admin/schools.php' ),
" schools_management "
2007-11-18 23:50:23 +00:00
);
2011-02-23 16:45:00 +00:00
$schoolid = intval ( $_GET [ 'edit' ]);
?>
< script type = " text/javascript " >
function removeUserFromSchool ( role , schoolid ) {
if ( ! confirmClick ( 'Are you sure you want to remove this ' + role + ' from the school?' ))
return false ;
else {
$ . post ( 'schools.php' ,{ action : 'removeuser' , role : role , schoolid : schoolid }, function () { updateUser ( role , schoolid ); });
return false ;
}
}
var global_schoolid ;
function updateUser ( role , schoolid ) {
global_schoolid = schoolid ;
$ ( " # " + role + " _row " ) . load ( 'schools.php?action=loaduser&role=' + role + '&schoolid=' + schoolid , null , function () {
$ ( " .user_select_autocomplete " ) . autocomplete ({
2011-03-01 16:21:29 +00:00
source : " user_select_autocomplete.php " ,
2011-02-23 16:45:00 +00:00
select : function ( event , ui ) {
var accounts_id = ui . item . accounts_id ;
var users_id = ui . item . users_id ;
var username = $ ( this ) . val ();
var field = $ ( this ) . attr ( " name " );
var conferenceid = $ ( " # " + field + '_conferenceid' ) . val ();
var role = $ ( " # " + field + '_role' ) . val ();
2011-02-23 21:57:33 +00:00
var options = { action : 'adduser' , accounts_id : accounts_id , users_id : users_id , username : username , field : field , conferenceid : conferenceid , schoolid : global_schoolid , role : role };
$ . post ( " schools.php " , options , function () {
updateUser ( role , global_schoolid );
});
2011-02-23 16:45:00 +00:00
}
});
});
}
$ ( document ) . ready ( function () {
updateUser ( 'principal' , < ? = $schoolid ?> );
updateUser ( 'teacher' , < ? = $schoolid ?> );
});
</ script >
< ?
if ( $_GET [ 'action' ] == " edit " ) {
2005-05-13 17:36:01 +00:00
$buttontext = " Save School " ;
2011-02-23 16:45:00 +00:00
$q = mysql_query ( " SELECT * FROM schools WHERE id=' $schoolid ' " );
2005-05-13 17:36:01 +00:00
$r = mysql_fetch_object ( $q );
}
2005-12-15 22:28:04 +00:00
else if ( $_GET [ 'action' ] == " add " )
2005-05-13 17:36:01 +00:00
{
$buttontext = " Add School " ;
}
$buttontext = i18n ( $buttontext );
echo " <form method= \" post \" action= \" schools.php \" > \n " ;
echo " <input type= \" hidden \" name= \" save \" value= \" " . $_GET [ 'action' ] . " \" > \n " ;
if ( $_GET [ 'action' ] == " edit " )
2011-02-23 16:45:00 +00:00
echo " <input type= \" hidden \" name= \" id \" value= \" " . $schoolid . " \" > \n " ;
2005-05-13 17:36:01 +00:00
echo " <table> \n " ;
2006-01-27 18:36:53 +00:00
echo " <tr><td> " . i18n ( " School Name " ) . " </td><td><input type= \" text \" name= \" school \" value= \" " . htmlspecialchars ( $r -> school ) . " \" size= \" 60 \" maxlength= \" 64 \" /></td></tr> \n " ;
2006-10-15 17:11:56 +00:00
echo " <tr><td> " . i18n ( " School Language " ) . " </td><td> " ;
echo " <select name= \" schoollang \" > " ;
echo " <option value= \" \" > " . i18n ( " Choose " ) . " </option> \n " ;
foreach ( $config [ 'languages' ] AS $k => $l )
{
if ( $r -> schoollang == $k ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" $k\ " > " .i18n( $l ). " </ option > \n " ;
}
echo " </select> " ;
echo " </td></tr> \n " ;
2009-09-09 00:26:12 +00:00
echo " <tr><td> " . i18n ( " School Designation " ) . " </td><td> " ;
$des = array ( '' => 'Choose' , 'public' => 'Public' ,
'independent' => 'Independent/Private' ,
'home' => 'Home School' );
echo " <select name= \" schooldesignate \" > " ;
foreach ( $des as $k => $v ) {
$sel = ( $r -> designate == $k ) ? 'selected="selected"' : '' ;
echo " <option $sel value= \" $k\ " > " .i18n( $v ). " </ option > \n " ;
}
echo " </select></td></tr> \n " ;
2006-10-15 17:11:56 +00:00
echo " <tr><td> " . i18n ( " School Level " ) . " </td><td><input type= \" text \" name= \" schoollevel \" value= \" " . htmlspecialchars ( $r -> schoollevel ) . " \" size= \" 32 \" maxlength= \" 32 \" /></td></tr> \n " ;
2006-01-27 18:36:53 +00:00
echo " <tr><td> " . i18n ( " School Board " ) . " </td><td><input type= \" text \" name= \" board \" value= \" " . htmlspecialchars ( $r -> board ) . " \" size= \" 60 \" maxlength= \" 64 \" /></td></tr> \n " ;
echo " <tr><td> " . i18n ( " School District " ) . " </td><td><input type= \" text \" name= \" district \" value= \" " . htmlspecialchars ( $r -> district ) . " \" size= \" 60 \" maxlength= \" 64 \" /></td></tr> \n " ;
2005-05-13 17:36:01 +00:00
echo " <tr><td> " . i18n ( " Address " ) . " </td><td><input type= \" text \" name= \" address \" value= \" " . htmlspecialchars ( $r -> address ) . " \" size= \" 60 \" maxlength= \" 64 \" /></td></tr> \n " ;
echo " <tr><td> " . i18n ( " City " ) . " </td><td><input type= \" text \" name= \" city \" value= \" " . htmlspecialchars ( $r -> city ) . " \" size= \" 32 \" maxlength= \" 32 \" /></td></tr> \n " ;
2008-07-16 17:23:53 +00:00
echo " <tr><td> " . i18n ( $config [ 'provincestate' ]) . " </td><td> " ;
2005-05-13 17:36:01 +00:00
emit_province_selector ( " province_code " , $r -> province_code );
echo " </td></tr> \n " ;
2008-07-16 17:23:53 +00:00
echo " <tr><td> " . i18n ( $config [ 'postalzip' ]) . " </td><td><input type= \" text \" name= \" postalcode \" value= \" $r->postalcode\ " size = \ " 8 \" maxlength= \" 7 \" /></td></tr> \n " ;
2005-05-13 17:36:01 +00:00
echo " <tr><td> " . i18n ( " Phone " ) . " </td><td><input type= \" text \" name= \" phone \" value= \" " . htmlspecialchars ( $r -> phone ) . " \" size= \" 16 \" maxlength= \" 16 \" /></td></tr> \n " ;
echo " <tr><td> " . i18n ( " Fax " ) . " </td><td><input type= \" text \" name= \" fax \" value= \" " . htmlspecialchars ( $r -> fax ) . " \" size= \" 16 \" maxlength= \" 16 \" /></td></tr> \n " ;
2009-10-11 03:32:14 +00:00
2006-10-15 17:11:56 +00:00
echo " <tr><td> " . i18n ( " School Email " ) . " </td><td><input type= \" text \" name= \" schoolemail \" value= \" " . htmlspecialchars ( $r -> schoolemail ) . " \" size= \" 60 \" maxlength= \" 128 \" /></td></tr> \n " ;
2005-05-13 17:36:01 +00:00
echo " <tr><td> " . i18n ( " Access Code " ) . " </td><td><input type= \" text \" name= \" accesscode \" value= \" " . htmlspecialchars ( $r -> accesscode ) . " \" size= \" 32 \" maxlength= \" 32 \" /></td></tr> \n " ;
2011-02-23 16:45:00 +00:00
echo " <tr><td colspan=2><br /><b> " . i18n ( " Principal " ) . " </b></td></tr> " ;
echo " <tr id= \" principal_row \" > " ;
//this gets filled in by javascript/jquery
echo " </tr> " ;
2005-05-13 17:36:01 +00:00
echo " <tr><td colspan=2><br /><b> " . i18n ( " Science head/teacher or science fair contact at school " ) . " </b></td></tr> " ;
2011-02-23 16:45:00 +00:00
echo " <tr id= \" teacher_row \" > " ;
//this gets filled in by javascript/jquery
echo " </tr> " ;
if ( $config [ 'participant_registration_type' ] == " schoolpassword " ) {
2005-11-24 20:21:55 +00:00
echo " <tr><td colspan=2><br /><b> " . i18n ( " Participant Registration Password " ) . " </b></td></tr> " ;
echo " <tr><td> " . i18n ( " Password " ) . " </td><td><input type= \" text \" name= \" registration_password \" value= \" " . htmlspecialchars ( $r -> registration_password ) . " \" size= \" 32 \" maxlength= \" 32 \" /></td></tr> \n " ;
2006-01-18 05:22:58 +00:00
}
echo " <tr><td colspan=2><br /><b> " . i18n ( " Participant Registration Limits " ) . " </b></td></tr> " ;
2011-02-23 16:45:00 +00:00
if ( $config [ 'participant_registration_type' ] == " invite " ) {
2006-01-18 05:22:58 +00:00
echo " <tr><td colspan=2> " . i18n ( " Set to 0 to have no registration limit " ) . " </td></tr> " ;
echo " <tr><td colspan=2> " . i18n ( " Maximum of " ) . " " ;
echo " <input type= \" text \" name= \" projectlimit \" value= \" " . htmlspecialchars ( $r -> projectlimit ) . " \" size= \" 4 \" maxlength= \" 4 \" /> " ;
echo " " ;
echo i18n ( " projects " );
echo " " ;
echo " <select name= \" projectlimitper \" > " ;
if ( $r -> projectlimitper == " total " ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" total \" > " . i18n ( " total " ) . " </option> \n " ;
if ( $r -> projectlimitper == " agecategory " ) $sel = " selected= \" selected \" " ; else $sel = " " ;
echo " <option $sel value= \" agecategory \" > " . i18n ( " per age category " ) . " </option> \n " ;
echo " </select> " ;
echo " </td></tr> \n " ;
}
else
{
echo " <tr><td colspan=2> " . i18n ( " Participant registration limits are currently disabled. In order to use participant registration limits for schools, the participant registration type must be set to 'invite' in Configuration / Configuration Variables " ) . " </td></tr> " ;
2005-11-24 20:21:55 +00:00
}
2009-09-09 00:26:12 +00:00
echo " <tr><td colspan=2><br /><b> " . i18n ( " Demographic Information " ) . " </b></td></tr> " ;
$ch = ( $r -> atrisk ) == 'yes' ? 'checked="checked"' : '' ;
echo " <tr><td align= \" right \" ><input type= \" checkbox \" name= \" atrisk \" value= \" yes \" $ch /></td><td> " . i18n ( " Inner City or At-Risk school " ) . " </td></tr> \n " ;
2005-11-24 20:21:55 +00:00
echo " <tr><td colspan= \" 2 \" > </td></tr> " ;
2005-05-13 17:36:01 +00:00
echo " <tr><td colspan= \" 2 \" align= \" center \" ><input type= \" submit \" value= \" $buttontext\ " /></ td ></ tr > \n " ;
echo " </table> \n " ;
echo " </form> \n " ;
2010-06-10 22:10:20 +00:00
}
else if ( $_GET [ 'action' ] == 'participation' )
{
send_header (
" Conference Participation " ,
array (
'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ,
'School Management' => 'admin/schools.php'
),
" participation "
);
echo " <form method= \" post \" action= \" schools.php \" > \n " ;
echo " <table class= \" tableview \" > " ;
echo " <thead><tr> " ;
echo " <th> " . i18n ( " School " ) . " </th> " ;
echo " <th> " . i18n ( " Participation " ) . " </th> " ;
echo " </tr></thead> \n " ;
2010-11-01 17:14:42 +00:00
$query = mysql_query ( " SELECT id, school, include_fairs, include_olympics FROM schools WHERE conferences_id=' " . $conference [ 'id' ] . " ' ORDER BY school " );
2010-06-10 22:10:20 +00:00
while ( $record = mysql_fetch_array ( $query )){
echo " <tr><td> " . $record [ 'school' ] . " </td> " ;
echo " <td><label style= \" margin-right: 2em \" > " ;
echo '<input type="checkbox" name="' . $record [ 'id' ] . '_fairs' . '"' ;
if ( $record [ 'include_fairs' ] == true ) echo " CHECKED " ;
echo " > " . i18n ( " fairs " ) . " </label> " ;
echo " <label> " ;
echo '<input type="checkbox" name="' . $record [ 'id' ] . '_olympics' . '"' ;
if ( $record [ 'include_olympics' ] == true ) echo " CHECKED " ;
echo " > " . i18n ( " olympics " ) . " </label> " ;
echo " </td></tr> " ;
}
2010-06-11 14:48:29 +00:00
echo " <tr><td colspan= \" 2 \" align= \" center \" ><input type= \" submit \" value= \" " . i18n ( 'Save' ) . " \" /></td></tr> \n " ;
2010-06-10 22:10:20 +00:00
echo " </table> \n " ;
echo '<input type="hidden" name="action" value="save_participation"></input>' . " \n " ;
echo " </form> \n " ;
2005-05-13 17:36:01 +00:00
}
2011-01-11 20:10:51 +00:00
else if ( $_GET [ 'action' ] == " copy " ) {
send_header ( " School Management " ,
array ( 'Committee Main' => 'committee_main.php' ,
'Administration' => 'admin/index.php' ),
" schools_management "
);
echo " <form method= \" post \" action= \" schools.php \" > " ;
echo " <input type= \" hidden \" name= \" action \" value= \" copy \" > \n " ;
echo i18n ( " Choose a conference to copy schools from " );
echo " <br /> " ;
$q = mysql_query ( " SELECT * FROM conferences WHERE id!=' { $conference [ 'id' ] } ' ORDER BY id DESC " );
echo mysql_error ();
echo " <select name= \" copyconference \" > " ;
echo " <option value= \" \" > " . i18n ( " Choose a Conference " ) . " </option> \n " ;
while ( $r = mysql_fetch_object ( $q )) {
$numq = mysql_query ( " SELECT COUNT(*) AS c FROM schools WHERE conferences_id=' { $r -> id } ' " );
$numr = mysql_fetch_object ( $numq );
echo " <option value= \" { $r -> id } \" > { $r -> name } ( $numr->c schools)</option> \n " ;
}
echo " </select> \n " ;
echo " <input type= \" submit \" value= \" " . i18n ( " Copy Schools " ) . " \" > " ;
echo " </form> \n " ;
}
else {
2007-11-18 23:50:23 +00:00
send_header ( " School Management " ,
array ( 'Committee Main' => 'committee_main.php' ,
2008-08-22 20:50:38 +00:00
'Administration' => 'admin/index.php' ),
" schools_management "
2007-11-18 23:50:23 +00:00
);
switch ( $notice ) {
case 'added' :
2011-01-11 20:10:51 +00:00
echo happy ( i18n ( " School successfully added " ));
2007-11-18 23:50:23 +00:00
break ;
case 'saved' :
2011-01-11 20:10:51 +00:00
echo happy ( i18n ( " Successfully saved changes to school " ));
2007-11-18 23:50:23 +00:00
break ;
case 'deleted' :
2011-01-11 20:10:51 +00:00
echo happy ( i18n ( " School successfully deleted " ));
2007-11-18 23:50:23 +00:00
break ;
case 'clearaccess' :
2011-01-11 20:10:51 +00:00
echo happy ( i18n ( " Access Codes successfully cleared from all schools " ));
2007-11-18 23:50:23 +00:00
break ;
case 'makeaccess' :
2011-01-11 20:10:51 +00:00
echo happy ( i18n ( " Access Codes successfully set for schools that didn't have one " ));
break ;
case 'copied' :
echo happy ( i18n ( " Schools successfully copied from other conference " ));
2007-11-18 23:50:23 +00:00
break ;
}
2005-05-13 17:36:01 +00:00
echo " <br /> " ;
2008-10-06 19:09:00 +00:00
echo " <a href= \" schools.php?action=add \" > " . i18n ( " Add new school " ) . " </a> \n " ;
2005-05-13 17:36:01 +00:00
echo " <br /> " ;
2011-01-11 20:10:51 +00:00
echo " <a href= \" schools.php?action=copy \" > " . i18n ( " Copy schools from a difference conference " ) . " </a> \n " ;
echo " <br /> " ;
2008-10-06 19:09:00 +00:00
echo " <a href= \" schoolsimport.php?action=add \" > " . i18n ( " Import schools from CSV " ) . " </a> \n " ;
2006-09-11 17:32:02 +00:00
echo " <br /> " ;
2008-10-06 19:09:00 +00:00
echo " <a href= \" schools.php?action=makeaccesscodes \" > " . i18n ( " Create Access Code for any school without one " ) . " </a> \n " ;
2006-12-06 19:24:09 +00:00
echo " <br /> " ;
2008-10-06 19:09:00 +00:00
echo " <a onclick= \" return confirmClick(' " . i18n ( " Are you sure you want to remove all access codes from all schools? " ) . " ') \" href= \" schools.php?action=clearaccesscodes \" > " . i18n ( " Remove Access Codes from all schools " ) . " </a> \n " ;
2006-12-06 19:24:09 +00:00
echo " <br /> " ;
2010-06-11 14:48:29 +00:00
// we only need to see this option if we are managing both types of conferences
2010-06-10 22:10:20 +00:00
$q = mysql_fetch_array ( mysql_query ( 'SELECT COUNT(DISTINCT(`type`)) as taly FROM conferences' ));
2010-06-11 14:48:29 +00:00
if ( $q [ 'tally' ] > 1 ){
2010-06-10 22:10:20 +00:00
echo " <a href= \" schools.php?action=participation \" > " . i18n ( " Set SFIAB/SOIAB participation " ) . " </a> \n " ;
echo " <br /> " ;
2010-06-11 14:48:29 +00:00
}
2009-09-11 16:18:47 +00:00
echo " <table class= \" tableview \" > " ;
2010-03-30 21:59:04 +00:00
echo " <thead><tr> " ;
2008-10-06 19:09:00 +00:00
echo " <th> " . i18n ( " School " ) . " </th> " ;
echo " <th> " . i18n ( " Address " ) . " </th> " ;
echo " <th> " . i18n ( " Phone " ) . " </th> " ;
2011-02-22 15:49:06 +00:00
echo " <th> " . i18n ( " Science Head " ) . " </th> " ;
echo " <th> " . i18n ( " Science Head Email " ) . " </th> " ;
2005-11-24 20:21:55 +00:00
if ( $config [ 'participant_registration_type' ] == " schoolpassword " )
2008-10-06 19:09:00 +00:00
echo " <th> " . i18n ( " Reg Pass " ) . " </th> " ;
echo " <th> " . i18n ( " Access Code " ) . " </th> " ;
echo " <th> " . i18n ( " Action " ) . " </th> " ;
2010-03-30 21:59:04 +00:00
echo " </tr></thead> \n " ;
2005-05-13 17:36:01 +00:00
2010-11-01 17:14:42 +00:00
$q = mysql_query ( " SELECT * FROM schools WHERE conferences_id=' " . $conference [ 'id' ] . " ' ORDER BY school " );
2005-05-13 17:36:01 +00:00
while ( $r = mysql_fetch_object ( $q ))
{
echo " <tr> \n " ;
echo " <td> $r->school </td> \n " ;
echo " <td> $r->address , $r->city , $r->postalcode </td> \n " ;
echo " <td> $r->phone </td> \n " ;
2009-12-02 01:22:47 +00:00
$sciencehead = '' ;
2011-02-22 15:49:06 +00:00
$scienceheademail = '' ;
2009-12-02 01:22:47 +00:00
if ( $r -> sciencehead_uid > 0 ) {
2011-01-11 20:10:51 +00:00
$sh = user_load ( $r -> sciencehead_uid );
2009-12-02 01:22:47 +00:00
$sciencehead = $sh [ 'name' ];
2011-03-07 22:34:28 +00:00
if ( ! $sciencehead ) $sciencehead = " <i>no name set</i> " ;
2011-02-22 15:49:06 +00:00
// print_r($sh);
$sha = account_load ( $sh [ 'accounts_id' ]);
2011-03-07 22:34:28 +00:00
if ( $sha [ 'email' ]) {
$scienceheademail = $sha [ 'email' ];
$pending = " " ;
}
else {
$scienceheademail = $sha [ 'pendingemail' ];
$pending = " (unconfirmed) " ;
}
2009-12-02 01:22:47 +00:00
}
echo " <td> $sciencehead </td> \n " ;
2011-03-07 22:34:28 +00:00
echo " <td><a href= \" mailto: $scienceheademail\ " > $scienceheademail </ a > $pending </ td > \n " ;
2005-11-24 20:21:55 +00:00
if ( $config [ 'participant_registration_type' ] == " schoolpassword " )
echo " <td> $r->registration_password </td> \n " ;
2006-12-06 19:24:09 +00:00
echo " <td> $r->accesscode </td> \n " ;
2005-05-13 17:36:01 +00:00
echo " <td align= \" center \" > " ;
echo " <a href= \" schools.php?action=edit&edit= $r->id\ " >< img border = \ " 0 \" src= \" " . $config [ 'SFIABDIRECTORY' ] . " /images/16/edit. " . $config [ 'icon_extension' ] . " \" ></a> " ;
echo " " ;
echo " <a onclick= \" return confirmClick('Are you sure you want to remove this school?') \" href= \" schools.php?action=delete&delete= $r->id\ " >< img border = 0 src = \ " " . $config [ 'SFIABDIRECTORY' ] . " /images/16/button_cancel. " . $config [ 'icon_extension' ] . " \" ></a> " ;
echo " </td> \n " ;
echo " </tr> \n " ;
}
echo " </table> \n " ;
}
send_footer ();
?>