1<?php
2include('../Code/confHeader.inc');
3$_SESSION[Me] -> goIfInvalid("../index.php");
4$_SESSION[Me] -> goIfNotChair('../index.php');
5$Conf -> connect();
6
7include('Code.inc');
8
9function quote( $str )
10{
11  return preg_replace( '/([^a-z0-9])/i', "\\\\$1", $str );
12}
13
14function unquote( $str )
15{
16  return preg_replace( '/(.)/', '\1', $str );
17}
18
19function htmlquote( $str )
20{
21  return htmlentities( $str, ENT_NOQUOTES );
22}
23
24if (IsSet($_REQUEST[assignConflicts])) {
25  if (!IsSet($_REQUEST[pcMember])) {
26    $Conf->errorMsg("You need to select a PC Member.");
27  } else {
28    if (IsSet($_REQUEST[Conflict])) {
29      for($i=0; $i < sizeof($_REQUEST[Conflict]); $i++) {
30	$paperId=$_REQUEST[Conflict][$i];
31	$query="INSERT INTO PaperConflict SET paperId='$paperId', "
32	  . " authorId='$_REQUEST[pcMember]'";
33	$Conf -> qe($query);
34	$Conf->log("Added reviewer conflict for $_REQUEST[pcMember] for paper $paper", $_SESSION[Me]);
35      }
36    }
37  }
38}
39
40
41?>
42
43<html>
44
45<?php  $Conf->header("Find Papers By PC Members") ?>
46<body>
47<?php
48
49if (IsSet($_REQUEST[removeConflict])) {
50  removePCConflictPapers($_REQUEST[ExistingConflicts]);
51}
52
53$Conf->infoMsg("This is the existing list of conflicts. "
54	       . " If you want to remove a conflict, check the box "
55	       . " and click the 'remove conflicts' button");
56
57showPCConflictPapers();
58
59print "<br> <br>\n";
60
61
62
63$Conf->infoMsg("This table shows you the papers that may be authored by "
64	       . " program committee members.");
65
66$qpc = "SELECT ContactInfo.contactId, firstName, lastName, email, collaborators"
67. ", affiliation"
68. " FROM ContactInfo,PCMember "
69. " WHERE ContactInfo.contactId=PCMember.contactId "
70. " ORDER BY lastName, firstName ";
71
72$rpc = $Conf->qe($qpc);
73
74if (DB::isError($rpc)) {
75  $Conf->errorMsg("Error in query " . $rpc->getMessage());
76  exit;
77}
78
79$useless = array ( "university" => 1, "the" => 1, "and" => 1, "univ" => 1 );
80
81while($pcdata=$rpc->fetchRow(DB_FETCHMODE_ASSOC)) {
82
83  flush();
84
85  $namestr=$pcdata['firstName'] . " " . $pcdata['lastName']
86    . " (" . $pcdata['email'] . ")";
87
88  $email=$pcdata['email'];
89
90  $collaborators=$pcdata['collaborators'];
91
92  $contactId=$pcdata['contactId'];
93
94  // Use " " for MATCH
95  $or = "|";
96
97  $searchstr= quote($pcdata['lastName']) . $or .
98              quote(substr($email, 0, strpos($email,'@')))
99              . $or . quote($pcdata['affiliation']);
100  $searchstr= preg_replace( "/[$or]+/", $or, $searchstr );
101  $searchstr= preg_replace( "/^[$or]/", "", $searchstr );
102  $searchstr= preg_replace( "/[$or]$/", "", $searchstr );
103
104  $collabsearchstr=$searchstr;
105
106  preg_match_all( "/[a-z]{3,}/i", $collaborators, $strs, PREG_PATTERN_ORDER );
107  foreach( $strs[0] as $str ){
108    $str = strtolower( $str );
109    if( ! IsSet( $useless[$str] ) ){
110      $searchstr = $searchstr . $or . $str;
111    }
112  }
113
114  $sqlcollabsearchstr=addslashes($collabsearchstr);
115  $sqlsearchstr=addslashes($searchstr);
116
117  print "<FORM ACTION=$_SERVER[PHP_SELF]>\n";
118  print "<INPUT type=hidden name=paperId value=$paperId>\n";
119  print "<INPUT type=hidden name=pcMember value=$contactId>\n";
120  print "<table align=center width=75% border=1>\n";
121  print "<tr> <th colspan=3 bgColor=$Conf->contrastColorOne> ";
122  //print "$namestr (search: $searchstr) </th> </tr>";
123  print "$namestr</th> </tr>";
124  print "<tr> <td colspan=3 bgColor=$Conf->contrastColorOne>Look for in Authors: ";
125  print htmlquote(preg_replace( "/[|]/", " ", $searchstr ));
126  print "</td> </tr>";
127  print "<tr> <td colspan=3 bgColor=$Conf->contrastColorOne>Look for in Collaborators: ";
128  print htmlquote(preg_replace( "/[|]/", " ", $collabsearchstr ));
129  print "</td> </tr>";
130
131  //
132  // The following are variations on searching
133  // for keywords. The MATCH requires a fulltext index,
134  // and this may not have been created
135  //
136  //$qc = "SELECT paperId, title FROM Paper "
137  //   . " WHERE contactId=$contactId OR MATCH(authorInformation,abstract) "
138  //   . " AGAINST ('$searchstr') "
139  //   . " ORDER BY paperId ";
140
141  //
142  // Version using regexp..
143  //
144
145  $qc = "SELECT paperId, title, authorInformation, collaborators, Paper.contactId FROM Paper "
146     . " WHERE Paper.contactId=$contactId "
147    . " OR Paper.authorInformation REGEXP '$sqlsearchstr'"
148    . " OR Paper.collaborators REGEXP '$sqlcollabsearchstr' "
149    // . " OR (Paper.abstract REGEXP '$searchstr') "
150    . "  "
151    . " ORDER BY paperId ";
152
153  //$collabsearchstr= unquote( $collabsearchstr );
154  //$searchstr= unquote( $searchstr );
155
156  $collabsearchstr= preg_replace( "/([^a-z0-9$or])/i", "\\\1", $collabsearchstr );
157  $collabsearchstr= preg_replace( "/[$or]/", "|", $collabsearchstr );
158  $searchstr= preg_replace( "/([^a-zA-Z0-9$or])/", "\\\1", $searchstr );
159  $searchstr= preg_replace( "/[$or]/", "|", $searchstr );
160
161  $rc = $Conf->qe($qc);
162
163  if (!DB::isError($rc)) {
164    while ($rowc=$rc->fetchRow(DB_FETCHMODE_ASSOC)) {
165      $paperId=$rowc['paperId'];
166      $title=$rowc['title'];
167
168      $conflict=$Conf->checkConflict($paperId, $contactId);
169
170      print "<tr> <th> $paperId </th> ";
171      print "<td> ";
172      print "<INPUT TYPE=checkbox name=Conflict[] value=$paperId ";
173      if ( $conflict ) {
174	print "CHECKED>\n";
175      } else {
176	print ">\n";
177      }
178      print "</td>";
179      print "<td><TABLE><TR><TH COLSPAN=2 ALIGN='LEFT'>";
180
181      $Conf->linkWithPaperId($title,
182			     "../Assistant/AssistantViewSinglePaper.php",
183			     $paperId);
184      print "</TH></TR>";
185
186  if( $rowc['contactID'] == $contactId ){
187      print "<TR><TD ALIGN='LEFT' COLSPAN=2>Is listed as the contact for this paper.</TD>";
188  }
189
190  preg_match_all( "/[a-z]*($collabsearchstr)[a-z]*/i", $rowc['authorInformation'], $strs, PREG_PATTERN_ORDER );
191  if( count($strs[0]) ){
192      print "<TR><TD ALIGN='LEFT'>PC-member &amp; Submit-Author:</TD><TD ALIGN='LEFT'>";
193      foreach( $strs[0] as $str ){ print htmlquote(" $str");}
194      print "</TD></TR>";
195  }
196
197  preg_match_all( "/[a-z]*($searchstr)[a-z]*/i", $rowc['authorInformation'], $strs, PREG_PATTERN_ORDER );
198  if( count($strs[0]) ){
199      print "<TR><TD ALIGN='LEFT'>PC-Collab &amp; Submit-Author:</TD><TD ALIGN='LEFT'>";
200      foreach( $strs[0] as $str ){ print htmlquote(" $str");}
201      print "</TD></TR>";
202  }
203
204  preg_match_all( "/[a-z]*($collabsearchstr)[a-z]*/i", $rowc['collaborators'], $strs, PREG_PATTERN_ORDER );
205  if( count($strs[0]) ){
206      print "<TR><TD ALIGN='LEFT'> PC-member &amp; Submit-Collab:</TD><TD ALIGN='LEFT'>";
207      foreach( $strs[0] as $str ){ print htmlquote(" $str");}
208      print "</TD></TR>";
209  }
210  print "</TABLE></td> </tr> ";
211
212
213      flush();
214
215    }
216  }
217  print "<tr> <td colspan=3 align=center> ";
218  print "<INPUT type=submit name=assignConflicts value=\"Assign These Conflicts\">\n";
219  print "</td> </tr>";
220  print "</table>";
221  print "</FORM>";
222  print "<br>";
223  //$Conf->errorMsg($qc);
224}
225
226?>
227</body>
228<?php  $Conf->footer() ?>
229</html>
230
231
232