00001 <?php
00002
00016 class UserAction {
00017
00021 function UserAction() {
00022 }
00023
00033 function mergeUsers($oldUserId, $newUserId) {
00034 $monographDao =& DAORegistry::getDAO('MonographDAO');
00035 $monographs =& $monographDao->getByUserId($oldUserId);
00036 while ($monograph =& $monographs->next()) {
00037 $monograph->setUserId($newUserId);
00038 $monographDao->updateMonograph($monograph);
00039 unset($monograph);
00040 }
00041
00042 $submissionFileDao =& DAORegistry::getDAO('SubmissionFileDAO');
00043 $submissionFileDao->transferOwnership($oldUserId, $newUserId);
00044
00045 $monographCommentDao =& DAORegistry::getDAO('MonographCommentDAO');
00046 $comments =& $monographCommentDao->getByUserId($oldUserId);
00047 while ($comment =& $comments->next()) {
00048 $comment->setAuthorId($newUserId);
00049 $monographCommentDao->updateObject($comment);
00050 unset($comment);
00051 }
00052
00053 $noteDao =& DAORegistry::getDAO('NoteDAO');
00054 $monographNotes =& $noteDao->getByUserId($oldUserId);
00055 while ($monographNote =& $monographNotes->next()) {
00056 $monographNote->setUserId($newUserId);
00057 $noteDao->updateObject($monographNote);
00058 unset($monographNote);
00059 }
00060
00061 $signoffDao =& DAORegistry::getDAO('SignoffDAO');
00062 $stageSignoffs =& $signoffDao->getByUserId($oldUserId);
00063 while ($stageSignoff =& $stageSignoffs->next()) {
00064 $stageSignoff->setUserId($newUserId);
00065 $signoffDao->updateObject($stageSignoff);
00066 unset($stageSignoff);
00067 }
00068
00069 $seriesEditorSubmissionDao =& DAORegistry::getDAO('SeriesEditorSubmissionDAO');
00070 $seriesEditorSubmissionDao->transferEditorDecisions($oldUserId, $newUserId);
00071
00072 $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
00073 $reviewAssignments =& $reviewAssignmentDao->getByUserId($oldUserId);
00074
00075 foreach ($reviewAssignments as $reviewAssignment) {
00076 $reviewAssignment->setReviewerId($newUserId);
00077 $reviewAssignmentDao->updateObject($reviewAssignment);
00078 unset($reviewAssignment);
00079 }
00080
00081 $monographEmailLogDao =& DAORegistry::getDAO('MonographEmailLogDAO');
00082 $monographEmailLogDao->changeUser($oldUserId, $newUserId);
00083 $monographEventLogDao =& DAORegistry::getDAO('MonographEventLogDAO');
00084 $monographEventLogDao->changeUser($oldUserId, $newUserId);
00085
00086 $monographCommentDao =& DAORegistry::getDAO('MonographCommentDAO');
00087 $comments =& $monographCommentDao->getByUserId($oldUserId);
00088 while ($comment =& $comments->next()) {
00089 $comment->setAuthorId($newUserId);
00090 $monographCommentDao->updateMonographComment($comment);
00091 unset($comment);
00092 }
00093
00094 $accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO');
00095 $accessKeyDao->transferAccessKeys($oldUserId, $newUserId);
00096
00097 $notificationDao =& DAORegistry::getDAO('NotificationDAO');
00098 $notificationDao->transferNotifications($oldUserId, $newUserId);
00099
00100
00101 $sessionDao =& DAORegistry::getDAO('SessionDAO');
00102 $sessionDao->deleteSessionsByUserId($oldUserId);
00103 $temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
00104 $temporaryFileDao->deleteTemporaryFilesByUserId($oldUserId);
00105 $notificationStatusDao =& DAORegistry::getDAO('NotificationStatusDAO');
00106 $notificationStatusDao->deleteNotificationStatusByUserId($oldUserId);
00107 $userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
00108 $userSettingsDao->deleteSettings($oldUserId);
00109 $seriesEditorsDao =& DAORegistry::getDAO('SeriesEditorsDAO');
00110 $seriesEditorsDao->deleteEditorsByUserId($oldUserId);
00111
00112
00113 $userGroupDao =& DAORegistry::getDAO('UserGroupDAO');
00114 $userGroups =& $userGroupDao->getByUserId($oldUserId);
00115 while( !$userGroups->eof() ) {
00116 $userGroup =& $userGroups->next();
00117 if (!$userGroupDao->userInGroup($newUserId, $userGroup->getId())) {
00118 $userGroupDao->assignUserToGroup($newUserId, $userGroup->getId());
00119 }
00120 unset($userGroup);
00121 }
00122 $userGroupDao->deleteAssignmentsByUserId($oldUserId);
00123
00124 $userDao =& DAORegistry::getDAO('UserDAO');
00125 $userDao->deleteUserById($oldUserId);
00126 }
00127 }
00128
00129 ?>