1<?php
2include('../Code/confHeader.inc');
3$_SESSION[Me] -> goIfInvalid($Conf->paperSite);
4$_SESSION[Me] -> goIfNotPC($Conf->paperSite);
5$Conf -> connect();
6?>
7
8<html>
9
10<?php  $Conf->header("Check reviews of your assigned reviewers and send reminders") ?>
11
12<?php
13
14If( !IsSet($_REQUEST[emailSubject])) {
15  $_REQUEST[emailSubject] = "URGENT: Reminder to Review Paper(s) for $Conf->shortName";
16}
17if (!IsSet($_REQUEST[emailBody])) {
18  $_REQUEST[emailBody] = "Greetings %FIRST% %LAST%,\n\n";
19  $_REQUEST[emailBody] .= $_SESSION[Me]->firstName . " " . $_SESSION[Me]->lastName . "(" . $_SESSION[Me]->email . ") ";
20  $_REQUEST[emailBody] .= "is reminding you to finish your review for\n";
21  $_REQUEST[emailBody] .= "paper #%NUMBER%, %TITLE%\n";
22  $_REQUEST[emailBody] .= "for the $Conf->longName ($Conf->shortName) conference.\n";
23  $_REQUEST[emailBody] .= "\n";
24  $_REQUEST[emailBody] .= "You can continue to modify your review(s)\n";
25  $_REQUEST[emailBody] .= $Conf->printTimeRange('reviewerSubmitReview');
26  $_REQUEST[emailBody] .= "or until you finalize them.\n";
27  $_REQUEST[emailBody] .= "\n";
28  $_REQUEST[emailBody] .= "If you are unable to complete the review by the deadline,\n";
29  $_REQUEST[emailBody] .= "please contact " . $_SESSION[Me]->firstName . " " . $_SESSION[Me]->lastName. " (" . $_SESSION[Me]->email .")\n";
30  $_REQUEST[emailBody] .= "\n";
31  $_REQUEST[emailBody] .= "You can access the reviewing website at this URL\n";
32  $_REQUEST[emailBody] .= "$Conf->paperSite\n";
33  $_REQUEST[emailBody] .= "or use the link at the bottom of this email to automatically log in.\n\n";
34  $_REQUEST[emailBody] .= "Contact $Conf->contactName ($Conf->contactEmail) about problems with the website.\n\n";
35  $_REQUEST[emailBody] .= "Thank you for helping $Conf->shortName - I understand that reviewing is hard work.\n";
36}
37
38//
39// Need to simply finding naglist
40//
41if (IsSet($_REQUEST[nagList])) {
42  for ($i = 0; $i < sizeof($_REQUEST[nagList]); $i++) {
43    $nagMe[$_REQUEST[nagList][$i]] = 1;
44  }
45}
46
47?>
48
49
50<body>
51
52<?php
53if (IsSet($_REQUEST[nagList])
54    && (IsSet($_REQUEST[SendReviews]) || IsSet($_REQUEST[SampleEmails]))) {
55
56      if (IsSet($_REQUEST[SendReviews])) {
57	print "<h2> Nag-o-Matic Status </h2> ";
58      } else {
59	print "<h2> Nag-o-Matic Preview </h2> ";
60      }
61
62
63      $emailFrom="From: $Conf->emailFrom";
64
65
66      for ($i = 0; $i < sizeof($_REQUEST[nagList]); $i++) {
67	//
68	// We send out nag notices one at a time
69	//
70	$them=$_REQUEST[nagList][$i];
71	$query="SELECT Paper.paperId, Paper.Title, "
72	. " ContactInfo.firstName, ContactInfo.lastName, ContactInfo.email, "
73	. " ContactInfo.password, "
74	. " Paper.title, Paper.paperId "
75	. "FROM Paper,ContactInfo,ReviewRequest "
76	. "WHERE ReviewRequest.reviewRequestId=$them "
77	. "AND Paper.paperId=ReviewRequest.paperId "
78	. "AND ContactInfo.contactId=ReviewRequest.asked";
79
80	$result=$Conf->qe($query);
81	if ( $result ) {
82	  $row = $result->fetchRow(DB_FETCHMODE_ASSOC);
83
84	  $msg = $_REQUEST[emailBody];
85
86	  $msg=str_replace("%TITLE%", $row['title'], $msg);
87	  $msg=str_replace("%NUMBER%", $row['paperId'], $msg);
88	  $msg=str_replace("%FIRST%", $row['firstName'], $msg);
89	  $msg=str_replace("%LAST%", $row['lastName'], $msg);
90	  $msg=str_replace("%EMAIL%", $row['email'], $msg);
91
92	  $cleanPasswd=htmlspecialchars($row['password']);
93	  $cleanEmail=htmlspecialchars($row['email']);
94
95	  $extraMsg = "\n";
96	  $extraMsg .= "Depending on your email client, you may be able to click on this link ";
97	  $extraMsg .= "to login:\n";
98	  $extraMsg .= "$Conf->paperSite/Reviewer/RequestedReviews.php?loginEmail=$cleanEmail&password=$cleanPasswd\n";
99
100	  $Conf->log("Nag $cleanEmail about reviews for paper #" . $row['paperId'], $_SESSION[Me]);
101
102	  if (IsSet($_REQUEST[SendReviews])) {
103
104	    mail($cleanEmail,
105		 $_REQUEST[emailSubject],
106		 $msg . "\n" . $extraMsg,
107		 $emailFrom);
108
109	    $Conf->confirmMsg("Sent email to $cleanEmail");
110
111	  } else if (IsSet($_REQUEST[SampleEmails])) {
112
113	    if (($i % 2) == 0 ) {
114	      $header=$Conf->contrastColorOne;
115	      $body=$Conf->contrastColorTwo;
116	    } else {
117	      $header=$Conf->contrastColorTwo;
118	      $body=$Conf->contrastColorOne;
119	    }
120	    print "<table width=75% align=center border=1>";
121	    print "<tr> <td bgcolor=$header> $emailFrom </td> </tr>";
122	    print "<tr> <td bgcolor=$header> To: $cleanEmail </td> </tr>";
123	    print "<tr> <td bgcolor=$header> Subject: $_REQUEST[emailSubject] </td> </tr>";
124	    print "<tr> <td bgcolor=$body> ";
125	    print nl2br(htmlspecialchars($msg));
126# For debug
127#	    print nl2br(htmlspecialchars($extraMsg));
128	    print "</td></tr>";
129	    print "</table>";
130	    print "<br> <br>";
131	  }
132	} else {
133	  $Conf->errorMsg("hmm - can't nag on review #$them" . $result->getMessage());
134	}
135      }
136} else {
137
138  print "<h3> Nag-O-Matic (tm) </h3>";
139
140$Conf->infoMsg(
141  "If you want to \"nag\" reviewers about specific reviews,"
142  . "select the checklist by appropriate reviewer / paper. When you've "
143  . "selected all reviewers, modify the template letter as you wish "
144  . "and simply push \"Send a Review Reminder\" "
145  . "at the bottom of the page. They will be sent email "
146  . "reminding them of the review deadline and the importance of finishing "
147  . "the reviews. "
148  . "Although you can preview the reviews, "
149  . "there is no confirmation step for sending the email, "
150  . "and there is no protection against sending "
151  . "a nag to someone who already submitted a review, so pay attention to your choices."
152  );
153
154
155?>
156
157<h3> Here are the reviews you have assigned: <h3>
158
159<h4>
160There are three degrees of review status: <br>
161<ol>
162<li> Not started  - The reviewer has not started the review. </li>
163<li> Not finalized -  The reviewer has started the review, but changes can be made. </li>
164<li> <b> Done </b> -  The reviewer has finalized their review and no more changes can be made. </li>
165</ol>
166</h4>
167
168<FORM METHOD=POST ACTION="<?php echo $_SERVER[PHP_SELF] ?>" target=_blank>
169<?php
170$result=$Conf->qe("SELECT Paper.paperId, Paper.Title, ContactInfo.email, "
171		  . " ContactInfo.contactId, ReviewRequest.reviewRequestId "
172		  . "FROM Paper, ContactInfo, ReviewRequest "
173		  . "WHERE (ReviewRequest.paperId=Paper.paperId "
174		  . "  AND ReviewRequest.asked=ContactInfo.contactId "
175		  . "  AND ReviewRequest.requestedBy=" . $_SESSION[Me]->contactId. ") "
176		  . " ORDER BY Paper.paperId "
177		  );
178
179if (DB::isError($result)) {
180  $Conf->errorMsg("Error in retrieving list of reviews: " . $result->getMessage());
181}
182else {
183  ?>
184 <table border=1>
185    <tr>
186    <th width=5%> Nag? </th>
187    <th width=5%> Paper # </th>
188    <th width=15%> Asked </th>
189    <th width=10%> Status </th>
190    <th width=15%> Review </th>
191    <th> Title </th>
192    </tr>
193    <?php
194    while ($row=$result->fetchRow()) {
195      $paperId = $row[0];
196      $title = $row[1];
197      $contactEmail = $row[2];
198      $contactId = $row[3];
199      $requestId = $row[4];
200
201      $query = "SELECT reviewer, finalized"
202      . " FROM PaperReview "
203      . " WHERE PaperReview.paperId='$paperId' "
204      . " AND PaperReview.reviewer='$contactId' "
205      ;
206
207      $review_result = $Conf->qe($query);
208      if ( DB::isError($review_result) ) {
209	$Conf->errorMsg("That's odd - no information on reivew. "
210			. $review_result->getMessage());
211      } else {
212
213	$review_row = $review_result->fetchRow();
214
215	$num = $review_result->numRows();
216	if ($num == 0) {
217	  $finalized = -1;
218	  $reviewer = "";
219	}
220	else if ($num == 1) {
221	  $finalized = $review_row[1];
222	  $reviewer = $review_row[0];
223	}
224
225	print "<tr>";
226	print "<td>";
227
228	if ( $finalized != 1 ) {
229	  print "<INPUT type=checkbox NAME=nagList[] VALUE='$requestId'";
230	  if ( $nagMe[$requestId] == 1 ) {
231	    print " CHECKED";
232	  }
233	  print ">";
234	} else {
235	  print "&nbsp";
236	}
237
238	print "</td>";
239
240	print "<td> $paperId </td> <td> $contactEmail </td>";
241
242	if ($finalized ==1) {
243	  $status = "<b> Done </b>";
244	  print "<td> $status </td>";
245	  print "<td> <b> <a href=\"PCReviewsForPaper.php?requestId=$requestId\" target=_blank> See review </a> </b>";
246	  print "</td>";
247	  print "<td> $title </td> </tr>\n";
248	}
249	else if ($finalized ==0) {
250	  $status = "Not finalized";
251	  print "<td> $status </td> \n";
252	  print "<td> <b> <a href=\"PCReviewsForPaper.php?requestId=$requestId\" target=_blank> See partial review </a> </b>";
253	  print "</td>";
254	  print "<td> $title </td>";
255	}
256	else {
257	  $status = "Not started";
258	  print "<td> Not started </td> <td> no review available</td>  <td> $title </td>";
259	}
260
261	print "</tr>\n";
262      }
263    }
264 ?>
265    </table>
266<?php
267}
268?>
269
270<br>
271<INPUT TYPE=SUBMIT name="SendReviews" value="Send a Reviewer Reminder">
272<br>
273<br>
274<INPUT TYPE=SUBMIT name="SampleEmails" value="Preview Email To Be Sent">
275<?php
276$Conf->infoMsg(
277"Now, type the email you want to send. You can use %TITLE% "
278. " to refer to the paper title, %NUMBER% to refer to the paper number. "
279. " The authors name is %FIRST%, %LAST% and %EMAIL%."
280. " When you press the Preview button, you'll see the email to be generated "
281. " and shown in another page. You won't see the passwords and automatic "
282. " link mentioned in the default template (this is always automatically appended). "
283);
284?>
285
286<table>
287<tr>
288<th> Subject: </th>
289<th>
290<INPUT type=text name="emailSubject" size=80 value="<?php echo $_REQUEST[emailSubject]?>">
291</th>
292</tr>
293<tr> <td colspan=2>
294<textarea rows=30 name="emailBody" cols=80><?php echo $_REQUEST[emailBody]?></textarea>
295</td> </tr>
296</table>
297</FORM>
298
299<?php
300   }
301?>
302
303</body>
304<?php  $Conf->footer() ?>
305</html>
306
307
308
309
310