Copyright (C) 2005 James Grant Copyright (C) 2007 David Grant 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_once('common.inc.php'); require_once('user.inc.php'); /* Ensure they're logged in as something, anything */ user_auth_required(); $edit_id = isset($_GET['users_id']) ? intval($_GET['users_id']) : $_SESSION['users_id']; if($edit_id != $_SESSION['users_id']) user_auth_required('admin'); else user_auth_required(); $u = user_load($edit_id); if(array_key_exists('action', $_POST)){ switch($_POST['action']){ case 'submit_code': $code = mysql_real_escape_string($_POST['code']); $school = mysql_real_escape_string($_POST['school']); $query = "SELECT * FROM schools WHERE id = $school AND accesscode = '$code'"; $data = mysql_fetch_assoc(mysql_query($query)); if(is_array($data)){ $query = "UPDATE users SET schools_id = $school WHERE id = $edit_id"; if(mysql_query($query)){ // we successfully updated the school for this user. Now send the info back to papulate the page $schoolData = mysql_fetch_assoc(mysql_query("SELECT school, address, city, province_code, postalcode, phone FROM schools WHERE id='$school'")); echo "schoolInfo = '" . implode("
", $schoolData) . "';"; } } break; default: // invalid action break; } exit; } $translations = array( 'if_incorrect' => i18n("If this is incorrect, please select the correct school and enter its access code in the fields below."), 'incorrect' => i18n("That does not appear to be the correct access code. Please select the school and enter its access code in the fields below."), 'not_associated' => i18n("You are not currently associated with any school. Please select the school and enter its access code in the fields below.") ); ?> " . i18n("School Information") . ""; $currentSchool = $u['schools_id']; if($currentSchool != null){ echo i18n("You are currently listed as a member of") . "
"; echo '
'; $schoolData = mysql_fetch_assoc(mysql_query("SELECT school, address, city, province_code, postalcode, phone FROM schools WHERE id='$currentSchool'")); echo implode('
', $schoolData); echo '
'; echo '

' . $translations['if_incorrect'] . "

"; }else{ echo '
'; echo '

' . $translations['not_associated'] . "

"; } // draw the form elements for changing the school echo "
"; echo "" . i18n("School") . ": "; echo ""; // build a select box for them to pick out a school echo '"; echo "
"; // and the rest of the form... echo "" . i18n("Access Code") . ": "; echo ""; echo '
'; echo "
"; echo ''; echo "
";