1<?php
2include('../Code/confHeader.inc');
3$Conf -> connect();
4$_SESSION[Me] -> goIfInvalid("../");
5?>
6
7<html>
8<?php  $Conf->header("Merge Account Information From Two Accounts") ?>
9<body>
10
11<?php
12
13if (IsSet($_REQUEST[Merge])) {
14  if ($_REQUEST[firstEmail] != $_REQUEST[secondEmail]) {
15    $Conf->errorMsg("The first and second email addresses don't match");
16  } else if ($_REQUEST[firstEmail] == "") {
17    $Conf->errorMsg("You specified an empty email string");
18  } else if ($_REQUEST[passwd] == "") {
19    $Conf->errorMsg("You need to specify a password");
20  } else {
21    //
22    // Look up that account
23    //
24    $MiniMe = new Contact();
25    $MiniMe -> lookupByEmail($_REQUEST[firstEmail], $Conf);
26
27    if ($MiniMe->contactId == $_SESSION[Me] -> contactId) {
28      $Conf->errorMsg("You can't merge yourself with yourself");
29    } else if (! $MiniMe -> valid() || $MiniMe -> password != $_REQUEST[passwd]) {
30      $Conf-> errorMsg("Either the other acccount doesn't "
31		       . " exist or you specified the wrong password");
32    } else {
33      $Conf->infoMsg("You match -- updating database!");
34
35      $message = "Your account at the $Conf->shortName conference site "
36	. " has been merged with the account of \n"
37	. $_SESSION[Me]->fullname() . " ( " . $_SESSION[Me] -> email . " )\n";
38      $message .= "If you suspect something fishy, contact the "
39	. "conference contact (" . $Conf -> contactEmail . " )\n";
40
41      mail($MiniMe->email,
42	   "Account information for $conf->shortName",
43	   $message,
44	   "From: $conf->emailFrom");
45      //
46      // Now, scan through all the tables that possibly
47      // specify a contactID and change it from their 2nd
48      // contactID to their first contactId
49      //
50      $oldid = $MiniMe->contactId;
51      $newid = $_SESSION[Me]->contactId;
52      //
53      // Paper
54      //
55      $Conf->qe("UPDATE Paper SET contactId=$newid  WHERE "
56		. " contactId=$oldid");
57      $Conf->qe("UPDATE PaperAuthor SET authorId=$newid  WHERE "
58		. " authorId=$oldid");
59      $Conf->qe("UPDATE PaperConflict SET authorId=$newid  WHERE "
60		. " authorId=$oldid");
61      $Conf->qe("UPDATE PCMember SET contactId=$newid  WHERE "
62		. " contactId=$oldid");
63      $Conf->qe("UPDATE Chair SET contactId=$newid  WHERE "
64		. " contactId=$oldid");
65      $Conf->qe("UPDATE TopicInterest SET contactId=$newid  WHERE "
66		. " contactId=$oldid");
67      $Conf->qe("UPDATE ReviewRequest SET asked=$newid  WHERE "
68		. " asked=$oldid");
69      $Conf->qe("UPDATE ReviewRequest SET requestedBy=$newid  WHERE "
70		. " requestedBy=$oldid");
71      $Conf->qe("UPDATE PrimaryReviewer SET reviewer=$newid  WHERE "
72		. " reviewer=$oldid");
73      $Conf->qe("UPDATE SecondaryReviewer SET reviewer=$newid  WHERE "
74		. " reviewer=$oldid");
75      $Conf->qe("UPDATE PaperReview SET reviewer=$newid  WHERE "
76		. " reviewer=$oldid");
77
78      //
79      // Remove the contact record
80      //
81      $Conf->qe("DELETE From ContactInfo WHERE contactId=$oldid");
82
83      $Conf->log("Merged account $oldid into " . $_SESSION[Me]->contactId, $_SESSION[Me]);
84
85    }
86  }
87}
88
89?>
90
91
92<?php
93$Conf->infoMsg(
94"You may have multiple accounts registered with the "
95.  $Conf->shortName . " conference, usually because "
96. "multiple people asked you to review a paper using "
97. "different email addresses. "
98. "This may make it "
99. "more difficult to keep track of your different papers. "
100. "If you have been informed of multiple accounts, you "
101. "can enter the email address and the password "
102. "of the secondary account here and press the \"MERGE\" "
103. "button. This will then merge all the information from "
104. "the account you specify into this account (papers, reviews, etc). "
105. "<br>"
106. "If you simply want to change your email address, you can update "
107. "that in the \"update contact information\" page."
108);
109?>
110
111<form method="POST" action="<?php  echo $_SERVER[PHP_SELF] ?>">
112<div align="center">
113<table border="1" width="75%" bgcolor="<?php echo $Conf->bgOne?>">
114<tr>
115<tr>
116<td width="35%">Email To Merge</td>
117<td width="65%"><input type="text" name="firstEmail" size="44"
118value="<?php  echo $_REQUEST[firstEmail]?>" ></td>
119</tr>
120<tr>
121<td width="35%">Email To Merge Again</td>
122<td width="65%"><input type="text" name="secondEmail" size="44"
123value="<?php  echo $_REQUEST[secondEmail]?>" ></td>
124</tr>
125<tr>
126<td width="35%">Password of that account</td>
127<td width="65%"><input type="password" name="passwd" size="44"
128value="<?php echo $_REQUEST[password]?>" ></td>
129</tr>
130<td colspan=2 align=center>
131<input type="submit" value="Merge" name="Merge">
132</td>
133</table>
134</div>
135</form>
136
137<?php  $Conf->footer() ?>
138</body>
139</html>
140
141