From c3cf69852404c151c197cb095dac1ff2ce86c912 Mon Sep 17 00:00:00 2001 From: jacob Date: Wed, 3 Nov 2010 17:18:02 +0000 Subject: [PATCH] Updates converting from year to conference id. --- admin/communication.inc.php | 20 +++--- admin/export_checkin.php | 2 +- admin/fair_stats.php | 29 +++++---- admin/fundraising_reports_std.php | 4 +- admin/reports_acscript.php | 2 +- admin/reports_judges.inc.php | 5 +- admin/reports_judges.php | 13 ++-- admin/reports_judges_teams_projects.php | 2 +- admin/reports_mailinglabels_generator.php | 2 +- admin/reports_program_awards.php | 2 +- admin/reports_projects_details.php | 2 +- admin/reports_projects_judges_teams.php | 2 +- fair_stats.php | 61 ++++++++---------- tcpdf.inc.php | 11 ++-- user.inc.php | 77 ++--------------------- 15 files changed, 80 insertions(+), 154 deletions(-) diff --git a/admin/communication.inc.php b/admin/communication.inc.php index d214223..612f109 100644 --- a/admin/communication.inc.php +++ b/admin/communication.inc.php @@ -88,18 +88,16 @@ "SELECT id, organization, email FROM sponsors WHERE email!='' ORDER BY email"), "sponsors_primarycontacts"=>array("name"=>"Organization sponsors (primary contacts)","query"=> - "SELECT uid, MAX(users.conferences_id) AS conferences_id, sponsors.organization, users.firstname, users.lastname, users.email, deleted, users_sponsor.primary - FROM sponsors, - users_sponsor, - users + "SELECT users.id, conferences_id, organization, firstname, lastname, email, `primary` + FROM users + JOIN user_roles on users.id = user_roles.id + JOIN roles ON user_roles.roles_id = roles.id WHERE - users.id=users_sponsor.users_id - AND users_sponsor.sponsors_id=sponsors.id - AND users.types LIKE '%sponsor%' - AND users.email!='' - GROUP BY uid - HAVING deleted='no' AND users_sponsor.primary='yes' - ORDER BY users.email + roles.type = 'sponsor' + AND email != '' + AND deleted='no' + AND `primary`='yes' + ORDER BY email "), "sponsors_allcontacts"=>array("name"=>"Organization sponsors (all contacts)","query"=> "SELECT DISTINCT(users.email), sponsors.organization, users.firstname, users.lastname, users.email diff --git a/admin/export_checkin.php b/admin/export_checkin.php index d3065fc..5b05f71 100644 --- a/admin/export_checkin.php +++ b/admin/export_checkin.php @@ -33,7 +33,7 @@ if($catr=mysql_fetch_object($catq)) $pdf=new lpdf( i18n($config['fairname']), i18n("Checkin List")." - ".i18n($catr->category), - $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif" + $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']-logo-200.gif" ); $pdf->newPage(); diff --git a/admin/fair_stats.php b/admin/fair_stats.php index ca5b988..9247c12 100644 --- a/admin/fair_stats.php +++ b/admin/fair_stats.php @@ -299,21 +299,26 @@ } - $q=mysql_query("SELECT COUNT(id) AS num FROM users - LEFT JOIN users_committee ON users_committee.users_id=users.id - WHERE types LIKE '%committee%' - AND year='$year' - AND users_committee.committee_active='yes' - AND deleted='no'"); + $q=mysql_query("SELECT COUNT(users.id) AS num FROM users + JOIN user_roles ON user_roles.users_id = users.id + JOIN roles ON roles.id = user_roles.roles_id + WHERE roles.type = 'committee' + AND users.conferences_id = '{$conference['id']}' + AND users.deleted = 'no'"); + $r = mysql_fetch_object($q); $stats['committee_members'] = $r->num; - $q=mysql_query("SELECT COUNT(id) AS num FROM users LEFT JOIN users_judge ON users_judge.users_id=users.id - WHERE users.year='$year' - AND users.types LIKE '%judge%' - AND users.deleted='no' - AND users_judge.judge_complete='yes' - AND users_judge.judge_active='yes'"); + $q=mysql_query(" + SELECT COUNT(users.id) AS num FROM users + JOIN user_roles ON user_roles.users_id = users.id + JOIN roles ON roles.id = user_roles.roles_id + WHERE users.conferences_id = '{$conference['id']}' + AND users.deleted = 'no' + AND roles.type = 'judge' + AND user_roles.complete='yes' + AND user_roles.active='yes'"); + $r=mysql_fetch_object($q); $stats['judges'] = $r->num; diff --git a/admin/fundraising_reports_std.php b/admin/fundraising_reports_std.php index 7556449..5bc73f3 100644 --- a/admin/fundraising_reports_std.php +++ b/admin/fundraising_reports_std.php @@ -41,7 +41,7 @@ } else if($type=="pdf") { $rep=new lpdf( i18n($config['fairname']), i18n("List of Prospects By Appeal"), - $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif" + $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif" ); $rep->newPage(); $rep->setFontSize(8); @@ -125,7 +125,7 @@ } else if($type=="pdf") { $rep=new lpdf( i18n($config['fairname']), i18n("Results of Appeal by Purpose"), - $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif" + $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif" ); $rep->newPage(); $rep->setFontSize(8); diff --git a/admin/reports_acscript.php b/admin/reports_acscript.php index f892989..41754c9 100644 --- a/admin/reports_acscript.php +++ b/admin/reports_acscript.php @@ -51,7 +51,7 @@ if(!$scriptformat) $scriptformat="default"; if($type=="pdf") { $rep=new lpdf( i18n($config['fairname']), i18n("Awards Ceremony Script"), - $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif" + $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif" ); $rep->newPage(); diff --git a/admin/reports_judges.inc.php b/admin/reports_judges.inc.php index c7c5d16..268b18b 100644 --- a/admin/reports_judges.inc.php +++ b/admin/reports_judges.inc.php @@ -972,12 +972,13 @@ function report_judges_fromwhere($report, $components) $q = " FROM users LEFT JOIN accounts ON accounts.id=users.accounts_id - LEFT JOIN user_roles as ROLE_JUDGE ON (ROLE_JUDGE.users_id=users.id AND ROLE_JUDGE.type='judge') + LEFT JOIN user_roles as ROLE_JUDGE ON (ROLE_JUDGE.users_id=users.id) + JOIN roles ON roles.id = ROLE_JUDGE.roles_id $teams_from $projects_from $students_from WHERE - users.types LIKE '%judge%' + ROLE_JUDGE.type='judge' $conferences_id_where $teams_where $projects_where diff --git a/admin/reports_judges.php b/admin/reports_judges.php index ed0028b..791ca5c 100644 --- a/admin/reports_judges.php +++ b/admin/reports_judges.php @@ -36,7 +36,7 @@ if($type=="pdf") { $rep=new lpdf( i18n($config['fairname']), i18n("Judge List"), - $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif" + $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif" ); $rep->newPage(); @@ -105,16 +105,15 @@ $table['widths']=array(); $table['dataalign']=array(); $q=mysql_query("SELECT - users.*, - users_judge.* + users.* FROM users - JOIN users_judge ON users.id=users_judge.users_id - WHERE + JOIN user_roles ON user_roles.users_id = users.id + JOIN roles ON roles.id = user_roles.roles_id + WHERE + roles.type = 'judge' AND users.deleted='no' AND users.conferences_id='".$conference['id']."' - AND users.types LIKE '%judge%' - ORDER BY lastname, firstname"); diff --git a/admin/reports_judges_teams_projects.php b/admin/reports_judges_teams_projects.php index 77da7a7..ce50175 100644 --- a/admin/reports_judges_teams_projects.php +++ b/admin/reports_judges_teams_projects.php @@ -36,7 +36,7 @@ $rep=new lpdf( i18n($config['fairname']), i18n("Judging Team Project Assignments"), - $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif" + $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif" ); $rep->newPage(); diff --git a/admin/reports_mailinglabels_generator.php b/admin/reports_mailinglabels_generator.php index 76031bc..5fcd401 100644 --- a/admin/reports_mailinglabels_generator.php +++ b/admin/reports_mailinglabels_generator.php @@ -51,7 +51,7 @@ if($report) $rep=new lpdf( i18n($conference['name']), "$reportname Mailing Labels", - $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif" + $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif" ); $rep->setPageStyle("labels"); diff --git a/admin/reports_program_awards.php b/admin/reports_program_awards.php index 3209622..1ca09b2 100644 --- a/admin/reports_program_awards.php +++ b/admin/reports_program_awards.php @@ -13,7 +13,7 @@ $rep=new lpdf( i18n($config['fairname']), i18n("Program Awards"), - $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif" + $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif" ); $rep->newPage(); diff --git a/admin/reports_projects_details.php b/admin/reports_projects_details.php index e252ca0..37c2c25 100644 --- a/admin/reports_projects_details.php +++ b/admin/reports_projects_details.php @@ -36,7 +36,7 @@ $rep=new lpdf( i18n($config['fairname']), i18n("Project Details"), - $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif" + $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif" ); $rep->newPage(); diff --git a/admin/reports_projects_judges_teams.php b/admin/reports_projects_judges_teams.php index e9c37d4..d2f644f 100644 --- a/admin/reports_projects_judges_teams.php +++ b/admin/reports_projects_judges_teams.php @@ -36,7 +36,7 @@ $rep=new lpdf( i18n($config['fairname']), i18n("Project Judging Team Assignments"), - $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/logo-200.gif" + $_SERVER['DOCUMENT_ROOT'].$config['SFIABDIRECTORY']."/data/{$conference['id']}-logo-200.gif" ); $rep->newPage(); diff --git a/fair_stats.php b/fair_stats.php index 425e2ac..43c5594 100644 --- a/fair_stats.php +++ b/fair_stats.php @@ -46,16 +46,16 @@ $u = user_load($eid); switch($_GET['action']) { case 'save': $stats = $_POST['stats']; - $year = intval($_POST['year']); + $conferences_id = intval($_POST['conferences_id']); foreach($stats as $k=>$v) { $stats[$k] = mysql_escape_string($stats[$k]); } // $str = join(',',$stats); - $keys = '`fairs_id`,`year`,`'.join('`,`', array_keys($stats)).'`'; - $vals = "'{$u['fairs_id']}','$year','".join("','", array_values($stats))."'"; - mysql_query("DELETE FROM fairs_stats WHERE fairs_id='{$u['fairs_id']}' AND year='$year'"); + $keys = '`fairs_id`,`conferences_id`,`'.join('`,`', array_keys($stats)).'`'; + $vals = "'{$u['fairs_id']}','$conferences_id','".join("','", array_values($stats))."'"; + mysql_query("DELETE FROM fairs_stats WHERE fairs_id='{$u['fairs_id']}' AND conferences_id='$conferences_id'"); echo mysql_error(); mysql_query("INSERT INTO fairs_stats (`id`,$keys) VALUES ('',$vals)"); echo mysql_error(); @@ -104,8 +104,6 @@ $server_config['scholarships'] = false; $server_config['delegates'] = false; $server_any_stats = false; -$year = intval($_POST['year']); -if($year < 1900) $year = $config['FAIRYEAR']; /* Get the stats we want from this fair */ $q = mysql_query("SELECT * FROM fairs WHERE id='{$u['fairs_id']}'"); @@ -119,38 +117,31 @@ foreach($s as $k) { $server_any_stats = true; } - -/* -$s = ($_SESSION['embed'] == true) ? $_SESSION['embed_submit_url'] : 'fair_stats.php'; -echo "
"; -echo i18n('Select Year').": "; -$q = mysql_query("SELECT DISTINCT year FROM config WHERE year>1000 ORDER BY year DESC"); -echo ""; -echo "
"; -*/ -echo "
"; - /* Load stats */ +$confDat = null; +if(array_key_exists('conferences_id', $_POST)){ + $conferences_id = intval($_POST['conferences_id']); + $confDat = get_conference_info($conferences_id); +} +if($confDat == null){ // can't be an else, as get_conference_info returns null if the id isn't found + $conferences_id = $conference['id']; + $confDat = get_conference_info($conferences_id); +} + $q = mysql_query("SELECT * FROM fairs_stats WHERE fairs_id='{$u['fairs_id']}' - AND year='$year'"); + AND conferences_id='$conferences_id'"); $stats = mysql_fetch_assoc($q); /* Print stats */ /* Print all blocks the server requests */ - + echo "
"; echo "
"; - echo ""; + echo ""; if($server_config['info']) { - echo '

'.i18n('%1 Fair information', array($year)).'

'; + echo '

'.i18n('%1 information', array($confDat['name'])).'

'; echo ''; echo ''; echo ""; @@ -176,7 +167,7 @@ $stats = mysql_fetch_assoc($q); if($server_config['next_chair']) { - echo '

'.i18n('%1 - %2 Chairperson (if known)', array($year, $year+1)).'

'; + echo '

'.i18n('%1 Chairperson (if known)', array($confDat['name'])).'

'; echo '
'.i18n('Fair Start Date').':(YYYY-MM-DD)
'; echo ''; echo ""; @@ -195,7 +186,7 @@ $stats = mysql_fetch_assoc($q); } if($server_config['delegates']) { - echo '

'.i18n('%1 CWSF Delegates and Alternatives', array($year)).'

'; + echo '

'.i18n('%1 CWSF Delegates and Alternatives', array($confDat['name'])).'

'; echo '
'.i18n('Name').':
'; echo ''; for($x=1;$x<=3;$x++) { @@ -216,7 +207,7 @@ $stats = mysql_fetch_assoc($q); } if($server_config['scholarships']) { - echo '

'.i18n('%1 Scholarships', array($year)).'

'; + echo '

'.i18n('%1 Scholarships', array($confDat['name'])).'

'; echo 'How many university/college scholarships are available at your fair? (use a format like:
6 - University of British Columbia - Entrance Scholarships
'; echo ''; echo '

'; @@ -224,7 +215,7 @@ $stats = mysql_fetch_assoc($q); if($server_config['participation']) { $rangemap = array(1=>'1-3', 4=>'4-6', 7=>'7-8', 9=>'9-10', 11=>'11-12'); - echo '

'.i18n('%1 Fair participation', array($year)).'

'; + echo '

'.i18n('%1 participation', array($confDat['name'])).'

'; echo '
'; echo i18n("Number of students").": "; echo ""; @@ -257,7 +248,7 @@ $stats = mysql_fetch_assoc($q); } if($server_config['schools_ext']) { - echo '

'.i18n('%1 Extended School/Participant data', array($year)).'

'; + echo '

'.i18n('%1 Extended School/Participant data', array($confDat['name'])).'

'; echo '
'; ?>
'.i18n('Delegate Name(s)').''.i18n('Email').''.i18n('Jacket Size').'
@@ -284,7 +275,7 @@ $stats = mysql_fetch_assoc($q); '.i18n('%1 Data on minority groups', array($year)).''; + echo '

'.i18n('%1 Data on minority groups', array($confDat['name'])).'

'; echo '
'; echo '
'; echo '
'.i18n('Number of First Nations students'); @@ -295,7 +286,7 @@ $stats = mysql_fetch_assoc($q); echo '
'; } if($server_config['guests'] ) { - echo '

'.i18n('%1 Guests visiting the fair', array($year)).'

'; + echo '

'.i18n('%1 Guests visiting the fair', array($confDat['name'])).'

'; echo '
'; echo ''; echo '
'.i18n('Number of Students that visited the fair (tours, etc.)'); @@ -310,7 +301,7 @@ $stats = mysql_fetch_assoc($q); } if($server_config['sffbc_misc']) { - echo '

'.i18n('%1 Misc. SFFBC Questions', array($year)).'

'; + echo '

'.i18n('%1 Misc. SFFBC Questions', array($confDat['name'])).'

'; echo '
'; echo ''; echo '
'.i18n('Number of Teachers supporting student projects'); diff --git a/tcpdf.inc.php b/tcpdf.inc.php index 4e11114..238e7e6 100644 --- a/tcpdf.inc.php +++ b/tcpdf.inc.php @@ -17,7 +17,7 @@ class pdf extends TCPDF { function __construct($report_name='', $format='LETTER', $orientation='P') { - global $config; + global $conference; /* Start an output PDF */ @@ -50,16 +50,16 @@ class pdf extends TCPDF { // set document information $this->SetCreator('SFIAB'); $this->SetAuthor('SFIAB'); - $this->SetTitle(i18n($config['fairname'])); + $this->SetTitle(i18n($conference['name'])); $this->SetSubject($report_name); $this->SetKeywords(''); - /* Set default header data (K_PATH_IMAGES/logo-500.jpg, 16mm wide, header, name) + /* Set default header data (K_PATH_IMAGES/[conference id]-logo-500.jpg, 16mm wide, header, name) * PDFs use JPG internally, so we should feed it a jpeg, if we dont', tcpdf will * convert it to a jpg anyway, and that takes FOREVER if there's lots of * pages/labels.*/ - $this->SetHeaderData('logo-500.jpg', 16 /* mm */, - i18n($config['fairname']), i18n($report_name)); + $this->SetHeaderData($conference['id'] . '-logo-500.jpg', 16 /* mm */, + i18n($conference['name']), i18n($report_name)); // set header and footer fonts $this->setHeaderFont(Array('helvetica', '', 14)); @@ -315,7 +315,6 @@ class pdf extends TCPDF { function label_new() { - global $config; /* Advance to new label */ // echo "cindex=$this->current_label_index, perpage=$this->labels_per_page\n"; if($this->current_label_index + 1 == $this->labels_per_page) { diff --git a/user.inc.php b/user.inc.php index 8154ad2..fe2c00e 100644 --- a/user.inc.php +++ b/user.inc.php @@ -99,7 +99,6 @@ function user_load($users_id, $accounts_id = false) $u = array_merge($u, $userDat); $u['id'] = intval($u['id']); $u['accounts_id'] = intval($u['accounts_id']); - $u['year'] = intval($u['year']); // Convenience $u['name'] = ($u['firstname'] ? "{$u['firstname']} " : '').$u['lastname']; @@ -234,11 +233,6 @@ function user_load($users_id, $accounts_id = false) /* Do this assignment without recursion :) */ unset($u['orig']); -/* -echo "
";
-print_r($u);
-echo "
"; -*/ $orig = $u; $u['orig'] = $orig; $u['required_fields']=user_all_fields_required(array_keys($u['roles'])); @@ -454,11 +448,7 @@ function user_get_fields($userRoles = null){ $fields[$fieldName]['options'] = array(1 => 'Very Little', 2 => 'Little', 3 => 'Average', 4 => 'Knowledgable', 5 => 'Very Knowledgable'); while($divdata = mysql_fetch_assoc($divquery)){ $divid = $divdata['id']; - $fields[$fieldName]['entries'][$divdata['id']] = $divdata['division'];/* - $subdivquery = mysql_query("SELECT * FROM projectsubdivisions WHERE conferences_id = {$conference['id']} AND projectdivisions_id = $divid"); - while($subdivdata = mysql_fetch_assoc($subdivquery)){ - $divisions[$divdata['division']][$subdivdata['id']] = $subdivdata['subdivision']; - }*/ + $fields[$fieldName]['entries'][$divdata['id']] = $divdata['division']; } break; case 'divsub_prefs': @@ -472,7 +462,6 @@ function user_get_fields($userRoles = null){ $divquery = mysql_query("SELECT * FROM projectdivisions WHERE conferences_id = {$conference['id']}"); while($divdata = mysql_fetch_assoc($divquery)){ $divid = $divdata['id']; -// $fields[$fieldName]['entries'][$divdata['id']] = array('division' => $divdata['division']); $subset = array(); $subdivquery = mysql_query("SELECT * FROM projectsubdivisions WHERE conferences_id = {$conference['id']} AND projectdivisions_id = $divid"); while($subdivdata = mysql_fetch_assoc($subdivquery)){ @@ -543,24 +532,9 @@ function user_get_fields($userRoles = null){ $fields['available_times']['entries'][$slot['id']] = trim($slot['name'] . ' (' . $slot['date'] . ' ' . $slot['starttime'] . ' - ' . $slot['endtime'] . ')'); } } -// echo "
";
-//	print_r($fields);
-//	echo "
"; - return $fields; } -/* FIXME: these are going to need conference IDs too */ -function user_load_by_accounts_id_year($uid, $year) -{ - echo "FIXME"; - exit; - $q = mysql_query("SELECT id FROM users WHERE uid='$uid' AND year <= '$year'"); - if(!mysql_num_rows($q)) return false; - $i = mysql_fetch_assoc($q); - return user_load($i['id']); -} - // this depends on the naming convention that any given role that needs a completion check // will have a function called _status_update, which updates their status with the // current session data and returns 'complete' or 'incomplete' accordingly. @@ -849,7 +823,7 @@ function user_purge($u, $role=false) /* Duplicate a row in the users table, or any one of the users_* tables. */ function user_dupe_row($db, $key, $val, $newval) { - global $config; + global $conference; $nullfields = array('deleteddatetime'); /* Fields that can be null */ $q = mysql_query("SELECT * FROM $db WHERE $key='$val'"); if(mysql_num_rows($q) != 1) { @@ -862,8 +836,8 @@ function user_dupe_row($db, $key, $val, $newval) foreach($i as $k=>$v) { if($v == NULL && in_array($k, $nullfields)) $i[$k] = 'NULL'; - else if($k == 'year') - $i[$k] = $config['FAIRYEAR']; + else if($k == 'conferences_id') + $i[$k] = $conference['id']; else $i[$k] = '\''.mysql_escape_string($v).'\''; } @@ -879,41 +853,6 @@ function user_dupe_row($db, $key, $val, $newval) $id = mysql_insert_id(); return $id; } -/* Used by the login scripts to copy one user from one year to another */ -function user_dupe($u, $new_year) -{ - /* Dupe a user if: - * - They don't exist in the current year - * (users->year != the target year (passed in so we can use it in the rollover script) ) - * - They have a previous year entry - * (users->year DESC LIMIT 1 == 1 row) - * - That previous entry has deleted=no */ - - /* Find the last entry */ - $q = mysql_query("SELECT id,uid,year,deleted FROM users WHERE uid='{$u['uid']}' - ORDER BY year DESC LIMIT 1"); - $r = mysql_fetch_object($q); - if($r->deleted == 'yes') { - echo "Cannot duplicate user ID {$u['id']}, they are deleted. Undelete them first.\n"; - exit; - } - if($r->year == $new_year) { - echo "Cannot duplicate user ID {$u['id']}, they already exist in year $new_year\n"; - exit; - } - - $id = user_dupe_row('users', 'id', $u['id'], NULL); - $q = mysql_query("UPDATE users SET year='$new_year' WHERE id='$id'"); - - /* Load the new user */ - $u2 = user_load($id); - - foreach($u2['types'] as $t) { - user_dupe_row("users_$t", 'users_id', $u['id'], $id); - } - /* Return the ID of the new user */ - return $id; -} /* Returns true if loaded user ($u) is allowed to add role $role to their * profile. THis is intended as a last-stop mechanism, preventing, for example @@ -1275,13 +1214,7 @@ function try_login($user, $pass) $user = mysql_real_escape_string($user); $q = mysql_query("SELECT id,password,deleted FROM accounts WHERE username='$user'"); echo mysql_error(); - /* - $q = mysql_query("SELECT id,username,password,year,deleted - FROM users - WHERE username='$user' - AND deleted='no' - ORDER BY year DESC LIMIT 1"); - */ + if(mysql_num_rows($q) < 1) return false; $r = mysql_fetch_assoc($q);