forked from science-ation/science-ation
Add some user sponsor stubs
Fix some multi-year user stuff Add sponsor main page
This commit is contained in:
parent
3c1a4d29cc
commit
bce2cef92e
@ -2,6 +2,8 @@
|
||||
function db_update_118_post()
|
||||
{
|
||||
global $config;
|
||||
$available="ABCDEFGHJKLMNPQRSTUVWXYZabcdefghjkmnpqrstuvwxyz23456789";
|
||||
$availlen=strlen($available) - 1;
|
||||
|
||||
$userfields=array("salutation","firstname","lastname","email","phonehome","phonework","phonecell","fax");
|
||||
|
||||
@ -42,8 +44,24 @@ function db_update_118_post()
|
||||
|
||||
}
|
||||
else {
|
||||
$sql="INSERT INTO users (`types`,`username`,`".implode("`,`",$userfields)."`,`year`) VALUES (";
|
||||
$sql.="'sponsor','".mysql_real_escape_string($r->email)."'";
|
||||
//we need a username, if htere's no email, then we need to gerneate one to use.
|
||||
if($r->email) {
|
||||
$username=$r->email;
|
||||
}
|
||||
else {
|
||||
$username="";
|
||||
for($x=0;$x<16;$x++)
|
||||
$username.=$available{rand(0,$availlen)};
|
||||
}
|
||||
|
||||
//and create them a password
|
||||
$password="";
|
||||
for($x=0;$x<8;$x++)
|
||||
$password.=$available{rand(0,$availlen)};
|
||||
|
||||
//set passwordset to 0000-00-00 to force it to expire on next login
|
||||
$sql="INSERT INTO users (`types`,`username`,`created`,`password`,`passwordset`,`".implode("`,`",$userfields)."`,`year`) VALUES (";
|
||||
$sql.="'sponsor','".mysql_real_escape_string($username)."',NOW(),'$password','0000-00-00'";
|
||||
foreach($userfields AS $f) {
|
||||
$sql.=",'".mysql_real_escape_string($r->$f)."'";
|
||||
}
|
||||
@ -69,7 +87,6 @@ function db_update_118_post()
|
||||
'".mysql_real_escape_string($r->notes)."')");
|
||||
echo mysql_error();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
?>
|
||||
|
1
db/db.update.119.sql
Normal file
1
db/db.update.119.sql
Normal file
@ -0,0 +1 @@
|
||||
DROP TABLE award_contacts;
|
47
sponsor_main.php
Normal file
47
sponsor_main.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?
|
||||
/*
|
||||
This file is part of the 'Science Fair In A Box' project
|
||||
SFIAB Website: http://www.sfiab.ca
|
||||
|
||||
Copyright (C) 2008 Sci-Tech Ontario Inc <info@scitechontario.org>
|
||||
Copyright (C) 2008 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_once("common.inc.php");
|
||||
require_once("user.inc.php");
|
||||
require_once("user_page.inc.php");
|
||||
|
||||
user_auth_required('sponsor');
|
||||
|
||||
send_header("Sponsor Main", array());
|
||||
|
||||
//only display the named greeting if we have their name
|
||||
echo i18n("Hello <b>%1</b>",array($_SESSION['name']));
|
||||
echo "<br />";
|
||||
echo "<br />";
|
||||
|
||||
echo "<table class=\"adminconfigtable\">";
|
||||
echo " <tr>\n";
|
||||
echo " <td><a href=\"user_personal.php\">".theme_icon("edit_profile")."<br />".i18n("Edit My Profile")."</a></td>";
|
||||
echo " <td><a href=\"user_password.php\">".theme_icon("change_password")."<br />".i18n("Change My Password")."</a></td>";
|
||||
echo " <td><a href=\"user_activate.php\">".theme_icon("")."<br />".i18n("Manage My Roles")."</a></td>";
|
||||
echo " </tr>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
send_footer();
|
||||
?>
|
34
user.inc.php
34
user.inc.php
@ -24,10 +24,10 @@
|
||||
?>
|
||||
<?
|
||||
|
||||
$user_types = array('student','judge','committee','volunteer','fair');
|
||||
$user_types = array('student','judge','committee','volunteer','fair','sponsor');
|
||||
$user_what = array('student'=>'Participant', 'judge' => 'Judge',
|
||||
'committee'=>'Committee Member','volunteer' => 'Volunteer',
|
||||
'fair'=>'Science Fair');
|
||||
'fair'=>'Science Fair','sponsor' => 'Sponsor Contact');
|
||||
|
||||
|
||||
/* Duplicate of common.inc.php:generatePassword, which will be deleted
|
||||
@ -107,6 +107,21 @@ function user_load_volunteer(&$u)
|
||||
return true;
|
||||
}
|
||||
|
||||
function user_load_sponsor($u)
|
||||
{
|
||||
/* Double check, make sure the user is of this type */
|
||||
if(!in_array('sponsor', $u['types'])) return false;
|
||||
|
||||
$q = mysql_query("SELECT * FROM users_sponsor
|
||||
WHERE users_id='{$u['id']}'");
|
||||
if(mysql_num_rows($q)!=1) return false;
|
||||
|
||||
$r = mysql_fetch_object($q);
|
||||
$ret = array();
|
||||
$ret['sponsors_id'] = $r->sponsors_id;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
function user_load($user)
|
||||
{
|
||||
$id = intval($user);
|
||||
@ -267,6 +282,10 @@ function user_save_fair($u)
|
||||
user_save_type_list($u, 'users_fair', $fields);
|
||||
}
|
||||
|
||||
function user_save_sponsor($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_save($u)
|
||||
{
|
||||
$fields = array('firstname','lastname','username',
|
||||
@ -329,10 +348,15 @@ function user_delete_judge($u)
|
||||
function user_delete_fair($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_delete_student($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_delete_sponsor($u)
|
||||
{
|
||||
}
|
||||
|
||||
function user_delete($u, $type=false)
|
||||
{
|
||||
$finish_delete = false;
|
||||
@ -495,7 +519,8 @@ function user_add_role_allowed($type, $u)
|
||||
'volunteer' => array('judge', 'committee'),
|
||||
'judge' => array('volunteer', 'committee'),
|
||||
'student' => array(),
|
||||
'fair' => array() );
|
||||
'fair' => array(),
|
||||
'sponsor' => array('volunteer','judge') );
|
||||
|
||||
foreach($u['types'] as $ut) {
|
||||
$allowed_array = $allowed[$ut];
|
||||
@ -540,6 +565,9 @@ function user_create($type, $u = NULL)
|
||||
case 'committee':
|
||||
mysql_query("INSERT INTO users_committee(`users_id`, `committee_active`) VALUES ('$uid', 'yes')");
|
||||
break;
|
||||
case 'sponsor':
|
||||
mysql_query("INSERT INTO users_sponsor(`users_id`) VALUES ('$uid')");
|
||||
break;
|
||||
}
|
||||
return user_load($uid);
|
||||
}
|
||||
|
@ -48,8 +48,8 @@
|
||||
$q = mysql_query("SELECT id,username,password,year,deleted
|
||||
FROM users
|
||||
WHERE username='$user'
|
||||
ORDER BY year DESC");
|
||||
echo mysql_error();
|
||||
AND deleted='no'
|
||||
ORDER BY year DESC LIMIT 1");
|
||||
if(mysql_num_rows($q) < 1) return false;
|
||||
|
||||
$r = mysql_fetch_object($q);
|
||||
@ -115,6 +115,9 @@
|
||||
case 'fair':
|
||||
$reg_open = 'notpermitted';
|
||||
break;
|
||||
case 'sponsor':
|
||||
$reg_open = 'notpermitted';
|
||||
break;
|
||||
case 'student':
|
||||
default:
|
||||
exit;
|
||||
@ -298,7 +301,7 @@
|
||||
if(user_valid_email($email)) {
|
||||
/* valid email address */
|
||||
$e = mysql_escape_string($email);
|
||||
$q=mysql_query("SELECT * FROM users WHERE email='$e'");
|
||||
$q=mysql_query("SELECT * FROM users WHERE (username='$e' OR email='$e') ORDER BY year DESC LIMIT 1");
|
||||
$r=mysql_fetch_object($q);
|
||||
if($r) {
|
||||
$fn = trim($_POST['fn']);
|
||||
|
Loading…
Reference in New Issue
Block a user