forked from science-ation/science-ation
152 lines
3.9 KiB
PHP
152 lines
3.9 KiB
PHP
<?
|
|
/*
|
|
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>
|
|
Copyright (C) 2007 David Grant <dave@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_once("common.inc.php");
|
|
require_once("user.inc.php");
|
|
|
|
if(!isset($_SESSION['users_type'])) {
|
|
/* No type set, invalid session */
|
|
echo "ERROR: session is invalid";
|
|
exit;
|
|
}
|
|
|
|
$u = user_load($_SESSION['users_id']);
|
|
|
|
/* Load the fields the user can edit, and theones that are required */
|
|
$fields = array();
|
|
$required = array();
|
|
foreach($u['types'] as $t) {
|
|
$fields = array_merge($fields,
|
|
user_personal_fields($t));
|
|
$required = array_merge($required,
|
|
user_personal_required_fields($t));
|
|
}
|
|
|
|
//send the header
|
|
$type = $_SESSION['users_type'];
|
|
send_header("{$user_what[$type]} - Personal Information",
|
|
array("{$user_what[$type]} Registration" => "{$type}_main.php")
|
|
);
|
|
|
|
|
|
if($_POST['action']=="save")
|
|
{
|
|
/* Set values */
|
|
foreach($fields as $f) {
|
|
$u[$f] = mysql_escape_string(stripslashes($_POST[$f]));
|
|
}
|
|
|
|
user_save($u);
|
|
|
|
echo notice(i18n("%1 %2 successfully updated",array($_POST['firstname'],$_POST['lastname'])));
|
|
}
|
|
|
|
// updateJudgeCompleteStatus($judgeinfo);
|
|
|
|
//output the current status
|
|
$newstatus=user_personal_info_status($u);
|
|
if($newstatus!='complete')
|
|
{
|
|
echo error(i18n("Personal Information Incomplete"));
|
|
}
|
|
else
|
|
{
|
|
echo happy(i18n("Personal Information Complete"));
|
|
}
|
|
|
|
function item($user, $text, $fname)
|
|
{
|
|
global $fields, $required;
|
|
|
|
if(in_array($fname, $fields)) {
|
|
echo '<td>'.i18n($text).'</td>';
|
|
echo "<td><input onchange=\"fieldChanged()\" type=\"text\" name=\"$fname\" value=\"{$user[$fname]}\" />";
|
|
if(in_array($fname, $required)) echo REQUIREDFIELD;
|
|
echo '</td>';
|
|
} else {
|
|
echo '<td></td><td></td>';
|
|
}
|
|
|
|
}
|
|
|
|
|
|
echo "<form name=\"personalform\" method=\"post\" action=\"user_personal.php\">\n";
|
|
echo "<input type=\"hidden\" name=\"action\" value=\"save\" />\n";
|
|
echo "<table>\n";
|
|
|
|
echo "<tr>\n";
|
|
item($u, "First Name", 'firstname');
|
|
item($u, "Last Name", 'lastname');
|
|
echo "</tr>\n";
|
|
echo "<tr>\n";
|
|
item($u, "Email Address", 'email');
|
|
echo "<td></td><td></td>";
|
|
echo "</tr>\n";
|
|
echo "<tr>\n";
|
|
item($u, "Address 1", 'address');
|
|
item($u, "Address 2", 'address2');
|
|
echo "</tr>\n";
|
|
echo "<tr>\n";
|
|
item($u, "City", 'city');
|
|
if(in_array('province', $fields)) {
|
|
echo '<td>'.i18n('Province').'</td>';
|
|
echo '<td>';
|
|
emit_province_selector("province",$judgeinfo->province,"onchange=\"fieldChanged()\"");
|
|
if(in_array('province', $required)) echo REQUIREDFIELD;
|
|
echo '</td>';
|
|
} else {
|
|
echo '<td></td><td></td>';
|
|
}
|
|
echo "</tr>\n";
|
|
echo "<tr>\n";
|
|
item($u, "Postal Code", 'postalcode');
|
|
echo "<td></td><td></td>";
|
|
echo "</tr>\n";
|
|
echo "<tr>";
|
|
item($u, "Phone (Home)", 'phonehome');
|
|
item($u, "Phone (Cell)", 'phonecell');
|
|
echo "</tr>\n";
|
|
|
|
echo "<tr>\n";
|
|
item($u, "Organization", 'organization');
|
|
item($u, "Phone (Work)", 'phonework');
|
|
echo "</tr>";
|
|
echo "<tr>\n";
|
|
item($u, "Fax", 'fax');
|
|
echo '<td></td><td></td>';
|
|
echo "</tr>";
|
|
|
|
|
|
echo "<tr><td colspan=\"4\"><hr /></td></tr>";
|
|
|
|
echo "</table>";
|
|
echo "<input type=\"submit\" value=\"".i18n("Save Personal Information")."\" />\n";
|
|
echo "</form>";
|
|
|
|
echo "<br />";
|
|
|
|
send_footer();
|
|
?>
|