forked from science-ation/science-ation
Fix access codes for schools
This commit is contained in:
parent
54a5cc8da4
commit
c048e33f6a
@ -142,14 +142,14 @@
|
||||
|
||||
*/
|
||||
"school_principals"=>array("name"=>"School principals","query"=>
|
||||
"SELECT school, users.firstname AS firstname, users.lastname AS lastname, users.email AS email FROM schools
|
||||
"SELECT schools.principal_uid AS uid, schools.school, users.firstname AS firstname, users.lastname AS lastname, users.email AS email FROM schools
|
||||
JOIN users ON schools.principal_uid=users.uid AND users.id=(SELECT id FROM users WHERE users.uid=schools.principal_uid ORDER BY `year` DESC LIMIT 1)
|
||||
WHERE schools.year='".$config['FAIRYEAR']."' AND email!=''"),
|
||||
WHERE schools.year='".$config['FAIRYEAR']."' AND users.email!=''"),
|
||||
|
||||
"school_scienceheads"=>array("name"=>"School science heads","query"=>
|
||||
"SELECT school, users.firstname AS firstname, users.lastname AS lastname, users.email AS email FROM schools
|
||||
"SELECT schools.sciencehead_uid AS uid, schools.school, users.firstname AS firstname, users.lastname AS lastname, users.email AS email FROM schools
|
||||
JOIN users ON schools.sciencehead_uid=users.uid AND users.id=(SELECT id FROM users WHERE users.uid=schools.sciencehead_uid ORDER BY `year` DESC LIMIT 1)
|
||||
WHERE schools.year='".$config['FAIRYEAR']."' AND email!=''"),
|
||||
WHERE schools.year='".$config['FAIRYEAR']."' AND users.email!=''"),
|
||||
|
||||
"school_teachers_thisyear"=>array("name"=>"Teachers (as entered by students) this year","query"=>
|
||||
"SELECT DISTINCT(teacheremail) AS email, teachername AS firstname FROM students WHERE year='".$config['FAIRYEAR']."' AND teacheremail!=''"),
|
||||
|
@ -699,7 +699,7 @@ case "email_get_list":
|
||||
$u=user_load_by_uid($r->users_uid);
|
||||
|
||||
//we only send school access codes to science heads or principals
|
||||
$acq=mysql_query("SELECT accesscode FROM schools WHERE (sciencehead_uid='{$u['uid']}' OR principal_uid='{$u['uid']}) AND `year`='{$config['FAIRYEAR']}'");
|
||||
$acq=mysql_query("SELECT accesscode FROM schools WHERE (sciencehead_uid='{$u['uid']}' OR principal_uid='{$u['uid']}') AND `year`='{$config['FAIRYEAR']}'");
|
||||
$acr=mysql_fetch_object($acq);
|
||||
$accesscode=$acr->accesscode;
|
||||
|
||||
@ -875,12 +875,14 @@ case "email_get_list":
|
||||
"ORGANIZATION"=>$r->organization,
|
||||
"URLMAIN"=>$urlmain,
|
||||
"URLLOGIN"=>$urllogin,
|
||||
"ACCESSCODE"=>"unknown",
|
||||
);
|
||||
}
|
||||
if($u) {
|
||||
|
||||
//we only send school access codes to science heads or principals
|
||||
$acq=mysql_query("SELECT accesscode FROM schools WHERE (sciencehead_uid='{$u['uid']}' OR principal_uid='{$u['uid']}) AND `year`='{$config['FAIRYEAR']}'");
|
||||
$acq=mysql_query("SELECT accesscode FROM schools WHERE (sciencehead_uid='{$u['uid']}' OR principal_uid='{$u['uid']}') AND `year`='{$config['FAIRYEAR']}'");
|
||||
echo mysql_error();
|
||||
$acr=mysql_fetch_object($acq);
|
||||
$accesscode=$acr->accesscode;
|
||||
|
||||
|
@ -63,6 +63,8 @@
|
||||
} else
|
||||
$pl = false;
|
||||
|
||||
$em = $_POST['principalemail'];
|
||||
|
||||
/* If we loaded or created an entry, either
|
||||
* update and save, or purge it */
|
||||
if(is_array($pl)) {
|
||||
@ -72,6 +74,7 @@
|
||||
} else {
|
||||
$pl['firstname'] = $first;
|
||||
$pl['lastname'] = $last;
|
||||
$pl['email'] = $em;
|
||||
user_save($pl);
|
||||
}
|
||||
}
|
||||
@ -237,7 +240,11 @@
|
||||
$pl = user_load_by_uid($r->principal_uid);
|
||||
else
|
||||
$pl = array();
|
||||
/* Don't show autogenerated emails */
|
||||
$e = $pl['email'][0] == '*' ? '' : $pl['email'];
|
||||
echo "<tr><td>".i18n("Principal")."</td><td><input type=\"text\" name=\"principal\" value=\"".htmlspecialchars($pl['name'])."\" size=\"60\" maxlength=\"64\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Principal Email")."</td><td><input type=\"text\" name=\"principalemail\" value=\"".htmlspecialchars($e)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
|
||||
|
||||
echo "<tr><td>".i18n("School Email")."</td><td><input type=\"text\" name=\"schoolemail\" value=\"".htmlspecialchars($r->schoolemail)."\" size=\"60\" maxlength=\"128\" /></td></tr>\n";
|
||||
echo "<tr><td>".i18n("Access Code")."</td><td><input type=\"text\" name=\"accesscode\" value=\"".htmlspecialchars($r->accesscode)."\" size=\"32\" maxlength=\"32\" /></td></tr>\n";
|
||||
echo "<tr><td colspan=2><br /><b>".i18n("Science head/teacher or science fair contact at school")."</b></td></tr>";
|
||||
|
Loading…
Reference in New Issue
Block a user