From 93f4703b7168a12617748812f30a5033b2f9110c Mon Sep 17 00:00:00 2001 From: james Date: Wed, 16 Feb 2011 18:39:59 +0000 Subject: [PATCH] Add account_list (temporary hack) user_invite can find users by username OR by email address if the account is found, but user_load fails, thats okay, it just means that they dont have any roles yet --- account.inc.php | 6 +- admin/account_list.php | 266 +++++++++++++++++++++++++++++++++++++++++ admin/judges.php | 1 + user.inc.php | 1 + user_invite.php | 7 +- 5 files changed, 277 insertions(+), 4 deletions(-) create mode 100644 admin/account_list.php diff --git a/account.inc.php b/account.inc.php index 0d1579f..b9cde9e 100644 --- a/account.inc.php +++ b/account.inc.php @@ -146,19 +146,19 @@ function account_create($username,$password=NULL) /* Sanity check username */ if(!account_valid_user($username)) { - $errMsg .= i18n('Invalid user name "%1"', array($username)) . " "; + $errMsg .= i18n('Invalid user name "%1"', array($username)) . "\n"; }else{ /* Make sure the user doesn't exist */ $us = mysql_real_escape_string($username); $q = mysql_query("SELECT * FROM accounts WHERE username='$us'"); if(mysql_num_rows($q)) { - $errMsg .= i18n("The username %1 is already in use", array($username)) . " "; + $errMsg .= i18n("The username %1 is already in use", array($username)) . "\n"; } } //if the password is set, make sure its valid, if its null, thats OK, it'll get generated and set by account_set_password if($password && !account_valid_password($password)) { - $errMsg .= i18n("Invalid password") . " "; + $errMsg .= i18n("Invalid password") . "\n"; } if($errMsg != '') return $errMsg; diff --git a/admin/account_list.php b/admin/account_list.php new file mode 100644 index 0000000..fb330c3 --- /dev/null +++ b/admin/account_list.php @@ -0,0 +1,266 @@ + + Copyright (C) 2005 James 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. +*/ +?> + 'committee_main.php', + 'Administration' => 'admin/index.php') + ); +?> + + +"; + echo "- ".i18n('Show Display Options').""; + + echo "
"; + + echo "
"; + echo ""; + $x = 0; + foreach($user_what as $k=>$v ) { + $sel = (in_array($k, $show_types)) ? 'checked="checked"' : ''; + echo ""; + if($x) echo ""; + $x = ~$x; + } + echo ""; + + echo ""; + echo "
".i18n('Type').":".i18n($v)."
".i18n('Complete').":"; + echo ""; + + echo "
".i18n('Conference').":"; + echo ""; + echo "
"; + echo "
"; + echo ""; + echo "
"; + echo "
"; + + echo ""; + + + echo "
".i18n('Add New User').""; + echo ''; + echo "
"; + echo "
"; + */ + + /* Grab a list of users */ + $clauses = array(); + $showroles = array(); + foreach($show_types as $t){ + $showroles[] = "type = '$t'"; + } + if(count($showroles) > 0) $clauses[] = 'user_roles.roles_id IN(SELECT id FROM roles WHERE ' . implode(' OR ', $showroles) . ')'; + if($show_complete == 'yes') $clauses[] = 'user_roles.complete = "yes"'; + if($show_all == 'no') $clauses[] = "users.conferences_id={$conference['id']}"; + + $querystr = + "SELECT * FROM accounts ORDER BY username"; + /* + "SELECT users.*, + accounts.username, + accounts.email AS emailaddress, + user_roles.accounts_id, user_roles.roles_id, user_roles.active, user_roles.complete, + roles.type, + conferences.name AS conference_name + FROM users + JOIN user_roles ON user_roles.users_id = users.id + JOIN roles ON user_roles.roles_id=roles.id + JOIN conferences ON users.conferences_id = conferences.id + JOIN accounts ON user_roles.accounts_id=accounts.id"; + + if(count($clauses) > 0){ + $querystr .= " WHERE " . implode(' AND ', $clauses) . " "; + } + + $querystr .= " + ORDER BY lastname ASC, firstname ASC, conferences_id DESC "; + +*/ + +/* + echo $querystr; + echo "
\n"; + echo "
\n"; + */ + $q = mysql_query($querystr); + echo mysql_error(); + echo "
\n"; + $num = mysql_num_rows($q); + echo i18n("Listing %1 account total.",array($num)); + + echo mysql_error(); + echo ""; + echo ""; + echo ""; + echo " "; + echo " "; + echo " "; + echo " "; + echo ""; + echo ""; + echo ""; + + $tally = array(); + $tally['active'] = array(); + $tally['inactive'] = array(); + $tally['active']['complete'] = 0; + $tally['active']['incomplete'] = 0; + $tally['active']['na'] = 0; + $tally['inactive']['complete'] = 0; + $tally['inactive']['incomplete'] = 0; + $tally['inactive']['na'] = 0; + while($r=mysql_fetch_assoc($q)) { + // get the role data for this user + echo ""; + echo ""; + + echo ""; + + echo ""; + echo ""; + } + echo ""; + echo "
".i18n("Username")."".i18n("Email Address")."".i18n("Pending Email")."".i18n("Actions")."
"; + echo $r['id']; + echo ""; + echo $r['username']; + echo ""; + echo $r['email']; + echo ""; + echo $r['pendingemail']; + echo "
"; + + send_footer(); +?> diff --git a/admin/judges.php b/admin/judges.php index 0563b5e..605bb96 100644 --- a/admin/judges.php +++ b/admin/judges.php @@ -33,6 +33,7 @@ ); echo "
"; echo ''.i18n('Judges').''; diff --git a/user.inc.php b/user.inc.php index 8fbf893..5f18d65 100644 --- a/user.inc.php +++ b/user.inc.php @@ -43,6 +43,7 @@ function user_valid_role($role) } +//0,319 function user_load($users_id, $accounts_id = false) { global $conference; diff --git a/user_invite.php b/user_invite.php index fcbfcdb..8adb98b 100644 --- a/user_invite.php +++ b/user_invite.php @@ -43,7 +43,7 @@ //we use username='email' because if we are INVITING someone, then //they pretty much have to user their email address as their username //otherwise the system has no way to send them the details - $q = mysql_query("SELECT id,deleted FROM accounts WHERE username='$email'"); + $q = mysql_query("SELECT id,deleted FROM accounts WHERE username='$email' OR email='$email'"); if(mysql_num_rows($q) == 0) { /* Account doesn't exist */ echo "notexist\n"; @@ -57,6 +57,11 @@ } $u = user_load_by_accounts_id($account['id']); + if(!$u) { + //user_load_by_accounts_id returns false if there is no user record for this account for this conference + echo "norole\n"; + exit; + } if(!array_key_exists($type, $u['roles'])) { echo "norole\n";