| 1 |
csmall |
1.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 |
tbm |
1.7 |
$body = "Hello " . $row["name"] . ",\n\n"; |
| 20 |
csmall |
1.1 |
$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 |
tbm |
1.9 |
$body .= "website to inform the front desk whether or not you accept this applicant.\n\n"; |
| 24 |
csmall |
1.1 |
$body .= " - New Maintainer Website.\n"; |
| 25 |
tbm |
1.10 |
$headers = "From: NM Front Desk <new-maintainer@debian.org>\nReply-To: $forename $surname <" . $aemail . ">\nX-Mailer: PHP/" . phpversion(); |
| 26 |
csmall |
1.1 |
mail($row["email"], "New Debian Maintainer: $aemail", $body, $headers); |
| 27 |
|
|
return TRUE; |
| 28 |
|
|
} |
| 29 |
|
|
|
| 30 |
tbm |
1.11 |
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 |
tbm |
1.22 |
$body .= "\n"; |
| 54 |
tbm |
1.11 |
$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 |
csmall |
1.1 |
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 |
tbm |
1.8 |
echo "Only one row should be effected but $tuples rows were<BR>\n"; |
| 106 |
csmall |
1.1 |
} |
| 107 |
|
|
return $tuples; |
| 108 |
|
|
} |
| 109 |
|
|
function get_text($name, $value) |
| 110 |
|
|
{ |
| 111 |
|
|
if ($value == "" ) { |
| 112 |
|
|
$str = $name . "= null"; |
| 113 |
|
|
} else { |
| 114 |
csmall |
1.4 |
if (trim($value) == "today") { |
| 115 |
tbm |
1.12 |
$str = $name . "= CURRENT_DATE"; |
| 116 |
csmall |
1.4 |
} else { |
| 117 |
|
|
$str = $name . "='" . trim(strip_tags($value)) . "'"; |
| 118 |
|
|
} |
| 119 |
csmall |
1.1 |
} |
| 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 |
tbm |
1.18 |
You should not be here!</STRONG> |
| 150 |
csmall |
1.1 |
<? } 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 |
csmall |
1.4 |
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 |
tbm |
1.19 |
if ($application_ok != "n" && $application_ok_date == "") |
| 178 |
|
|
{ $errors .= "<LI>FD has checked report but there is no date.\n"; } |
| 179 |
|
|
if ($application_ok != "n" && $fd_member == "") |
| 180 |
|
|
{ $errors .= "<LI>FD has checked report but not specified their login (FD member).\n"; } |
| 181 |
csmall |
1.5 |
} # end of fd or dam |
| 182 |
csmall |
1.3 |
if ($am_confirm != "n" && $am_confirm_date == "") |
| 183 |
|
|
{ $errors .= "<LI>AM has confirmed applicant but not put a date in.\n"; } |
| 184 |
|
|
if ($am_confirm == "n" && $am_confirm_date != "") |
| 185 |
|
|
{ $errors .= "<LI>AM has not confirmed applicant but there is a date set.\n"; } |
| 186 |
|
|
|
| 187 |
csmall |
1.1 |
if ($id_ok != "n" && $id_checked == "") |
| 188 |
|
|
{ $errors .= "<LI>ID has been checked but there is no date of checking.\n"; } |
| 189 |
|
|
if ($id_ok == "n" && $id_checked != "") |
| 190 |
|
|
{ $errors .= "<LI>ID has not been checked but there is a date of checking.\n"; } |
| 191 |
|
|
if ($pnp_ok != "n" && $pnp_checked == "") |
| 192 |
tbm |
1.6 |
{ $errors .= "<LI>Philosophy and Procedures have been checked but there is no date of checking.\n"; } |
| 193 |
csmall |
1.1 |
if ($pnp_ok == "n" && $pnp_checked != "") |
| 194 |
tbm |
1.6 |
{ $errors .= "<LI>Philosophy and Procedures have not been checked but there is a date of checking.\n"; } |
| 195 |
csmall |
1.1 |
if ($tns_ok != "n" && $tns_checked == "") |
| 196 |
|
|
{ $errors .= "<LI>Tasks and Skills have been checked but there is no date of checking.\n"; } |
| 197 |
|
|
if ($tns_ok == "n" && $tns_checked != "") |
| 198 |
|
|
{ $errors .= "<LI>Tasks and Skills have not been checked but there is a date of checking.\n"; } |
| 199 |
|
|
if ($approved != "n" && $decision == "") |
| 200 |
tbm |
1.14 |
{ $errors .= "<LI>AM has approved applicant but there is no date.\n"; } |
| 201 |
csmall |
1.1 |
if ($approved == "n" && $decision != "") |
| 202 |
|
|
{ $errors .= "<LI>AM has not yet approved applicant but there is a date.\n"; } |
| 203 |
|
|
if (($manager != "") && !(find_manager($db, $manager))) |
| 204 |
|
|
{ $errors .= "<LI>I cannot find Application Manager $manager in the database.\n"; } |
| 205 |
|
|
# Possibly more checks later |
| 206 |
|
|
if ($errors != "") |
| 207 |
|
|
{ |
| 208 |
|
|
echo "<P>There have been some problems with what you entered, please hit ", |
| 209 |
|
|
"the back button and correct the following errors:", |
| 210 |
|
|
"<UL>$errors</UL>\n"; |
| 211 |
|
|
} else { |
| 212 |
|
|
echo "<P>Submission has passed sanity checks.<BR>\n"; |
| 213 |
tbm |
1.11 |
|
| 214 |
|
|
|
| 215 |
|
|
if ($s_isdam == 't') { |
| 216 |
|
|
$sql = "SELECT * FROM applicant WHERE email ='$emailkey'"; |
| 217 |
|
|
if (! ($result = pg_exec($db, $sql))) { |
| 218 |
|
|
echo "Problem with query: ", pg_ErrorMessage($db), "<BR>"; |
| 219 |
|
|
echo "SQL was: $sql <BR>\n"; |
| 220 |
|
|
return FALSE; |
| 221 |
|
|
} |
| 222 |
|
|
if (pg_NumRows($result) == 0) { |
| 223 |
|
|
echo "Could not find applicant $emailkey in the database.<BR>\n"; |
| 224 |
|
|
echo "SQL was: $sql <BR>\n"; |
| 225 |
|
|
return FALSE; |
| 226 |
|
|
} |
| 227 |
|
|
$row = pg_Fetch_Array($result, 0); |
| 228 |
tbm |
1.20 |
$old_newmaint = trim($row["newmaint"]); |
| 229 |
tbm |
1.11 |
} |
| 230 |
|
|
|
| 231 |
csmall |
1.1 |
$sql = "UPDATE applicant SET "; |
| 232 |
|
|
if ($s_isdam == 't' || $s_isfd == 't') { |
| 233 |
|
|
$sql .= get_text("surname", $surname) . |
| 234 |
|
|
", " . get_text("email", $email) . |
| 235 |
|
|
", " . get_text("forename", $forename) . |
| 236 |
|
|
", " . get_text("apply_date", $apply_date) . |
| 237 |
csmall |
1.4 |
", " . get_text("advocate", $advocate) . |
| 238 |
|
|
", " . get_text("advocate_date", $advocate_date) . |
| 239 |
|
|
", " . get_bool("advocate_ok", $advocate_ok) . |
| 240 |
|
|
", " . get_text("advocate_checked", $advocate_checked) . |
| 241 |
csmall |
1.1 |
", " . get_text("manager", $manager) . |
| 242 |
tbm |
1.15 |
", " . get_text("manager_date", $manager_date) . |
| 243 |
|
|
", " . get_bool("application_ok", $application_ok) . |
| 244 |
|
|
", " . get_text("application_ok_date", $application_ok_date) . |
| 245 |
tbm |
1.16 |
", " . get_text("fd_member", $fd_member) . |
| 246 |
tbm |
1.15 |
", " . get_textarea("da_comment", $da_comment) . ", " ; |
| 247 |
csmall |
1.1 |
} |
| 248 |
|
|
$sql .= get_bool("am_confirm", $am_confirm) . |
| 249 |
|
|
", " . get_text("am_confirm_date", $am_confirm_date) . |
| 250 |
|
|
", " . get_text("am_contact", $am_contact) . |
| 251 |
|
|
", " . get_bool("id_ok", $id_ok) . |
| 252 |
|
|
", " . get_text("id_checked", $id_checked) . |
| 253 |
|
|
", " . get_bool("pnp_ok", $pnp_ok) . |
| 254 |
|
|
", " . get_text("pnp_checked", $pnp_checked) . |
| 255 |
|
|
", " . get_bool("tns_ok", $tns_ok) . |
| 256 |
|
|
", " . get_text("tns_checked", $tns_checked) . |
| 257 |
|
|
", " . get_bool("approved", $approved) . |
| 258 |
|
|
", " . get_text("decision", $decision) . |
| 259 |
|
|
", " . get_textarea("man_comment", $man_comment) ; |
| 260 |
|
|
if ($s_isdam == 't') { |
| 261 |
tbm |
1.15 |
$sql .= ", " . get_bool("da_phone_required", $da_phone_required) . |
| 262 |
csmall |
1.1 |
", " . get_text("da_phone", $da_phone) . |
| 263 |
|
|
", " . get_bool("da_approved", $da_approved) . |
| 264 |
tbm |
1.21 |
", " . get_text("da_member", $da_member) . |
| 265 |
tbm |
1.15 |
", " . get_text("newmaint", $newmaint) ; |
| 266 |
csmall |
1.1 |
} |
| 267 |
|
|
$sql .= " WHERE email = '$emailkey'"; |
| 268 |
|
|
if ($s_isfd == 't') { |
| 269 |
|
|
if (!(check_manager($db, trim($manager), $email))) { |
| 270 |
|
|
echo "<P>Problem emailling manager.\n"; |
| 271 |
|
|
} |
| 272 |
|
|
} |
| 273 |
|
|
if (($erows = update_db($db, $sql)) > 0) |
| 274 |
|
|
{ |
| 275 |
|
|
echo "<P>$erows rows updated in database.<BR>\n"; |
| 276 |
tbm |
1.11 |
if ($s_isdam == 't') { |
| 277 |
tbm |
1.20 |
if ($newmaint != '' && $old_newmaint == '') { |
| 278 |
tbm |
1.11 |
$manager = trim($manager); |
| 279 |
|
|
echo "Applicant got approved, mailing manager $manager<p>"; |
| 280 |
|
|
email_manager_approved($db, $manager, $forename, |
| 281 |
|
|
$surname, $emailkey); |
| 282 |
|
|
} |
| 283 |
|
|
} |
| 284 |
csmall |
1.1 |
} |
| 285 |
|
|
} |
| 286 |
|
|
?> |
| 287 |
|
|
<? } #open database ?> |
| 288 |
|
|
<? } #session management ?> |