From 23d8765fa6c5b7df96cbf0672592e8504806d294 Mon Sep 17 00:00:00 2001 From: james Date: Tue, 22 Mar 2011 04:37:51 +0000 Subject: [PATCH] Fix all participant emails in communication module Make queries for communications easier, all you need is a users.id queried, the system will find everything else for you Add ability to use [PASSWORD], [USERNAME], [EMAIL] (tries accounts.email first, if its not there, it uses accounts.pendingemail), in _ANY_ email. [REGNUM] also added but will obviously only work for participants Add "all" section to the tabs list for user editor, so a user without any roles can still get the basic pages like "account", "roles", and "personal info" Put count on participant invitations for teachers (and superusers) Fix a bug where changing a password for a different user didnt work (it changed YOURS!) --- admin/account_list.php | 33 ++++++++++++------- admin/communication.inc.php | 66 +++++++++++++++++++++++++++++-------- admin/communication.php | 28 +++++++++++++--- admin/reports.inc.php | 1 + participant_invite.php | 4 +-- user.inc.php | 3 +- user_account.php | 2 +- user_edit.php | 1 + user_edit_tabs.inc.php | 6 ++-- user_editor_window.php | 2 ++ 10 files changed, 109 insertions(+), 37 deletions(-) diff --git a/admin/account_list.php b/admin/account_list.php index 7941031..bc61a0b 100644 --- a/admin/account_list.php +++ b/admin/account_list.php @@ -34,6 +34,13 @@ if($_POST['show_types']) require_once('judges.inc.php'); + if($_GET['action']=="join" && $_GET['accounts_id']) { + //we're making this user join this conference + echo "joining {$_GET['accounts_id']} with {$conference['id']}"; + $u = user_create(intval($_GET['accounts_id']), $conference['id']); + echo happy(i18n("User joined conference")); + } + send_header("Account List", array('Committee Main' => 'committee_main.php', 'Administration' => 'admin/index.php') @@ -93,17 +100,20 @@ if($_POST['show_types']) echo ""; $u=user_load_by_accounts_id($r['id']); if($u) { + //we can edit them even if they dont have any roles, duh + echo ""; + echo ""; + if($u['firstname'] || $u['lastname']) { + echo $u['firstname']." ".$u['lastname']; + } + else { + echo i18n("No name specified"); + } + echo ""; + echo ""; + echo "
"; + if(count($u['roles'])) { - echo ""; - echo ""; - if($u['firstname'] || $u['lastname']) { - echo $u['firstname']." ".$u['lastname']; - } - else { - echo i18n("No name specified"); - } - echo ""; - echo ""; echo ""; foreach($u['roles'] AS $r=>$rd) { echo ""; echo ""; diff --git a/admin/communication.inc.php b/admin/communication.inc.php index 75dd027..f05c64b 100644 --- a/admin/communication.inc.php +++ b/admin/communication.inc.php @@ -1,11 +1,13 @@ array("name"=>"Yourself (for testing)","query"=>"SELECT users.id FROM users WHERE users.id='{$_SESSION['users_id']}'"), + "committee_all"=>array("name"=>"Committee members (all)","query"=> - "SELECT firstname, lastname, organization, email FROM users + "SELECT users.id FROM users + JOIN accounts ON users.accounts_id=accounts.id 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.deleted = 'no' - GROUP BY users.id"), + WHERE roles.type = 'committee' AND accounts.deleted = 'no' "), /* The WHERE clause evaluates which rows to add to the GROUP BY, the HAVING clase evaluates which grouped rows show up. We @@ -58,31 +60,67 @@ AND user_roles.active='yes' ORDER BY email"), - "participants_complete_thisconference"=>array("name"=>"Participants complete for this conference","query"=> - "SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.conferences_id='".$conference['id']."' AND ( registrations.status='complete' OR registrations.status='paymentpending') ORDER BY students.email"), + "participants_all_thisconference"=>array("name"=>"Participants (all) for this conference","query"=> + "SELECT users.id + FROM users + JOIN user_roles ON user_roles.users_id=users.id + JOIN roles ON user_roles.roles_id=roles.id + WHERE users.conferences_id='{$conference['id']}' + AND roles.type='participant'"), - "participants_complete_paymentpending_thisconference"=>array("name"=>"Participants complete for this conference but payment pending","query"=> - "SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.conferences_id='".$conference['id']."' AND registrations.status!='complete' AND registrations.status='paymentpending' ORDER BY students.email"), + "participants_complete_thisconference"=>array("name"=>"Participants complete/paymentpending for this conference","query"=> + "SELECT users.id FROM users + JOIN registrations ON users.registrations_id=registrations.id + JOIN user_roles ON user_roles.users_id = users.id + JOIN roles ON roles.id = user_roles.roles_id + WHERE roles.type = 'participant' + AND registrations.conferences_id='".$conference['id']."' + AND ( registrations.status='complete' OR registrations.status='paymentpending')"), + + "participants_complete_paymentpending_thisconference"=>array("name"=>"Participants payment pending for this conference","query"=> + "SELECT users.id FROM users + JOIN registrations ON users.registrations_id=registrations.id + JOIN user_roles ON user_roles.users_id = users.id + JOIN roles ON roles.id = user_roles.roles_id + WHERE roles.type = 'participant' + AND registrations.conferences_id='".$conference['id']."' + AND registrations.status='paymentpending'"), "participants_notcomplete_thisconference"=>array("name"=>"Participants not complete for this conference","query"=> - "SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.conferences_id='".$conference['id']."' AND registrations.status!='complete' AND registrations.status!='new' ORDER BY students.email"), + "SELECT users.id + FROM users + JOIN user_roles ON user_roles.users_id=users.id + JOIN roles ON user_roles.roles_id=roles.id + LEFT JOIN registrations ON users.registrations_id=registrations.id + WHERE users.conferences_id='{$conference['id']}' + AND roles.type='participant' + AND (registrations.status IS NULL OR registrations.status='open' OR registrations.status='new')"), + + /* // FIXME - not sure if this has a sensible equivalent when dealing with "conferences" rather than fair years "participants_complete_lastyear"=>array("name"=>"Participants complete last year","query"=> "SELECT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND registrations.year='".($config['FAIRYEAR']-1)."' AND ( registrations.status='complete' OR registrations.status='paymentpending') ORDER BY students.email"), -*/ "participants_complete_allconferences"=>array("name"=>"Participants complete for all conferences","query"=> - "SELECT DISTINCT firstname, lastname, students.email FROM students,registrations WHERE students.registrations_id=registrations.id AND ( registrations.status='complete' OR registrations.status='paymentpending') ORDER BY students.email"), + "SELECT users.id, users.firstname, users.lastname, accounts.email FROM users + JOIN accounts on users.accounts_id=accounts.id + JOIN registrations ON users.registrations_id=registrations.id + JOIN user_roles ON user_roles.users_id = users.id + JOIN roles ON roles.id = user_roles.roles_id + WHERE roles.type = 'participant' + AND (registrations.status='complete' OR registrations.status='paymentpending') ORDER BY accounts.email"), + +*/ "participants_cwsf_thisconference"=>array("name"=>"CWSF Winners for this conference","query"=>" - SELECT DISTINCT students.firstname, students.lastname, students.email + SELECT users.id FROM award_awards JOIN award_prizes ON award_prizes.award_awards_id=award_awards.id JOIN winners ON winners.awards_prizes_id=award_prizes.id JOIN projects ON winners.projects_id=projects.id JOIN registrations ON projects.registrations_id=registrations.id - JOIN students ON students.registrations_id=registrations.id - WHERE award_awards.cwsfaward='1' AND winners.conferences_id='".$conference['id']."' - ORDER BY students.email"), + JOIN users ON users.registrations_id=registrations.id + WHERE award_awards.cwsfaward='1' + AND winners.conferences_id='".$conference['id']."' "), "sponsors"=>array("name"=>"Organization sponsors","query"=> "SELECT id, organization, email FROM sponsors WHERE email!='' ORDER BY email"), diff --git a/admin/communication.php b/admin/communication.php index 907593e..48fa547 100644 --- a/admin/communication.php +++ b/admin/communication.php @@ -803,7 +803,9 @@ case "email_get_list": $urllogin = "$urlmain/login.php"; while($r=mysql_fetch_object($recipq)) { - if($r->uid) + if($r->id) + $u=user_load($r->id); + else if($r->uid) $u=user_load_by_uid($r->uid); else if($r->users_uid) $u=user_load_by_uid($r->users_uid); @@ -816,27 +818,45 @@ case "email_get_list": "FIRSTNAME"=>$r->firstname, "LASTNAME"=>$r->lastname, "NAME"=>$r->firstname." ".$r->lastname, - "EMAIL"=>$r->email, "ORGANIZATION"=>$r->organization, "URLMAIN"=>$urlmain, "URLLOGIN"=>$urllogin, ); } if($u) { + $a=account_load($u['accounts_id']); + $apassword=account_get_password($u['accounts_id']); + if($a['email']) { + $e=$a['email']; + } + else if ($a['pendingemail']) { + $e=$a['pendingemail']; + } + else { + $e=""; + } + if($u['registrations_id']) { + $regq=mysql_query("SELECT num FROM registrations WHERE id='{$u['registrations_id']}'"); + $regr=mysql_fetch_assoc($regq); + } + $replacements=array( "FAIRNAME"=>$config['fairname'], "SALUTATION"=>$u['salutation'], "FIRSTNAME"=>$u['firstname'], "LASTNAME"=>$u['lastname'], "NAME"=>$u['name'], - "EMAIL"=>$u['email'], + "EMAIL"=>$e, + "USERNAME"=>$a['username'], + "PASSWORD"=>$apassword, + "REGNUM"=>$regq['num'], "ORGANIZATION"=>$u['sponsor']['organization'], "URLMAIN"=>$urlmain, "URLLOGIN"=>$urllogin, ); $toname=$u['name']; - $toemail=$u['email']; + $toemail=$e; } if($toemail) { diff --git a/admin/reports.inc.php b/admin/reports.inc.php index 6866fc5..4c03dac 100644 --- a/admin/reports.inc.php +++ b/admin/reports.inc.php @@ -92,6 +92,7 @@ LRP 180 99765 5967 4 1 3/4 x 1/2 80 */ /* FIXME: put these in a databse */ /* All dimensions are in millimeters */ $report_stock = array(); + $report_stock['fullpage'] = array('name' => 'Letter 8.5 x 11 (3/4" margin)', 'page_format' => 'LETTER', 'page_orientation' => 'P', diff --git a/participant_invite.php b/participant_invite.php index 5fbe8c1..82dff23 100644 --- a/participant_invite.php +++ b/participant_invite.php @@ -233,10 +233,10 @@ if( ($_POST['action']=="invitenew" || $_POST['action']=="inviteexisting") && tri echo "
"; echo "
"; if($_SESSION['superuser']=="yes") { - echo "

".i18n("The following participants have been invited from all school (you're a superuser!)")."

\n"; + echo "

".i18n("The following %1 participants have been invited from all schools (you're a superuser!)",array(mysql_num_rows($q)))."

\n"; } else { - echo "

".i18n("The following participants have been invited from your school")."

\n"; + echo "

".i18n("The following %1 participants have been invited from your school",array(mysql_num_rows($q)))."

\n"; } echo "
"; @@ -121,7 +131,8 @@ if($_POST['show_types']) } } else { - echo "no user record for this conference"; + echo "no user record for this conference. "; + echo " click to join conference"; } echo "
\n"; echo ""; diff --git a/user.inc.php b/user.inc.php index 047ff1d..82cb7b8 100644 --- a/user.inc.php +++ b/user.inc.php @@ -1181,8 +1181,7 @@ function user_create($accounts_id, $conferences_id=0) $q = mysql_query("SELECT id FROM users WHERE accounts_id='$accounts_id' AND conferences_id='$conferences_id'"); echo mysql_error(); if(mysql_num_rows($q)) { - echo "ERROR: user_create called for a user that already exists.\n"; - exit; + return "ERROR: user_create called for a user that already exists.\n"; } $fields = array( diff --git a/user_account.php b/user_account.php index 3a66e27..b032c96 100644 --- a/user_account.php +++ b/user_account.php @@ -132,7 +132,7 @@ case 'save': else if(account_valid_password($pass1) == false) error_("The password contains invalid characters or is not long enough"); else { - account_set_password($_SESSION['accounts_id'], $pass); + account_set_password($accounts_id, $pass); unset($_SESSION['password_expired']); happy_('Password has been successfully updated'); diff --git a/user_edit.php b/user_edit.php index bb4e45c..c882cd6 100644 --- a/user_edit.php +++ b/user_edit.php @@ -104,6 +104,7 @@ if(!array_key_exists($selected, $tabs)) { else $selected = ''; } +$types[]="all"; $fields = array(); $required = array(); diff --git a/user_edit_tabs.inc.php b/user_edit_tabs.inc.php index 5d2df3a..0cb2e66 100644 --- a/user_edit_tabs.inc.php +++ b/user_edit_tabs.inc.php @@ -15,7 +15,7 @@ $tabs = array( 'personal' => array( 'label' => 'Personal', 'name' => 'Personal Information', - 'types' => array('teacher','participant','judge','committee','volunteer','sponsor','fair','admin','config'), + 'types' => array('all'), 'file' => 'user_personal.php', 'status_func' => 'user_personal_info_status', 'enabled' => true, @@ -78,7 +78,7 @@ $tabs = array( 'account' => array( 'label' => 'Account/Login', 'name' => 'Change Username/Email/Password', - 'types' => array('teacher','participant','judge','committee','volunteer','sponsor','fair'), + 'types' => array('all'), 'file' => 'user_account.php', 'status_func' => false, 'enabled' => true, @@ -86,7 +86,7 @@ $tabs = array( 'roles' => array( 'label' => 'Roles', 'name' => 'Add/Remove Roles', - 'types' => array('teacher','participant','judge','committee','volunteer','sponsor','fair','admin','config'), + 'types' => array('all'), 'file' => 'user_roles.php', 'status_func' => false, 'enabled' => true, diff --git a/user_editor_window.php b/user_editor_window.php index 72e52b1..fe5fc6a 100644 --- a/user_editor_window.php +++ b/user_editor_window.php @@ -127,6 +127,8 @@ if(!array_key_exists($selected, $tabs)) { $selected = 'personal'; } +$types[]="all"; + if($_GET['sub'] == 1) { $_SESSION['embed'] = true;