From 93c05cbe2fdf4799c44cdae3aa0a1addfde84d1d Mon Sep 17 00:00:00 2001 From: dave Date: Fri, 16 Nov 2007 06:30:42 +0000 Subject: [PATCH] - New user and volunteer signup system --- user.inc.php | 343 +++++++++++++++++++++++++++++++++++++++++ user_login.php | 306 ++++++++++++++++++++++++++++++++++++ user_multirole.php | 87 +++++++++++ user_new.php | 196 +++++++++++++++++++++++ user_page.inc.php | 67 ++++++++ user_password.php | 138 +++++++++++++++++ user_personal.php | 151 ++++++++++++++++++ volunteer.inc.php | 40 +++++ volunteer_main.php | 79 ++++++++++ volunteer_position.php | 158 +++++++++++++++++++ 10 files changed, 1565 insertions(+) create mode 100644 user.inc.php create mode 100644 user_login.php create mode 100644 user_multirole.php create mode 100644 user_new.php create mode 100644 user_page.inc.php create mode 100644 user_password.php create mode 100644 user_personal.php create mode 100644 volunteer.inc.php create mode 100644 volunteer_main.php create mode 100644 volunteer_position.php diff --git a/user.inc.php b/user.inc.php new file mode 100644 index 0000000..643ece1 --- /dev/null +++ b/user.inc.php @@ -0,0 +1,343 @@ + + 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. +*/ +?> +'Participant', 'judge' => 'Judge', + 'committee'=>'Committee Member','volunteer' => 'Volunteer', + 'region'=>'Region'); + + +function user_load_region($u) +{ + /* Double check, make sure the user is of this type */ + if(!in_array('region', $u['types'])) return false; + + $q = mysql_query("SELECT * FROM users_region + WHERE id='{$u['id']}' + "); + if(mysql_num_rows($q)!=1) return false; + + $r = mysql_fetch_object($q); + $ret = array(); + $ret['regions_id'] = intval($r->regions_id); + return $ret; +} + +function user_load_student($u) +{ + /* Double check, make sure the user is of this type */ + if(!in_array('student', $u['types'])) return false; + $ret = array(); + return $ret; +} +function user_load_judge($u) +{ + /* Double check, make sure the user is of this type */ + if(!in_array('judge', $u['types'])) return false; + $ret = array(); + return $ret; +} + +function user_load_committee($u) +{ + /* Double check, make sure the user is of this type */ + if(!in_array('committee', $u['types'])) return false; + + $q = mysql_query("SELECT * FROM users_committee + WHERE users_id='{$u['id']}'"); + if(mysql_num_rows($q)!=1) return false; + + $r = mysel_fetch_object($q); + $ret = array(); + $ret['emailprivate'] = $r->emailprivate; + $ret['ord'] = intval($r->ord); + $ret['displayemail'] = ($r->displayemail == 'Y') ? 'Y' : 'N'; + $ret['access_admin'] = ($r->access_admin == 'Y') ? 'Y' : 'N'; + $ret['access_config'] = ($r->access_config == 'Y') ? 'Y' : 'N'; + $ret['access_super'] = ($r->access_super == 'Y') ? 'Y' : 'N'; + return $ret; +} + +function user_load_volunteer($u) +{ + /* Double check, make sure the user is of this type */ + if(!in_array('volunteer', $u['types'])) return false; + $ret = array(); + return $ret; +} + +function user_load($user, $load_full=false, $force_type=false) +{ + $id = 0; + + /* Sort out the type first */ + if(is_array($user)){ + /* User already loaded, this is just an extended load */ + $id = $user['id']; + $where = "id='$id'"; + $load_base = false; + } else { + + $id = intval($user); + if($id > 0) { + /* Load by ID FIXME: if we enable load-by-email below, + * then a user could use a number at the beginning of + * their email address to exploit here, must fix that. + * */ + $where = "id='$id'"; + } else { + return false; + /* Load by email */ +// $e = stripslashes($user); +// $where = "email='$e'"; + } + $load_base = true; + } + + if($load_base) { + $q=mysql_query("SELECT * FROM users + WHERE + $where + AND deleted='no' + "); + + if(mysql_num_rows($q)!=1) return false; + + $ret = mysql_fetch_assoc($q); + + /* Do we need to do number conversions? */ + $ret['id'] = intval($ret['id']); + + /* Turn the type into an array, because there could be more than one */ + $ts = explode(',', $ret['types']); + $ret['types'] = $ts; /* Now we can use in_array($ret['type'], 'judge') ; */ + + /* Set the current type if there's only one */ + if(count($ret['types']) == 1) { + $ret['type'] = $ret['types'][0]; + } else { + $ret['type'] = false; + } + } else { + $ret = $user; + } + + if($load_full) { + $r = true; + foreach($ret['types'] as $t) { + /* These all pass $ret by reference, and can modify + * $ret */ + $r = call_user_func("user_load_$type", $ret); + if($r == false) return false; + + /* It is important that each type database doesn't + have conflicting column names */ + foreach($r as $k->$v) { + if(array_key_exists($k, $ret)) { + echo "DATABSE DESIGN ERROR, duplicate user key $k"; + exit; + } + } + $ret = array_merge($ret, $r); + } + } + /* Do this assignment without recursion :) */ + $orig = $ret; + $ret['orig'] = $orig; + + return $ret; +} + + +function user_save($u) +{ + $fields = array('firstname','lastname','username','password', + 'email','emailprivate', + 'phonehome','phonework','phonecell','fax', + 'address','address2','city','province','postalcode'); + + $set = ""; + foreach($fields as $f) { + if($u[$f] == $u['orig'][$f]) continue; + + if($set != "") $set .=','; + +// if($f == 'types') +// $set .= "$f='".implode(',', $u[$f])."'"; + + $set .= "$f='{$u[$f]}'"; + } + //echo "
";
+	//print_r($u);
+	//echo "
"; + if($set != "") { + $query = "UPDATE users SET $set WHERE id='{$u['id']}'"; + mysql_query($query); + // echo "query=[$query]"; + echo mysql_error(); + } +} + + +function user_valid_user($user) +{ + /* Find any character that doesn't match the valid username characters + * (^ inverts the matching remember */ + $x = preg_match('[^a-zA-Z0-9@.-_]',$user); + + /* If x==1, a match was found, and the input is bad */ + return ($x == 1) ? false : true; +} + +function user_valid_password($pass) +{ + /* Same as user, but allow more characters */ + $x = preg_match('[^a-zA-Z0-9 ~!@#$%^&*()-_=+|;:,<.>/?]',$pass); + + /* If x==1, a match was found, and the input is bad */ + if($x == 1) return false; + + if(strlen($pass) < 6) return false; + + return true; +} + +/* Perform some checks. Make sure the person is logged in, and that their + * password hasn't expired (the password_expired var is set in the login page) + */ +function user_auth_required($type, $check_expiry=true) +{ + if(!isset($_SESSION['users_type'])) { + header("location: user_login.php?type=$type¬ice=auth_required"); + exit; + } + + if($_SESSION['users_type'] != $type) { + header("location: user_login.php?type=$type¬ice=auth_required"); + exit; + } + + if($_SESSION['password_expired'] == true && $check_expiry==true) { + header("location: user_password.php"); + exit; + } + return true; +} + + +function user_volunteer_registration_status() +{ + global $config; +// $now = date('Y-m-d H:i:s'); + // if($now < $config['dates']['judgeregopen']) return "notopenyet"; +// if($now > $config['dates']['judgeregclose']) return "closed"; + return "open"; +} + +function user_judge_registration_status() +{ + global $config; + $now = date('Y-m-d H:i:s'); + if($now < $config['dates']['judgeregopen']) return "notopenyet"; + if($now > $config['dates']['judgeregclose']) return "closed"; + return "open"; +} + +function user_personal_fields($type) +{ + /* Figure out what fields we should show. */ + $all_fields = array('firstname','lastname','email','phonehome','phonecell','organization'); + switch($type) { + case 'volunteer': + $f = array(); + case 'committee': + $f = array('workphone','fax'); + case 'judge': + $f = array(); + case 'student': + $f = array(); + case 'region': + $f = array(); + } + return array_merge($all_fields, $f); + return null; +} + +function user_personal_required_fields($type) +{ + $all_fields = array('firstname','lastname','email'); + switch($type) { + case 'volunteer': + $f = array(); + case 'committee': + $f = array(); + case 'judge': + $f = array(); + case 'student': + $f = array(); + case 'region': + $f = array(); + } + return array_merge($all_fields, $f); + return null; +} + +function user_personal_info_status($u = false) +{ + if($u == false) { + $u = user_load($_SESSION['users_id']); + } + $required = array(); + foreach($u['types'] as $t) { + $required = array_merge($required, user_personal_required_fields($t)); + } + foreach($required as $r) { + $val = trim($u[$r]); + + if(strlen($val) > 0) { + /* Ok */ + } else { + return 'incomplete'; + } + } + return 'complete'; +} + +function user_update_complete(&$u, $status) +{ + if($status == 'complete' && $u['complete'] != 'yes') { + mysql_query("UPDATE users SET complete='yes' WHERE id='{$_SESSION['users_id']}'"); + $u['complete'] = 'yes'; + return; + } + if($status != 'complete' && $u['complete'] == 'yes') { + mysql_query("UPDATE users SET complete='no' WHERE id='{$_SESSION['users_id']}'"); + $u['complete'] = 'no'; + return; + } +} diff --git a/user_login.php b/user_login.php new file mode 100644 index 0000000..a96413b --- /dev/null +++ b/user_login.php @@ -0,0 +1,306 @@ + + 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. +*/ +?> +password != $pass) return false; + + /* Login successful */ + return $r->id; + } + + /* If there is no session, accept a type from the URL, else, + * if there is a session, always take the session's type. The idea is + * eventually, you'll never be able to see a login page if you're already + * logged in. */ + $type = false; + if(isset($_SESSION['users_type'])) { + $type = $_SESSION['users_type']; + } else { + $type = $_GET['type']; + /* user_types is in user.inc.php */ + if(!in_array($type, $user_types)) $type = false; + } + + $notice=$_GET['notice']; + + switch($type) { + case 'volunteer': + // returns "notopenyet", "closed", or "open" + $reg_open = user_volunteer_registration_status(); + break; + case 'committee': + $reg_open = 'notpermitted'; + break; + case 'judge': + $reg_open = user_judge_registration_status(); + break; + case 'student': + default: + $reg_open = 'closed'; + break; + } + + if($_POST['action']=="login" ) + { + if($_POST['pass'] && $_POST['user']) + { + $id = try_login($_POST['user'], $_POST['pass']); + if($id == false) { + header("location: user_login.php?type=$type¬ice=login_failed"); + exit; + } else { + $u = user_load($id); + $_SESSION['name']="{$u['firstname']} {$u['lastname']}"; + $_SESSION['username']=$u['username']; + $_SESSION['email']=$u['email']; + $_SESSION['users_id']=$u['id']; + $_SESSION['users_type']=$u['type']; + + /* Check for an expired password */ + $now = date('Y-m-d H:i:s'); + if($now > $u['passwordexpiry']) { + $_SESSION['password_expired'] = true; + /* The main page (or any other user page) will catch this now and + * require them to set a password */ + } + + /* FIXME: call a type sepcific function + to set type specific session variables */ + + mysql_query("UPDATE users SET lastlogin=NOW() + WHERE id={$u['id']}"); + + if(count($u['types']) > 1) { + $_SESSION['multirole'] = true; + header("location: user_multirole.php"); + } else { + $_SESSION['multirole'] = false; + header("location: {$type}_main.php"); + } + + exit; + } + + } + header("location: user_login.php?type=$type¬ice=login_failed"); + exit; + } + else if($_GET['action']=="logout") + { + /* Do these explicitly because i'm paranoid */ + unset($_SESSION['name']); + unset($_SESSION['username']); + unset($_SESSION['email']); + unset($_SESSION['users_id']); + unset($_SESSION['users_type']); + /* Take care of anything else */ + $keys = array_keys($_SESSION); + foreach($keys as $k) unset($_SESSION[$k]); + + header("location: user_login.php?type=$type¬ice=logged_out"); + exit; + } + else if($_GET['action']=="recover") + { + send_header("{$user_what[$type]} - Password Recovery", + array("{$user_what[$type]} Login" => "user_login.php?type=$type")); + + $recover_link = "user_login.php?type=$type&action=recover"; + + ?> +
+
+
+
+ + + + + +
+ : +
+ : +
+ : +
+ " /> +
+
+
+
+
+

+ firstname, $fn)!=0 || strcasecmp($r->lastname, $ln)!=0) { + header("Location: user_login.php?type=$type¬ice=recover_name_error"); + exit; + } + + $password = ''; + $pchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + for($x=0;$x<12;$x++) $password .= $pchars{rand(0,61)}; + + mysql_query("UPDATE users SET password='$password',passwordexpiry='0000-00-00' WHERE id={$r->id}"); + + /* volunteer_recover_password, judge_recover_password, student_recover_password, + committee_recover_password */ + email_send("{$type}_recover_password", + $email, + array("FAIRNAME"=>i18n($config['fairname'])), + array( "PASSWORD"=>$password, + "EMAIL"=>$email) + ); + header("Location: user_login.php?type=$type¬ice=recover_sent"); + exit; + } else { + header("Location: user_login.php?type=$type¬ice=recover_email_error"); + exit; + } + } + header("Location: user_login.php?type=$type¬ice=email_error"); + exit; + } + else + { + + send_header("{$user_what[$type]} - Login", array()); + + switch($notice) { + case 'created_sent': + echo happy(i18n("Your new password has been sent to your email address. Please check your email and use the password to login")); + break; + case 'recover_sent': + echo notice(i18n("Your password has been sent to your email address")); + break; + case 'recover_email_error': + echo error(i18n("Could not find your email address for recovery")); + break; + case 'recover_name_error': + echo error(i18n("The name you entered does not match the one in your account")); + break; + case 'email_error': + echo error(i18n("Email address error")); + break; + case 'login_failed': + echo error(i18n("Invalid Email/Password")); + break; + case 'auth_required': + echo error(i18n("You must login to view that page")); + break; + case 'logged_out': + echo notice(i18n("You have been successfully logged out")); + break; + } + + $recover_link = "user_login.php?type=$type&action=recover"; + $new_link = "user_new.php?type=$type"; + + ?> +
+ + + +
+ : +
+ : +
+ /> +
+
+ +
+
+ click here to recover it")?>.

+
+click here.
"); + break; + + case 'closed': + echo i18n("Registration for the %1 %2 is now closed", + array( $config['FAIRYEAR'], + $config['fairname']), + array("Fair year","Fair name") + ); + break; + case 'notpermitted': + default: + break; + } + + } + + send_footer(); +?> + diff --git a/user_multirole.php b/user_multirole.php new file mode 100644 index 0000000..1597cfc --- /dev/null +++ b/user_multirole.php @@ -0,0 +1,87 @@ + + 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. +*/ +?> +%1",array($_SESSION['name'])); + echo "
"; + echo "
"; + + echo i18n('Your account has more than one role associated with it, please select a role from the links below.'); + echo "
"; + echo "
"; + + foreach($user_types as $t) { + if(in_array($t, $u['types'])) { + echo "{$user_what[$t]}
"; + echo "
"; + } + } + + send_footer(); +?> diff --git a/user_new.php b/user_new.php new file mode 100644 index 0000000..2299b73 --- /dev/null +++ b/user_new.php @@ -0,0 +1,196 @@ + + 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. +*/ +?> + "user_login.php?type=$type") ); + echo i18n("{$user_what[$type]} registration is not open"); + echo "
"; + send_footer(); + exit; + } + + if($reg_mode == 'invite') { + send_header("{$user_what[$type]} - Registration", + array("{$user_what[$type]} Login" => "user_login.php?type=$type") ); + + echo i18n("{$user_what[$type]} is by invitation only. You can not create a new account. In order to register you must have your account created for you by the science fair committee.")."
"; + echo i18n("Once your account is created you'll be invited via email to login and complete your {$user_what[$type]} registration information. If you have been invited already, you need to use login using the email address that you were invited with. If you need an invitation, please contact the science fair committee by sending us an email: %1.", + array($config['fairname'],$config['fairmanageremail'])); + echo "
"; + echo "
"; + echo "Back to Login"; + send_footer(); + exit; + } + + + if($_POST['action']=="new") + { + $create = true; + $data_fn = mysql_escape_string(stripslashes($_POST['fn'])); + $data_ln = mysql_escape_string(stripslashes($_POST['ln'])); + $data_email = $_POST['email']; + + if(!isEmailAddress($data_email)) { + $notice = 'email_invalid'; + $data_email = ''; + $create = false; + } + + if($create == true) { + /* Generate a password */ + $password = ''; + $pchars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; + for($x=0;$x<12;$x++) $password .= $pchars{rand(0,61)}; + + /* Add the user */ + $q = "INSERT INTO users (types,firstname,lastname,username,password,passwordexpiry,email,created) VALUES ( + '$type', '$data_fn','$data_ln','$data_email','$password','0000-00-00','$data_email',NOW());"; + mysql_query($q); + echo mysql_error(); + + /* Send the email */ + email_send($welcome_email, $data_email, + array("FAIRNAME"=>i18n($config['fairname'])), + array("PASSWORD"=>$password, + "EMAIL"=>$data_email) + ); + + /* now redirect to the login page */ + header("Location: user_login.php?type=$type¬ice=created_sent"); + exit; + } + + + } + + send_header("{$user_what[$type]} - Registration", + array("{$user_what[$type]} Login" => "user_login.php?type=$type") ); + + switch($notice) { + case 'email_invalid': + echo '
'; + echo error(i18n("The email address is invalid")); + echo '
'; + } + + ?> +
+ + + "; + } + ?> + + +
+ : +
+ : +
+ : +
"; + echo i18n("{$user_what[$type]} Password").":"; + echo "
+ /> +
+
+ "; + echo i18n("When you click the 'Register' button, your password will be randomly created and emailed to you. When you login for the first time you will be prompted to change your password. It can sometimes take several minutes for the email to send, so be patient."); + echo "
"; + + if($reg_mode == 'singlepassword') { + echo "
"; + echo i18n("{$user_what[$type]} registration is protected by a password. You must know the $what Password in order to create an account. Please contact the committee to obtain the password if you wish to register."); + echo "
"; + } + + send_footer(); +?> diff --git a/user_page.inc.php b/user_page.inc.php new file mode 100644 index 0000000..0819077 --- /dev/null +++ b/user_page.inc.php @@ -0,0 +1,67 @@ + + 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. +*/ +?> +"; + echo "".i18n("Item")."".i18n("Status").""; + $user_page_overall_status = 'complete'; +} + +function user_page_summary_item($name, $link, $status_function, $args=array()) +{ + global $user_page_overall_status; + echo ""; + echo ""; + echo i18n("$name"); + echo ""; + echo ""; + //check to see if its complete + $status=call_user_func_array($status_function, $args); + echo outputStatus($status); + echo ""; + if($status != 'complete') { + $user_page_overall_status = 'incomplete'; + } +} + +function user_page_summary_end($print_overall) +{ + global $user_page_overall_status; + if($print_overall) { + echo "
"; + echo "".i18n("Overall Status").""; + echo outputStatus($user_page_overall_status); + echo ""; + } + echo ""; + return $user_page_overall_status; +} + +?> diff --git a/user_password.php b/user_password.php new file mode 100644 index 0000000..9218fbe --- /dev/null +++ b/user_password.php @@ -0,0 +1,138 @@ + + 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. +*/ +?> + 0) + $ex="passwordexpiry=DATE_ADD(CURDATE(),INTERVAL $password_expiry_days DAY)"; + else + $ex="passwordexpiry=NULL"; + + mysql_query("UPDATE users SET password='".$_POST['pass1']."', $ex WHERE id='".$_SESSION['users_id']."' AND email='".$_SESSION['email']."'"); + if($_SESSION['password_expired']) + { + unset($_SESSION['password_expired']); + header("location: $back_link?notice=password_changed"); + exit; + } + } + } + + send_header("$what - Change Password"); + + if($_SESSION['password_expired'] == true) + { + echo i18n('Your password has expired. You must choose a new password now.'); + } + + switch($notice) { + case 'same': + echo error(i18n("You cannot choose the same password again. Please choose a different password")); + break; + case 'passwordrequired': + echo error(i18n("New Password is required")); + break; + case 'nomatch': + echo error(i18n("Passwords do not match")); + break; + case 'invalidchars': + echo error(i18n("The password contains invalid characters or is not long enough")); + + default: + } + + echo "
\n"; + echo "\n"; + echo "\n"; + + echo "
"; + echo "
"; + echo ""; + echo ""; + +echo "
"; + echo i18n("Enter New Password:"); + echo ""; + echo ""; + echo "
"; + echo i18n("Confirm New Password:"); + echo ""; + echo ""; + echo "
"; +echo "\n"; +echo "
"; +echo "
"; +echo "
".i18n('Passwords must be be between 6 and 32 characters, and may NOT contain any quote or a backslash.')."
"; + + +send_footer(); +?> diff --git a/user_personal.php b/user_personal.php new file mode 100644 index 0000000..1604eb9 --- /dev/null +++ b/user_personal.php @@ -0,0 +1,151 @@ + + 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. +*/ +?> + "{$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 ''.i18n($text).''; + echo ""; + if(in_array($fname, $required)) echo REQUIREDFIELD; + echo ''; + } else { + echo ''; + } + +} + + + echo "
\n"; + echo "\n"; + echo "\n"; + +echo "\n"; +item($u, "First Name", 'firstname'); +item($u, "Last Name", 'lastname'); +echo "\n"; +echo "\n"; +item($u, "Email Address", 'email'); +echo ""; +echo "\n"; +echo "\n"; +item($u, "Address 1", 'address'); +item($u, "Address 2", 'address2'); +echo "\n"; +echo "\n"; +item($u, "City", 'city'); + if(in_array('province', $fields)) { + echo ''; + echo ''; + } else { + echo ''; + } +echo "\n"; +echo "\n"; +item($u, "Postal Code", 'postalcode'); +echo ""; +echo "\n"; +echo ""; +item($u, "Phone (Home)", 'phonehome'); +item($u, "Phone (Cell)", 'phonecell'); +echo "\n"; + +echo "\n"; +item($u, "Organization", 'organization'); +item($u, "Phone (Work)", 'phonework'); +echo ""; +echo "\n"; +item($u, "Fax", 'fax'); +echo ''; +echo ""; + + +echo ""; + +echo "
'.i18n('Province').''; + emit_province_selector("province",$judgeinfo->province,"onchange=\"fieldChanged()\""); + if(in_array('province', $required)) echo REQUIREDFIELD; + echo '

"; +echo "\n"; +echo "
"; + + echo "
"; + +send_footer(); +?> diff --git a/volunteer.inc.php b/volunteer.inc.php new file mode 100644 index 0000000..41cdecc --- /dev/null +++ b/volunteer.inc.php @@ -0,0 +1,40 @@ + + 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. +*/ +?> += 1) { + return "complete"; + } + return "incomplete"; +} +?> diff --git a/volunteer_main.php b/volunteer_main.php new file mode 100644 index 0000000..ab170ff --- /dev/null +++ b/volunteer_main.php @@ -0,0 +1,79 @@ + + 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. +*/ +?> +%1",array($_SESSION['name'])); + echo "
"; + echo "
"; + + echo i18n("Please use the checklist below to complete your data. Click on an item in the table to edit that information. When you have entered all information, the Status field will change to Complete"); + echo "
"; + echo "
"; + + $u = user_load($_SESSION['users_id']); + + user_page_summary_begin(); + user_page_summary_item("Contact Information", + "user_personal.php", "user_personal_info_status", array($u)); + user_page_summary_item("Volunteer Positions", + "volunteer_position.php", "volunteer_status_position", array($u)); + $overallstatus = user_page_summary_end(true); + + /* A bit of a FIXME here, if a user completes everythign but doesn't refresh + this page, they will never be marked as complete. Not sure how to handle + this, it's kinda hackey to call EVERY status() fucntion within EACH page to + get teh overall status. */ + user_update_complete($u, $overallstatus); + + echo "
"; + echo "
"; + + if($overallstatus!='complete') + { + echo error(i18n("You will not be marked as an active volunteer until your \"Overall Status\" is \"Complete\"")); + } + else + { + echo happy(i18n("Thank you for completing the volunteer registration process. We look forward to seeing you at the fair")); + } + echo "
"; + + send_footer(); +?> diff --git a/volunteer_position.php b/volunteer_position.php new file mode 100644 index 0000000..0ffe618 --- /dev/null +++ b/volunteer_position.php @@ -0,0 +1,158 @@ + + 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. +*/ +?> + "{$type}_main.php") + ); + + + if($_POST['action']=="save") + { + $vals = ''; + if(is_array($_POST['posn'])) { + + /* Load available IDs */ + $posns = array(); + $q = "SELECT * FROM volunteer_positions WHERE year='{$config['FAIRYEAR']}'"; + $r = mysql_query($q); + while($p = mysql_fetch_object($r)) { + $posns[] = $p->id; + } + + /* Match selections with avaiulable positions */ + foreach($_POST['posn'] as $id=>$val) { + if(!in_array($id, $posns)) continue; + + if($vals != '') $vals .=','; + $vals .= "('{$_SESSION['users_id']}','$id','{$config['FAIRYEAR']}')"; + } + } + + /* Delete existing selections */ + mysql_query("DELETE FROM volunteer_positions_signup + WHERE + users_id='{$_SESSION['users_id']}' + AND year='{$config['FAIRYEAR']}' "); + echo mysql_error(); + + /* Add new selections if there are any */ + if($vals != '') { + $q = "INSERT INTO volunteer_positions_signup (users_id, volunteer_positions_id,year) + VALUES $vals"; + $r=mysql_query($q); + echo mysql_error(); + + } + + echo notice(i18n("Volunteer Positions successfully updated")); + } + +//output the current status +$newstatus=volunteer_status_position($u); +if($newstatus!='complete') +{ + echo error(i18n("Volunteer Position Selection Incomplete")); +} +else +{ + echo happy(i18n("Volunteer Position Selection Complete")); +} + + + echo "
\n"; + echo "\n"; + echo "\n"; + + /* Read current selections */ + $q = "SELECT * FROM volunteer_positions_signup WHERE + users_id = '{$_SESSION['users_id']}' + AND year='{$config['FAIRYEAR']}'"; + $r = mysql_query($q); + $checked_positions = array(); + while($p = mysql_fetch_object($r)) { + $checked_positions[] = $p->volunteer_positions_id; + } + + /* Load available volunteer positions */ + $q = "SELECT *,UNIX_TIMESTAMP(start) as ustart, UNIX_TIMESTAMP(end) as uend + FROM volunteer_positions WHERE year='{$config['FAIRYEAR']}'"; + $r = mysql_query($q); + while($p = mysql_fetch_object($r)) { + + echo '' ; + + echo ""; + echo ''; +} + +echo "
'; + + $checked = false; + + if($_SESSION['lang'] == 'en') { + $sday = strftime("%a. %B %e, %Y", $p->ustart); + $stime = strftime("%H:%M", $p->ustart); + $eday = strftime("%a. %B %e, %Y", $p->uend); + $etime = strftime("%H:%M", $p->uend); + if($sday == $eday) { + $start = $stime; + $end = "$etime, $sday"; + } else { + $start = "$sday, $stime"; + $end = "$eday, $etime"; + } + } else { + $start = $p->start; + $end = $p->end; + } + + + $ch = in_array($p->id, $checked_positions) ? 'checked="checked"' : ''; + echo "id]\" value=\"checked\" />"; + + echo ''; + echo ''.i18n($p->name).'($start - $end)
'; + echo i18n($p->desc); + echo '

"; +echo "\n"; +echo "
"; + + echo "
"; + +send_footer(); +?>