2006-03-01 15:59:51 +00:00
< ?
$mailqueries = array (
2008-01-09 17:25:30 +00:00
" committee_all " => array ( " name " => " Committee members (all) " , " query " =>
2010-11-01 21:23:17 +00:00
" SELECT firstname, lastname, organization, email 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 . deleted = 'no'
GROUP BY users . id " ),
2007-10-31 15:22:30 +00:00
2009-09-18 04:04:20 +00:00
/* The WHERE clause evaluates which rows to add to the GROUP
BY , the HAVING clase evaluates which grouped rows show up . We
want to to evaluate 'deleted' AFTER the grouping , so we catch
2010-11-01 21:23:17 +00:00
the case where the MAX ( conferences_id ) has deleted = 'yes' . If we use WHERE
2009-09-18 04:04:20 +00:00
deleted = 'no' , we ' ll only add non - deleted rows to the group , and
end up picking up a user active in , say 2007 and 2008 , but
deleted in 2009. */
2010-11-01 21:23:17 +00:00
" judges_all " => array ( " name " => " Judges from all conferences (except deleted judges) " , " query " =>
" SELECT firstname, lastname, email, deleted, MAX(conferences_id) FROM users
JOIN user_roles ON user_roles . users_id = users . id
JOIN roles ON roles . id = user_roles . roles_id
WHERE roles . type = 'judge' GROUP BY users . accounts_id HAVING deleted = 'no' ORDER BY email " ),
" judges_active_thisconference " => array ( " name " => " Judges active for this conference " , " query " =>
" SELECT firstname, lastname, email FROM users
LEFT JOIN user_roles ON user_roles . users_id = users . id
JOIN roles ON roles . id = user_roles . roles_id
WHERE roles . type = 'judge' AND conferences_id = { $conference [ 'id' ]} AND deleted = 'no' AND user_roles . active = 'yes' ORDER BY email " ),
" judges_inactive_thisconference " => array ( " name " => " Judges in the conference that are not active " , " query " =>
" SELECT firstname, lastname, email FROM users
LEFT JOIN user_roles ON user_roles . users_id = users . id
JOIN roles ON roles . id = user_roles . roles_id
WHERE roles . type = 'judge' AND conferences_id = { $conference [ 'id' ]} AND deleted = 'no' AND user_roles . active = 'no' ORDER BY email " ),
" judges_inactive_allconferences " => array ( " name " => " Judges inactive for any conference " , " query " =>
" SELECT firstname, lastname, email FROM users
LEFT JOIN user_roles ON user_roles . users_id = users . id
JOIN roles ON roles . id = user_roles . roles_id
WHERE roles . type = 'judge' AND deleted = 'no' AND user_roles . active = 'no' ORDER BY email " ),
" judges_active_complete_thisconference " => array ( " name " => " Judges active for this conference and complete " , " query " =>
" SELECT firstname, lastname, email FROM users
LEFT JOIN user_roles ON user_roles . users_id = users . id
JOIN roles ON roles . id = user_roles . id
WHERE roles . type = 'judge' AND conferences_id = { $conference [ 'id' ]}
AND user_roles . complete = 'yes'
AND deleted = 'no'
AND user_roles . active = 'yes'
ORDER BY email " ),
" judges_active_incomplete_thisconference " => array ( " name " => " Judges active for this conference but not complete " , " query " =>
" SELECT firstname, lastname, email FROM users
LEFT JOIN user_roles ON user_roles . users_id = users . id
JOIN roles ON roles . id = user_roles . id
WHERE roles . type = 'judge' AND conferences_id = { $conference [ 'id' ]}
AND user_roles . complete = 'no'
AND deleted = 'no'
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_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_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 " ),
/* // FIXME - not sure if this has a sensible equivalent when dealing with "conferences" rather than fair years
2008-09-17 14:23:30 +00:00
" 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 " ),
2010-11-01 21:23:17 +00:00
*/
" participants_complete_allconferences " => array ( " name " => " Participants complete for all conferences " , " query " =>
2008-09-17 14:23:30 +00:00
" 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 " ),
2010-11-01 21:23:17 +00:00
" participants_cwsf_thisconference " => array ( " name " => " CWSF Winners for this conference " , " query " => "
2010-04-13 15:00:03 +00:00
SELECT DISTINCT students . firstname , students . lastname , students . email
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
2010-11-01 21:23:17 +00:00
WHERE award_awards . cwsfaward = '1' AND winners . conferences_id = '".$conference[' id ']."'
2010-04-13 15:00:03 +00:00
ORDER BY students . email " ),
2009-09-18 15:57:35 +00:00
" sponsors " => array ( " name " => " Organization sponsors " , " query " =>
" SELECT id, organization, email FROM sponsors WHERE email!='' ORDER BY email " ),
2007-03-12 14:23:44 +00:00
2009-09-18 15:57:35 +00:00
" sponsors_primarycontacts " => array ( " name " => " Organization sponsors (primary contacts) " , " query " =>
2010-11-03 17:18:02 +00:00
" 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
2009-09-18 15:57:35 +00:00
WHERE
2010-11-03 17:18:02 +00:00
roles . type = 'sponsor'
AND email != ''
AND deleted = 'no'
AND `primary` = 'yes'
ORDER BY email
2009-09-18 15:57:35 +00:00
" ),
" sponsors_allcontacts " => array ( " name " => " Organization sponsors (all contacts) " , " query " =>
2010-11-01 21:23:17 +00:00
" SELECT DISTINCT(users.email), sponsors.organization, users.firstname, users.lastname, users.email
FROM sponsors
JOIN users_sponsor ON users_sponsor . sponsors_id = sponsors . id
JOIN users ON users . id = users_sponsor . users_id
JOIN user_roles ON user_roles . users_id = users . id
JOIN roles ON roles . id = user_roles . roles_id
WHERE
roles . type = 'sponsor'
AND users . deleted = 'no'
AND users . email != ''
ORDER BY users . email " ),
2009-09-18 15:57:35 +00:00
/*
2008-01-09 17:25:30 +00:00
" special_award_sponsors_unconfirmed " => array ( " name " => " Special award sponsors (unconfirmed only) " , " query " =>
2010-03-26 17:41:44 +00:00
" SELECT DISTINCT(award_sponsors.id), organization, firstname, lastname, award_contacts.email FROM award_sponsors, award_awards, award_contacts WHERE award_awards.sponsors_id=award_sponsors.id AND award_contacts.award_sponsors_id=award_sponsors.id AND award_sponsors.confirmed='no' AND award_awards.award_types_id='2' AND award_contacts.year=' " . $config [ 'FAIRYEAR' ] . " ' " ),
2007-03-12 14:23:44 +00:00
2008-01-09 17:25:30 +00:00
" special_award_sponsors_all " => array ( " name " => " Special award sponsors (all) " , " query " =>
2010-03-26 17:41:44 +00:00
" SELECT DISTINCT(award_sponsors.id), organization, firstname, lastname, award_contacts.email FROM award_sponsors, award_awards, award_contacts WHERE award_awards.sponsors_id=award_sponsors.id AND award_contacts.award_sponsors_id=award_sponsors.id AND award_awards.award_types_id='2' AND award_contacts.year=' " . $config [ 'FAIRYEAR' ] . " ' " ),
2009-09-18 15:57:35 +00:00
*/
2011-03-04 02:26:22 +00:00
" school_principals " => array ( " name " => " School principals this conference " , " query " =>
" SELECT school, accounts.email, users.firstname, users.lastname FROM schools
JOIN users ON users . id = schools . principal_uid
JOIN accounts ON users . accounts_id = accounts . id
WHERE schools . conferences_id = '".$conference[' id ']."'
AND accounts . email != ''
" ),
" school_scienceheads " => array ( " name " => " School science heads this conference " , " query " =>
" SELECT school, accounts.email, users.firstname, users.lastname FROM schools
JOIN users ON users . id = schools . sciencehead_uid
JOIN accounts ON users . accounts_id = accounts . id
WHERE schools . conferences_id = '".$conference[' id ']."'
AND accounts . email != ''
" ),
" teachers_with_school " => array ( " name " => " Teachers with a confirmed school this conference " , " query " =>
" SELECT schools.school, accounts.email, users.firstname, users.lastname
FROM users
JOIN schools ON users . schools_id = schools . id
JOIN accounts ON users . accounts_id = accounts . id
JOIN user_roles ON users . id = user_roles . users_id
JOIN roles ON user_roles . roles_id = roles . id
WHERE schools . conferences_id = '".$conference[' id ']."'
AND roles . type = 'teacher'
AND accounts . email != ''
" ),
" teachers_without_school " => array ( " name " => " Teachers without a confirmed school this conference " , " query " =>
" SELECT accounts.email, users.firstname, users.lastname
FROM users
JOIN accounts ON users . accounts_id = accounts . id
JOIN user_roles ON users . id = user_roles . users_id
JOIN roles ON user_roles . roles_id = roles . id
WHERE roles . type = 'teacher'
AND users . conferences_id = '".$conference[' id ']."'
AND ( users . schools_id = '' OR users . schools_id = 0 )
AND accounts . email != ''
" ),
/*
2010-11-01 21:23:17 +00:00
" school_teachers_thisconference " => array ( " name " => " Teachers (as entered by students) for this conference " , " query " =>
" SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE conferences_id=' " . $conference [ 'id' ] . " ' AND teacheremail!='' " ),
2011-03-04 02:26:22 +00:00
*/
2010-11-01 21:23:17 +00:00
/* // FIXME again, not sure that this has a sensible equivalent with conferences
2008-01-09 17:25:30 +00:00
" school_teachers_lastyear " => array ( " name " => " Teachers (as entered by students) last year " , " query " =>
2008-01-09 17:28:11 +00:00
" SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE year=' " . ( $config [ 'FAIRYEAR' ] - 1 ) . " ' AND teacheremail!='' " ),
2010-11-01 21:23:17 +00:00
*/
2011-03-04 02:26:22 +00:00
/*
2010-11-01 21:23:17 +00:00
" school_teachers_allconferences " => array ( " name " => " Teachers (as entered by students) all conferences " , " query " =>
2008-01-09 17:28:11 +00:00
" SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE teacheremail!='' " ),
2011-03-04 02:26:22 +00:00
*/
2009-09-09 00:26:12 +00:00
/* Volunteers */
2010-11-01 21:23:17 +00:00
" volunteers_active_complete_thisconference " => array ( " name " => " Volunteers active for this conference and complete " , " query " =>
" SELECT users.id, firstname, lastname, email
FROM users LEFT 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 roles . type = 'volunteer'
AND user_roles . complete = 'yes'
AND user_roles . active = 'yes'
AND users . deleted = 'no'
ORDER BY email " ),
" volunteers_active_incomplete_thisconference " => array ( " name " => " Volunteers active for this conference but not complete " , " query " =>
" SELECT users.id, firstname, lastname, email
FROM users LEFT 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 roles . type = 'volunteer'
AND user_roles . complete = 'no'
AND user_roles . active = 'yes'
AND users . deleted = 'no'
ORDER BY email " ),
2009-09-09 00:26:12 +00:00
2006-03-01 15:59:51 +00:00
);
2006-10-25 01:50:59 +00:00
?>