| Server IP : 195.130.67.5 / Your IP : 216.73.217.154 Web Server : Microsoft-IIS/10.0 System : Windows NT WEBSERVER1 10.0 build 17763 (Windows Server 2016) i586 User : IUSR ( 0) PHP Version : 7.4.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /Old Sites/Libteiser - Ojs/ojs2/classes/user/ |
Upload File : |
<?php
/**
* @file classes/user/UserAction.inc.php
*
* Copyright (c) 2003-2009 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* @class UserAction
* @ingroup user
* @see User
*
* @brief UserAction class.
*/
// $Id: UserAction.inc.php,v 1.1.2.2 2009/04/08 19:42:51 asmecher Exp $
class UserAction {
/**
* Constructor.
*/
function UserAction() {
}
/**
* Actions.
*/
/**
* Merge user accounts, including attributed articles etc.
*/
function mergeUsers($oldUserId, $newUserId) {
// Need both user ids for merge
if (empty($oldUserId) || empty($newUserId)) {
return false;
}
$articleDao =& DAORegistry::getDAO('ArticleDAO');
foreach ($articleDao->getArticlesByUserId($oldUserId) as $article) {
$article->setUserId($newUserId);
$articleDao->updateArticle($article);
unset($article);
}
$commentDao =& DAORegistry::getDAO('CommentDAO');
foreach ($commentDao->getCommentsByUserId($oldUserId) as $comment) {
$comment->setUserId($newUserId);
$commentDao->updateComment($comment);
unset($comment);
}
$articleNoteDao =& DAORegistry::getDAO('ArticleNoteDAO');
$articleNotes =& $articleNoteDao->getArticleNotesByUserId($oldUserId);
while ($articleNote =& $articleNotes->next()) {
$articleNote->setUserId($newUserId);
$articleNoteDao->updateArticleNote($articleNote);
unset($articleNote);
}
$editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO');
$editAssignments =& $editAssignmentDao->getEditAssignmentsByUserId($oldUserId);
while ($editAssignment =& $editAssignments->next()) {
$editAssignment->setEditorId($newUserId);
$editAssignmentDao->updateEditAssignment($editAssignment);
unset($editAssignment);
}
$editorSubmissionDao =& DAORegistry::getDAO('EditorSubmissionDAO');
$editorSubmissionDao->transferEditorDecisions($oldUserId, $newUserId);
$reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO');
foreach ($reviewAssignmentDao->getReviewAssignmentsByUserId($oldUserId) as $reviewAssignment) {
$reviewAssignment->setReviewerId($newUserId);
$reviewAssignmentDao->updateReviewAssignment($reviewAssignment);
unset($reviewAssignment);
}
$copyeditorSubmissionDao =& DAORegistry::getDAO('CopyeditorSubmissionDAO');
$copyeditorSubmissions =& $copyeditorSubmissionDao->getCopyeditorSubmissionsByCopyeditorId($oldUserId);
while ($copyeditorSubmission =& $copyeditorSubmissions->next()) {
$copyeditorSubmission->setCopyeditorId($newUserId);
$copyeditorSubmissionDao->updateCopyeditorSubmission($copyeditorSubmission);
unset($copyeditorSubmission);
}
$layoutEditorSubmissionDao =& DAORegistry::getDAO('LayoutEditorSubmissionDAO');
$layoutEditorSubmissions =& $layoutEditorSubmissionDao->getSubmissions($oldUserId);
while ($layoutEditorSubmission =& $layoutEditorSubmissions->next()) {
$layoutAssignment =& $layoutEditorSubmission->getLayoutAssignment();
$layoutAssignment->setEditorId($newUserId);
$layoutEditorSubmissionDao->updateSubmission($layoutEditorSubmission);
unset($layoutAssignment);
unset($layoutEditorSubmission);
}
$proofreaderSubmissionDao =& DAORegistry::getDAO('ProofreaderSubmissionDAO');
$proofreaderSubmissions =& $proofreaderSubmissionDao->getSubmissions($oldUserId);
while ($proofreaderSubmission =& $proofreaderSubmissions->next()) {
$proofAssignment =& $proofreaderSubmission->getProofAssignment();
$proofAssignment->setProofreaderId($newUserId);
$proofreaderSubmissionDao->updateSubmission($proofreaderSubmission);
unset($proofAssignment);
unset($proofreaderSubmission);
}
$articleEmailLogDao =& DAORegistry::getDAO('ArticleEmailLogDAO');
$articleEmailLogDao->transferArticleLogEntries($oldUserId, $newUserId);
$articleEventLogDao =& DAORegistry::getDAO('ArticleEventLogDAO');
$articleEventLogDao->transferArticleLogEntries($oldUserId, $newUserId);
$articleCommentDao =& DAORegistry::getDAO('ArticleCommentDAO');
foreach ($articleCommentDao->getArticleCommentsByUserId($oldUserId) as $articleComment) {
$articleComment->setAuthorId($newUserId);
$articleCommentDao->updateArticleComment($articleComment);
unset($articleComment);
}
$accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO');
$accessKeyDao->transferAccessKeys($oldUserId, $newUserId);
// Delete the old user and associated info.
$sessionDao =& DAORegistry::getDAO('SessionDAO');
$sessionDao->deleteSessionsByUserId($oldUserId);
$subscriptionDao =& DAORegistry::getDAO('SubscriptionDAO');
$subscriptionDao->deleteSubscriptionsByUserId($oldUserId);
$temporaryFileDao =& DAORegistry::getDAO('TemporaryFileDAO');
$temporaryFileDao->deleteTemporaryFilesByUserId($oldUserId);
$notificationStatusDao =& DAORegistry::getDAO('NotificationStatusDAO');
$notificationStatusDao->deleteNotificationStatusByUserId($oldUserId);
$userSettingsDao =& DAORegistry::getDAO('UserSettingsDAO');
$userSettingsDao->deleteSettings($oldUserId);
$groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO');
$groupMembershipDao->deleteMembershipByUserId($oldUserId);
$sectionEditorsDao =& DAORegistry::getDAO('SectionEditorsDAO');
$sectionEditorsDao->deleteEditorsByUserId($oldUserId);
// Transfer old user's roles
$roleDao =& DAORegistry::getDAO('RoleDAO');
$userDao =& DAORegistry::getDAO('UserDAO');
$roles =& $roleDao->getRolesByUserId($oldUserId);
foreach ($roles as $role) {
if (!$roleDao->roleExists($role->getJournalId(), $newUserId, $role->getRoleId())) {
$role->setUserId($newUserId);
$roleDao->insertRole($role);
}
}
$roleDao->deleteRoleByUserId($oldUserId);
$userDao->deleteUserById($oldUserId);
return true;
}
}
?>