| 1 |
<?
|
| 2 |
session_start();
|
| 3 |
include("config.inc");
|
| 4 |
include("common.inc");
|
| 5 |
|
| 6 |
function email_manager($db, $login, $forename, $surname, $aemail) {
|
| 7 |
$sql = "SELECT * FROM manager WHERE login = '$login'";
|
| 8 |
if (! ($result = pg_exec($db, $sql))) {
|
| 9 |
echo "Problem with query: ", pg_ErrorMessage($db), "<BR>";
|
| 10 |
echo "SQL was: $sql <BR>\n";
|
| 11 |
return FALSE;
|
| 12 |
}
|
| 13 |
if (pg_NumRows($result) == 0) {
|
| 14 |
echo "Cannot find mananger in database.<BR>\n";
|
| 15 |
echo "SQL was: $sql <BR>\n";
|
| 16 |
return FALSE;
|
| 17 |
}
|
| 18 |
$row = pg_Fetch_Array($result, 0);
|
| 19 |
$body = "Hello " . $row["name"] . ",\n\n";
|
| 20 |
$body .= "This is an automatic message from the New Maintainer website found at\n";
|
| 21 |
$body .= "http://nm.debian.org/ The Front Desk has assigned a new applicant to you:\n";
|
| 22 |
$body .= "$forename $surname <" . $aemail . ">. Please remember to visit the\n";
|
| 23 |
$body .= "website to inform the front desk whether or not you accept this applicant.\n\n";
|
| 24 |
$body .= " - New Maintainer Website.\n";
|
| 25 |
$headers = "From: NM Front Desk <new-maintainer@debian.org>\nReply-To: $forename $surname <" . $aemail . ">\nX-Mailer: PHP/" . phpversion();
|
| 26 |
mail($row["email"], "New Debian Maintainer: $aemail", $body, $headers);
|
| 27 |
return TRUE;
|
| 28 |
}
|
| 29 |
|
| 30 |
function email_manager_approved($db, $login, $forename, $surname, $aemail) {
|
| 31 |
$sql = "SELECT * FROM manager WHERE login = '$login'";
|
| 32 |
if (! ($result = pg_exec($db, $sql))) {
|
| 33 |
echo "Problem with query: ", pg_ErrorMessage($db), "<BR>";
|
| 34 |
echo "SQL was: $sql <BR>\n";
|
| 35 |
return FALSE;
|
| 36 |
}
|
| 37 |
if (pg_NumRows($result) == 0) {
|
| 38 |
echo "Cannot find mananger in database.<BR>\n";
|
| 39 |
echo "SQL was: $sql <BR>\n";
|
| 40 |
return FALSE;
|
| 41 |
}
|
| 42 |
$row = pg_Fetch_Array($result, 0);
|
| 43 |
$body = "Hello " . $row["name"] . ",\n\n";
|
| 44 |
$body .= "This is an automatic message from the New Maintainer website found at\n";
|
| 45 |
$body .= "http://nm.debian.org/ It seems that the DAM has approved your applicant\n";
|
| 46 |
$body .= "$forename $surname <" . $aemail . ">. Please remember that nm.d.o is\n";
|
| 47 |
$body .= "not authoritative and this mail may be an error! Make sure to use finger\n";
|
| 48 |
$body .= "on a .d.o host to check whether an account is really there (also\n";
|
| 49 |
$body .= "remember that LDAP info is only updated every 15 minutes).\n";
|
| 50 |
$body .= "\n";
|
| 51 |
$body .= "\n";
|
| 52 |
$body .= "Thanks for going through the NM process with $forename.\n";
|
| 53 |
$body .= "\n";
|
| 54 |
$body .= " - New Maintainer Website.\n";
|
| 55 |
$headers = "From: NM Front Desk <new-maintainer@debian.org>\nReply-To: $forename $surname <" . $aemail . ">\nX-Mailer: PHP/" . phpversion();
|
| 56 |
mail($row["email"], "New Debian Developer: $aemail", $body, $headers);
|
| 57 |
return TRUE;
|
| 58 |
}
|
| 59 |
|
| 60 |
function check_manager($db, $manager, $aemail)
|
| 61 |
{
|
| 62 |
$sql = "SELECT * FROM applicant WHERE email ='$aemail'";
|
| 63 |
if (! ($result = pg_exec($db, $sql))) {
|
| 64 |
echo "Problem with query: ", pg_ErrorMessage($db), "<BR>";
|
| 65 |
echo "SQL was: $sql <BR>\n";
|
| 66 |
return FALSE;
|
| 67 |
}
|
| 68 |
if (pg_NumRows($result) == 0) {
|
| 69 |
echo "Could not find applicant $aemail in the database.<BR>\n";
|
| 70 |
echo "SQL was: $sql <BR>\n";
|
| 71 |
return FALSE;
|
| 72 |
}
|
| 73 |
$row = pg_Fetch_Array($result, 0);
|
| 74 |
if (trim($row["manager"]) != $manager) {
|
| 75 |
if ($manager != "") {
|
| 76 |
echo "<P>Old manager was '", $row["manager"], "' new one is '$manager'. Emailling new manager.\n";
|
| 77 |
return (email_manager($db, $manager, $row['forename'],
|
| 78 |
$row['surname'],$aemail));
|
| 79 |
} else {
|
| 80 |
echo "<P>Old manager was '", $row["manager"], "' new one is blank.\n";
|
| 81 |
return TRUE;
|
| 82 |
}
|
| 83 |
}
|
| 84 |
return TRUE;
|
| 85 |
} #check manager
|
| 86 |
|
| 87 |
function find_manager($db, $login) {
|
| 88 |
$sql = "SELECT * FROM manager WHERE login = '$login'";
|
| 89 |
if (! ($result = pg_exec($db, $sql))) {
|
| 90 |
echo "Problem with query", pg_ErrorMessage($db), "<BR>";
|
| 91 |
return TRUE;
|
| 92 |
}
|
| 93 |
if (pg_NumRows($result) == 0) {
|
| 94 |
return FALSE;
|
| 95 |
}
|
| 96 |
return TRUE;
|
| 97 |
}
|
| 98 |
|
| 99 |
function update_db($db, $sql) {
|
| 100 |
if (! ($result = pg_exec($db, $sql))) {
|
| 101 |
echo "Problem with query", pg_ErrorMessage($db), "<BR>";
|
| 102 |
return -1;
|
| 103 |
}
|
| 104 |
if (($tuples = pg_CmdTuples($result)) != 1) {
|
| 105 |
echo "Only one row should be effected but $tuples rows were<BR>\n";
|
| 106 |
}
|
| 107 |
return $tuples;
|
| 108 |
}
|
| 109 |
function get_text($name, $value)
|
| 110 |
{
|
| 111 |
if ($value == "" ) {
|
| 112 |
$str = $name . "= null";
|
| 113 |
} else {
|
| 114 |
if (trim($value) == "today") {
|
| 115 |
$str = $name . "= CURRENT_DATE";
|
| 116 |
} else {
|
| 117 |
$str = $name . "='" . trim(strip_tags($value)) . "'";
|
| 118 |
}
|
| 119 |
}
|
| 120 |
return $str;
|
| 121 |
}
|
| 122 |
function get_bool($name, $value)
|
| 123 |
{
|
| 124 |
if ($value == 't')
|
| 125 |
{
|
| 126 |
$str = $name . "= true ";
|
| 127 |
} else if ($value == 'f') {
|
| 128 |
$str = $name . " = false ";
|
| 129 |
} else {
|
| 130 |
$str = $name . " = null ";
|
| 131 |
}
|
| 132 |
return $str;
|
| 133 |
}
|
| 134 |
function get_textarea($name, $value)
|
| 135 |
{
|
| 136 |
if ($value == "" ) {
|
| 137 |
$str = $name . "= null";
|
| 138 |
} else {
|
| 139 |
$str = $name . "='" . trim(strip_tags($value)) . "'";
|
| 140 |
}
|
| 141 |
return $str;
|
| 142 |
}
|
| 143 |
?>
|
| 144 |
#use wml::nmpage title="Debian New Maintainer - Applicant Status Update"
|
| 145 |
<?
|
| 146 |
if (!session_is_registered("s_username") || !session_is_registered("s_isam")) {
|
| 147 |
?>
|
| 148 |
<STRONG>
|
| 149 |
You should not be here!</STRONG>
|
| 150 |
<? } else {
|
| 151 |
session_register("s_username");
|
| 152 |
session_register("s_isfd");
|
| 153 |
session_register("s_isdam");
|
| 154 |
|
| 155 |
|
| 156 |
?>
|
| 157 |
<H1>Debian New Maintainer</H1><BR>
|
| 158 |
<H3>Updating Applicant's status</H3>
|
| 159 |
<?
|
| 160 |
# Check ze values, any bad things we abort
|
| 161 |
if ( ($db = open_db())) {
|
| 162 |
$errors = "";
|
| 163 |
if ($emailkey == "") { $errors .= "<LI><STRONG>Blank old email address, problem with script!</STRONG>"; }
|
| 164 |
if ($s_isdam == 't' || $s_isfd == 't') {
|
| 165 |
if ($email == "") { $errors .= "<LI>No new email address.\n"; }
|
| 166 |
if ($forename == "") { $errors .= "<LI>You must have a first name entered.\n"; }
|
| 167 |
if ($surname == "") { $errors .= "<LI>You must have a surname entered.\n"; }
|
| 168 |
if ($apply_date == "") { $errors .= "<LI>You must have a date of application.\n"; }
|
| 169 |
if ($manager != "" && $manager_date == "")
|
| 170 |
{ $errors .= "<LI>A manager has been assigned but with no date.\n"; }
|
| 171 |
if ($manager == "" && $manager_date != "")
|
| 172 |
{ $errors .= "<LI>A manager has not been assigned but there is a manager assigned date.\n"; }
|
| 173 |
if ($advocate_ok != "n" && $advocate_checked == "")
|
| 174 |
{ $errors .= "<LI>Advocate check entered but no date given.\n"; }
|
| 175 |
if ($advocate_ok == "n" && $advocate_checked != "")
|
| 176 |
{ $errors .= "<LI>Advocate Check Date given but Advocate check not changed.\n"; }
|
| 177 |
} # end of fd or dam
|
| 178 |
|
| 179 |
if ($s_isfd == 't') {
|
| 180 |
if ($application_ok != "n" && $application_ok_date == "")
|
| 181 |
{ $errors .= "<LI>FD has checked report but there is no date.\n"; }
|
| 182 |
if ($application_ok != "n" && $fd_member == "")
|
| 183 |
{ $errors .= "<LI>FD has checked report but not specified their login (FD member).\n"; }
|
| 184 |
} # end of fd only
|
| 185 |
|
| 186 |
if ($am_confirm != "n" && $am_confirm_date == "")
|
| 187 |
{ $errors .= "<LI>AM has confirmed applicant but not put a date in.\n"; }
|
| 188 |
if ($am_confirm == "n" && $am_confirm_date != "")
|
| 189 |
{ $errors .= "<LI>AM has not confirmed applicant but there is a date set.\n"; }
|
| 190 |
|
| 191 |
if ($id_ok != "n" && $id_checked == "")
|
| 192 |
{ $errors .= "<LI>ID has been checked but there is no date of checking.\n"; }
|
| 193 |
if ($id_ok == "n" && $id_checked != "")
|
| 194 |
{ $errors .= "<LI>ID has not been checked but there is a date of checking.\n"; }
|
| 195 |
if ($pnp_ok != "n" && $pnp_checked == "")
|
| 196 |
{ $errors .= "<LI>Philosophy and Procedures have been checked but there is no date of checking.\n"; }
|
| 197 |
if ($pnp_ok == "n" && $pnp_checked != "")
|
| 198 |
{ $errors .= "<LI>Philosophy and Procedures have not been checked but there is a date of checking.\n"; }
|
| 199 |
if ($tns_ok != "n" && $tns_checked == "")
|
| 200 |
{ $errors .= "<LI>Tasks and Skills have been checked but there is no date of checking.\n"; }
|
| 201 |
if ($tns_ok == "n" && $tns_checked != "")
|
| 202 |
{ $errors .= "<LI>Tasks and Skills have not been checked but there is a date of checking.\n"; }
|
| 203 |
if ($approved != "n" && $decision == "")
|
| 204 |
{ $errors .= "<LI>AM has approved applicant but there is no date.\n"; }
|
| 205 |
if ($approved == "n" && $decision != "")
|
| 206 |
{ $errors .= "<LI>AM has not yet approved applicant but there is a date.\n"; }
|
| 207 |
if (($manager != "") && !(find_manager($db, $manager)))
|
| 208 |
{ $errors .= "<LI>I cannot find Application Manager $manager in the database.\n"; }
|
| 209 |
# Possibly more checks later
|
| 210 |
if ($errors != "")
|
| 211 |
{
|
| 212 |
echo "<P>There have been some problems with what you entered, please hit ",
|
| 213 |
"the back button and correct the following errors:",
|
| 214 |
"<UL>$errors</UL>\n";
|
| 215 |
} else {
|
| 216 |
echo "<P>Submission has passed sanity checks.<BR>\n";
|
| 217 |
|
| 218 |
|
| 219 |
if ($s_isdam == 't') {
|
| 220 |
$sql = "SELECT * FROM applicant WHERE email ='$emailkey'";
|
| 221 |
if (! ($result = pg_exec($db, $sql))) {
|
| 222 |
echo "Problem with query: ", pg_ErrorMessage($db), "<BR>";
|
| 223 |
echo "SQL was: $sql <BR>\n";
|
| 224 |
return FALSE;
|
| 225 |
}
|
| 226 |
if (pg_NumRows($result) == 0) {
|
| 227 |
echo "Could not find applicant $emailkey in the database.<BR>\n";
|
| 228 |
echo "SQL was: $sql <BR>\n";
|
| 229 |
return FALSE;
|
| 230 |
}
|
| 231 |
$row = pg_Fetch_Array($result, 0);
|
| 232 |
$old_newmaint = trim($row["newmaint"]);
|
| 233 |
}
|
| 234 |
|
| 235 |
$sql = "UPDATE applicant SET ";
|
| 236 |
if ($s_isdam == 't' || $s_isfd == 't') {
|
| 237 |
$sql .= get_text("surname", $surname) .
|
| 238 |
", " . get_text("email", $email) .
|
| 239 |
", " . get_text("forename", $forename) .
|
| 240 |
", " . get_text("apply_date", $apply_date) .
|
| 241 |
", " . get_text("advocate", $advocate) .
|
| 242 |
", " . get_text("advocate_date", $advocate_date) .
|
| 243 |
", " . get_bool("advocate_ok", $advocate_ok) .
|
| 244 |
", " . get_text("advocate_checked", $advocate_checked) .
|
| 245 |
", " . get_text("manager", $manager) .
|
| 246 |
", " . get_text("manager_date", $manager_date) .
|
| 247 |
", " . get_bool("application_ok", $application_ok) .
|
| 248 |
", " . get_text("application_ok_date", $application_ok_date) .
|
| 249 |
", " . get_text("fd_member", $fd_member) .
|
| 250 |
", " . get_textarea("da_comment", $da_comment) . ", " ;
|
| 251 |
}
|
| 252 |
$sql .= get_bool("am_confirm", $am_confirm) .
|
| 253 |
", " . get_text("am_confirm_date", $am_confirm_date) .
|
| 254 |
", " . get_text("am_contact", $am_contact) .
|
| 255 |
", " . get_bool("id_ok", $id_ok) .
|
| 256 |
", " . get_text("id_checked", $id_checked) .
|
| 257 |
", " . get_bool("pnp_ok", $pnp_ok) .
|
| 258 |
", " . get_text("pnp_checked", $pnp_checked) .
|
| 259 |
", " . get_bool("tns_ok", $tns_ok) .
|
| 260 |
", " . get_text("tns_checked", $tns_checked) .
|
| 261 |
", " . get_bool("approved", $approved) .
|
| 262 |
", " . get_text("decision", $decision) .
|
| 263 |
", " . get_textarea("man_comment", $man_comment) ;
|
| 264 |
if ($s_isdam == 't') {
|
| 265 |
$sql .= ", " . get_bool("da_phone_required", $da_phone_required) .
|
| 266 |
", " . get_text("da_phone", $da_phone) .
|
| 267 |
", " . get_bool("da_approved", $da_approved) .
|
| 268 |
", " . get_text("da_member", $da_member) .
|
| 269 |
", " . get_text("newmaint", $newmaint) ;
|
| 270 |
}
|
| 271 |
$sql .= " WHERE email = '$emailkey'";
|
| 272 |
if ($s_isfd == 't') {
|
| 273 |
if (!(check_manager($db, trim($manager), $email))) {
|
| 274 |
echo "<P>Problem emailling manager.\n";
|
| 275 |
}
|
| 276 |
}
|
| 277 |
if (($erows = update_db($db, $sql)) > 0)
|
| 278 |
{
|
| 279 |
echo "<P>$erows rows updated in database.<BR>\n";
|
| 280 |
if ($s_isdam == 't') {
|
| 281 |
if ($newmaint != '' && $old_newmaint == '') {
|
| 282 |
$manager = trim($manager);
|
| 283 |
echo "Applicant got approved, mailing manager $manager<p>";
|
| 284 |
email_manager_approved($db, $manager, $forename,
|
| 285 |
$surname, $emailkey);
|
| 286 |
}
|
| 287 |
}
|
| 288 |
}
|
| 289 |
}
|
| 290 |
?>
|
| 291 |
<? } #open database ?>
|
| 292 |
<? } #session management ?>
|