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

Contents of /newmaint/amupdate.wml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (show annotations) (download)
Tue Feb 6 01:36:47 2001 UTC (12 years, 4 months ago) by csmall
Branch: MAIN
Changes since 1.4: +1 -1 lines
smoe real life fixes
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";
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 wether or not you accept this applicant.\n\n";
24 $body .= " - New Maintainer Website.\n";
25 $headers = "From: 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 check_manager($db, $manager, $aemail)
31 {
32 $sql = "SELECT * FROM applicant WHERE email ='$aemail'";
33 if (! ($result = pg_exec($db, $sql))) {
34 echo "Problem with query: ", pg_ErrorMessage($db), "<BR>";
35 echo "SQL was: $sql <BR>\n";
36 return FALSE;
37 }
38 if (pg_NumRows($result) == 0) {
39 echo "Could not find applicant $aemail in the database.<BR>\n";
40 echo "SQL was: $sql <BR>\n";
41 return FALSE;
42 }
43 $row = pg_Fetch_Array($result, 0);
44 if (trim($row["manager"]) != $manager) {
45 if ($manager != "") {
46 echo "<P>Old manager was '", $row["manager"], "' new one is '$manager'. Emailling new manager.\n";
47 return (email_manager($db, $manager, $row['forename'],
48 $row['surname'],$aemail));
49 } else {
50 echo "<P>Old manager was '", $row["manager"], "' new one is blank.\n";
51 return TRUE;
52 }
53 }
54 return TRUE;
55 } #check manager
56
57 function find_manager($db, $login) {
58 $sql = "SELECT * FROM manager WHERE login = '$login'";
59 if (! ($result = pg_exec($db, $sql))) {
60 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
61 return TRUE;
62 }
63 if (pg_NumRows($result) == 0) {
64 return FALSE;
65 }
66 return TRUE;
67 }
68
69 function update_db($db, $sql) {
70 if (! ($result = pg_exec($db, $sql))) {
71 echo "Problem with query", pg_ErrorMessage($db), "<BR>";
72 return -1;
73 }
74 if (($tuples = pg_CmdTuples($result)) != 1) {
75 echo "Only one row should be effected but $tuple rows were<BR>\n";
76 }
77 return $tuples;
78 }
79 function get_text($name, $value)
80 {
81 if ($value == "" ) {
82 $str = $name . "= null";
83 } else {
84 if (trim($value) == "today") {
85 $str = $name . "='now'::date";
86 } else {
87 $str = $name . "='" . trim(strip_tags($value)) . "'";
88 }
89 }
90 return $str;
91 }
92 function get_bool($name, $value)
93 {
94 if ($value == 't')
95 {
96 $str = $name . "= true ";
97 } else if ($value == 'f') {
98 $str = $name . " = false ";
99 } else {
100 $str = $name . " = null ";
101 }
102 return $str;
103 }
104 function get_textarea($name, $value)
105 {
106 if ($value == "" ) {
107 $str = $name . "= null";
108 } else {
109 $str = $name . "='" . trim(strip_tags($value)) . "'";
110 }
111 return $str;
112 }
113 ?>
114 #use wml::nmpage title="Debian New Maintainer - Applicant Status Update"
115 <?
116 if (!session_is_registered("s_username") || !session_is_registered("s_isam")) {
117 ?>
118 <STRONG>
119 You should not be here!!</STRONG>
120 <? } else {
121 session_register("s_username");
122 session_register("s_isfd");
123 session_register("s_isdam");
124
125
126 ?>
127 <H1>Debian New Maintainer</H1><BR>
128 <H3>Updating Applicant's status</H3>
129 <?
130 # Check ze values, any bad things we abort
131 if ( ($db = open_db())) {
132 $errors = "";
133 if ($emailkey == "") { $errors .= "<LI><STRONG>Blank old email address, problem with script!</STRONG>"; }
134 if ($s_isdam == 't' || $s_isfd == 't') {
135 if ($email == "") { $errors .= "<LI>No new email address.\n"; }
136 if ($forename == "") { $errors .= "<LI>You must have a first name entered.\n"; }
137 if ($surname == "") { $errors .= "<LI>You must have a surname entered.\n"; }
138 if ($apply_date == "") { $errors .= "<LI>You must have a date of application.\n"; }
139 if ($manager != "" && $manager_date == "")
140 { $errors .= "<LI>A manager has been assigned but with no date.\n"; }
141 if ($manager == "" && $manager_date != "")
142 { $errors .= "<LI>A manager has not been assigned but there is a manager assigned date.\n"; }
143 if ($advocate_ok != "n" && $advocate_checked == "")
144 { $errors .= "<LI>Advocate check entered but no date given.\n"; }
145 if ($advocate_ok == "n" && $advocate_checked != "")
146 { $errors .= "<LI>Advocate Check Date given but Advocate check not changed.\n"; }
147 } # end of fd or dam
148 if ($am_confirm != "n" && $am_confirm_date == "")
149 { $errors .= "<LI>AM has confirmed applicant but not put a date in.\n"; }
150 if ($am_confirm == "n" && $am_confirm_date != "")
151 { $errors .= "<LI>AM has not confirmed applicant but there is a date set.\n"; }
152
153 if ($id_ok != "n" && $id_checked == "")
154 { $errors .= "<LI>ID has been checked but there is no date of checking.\n"; }
155 if ($id_ok == "n" && $id_checked != "")
156 { $errors .= "<LI>ID has not been checked but there is a date of checking.\n"; }
157 if ($pnp_ok != "n" && $pnp_checked == "")
158 { $errors .= "<LI>Policy and Procedures have been checked but there is no date of checking.\n"; }
159 if ($pnp_ok == "n" && $pnp_checked != "")
160 { $errors .= "<LI>Policy and Procedures have not been checked but there is a date of checking.\n"; }
161 if ($tns_ok != "n" && $tns_checked == "")
162 { $errors .= "<LI>Tasks and Skills have been checked but there is no date of checking.\n"; }
163 if ($tns_ok == "n" && $tns_checked != "")
164 { $errors .= "<LI>Tasks and Skills have not been checked but there is a date of checking.\n"; }
165 if ($approved != "n" && $decision == "")
166 { $errors .= "<LI>AM has approved applicant but there is not date.\n"; }
167 if ($approved == "n" && $decision != "")
168 { $errors .= "<LI>AM has not yet approved applicant but there is a date.\n"; }
169 if (($manager != "") && !(find_manager($db, $manager)))
170 { $errors .= "<LI>I cannot find Application Manager $manager in the database.\n"; }
171 # Possibly more checks later
172 if ($errors != "")
173 {
174 echo "<P>There have been some problems with what you entered, please hit ",
175 "the back button and correct the following errors:",
176 "<UL>$errors</UL>\n";
177 } else {
178 echo "<P>Submission has passed sanity checks.<BR>\n";
179 $sql = "UPDATE applicant SET ";
180 if ($s_isdam == 't' || $s_isfd == 't') {
181 $sql .= get_text("surname", $surname) .
182 ", " . get_text("email", $email) .
183 ", " . get_text("forename", $forename) .
184 ", " . get_text("apply_date", $apply_date) .
185 ", " . get_text("advocate", $advocate) .
186 ", " . get_text("advocate_date", $advocate_date) .
187 ", " . get_bool("advocate_ok", $advocate_ok) .
188 ", " . get_text("advocate_checked", $advocate_checked) .
189 ", " . get_text("manager", $manager) .
190 ", " . get_text("manager_date", $manager_date) . ", ";
191 }
192 $sql .= get_bool("am_confirm", $am_confirm) .
193 ", " . get_text("am_confirm_date", $am_confirm_date) .
194 ", " . get_text("am_contact", $am_contact) .
195 ", " . get_bool("id_ok", $id_ok) .
196 ", " . get_text("id_checked", $id_checked) .
197 ", " . get_bool("pnp_ok", $pnp_ok) .
198 ", " . get_text("pnp_checked", $pnp_checked) .
199 ", " . get_bool("tns_ok", $tns_ok) .
200 ", " . get_text("tns_checked", $tns_checked) .
201 ", " . get_bool("approved", $approved) .
202 ", " . get_text("decision", $decision) .
203 ", " . get_textarea("man_comment", $man_comment) ;
204 if ($s_isdam == 't') {
205 $sql .= ", " . get_bool("application_ok", $application_ok) .
206 ", " . get_bool("da_phone_required", $da_phone_required) .
207 ", " . get_text("da_phone", $da_phone) .
208 ", " . get_bool("da_approved", $da_approved) .
209 ", " . get_text("newmaint", $newmaint) .
210 ", " . get_textarea("da_comment", $da_comment) ;
211 }
212 $sql .= " WHERE email = '$emailkey'";
213 if ($s_isfd == 't') {
214 if (!(check_manager($db, trim($manager), $email))) {
215 echo "<P>Problem emailling manager.\n";
216 }
217 }
218 if (($erows = update_db($db, $sql)) > 0)
219 {
220 echo "<P>$erows rows updated in database.<BR>\n";
221 }
222 }
223 ?>
224 <? } #open database ?>
225 <? } #session management ?>

  ViewVC Help
Powered by ViewVC 1.1.5