/[webwml]/newmaint/amupdate.wml
ViewVC logotype

Contents of /newmaint/amupdate.wml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.21 - (show annotations) (download)
Fri Dec 24 20:57:48 2004 UTC (8 years, 4 months ago) by tbm
Branch: MAIN
Changes since 1.20: +1 -1 lines
it's text, not bool
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 .= " - New Maintainer Website.\n";
54 $headers = "From: NM Front Desk <new-maintainer@debian.org>\nReply-To: $forename $surname <" . $aemail . ">\nX-Mailer: PHP/" . phpversion();
55 mail($row["email"], "New Debian Developer: $aemail", $body, $headers);
56 return TRUE;
57 }
58
59 function check_manager($db, $manager, $aemail)
60 {
61 $sql = "SELECT * FROM applicant WHERE email ='$aemail'";
62 if (! ($result = pg_exec($db, $sql))) {
63 echo "Problem with query: ", pg_ErrorMessage($db), "<BR>";
64 echo "SQL was: $sql <BR>\n";
65 return FALSE;
66 }
67 if (pg_NumRows($result) == 0) {
68 echo "Could not find applicant $aemail in the database.<BR>\n";
69 echo "SQL was: $sql <BR>\n";
70 return FALSE;
71 }
72 $row = pg_Fetch_Array($result, 0);
73 if (trim($row["manager"]) != $manager) {
74 if ($manager != "") {
75 echo "<P>Old manager was '", $row["manager"], "' new one is '$manager'. Emailling new manager.\n";
76 return (email_manager($db, $manager, $row['forename'],
77 $row['surname'],$aemail));
78 } else {
79 echo "<P>Old manager was '", $row["manager"], "' new one is blank.\n";
80 return TRUE;
81 }
82 }
83 return TRUE;
84 } #check manager
85
86 function find_manager($db, $login) {
87 $sql = "SELECT * FROM manager WHERE login = '$login'";
88 if (! ($result = pg_exec($db, $sql))) {
89 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
90 return TRUE;
91 }
92 if (pg_NumRows($result) == 0) {
93 return FALSE;
94 }
95 return TRUE;
96 }
97
98 function update_db($db, $sql) {
99 if (! ($result = pg_exec($db, $sql))) {
100 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
101 return -1;
102 }
103 if (($tuples = pg_CmdTuples($result)) != 1) {
104 echo "Only one row should be effected but $tuples rows were<BR>\n";
105 }
106 return $tuples;
107 }
108 function get_text($name, $value)
109 {
110 if ($value == "" ) {
111 $str = $name . "= null";
112 } else {
113 if (trim($value) == "today") {
114 $str = $name . "= CURRENT_DATE";
115 } else {
116 $str = $name . "='" . trim(strip_tags($value)) . "'";
117 }
118 }
119 return $str;
120 }
121 function get_bool($name, $value)
122 {
123 if ($value == 't')
124 {
125 $str = $name . "= true ";
126 } else if ($value == 'f') {
127 $str = $name . " = false ";
128 } else {
129 $str = $name . " = null ";
130 }
131 return $str;
132 }
133 function get_textarea($name, $value)
134 {
135 if ($value == "" ) {
136 $str = $name . "= null";
137 } else {
138 $str = $name . "='" . trim(strip_tags($value)) . "'";
139 }
140 return $str;
141 }
142 ?>
143 #use wml::nmpage title="Debian New Maintainer - Applicant Status Update"
144 <?
145 if (!session_is_registered("s_username") || !session_is_registered("s_isam")) {
146 ?>
147 <STRONG>
148 You should not be here!</STRONG>
149 <? } else {
150 session_register("s_username");
151 session_register("s_isfd");
152 session_register("s_isdam");
153
154
155 ?>
156 <H1>Debian New Maintainer</H1><BR>
157 <H3>Updating Applicant's status</H3>
158 <?
159 # Check ze values, any bad things we abort
160 if ( ($db = open_db())) {
161 $errors = "";
162 if ($emailkey == "") { $errors .= "<LI><STRONG>Blank old email address, problem with script!</STRONG>"; }
163 if ($s_isdam == 't' || $s_isfd == 't') {
164 if ($email == "") { $errors .= "<LI>No new email address.\n"; }
165 if ($forename == "") { $errors .= "<LI>You must have a first name entered.\n"; }
166 if ($surname == "") { $errors .= "<LI>You must have a surname entered.\n"; }
167 if ($apply_date == "") { $errors .= "<LI>You must have a date of application.\n"; }
168 if ($manager != "" && $manager_date == "")
169 { $errors .= "<LI>A manager has been assigned but with no date.\n"; }
170 if ($manager == "" && $manager_date != "")
171 { $errors .= "<LI>A manager has not been assigned but there is a manager assigned date.\n"; }
172 if ($advocate_ok != "n" && $advocate_checked == "")
173 { $errors .= "<LI>Advocate check entered but no date given.\n"; }
174 if ($advocate_ok == "n" && $advocate_checked != "")
175 { $errors .= "<LI>Advocate Check Date given but Advocate check not changed.\n"; }
176 if ($application_ok != "n" && $application_ok_date == "")
177 { $errors .= "<LI>FD has checked report but there is no date.\n"; }
178 if ($application_ok != "n" && $fd_member == "")
179 { $errors .= "<LI>FD has checked report but not specified their login (FD member).\n"; }
180 } # end of fd or dam
181 if ($am_confirm != "n" && $am_confirm_date == "")
182 { $errors .= "<LI>AM has confirmed applicant but not put a date in.\n"; }
183 if ($am_confirm == "n" && $am_confirm_date != "")
184 { $errors .= "<LI>AM has not confirmed applicant but there is a date set.\n"; }
185
186 if ($id_ok != "n" && $id_checked == "")
187 { $errors .= "<LI>ID has been checked but there is no date of checking.\n"; }
188 if ($id_ok == "n" && $id_checked != "")
189 { $errors .= "<LI>ID has not been checked but there is a date of checking.\n"; }
190 if ($pnp_ok != "n" && $pnp_checked == "")
191 { $errors .= "<LI>Philosophy and Procedures have been checked but there is no date of checking.\n"; }
192 if ($pnp_ok == "n" && $pnp_checked != "")
193 { $errors .= "<LI>Philosophy and Procedures have not been checked but there is a date of checking.\n"; }
194 if ($tns_ok != "n" && $tns_checked == "")
195 { $errors .= "<LI>Tasks and Skills have been checked but there is no date of checking.\n"; }
196 if ($tns_ok == "n" && $tns_checked != "")
197 { $errors .= "<LI>Tasks and Skills have not been checked but there is a date of checking.\n"; }
198 if ($approved != "n" && $decision == "")
199 { $errors .= "<LI>AM has approved applicant but there is no date.\n"; }
200 if ($approved == "n" && $decision != "")
201 { $errors .= "<LI>AM has not yet approved applicant but there is a date.\n"; }
202 if (($manager != "") && !(find_manager($db, $manager)))
203 { $errors .= "<LI>I cannot find Application Manager $manager in the database.\n"; }
204 # Possibly more checks later
205 if ($errors != "")
206 {
207 echo "<P>There have been some problems with what you entered, please hit ",
208 "the back button and correct the following errors:",
209 "<UL>$errors</UL>\n";
210 } else {
211 echo "<P>Submission has passed sanity checks.<BR>\n";
212
213
214 if ($s_isdam == 't') {
215 $sql = "SELECT * FROM applicant WHERE email ='$emailkey'";
216 if (! ($result = pg_exec($db, $sql))) {
217 echo "Problem with query: ", pg_ErrorMessage($db), "<BR>";
218 echo "SQL was: $sql <BR>\n";
219 return FALSE;
220 }
221 if (pg_NumRows($result) == 0) {
222 echo "Could not find applicant $emailkey in the database.<BR>\n";
223 echo "SQL was: $sql <BR>\n";
224 return FALSE;
225 }
226 $row = pg_Fetch_Array($result, 0);
227 $old_newmaint = trim($row["newmaint"]);
228 }
229
230 $sql = "UPDATE applicant SET ";
231 if ($s_isdam == 't' || $s_isfd == 't') {
232 $sql .= get_text("surname", $surname) .
233 ", " . get_text("email", $email) .
234 ", " . get_text("forename", $forename) .
235 ", " . get_text("apply_date", $apply_date) .
236 ", " . get_text("advocate", $advocate) .
237 ", " . get_text("advocate_date", $advocate_date) .
238 ", " . get_bool("advocate_ok", $advocate_ok) .
239 ", " . get_text("advocate_checked", $advocate_checked) .
240 ", " . get_text("manager", $manager) .
241 ", " . get_text("manager_date", $manager_date) .
242 ", " . get_bool("application_ok", $application_ok) .
243 ", " . get_text("application_ok_date", $application_ok_date) .
244 ", " . get_text("fd_member", $fd_member) .
245 ", " . get_textarea("da_comment", $da_comment) . ", " ;
246 }
247 $sql .= get_bool("am_confirm", $am_confirm) .
248 ", " . get_text("am_confirm_date", $am_confirm_date) .
249 ", " . get_text("am_contact", $am_contact) .
250 ", " . get_bool("id_ok", $id_ok) .
251 ", " . get_text("id_checked", $id_checked) .
252 ", " . get_bool("pnp_ok", $pnp_ok) .
253 ", " . get_text("pnp_checked", $pnp_checked) .
254 ", " . get_bool("tns_ok", $tns_ok) .
255 ", " . get_text("tns_checked", $tns_checked) .
256 ", " . get_bool("approved", $approved) .
257 ", " . get_text("decision", $decision) .
258 ", " . get_textarea("man_comment", $man_comment) ;
259 if ($s_isdam == 't') {
260 $sql .= ", " . get_bool("da_phone_required", $da_phone_required) .
261 ", " . get_text("da_phone", $da_phone) .
262 ", " . get_bool("da_approved", $da_approved) .
263 ", " . get_text("da_member", $da_member) .
264 ", " . get_text("newmaint", $newmaint) ;
265 }
266 $sql .= " WHERE email = '$emailkey'";
267 if ($s_isfd == 't') {
268 if (!(check_manager($db, trim($manager), $email))) {
269 echo "<P>Problem emailling manager.\n";
270 }
271 }
272 if (($erows = update_db($db, $sql)) > 0)
273 {
274 echo "<P>$erows rows updated in database.<BR>\n";
275 if ($s_isdam == 't') {
276 if ($newmaint != '' && $old_newmaint == '') {
277 $manager = trim($manager);
278 echo "Applicant got approved, mailing manager $manager<p>";
279 email_manager_approved($db, $manager, $forename,
280 $surname, $emailkey);
281 }
282 }
283 }
284 }
285 ?>
286 <? } #open database ?>
287 <? } #session management ?>

  ViewVC Help
Powered by ViewVC 1.1.5