/** * Display a list of users from which to choose a subscriber/subscription contact. */ function selectSubscriber($args = array(), $institutional = false) { $templateMgr =& TemplateManager::getManager(); if ($institutional) { $pageTitle = 'manager.subscriptions.selectContact'; $redirect = 'institutional'; } else { $pageTitle = 'manager.subscriptions.selectUser'; $redirect = 'individual'; } $userDao =& DAORegistry::getDAO('UserDAO'); $searchType = null; $searchMatch = null; $search = $searchQuery = Request::getUserVar('search'); $searchInitial = Request::getUserVar('searchInitial'); if (!empty($search)) { $searchType = Request::getUserVar('searchField'); $searchMatch = Request::getUserVar('searchMatch'); } else { if (isset($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } } $rangeInfo = Handler::getRangeInfo('users'); $users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); import('classes.security.Validation'); $templateMgr->assign('isJournalManager', Validation::isJournalManager()); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign('helpTopicId', 'journal.managementPages.subscriptions'); $templateMgr->assign('subscriptionId', Request::getUserVar('subscriptionId')); $templateMgr->assign('pageTitle', $pageTitle); $templateMgr->assign('redirect', $redirect); $templateMgr->assign('alphaList', explode(' ', __('common.alphaList'))); $templateMgr->display('subscription/users.tpl'); }
/** * Allow the Site Administrator to merge user accounts, including attributed monographs etc. */ function mergeUsers($args) { $this->validate(); $this->setupTemplate(true); $userGroupDao =& DAORegistry::getDAO('UserGroupDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); $templateMgr =& TemplateManager::getManager(); $oldUserId = Request::getUserVar('oldUserId'); $newUserId = Request::getUserVar('newUserId'); if (!empty($oldUserId) && !empty($newUserId)) { // Both user IDs have been selected. Merge the accounts. $monographDao =& DAORegistry::getDAO('MonographDAO'); foreach ($monographDao->getMonographsByUserId($oldUserId) as $monograph) { $monograph->setUserId($newUserId); $monographDao->updateMonograph($monograph); unset($monograph); } $commentDao =& DAORegistry::getDAO('CommentDAO'); foreach ($commentDao->getCommentsByUserId($oldUserId) as $comment) { $comment->setUserId($newUserId); $commentDao->updateComment($comment); unset($comment); } $monographNoteDao =& DAORegistry::getDAO('MonographNoteDAO'); $monographNotes =& $monographNoteDao->getMonographNotesByUserId($oldUserId); while ($monographNote =& $monographNotes->next()) { $monographNote->setUserId($newUserId); $monographNoteDao->updateMonographNote($monographNote); unset($monographNote); } $stageSignoffs =& $signoffDao->getByUserId($oldUserId); while ($stageSignoff =& $stageSignoffs->next()) { $stageSignoff->setUserId($newUserId); $signoffDao->updateObject($stageSignoff); unset($stageSignoff); } $editorSubmissionDao =& DAORegistry::getDAO('EditorSubmissionDAO'); $editorSubmissionDao->transferEditorDecisions($oldUserId, $newUserId); $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); foreach ($reviewAssignmentDao->getByUserId($oldUserId) as $reviewAssignment) { $reviewAssignment->setReviewerId($newUserId); $reviewAssignmentDao->updateObject($reviewAssignment); unset($reviewAssignment); } $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); } $monographEmailLogDao =& DAORegistry::getDAO('MonographEmailLogDAO'); $monographEmailLogDao->changeUser($oldUserId, $newUserId); $monographEventLogDao =& DAORegistry::getDAO('MonographEventLogDAO'); $monographEventLogDao->changeUser($oldUserId, $newUserId); $monographCommentDao =& DAORegistry::getDAO('MonographCommentDAO'); foreach ($monographCommentDao->getMonographCommentsByUserId($oldUserId) as $monographComment) { $monographComment->setAuthorId($newUserId); $monographCommentDao->updateMonographComment($monographComment); unset($monographComment); } $accessKeyDao =& DAORegistry::getDAO('AccessKeyDAO'); $accessKeyDao->transferAccessKeys($oldUserId, $newUserId); // Delete the old user and associated info. $sessionDao =& DAORegistry::getDAO('SessionDAO'); $sessionDao->deleteSessionsByUserId($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); $seriesEditorsDao =& DAORegistry::getDAO('SeriesEditorsDAO'); $seriesEditorsDao->deleteEditorsByUserId($oldUserId); // Transfer old user's roles $userGroups =& $userGroupDao->getByUserId($oldUserId); while (!$userGroups->eof()) { $userGroup =& $userGroups->next(); if (!$userGroupDao->userInGroup($userGroup->getContextId(), $newUserId, $userGroup->getId())) { $userGroupDao->assignUserToGroup($newUserId, $userGroup->getId()); } unset($userGroup); } $userGroupDao->deleteAssignmentsByUserId($oldUserId); $userDao->deleteUserById($oldUserId); Request::redirect(null, 'admin', 'mergeUsers'); } if (!empty($oldUserId)) { // Get the old username for the confirm prompt. $oldUser =& $userDao->getUser($oldUserId); $templateMgr->assign('oldUsername', $oldUser->getUsername()); unset($oldUser); } // The administrator must select one or both IDs. if (Request::getUserVar('roleSymbolic') != null) { $roleSymbolic = Request::getUserVar('roleSymbolic'); } else { $roleSymbolic = isset($args[0]) ? $args[0] : 'all'; } if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) { $roleId = $roleDao->getRoleIdFromPath($matches[1]); if ($roleId == null) { Request::redirect(null, null, null, 'all'); } $roleName = $roleDao->getRoleName($roleId, true); } else { $roleId = 0; $roleName = 'admin.mergeUsers.allUsers'; } $searchType = null; $searchMatch = null; $search = Request::getUserVar('search'); $searchInitial = Request::getUserVar('searchInitial'); if (!empty($search)) { $searchType = Request::getUserVar('searchField'); $searchMatch = Request::getUserVar('searchMatch'); } else { if (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } } $rangeInfo = Handler::getRangeInfo('users'); if ($roleId) { $users =& $roleDao->getUsersByRoleId($roleId, null, $searchType, $search, $searchMatch, $rangeInfo); $templateMgr->assign('roleId', $roleId); } else { $users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo); } $templateMgr->assign('currentUrl', Request::url(null, null, 'mergeUsers')); $templateMgr->assign('helpTopicId', 'site.administrativeFunctions'); $templateMgr->assign('roleName', $roleName); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign_by_ref('thisUser', Request::getUser()); $templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $search); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests')); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->assign('oldUserId', $oldUserId); $templateMgr->assign('rolePath', $roleDao->getRolePath($roleId)); $templateMgr->assign('roleSymbolic', $roleSymbolic); $templateMgr->display('admin/selectMergeUser.tpl'); }
function testStrtoupper() { $string = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`abcdefghijklmnopqrstuvwxyz{|}~'; $result = String::strtoupper($string); $expected = '!"#$%&\'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^_`ABCDEFGHIJKLMNOPQRSTUVWXYZ{|}~'; $this->assertEqual($result, $expected); $string = 'à'; $result = String::strtoupper($string); $expected = 'À'; $this->assertEqual($result, $expected); $string = 'á'; $result = String::strtoupper($string); $expected = 'Á'; $this->assertEqual($result, $expected); $string = 'â'; $result = String::strtoupper($string); $expected = 'Â'; $this->assertEqual($result, $expected); $string = 'ã'; $result = String::strtoupper($string); $expected = 'Ã'; $this->assertEqual($result, $expected); $string = 'ä'; $result = String::strtoupper($string); $expected = 'Ä'; $this->assertEqual($result, $expected); $string = 'å'; $result = String::strtoupper($string); $expected = 'Å'; $this->assertEqual($result, $expected); $string = 'æ'; $result = String::strtoupper($string); $expected = 'Æ'; $this->assertEqual($result, $expected); $string = 'ç'; $result = String::strtoupper($string); $expected = 'Ç'; $this->assertEqual($result, $expected); $string = 'è'; $result = String::strtoupper($string); $expected = 'È'; $this->assertEqual($result, $expected); $string = 'é'; $result = String::strtoupper($string); $expected = 'É'; $this->assertEqual($result, $expected); $string = 'ê'; $result = String::strtoupper($string); $expected = 'Ê'; $this->assertEqual($result, $expected); $string = 'ë'; $result = String::strtoupper($string); $expected = 'Ë'; $this->assertEqual($result, $expected); $string = 'ì'; $result = String::strtoupper($string); $expected = 'Ì'; $this->assertEqual($result, $expected); $string = 'í'; $result = String::strtoupper($string); $expected = 'Í'; $this->assertEqual($result, $expected); $string = 'î'; $result = String::strtoupper($string); $expected = 'Î'; $this->assertEqual($result, $expected); $string = 'ï'; $result = String::strtoupper($string); $expected = 'Ï'; $this->assertEqual($result, $expected); $string = 'ð'; $result = String::strtoupper($string); $expected = 'Ð'; $this->assertEqual($result, $expected); $string = 'ñ'; $result = String::strtoupper($string); $expected = 'Ñ'; $this->assertEqual($result, $expected); $string = 'ò'; $result = String::strtoupper($string); $expected = 'Ò'; $this->assertEqual($result, $expected); $string = 'ó'; $result = String::strtoupper($string); $expected = 'Ó'; $this->assertEqual($result, $expected); $string = 'ô'; $result = String::strtoupper($string); $expected = 'Ô'; $this->assertEqual($result, $expected); $string = 'õ'; $result = String::strtoupper($string); $expected = 'Õ'; $this->assertEqual($result, $expected); $string = 'ö'; $result = String::strtoupper($string); $expected = 'Ö'; $this->assertEqual($result, $expected); $string = 'ø'; $result = String::strtoupper($string); $expected = 'Ø'; $this->assertEqual($result, $expected); $string = 'ù'; $result = String::strtoupper($string); $expected = 'Ù'; $this->assertEqual($result, $expected); $string = 'ú'; $result = String::strtoupper($string); $expected = 'Ú'; $this->assertEqual($result, $expected); $string = 'û'; $result = String::strtoupper($string); $expected = 'Û'; $this->assertEqual($result, $expected); $string = 'ü'; $result = String::strtoupper($string); $expected = 'Ü'; $this->assertEqual($result, $expected); $string = 'ý'; $result = String::strtoupper($string); $expected = 'Ý'; $this->assertEqual($result, $expected); $string = 'þ'; $result = String::strtoupper($string); $expected = 'Þ'; $this->assertEqual($result, $expected); $string = 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýþ'; $result = String::strtoupper($string); $expected = 'ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝÞ'; $this->assertEqual($result, $expected); $string = 'ā'; $result = String::strtoupper($string); $expected = 'Ā'; $this->assertEqual($result, $expected); $string = 'ă'; $result = String::strtoupper($string); $expected = 'Ă'; $this->assertEqual($result, $expected); $string = 'ą'; $result = String::strtoupper($string); $expected = 'Ą'; $this->assertEqual($result, $expected); $string = 'ć'; $result = String::strtoupper($string); $expected = 'Ć'; $this->assertEqual($result, $expected); $string = 'ĉ'; $result = String::strtoupper($string); $expected = 'Ĉ'; $this->assertEqual($result, $expected); $string = 'ċ'; $result = String::strtoupper($string); $expected = 'Ċ'; $this->assertEqual($result, $expected); $string = 'č'; $result = String::strtoupper($string); $expected = 'Č'; $this->assertEqual($result, $expected); $string = 'ď'; $result = String::strtoupper($string); $expected = 'Ď'; $this->assertEqual($result, $expected); $string = 'đ'; $result = String::strtoupper($string); $expected = 'Đ'; $this->assertEqual($result, $expected); $string = 'ē'; $result = String::strtoupper($string); $expected = 'Ē'; $this->assertEqual($result, $expected); $string = 'ĕ'; $result = String::strtoupper($string); $expected = 'Ĕ'; $this->assertEqual($result, $expected); $string = 'ė'; $result = String::strtoupper($string); $expected = 'Ė'; $this->assertEqual($result, $expected); $string = 'ę'; $result = String::strtoupper($string); $expected = 'Ę'; $this->assertEqual($result, $expected); $string = 'ě'; $result = String::strtoupper($string); $expected = 'Ě'; $this->assertEqual($result, $expected); $string = 'ĝ'; $result = String::strtoupper($string); $expected = 'Ĝ'; $this->assertEqual($result, $expected); $string = 'ğ'; $result = String::strtoupper($string); $expected = 'Ğ'; $this->assertEqual($result, $expected); $string = 'ġ'; $result = String::strtoupper($string); $expected = 'Ġ'; $this->assertEqual($result, $expected); $string = 'ģ'; $result = String::strtoupper($string); $expected = 'Ģ'; $this->assertEqual($result, $expected); $string = 'ĥ'; $result = String::strtoupper($string); $expected = 'Ĥ'; $this->assertEqual($result, $expected); $string = 'ħ'; $result = String::strtoupper($string); $expected = 'Ħ'; $this->assertEqual($result, $expected); $string = 'ĩ'; $result = String::strtoupper($string); $expected = 'Ĩ'; $this->assertEqual($result, $expected); $string = 'ī'; $result = String::strtoupper($string); $expected = 'Ī'; $this->assertEqual($result, $expected); $string = 'ĭ'; $result = String::strtoupper($string); $expected = 'Ĭ'; $this->assertEqual($result, $expected); $string = 'į'; $result = String::strtoupper($string); $expected = 'Į'; $this->assertEqual($result, $expected); $string = 'ij'; $result = String::strtoupper($string); $expected = 'IJ'; $this->assertEqual($result, $expected); $string = 'ĵ'; $result = String::strtoupper($string); $expected = 'Ĵ'; $this->assertEqual($result, $expected); $string = 'ķ'; $result = String::strtoupper($string); $expected = 'Ķ'; $this->assertEqual($result, $expected); $string = 'ĺ'; $result = String::strtoupper($string); $expected = 'Ĺ'; $this->assertEqual($result, $expected); $string = 'ļ'; $result = String::strtoupper($string); $expected = 'Ļ'; $this->assertEqual($result, $expected); $string = 'ľ'; $result = String::strtoupper($string); $expected = 'Ľ'; $this->assertEqual($result, $expected); $string = 'ŀ'; $result = String::strtoupper($string); $expected = 'Ŀ'; $this->assertEqual($result, $expected); $string = 'ł'; $result = String::strtoupper($string); $expected = 'Ł'; $this->assertEqual($result, $expected); $string = 'ń'; $result = String::strtoupper($string); $expected = 'Ń'; $this->assertEqual($result, $expected); $string = 'ņ'; $result = String::strtoupper($string); $expected = 'Ņ'; $this->assertEqual($result, $expected); $string = 'ň'; $result = String::strtoupper($string); $expected = 'Ň'; $this->assertEqual($result, $expected); $string = 'ŋ'; $result = String::strtoupper($string); $expected = 'Ŋ'; $this->assertEqual($result, $expected); $string = 'ō'; $result = String::strtoupper($string); $expected = 'Ō'; $this->assertEqual($result, $expected); $string = 'ŏ'; $result = String::strtoupper($string); $expected = 'Ŏ'; $this->assertEqual($result, $expected); $string = 'ő'; $result = String::strtoupper($string); $expected = 'Ő'; $this->assertEqual($result, $expected); $string = 'œ'; $result = String::strtoupper($string); $expected = 'Œ'; $this->assertEqual($result, $expected); $string = 'ŕ'; $result = String::strtoupper($string); $expected = 'Ŕ'; $this->assertEqual($result, $expected); $string = 'ŗ'; $result = String::strtoupper($string); $expected = 'Ŗ'; $this->assertEqual($result, $expected); $string = 'ř'; $result = String::strtoupper($string); $expected = 'Ř'; $this->assertEqual($result, $expected); $string = 'ś'; $result = String::strtoupper($string); $expected = 'Ś'; $this->assertEqual($result, $expected); $string = 'ŝ'; $result = String::strtoupper($string); $expected = 'Ŝ'; $this->assertEqual($result, $expected); $string = 'ş'; $result = String::strtoupper($string); $expected = 'Ş'; $this->assertEqual($result, $expected); $string = 'š'; $result = String::strtoupper($string); $expected = 'Š'; $this->assertEqual($result, $expected); $string = 'ţ'; $result = String::strtoupper($string); $expected = 'Ţ'; $this->assertEqual($result, $expected); $string = 'ť'; $result = String::strtoupper($string); $expected = 'Ť'; $this->assertEqual($result, $expected); $string = 'ŧ'; $result = String::strtoupper($string); $expected = 'Ŧ'; $this->assertEqual($result, $expected); $string = 'ũ'; $result = String::strtoupper($string); $expected = 'Ũ'; $this->assertEqual($result, $expected); $string = 'ū'; $result = String::strtoupper($string); $expected = 'Ū'; $this->assertEqual($result, $expected); $string = 'ŭ'; $result = String::strtoupper($string); $expected = 'Ŭ'; $this->assertEqual($result, $expected); $string = 'ů'; $result = String::strtoupper($string); $expected = 'Ů'; $this->assertEqual($result, $expected); $string = 'ű'; $result = String::strtoupper($string); $expected = 'Ű'; $this->assertEqual($result, $expected); $string = 'ų'; $result = String::strtoupper($string); $expected = 'Ų'; $this->assertEqual($result, $expected); $string = 'ŵ'; $result = String::strtoupper($string); $expected = 'Ŵ'; $this->assertEqual($result, $expected); $string = 'ŷ'; $result = String::strtoupper($string); $expected = 'Ŷ'; $this->assertEqual($result, $expected); $string = 'ź'; $result = String::strtoupper($string); $expected = 'Ź'; $this->assertEqual($result, $expected); $string = 'ż'; $result = String::strtoupper($string); $expected = 'Ż'; $this->assertEqual($result, $expected); $string = 'ž'; $result = String::strtoupper($string); $expected = 'Ž'; $this->assertEqual($result, $expected); $string = 'āăąćĉċčďđēĕėęěĝğġģĥħĩīĭįijĵķĺļľŀłńņňŋōŏőœŕŗřśŝşšţťŧũūŭůűųŵŷźżž'; $result = String::strtoupper($string); $expected = 'ĀĂĄĆĈĊČĎĐĒĔĖĘĚĜĞĠĢĤĦĨĪĬĮIJĴĶĹĻĽĿŁŃŅŇŊŌŎŐŒŔŖŘŚŜŞŠŢŤŦŨŪŬŮŰŲŴŶŹŻŽ'; $this->assertEqual($result, $expected); $string = 'Ĥēĺļŏ, Ŵőřļď!'; $result = String::strtoupper($string); $expected = 'ĤĒĹĻŎ, ŴŐŘĻĎ!'; $this->assertEqual($result, $expected); }
/** * Search for users to enroll as reviewers. */ function enrollSearch($args, $request) { $paperId = (int) array_shift($args); $this->validate($request, $paperId, TRACK_DIRECTOR_ACCESS_REVIEW); Locale::requireComponents(array(LOCALE_COMPONENT_PKP_MANAGER)); // manager.people.enrollment, manager.people.enroll $conference =& $request->getConference(); $schedConf =& $request->getSchedConf(); $submission =& $this->submission; $roleDao =& DAORegistry::getDAO('RoleDAO'); $roleId = $roleDao->getRoleIdFromPath('reviewer'); $user =& $request->getUser(); $templateMgr =& TemplateManager::getManager(); $this->setupTemplate($request, true); $searchType = null; $searchMatch = null; $search = $searchQuery = $request->getUserVar('search'); $searchInitial = $request->getUserVar('searchInitial'); if (!empty($search)) { $searchType = $request->getUserVar('searchField'); $searchMatch = $request->getUserVar('searchMatch'); } elseif (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } $rangeInfo = Handler::getRangeInfo('users', array((string) $searchType, (string) $searchMatch, (string) $search)); // Paper ID intentionally omitted $userDao =& DAORegistry::getDAO('UserDAO'); while (true) { $users =& $userDao->getUsersByField($searchType, $searchMatch, $search, false, $rangeInfo); if ($users->isInBounds()) { break; } unset($rangeInfo); $rangeInfo =& $users->getLastPageRangeInfo(); unset($users); } $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', $request->getUserVar('searchInitial')); $templateMgr->assign('paperId', $paperId); $templateMgr->assign('fieldOptions', array(USER_FIELD_INTERESTS => 'user.interests', USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign('roleId', $roleId); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->assign('helpTopicId', 'conference.roles.index'); $templateMgr->display('trackDirector/searchUsers.tpl'); }
/** * Select Proofreader. * @param $args array ($articleId, $userId) */ function selectProofreader($args) { $articleId = isset($args[0]) ? (int) $args[0] : 0; $userId = isset($args[1]) ? (int) $args[1] : 0; list($journal, $submission) = SubmissionEditHandler::validate($articleId, SECTION_EDITOR_ACCESS_EDIT); $roleDao =& DAORegistry::getDAO('RoleDAO'); if ($userId && $articleId && $roleDao->roleExists($journal->getJournalId(), $userId, ROLE_ID_PROOFREADER)) { import('submission.proofreader.ProofreaderAction'); ProofreaderAction::selectProofreader($userId, $submission); Request::redirect(null, null, 'submissionEditing', $articleId); } else { parent::setupTemplate(true, $articleId, 'editing'); $searchType = null; $searchMatch = null; $search = $searchQuery = Request::getUserVar('search'); $searchInitial = Request::getUserVar('searchInitial'); if (isset($search)) { $searchType = Request::getUserVar('searchField'); $searchMatch = Request::getUserVar('searchMatch'); } else { if (isset($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } } $proofreaders = $roleDao->getUsersByRoleId(ROLE_ID_PROOFREADER, $journal->getJournalId(), $searchType, $search, $searchMatch); $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO'); $proofreaderStatistics = $sectionEditorSubmissionDao->getProofreaderStatistics($journal->getJournalId()); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); $templateMgr->assign_by_ref('users', $proofreaders); $proofAssignment =& $submission->getProofAssignment(); if ($proofAssignment) { $templateMgr->assign('currentUser', $proofAssignment->getProofreaderId()); } $templateMgr->assign('statistics', $proofreaderStatistics); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign('articleId', $articleId); $templateMgr->assign('pageSubTitle', 'editor.article.selectProofreader'); $templateMgr->assign('pageTitle', 'user.role.proofreaders'); $templateMgr->assign('actionHandler', 'selectProofreader'); $templateMgr->assign('helpTopicId', 'journal.roles.proofreader'); $templateMgr->display('sectionEditor/selectUser.tpl'); } }
/** * Allow the Site Administrator to merge user accounts. */ function mergeUsers($args) { $this->validate(); $this->setupTemplate(true); $roleDao =& DAORegistry::getDAO('RoleDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $templateMgr =& TemplateManager::getManager(); $oldUserIds = (array) Request::getUserVar('oldUserIds'); $newUserId = Request::getUserVar('newUserId'); if (!empty($oldUserIds) && !empty($newUserId)) { import('user.UserAction'); foreach ($oldUserIds as $oldUserId) { UserAction::mergeUsers($oldUserId, $newUserId); } Request::redirect(null, null, 'admin', 'mergeUsers'); } // The administrator must select one or both IDs. if (Request::getUserVar('roleSymbolic') != null) { $roleSymbolic = Request::getUserVar('roleSymbolic'); } else { $roleSymbolic = isset($args[0]) ? $args[0] : 'all'; } if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) { $roleId = $roleDao->getRoleIdFromPath($matches[1]); if ($roleId == null) { Request::redirect(null, null, null, null, 'all'); } $roleName = $roleDao->getRoleName($roleId, true); } else { $roleId = 0; $roleName = 'admin.mergeUsers.allUsers'; } $searchType = null; $searchMatch = null; $search = Request::getUserVar('search'); $searchInitial = Request::getUserVar('searchInitial'); if (!empty($search)) { $searchType = Request::getUserVar('searchField'); $searchMatch = Request::getUserVar('searchMatch'); } elseif (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } $rangeInfo =& Handler::getRangeInfo('users', array($roleId, (string) $search, (string) $searchMatch, (string) $searchType)); if ($roleId) { while (true) { $users =& $roleDao->getUsersByRoleId($roleId, null, null, $searchType, $search, $searchMatch, $rangeInfo); if ($users->isInBounds()) { break; } unset($rangeInfo); $rangeInfo =& $users->getLastPageRangeInfo(); unset($users); } $templateMgr->assign('roleId', $roleId); } else { while (true) { $users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo); if ($users->isInBounds()) { break; } unset($rangeInfo); $rangeInfo =& $users->getLastPageRangeInfo(); unset($users); } } $templateMgr->assign('currentUrl', Request::url(null, null, 'admin', 'mergeUsers')); $templateMgr->assign('helpTopicId', 'site.administrativeFunctions'); $templateMgr->assign('roleName', $roleName); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign_by_ref('thisUser', Request::getUser()); $templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $search); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); if ($roleId == ROLE_ID_REVIEWER) { $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $templateMgr->assign('rateReviewerOnQuality', $conference->getSetting('rateReviewerOnQuality')); $templateMgr->assign('qualityRatings', $conference->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($conference->getId()) : null); } $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests')); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->assign('oldUserIds', $oldUserIds); $templateMgr->assign('rolePath', $roleDao->getRolePath($roleId)); $templateMgr->assign('roleSymbolic', $roleSymbolic); $templateMgr->display('admin/selectMergeUser.tpl'); }
/** * Search for users to enroll as reviewers. * Last modified: EL on February 16th 2013 * Enroll only enrollable users (no reviewers, secretaries, * administrators or coordinators) * Originally comming from SubmissionEditHandler * (just doing the redirection after the enrollment) * Which is not anymore the case */ function enrollSearch($args) { $sectionId = isset($args[0]) ? (int) $args[0] : 0; Locale::requireComponents(array(LOCALE_COMPONENT_PKP_MANAGER)); // manager.people.enrollment, manager.people.enroll $journal =& Request::getJournal(); // For security purposes $thisUser =& Request::getUser(); if ($thisUser->getSecretaryCommitteeId() == $sectionId) { $roleDao =& DAORegistry::getDAO('RoleDAO'); $roleId = $roleDao->getRoleIdFromPath('reviewer'); $rangeInfo = Handler::getRangeInfo('users'); $templateMgr =& TemplateManager::getManager(); $this->setupTemplate(2); $searchType = null; $searchMatch = null; $search = $searchQuery = Request::getUserVar('search'); $searchInitial = Request::getUserVar('searchInitial'); if (!empty($search)) { $searchType = Request::getUserVar('searchField'); $searchMatch = Request::getUserVar('searchMatch'); } elseif (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } $sort = Request::getUserVar('sort'); $sort = isset($sort) ? $sort : 'name'; $sortDirection = Request::getUserVar('sortDirection'); $userDao =& DAORegistry::getDAO('UserDAO'); $users =& $userDao->getEnrollableUsers($journal->getId(), $searchType, $searchMatch, $search, false, $rangeInfo, $sort, $sortDirection); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $erc =& $sectionDao->getSection($sectionId); $templateMgr->assign('ercAbbrev', $erc->getLocalizedAbbrev()); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); $templateMgr->assign('sort', $sort); $templateMgr->assign('sortDirection', $sortDirection); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign('sectionId', $sectionId); $templateMgr->assign('roleId', $roleId); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->assign('helpTopicId', 'journal.roles.index'); $templateMgr->display('sectionEditor/searchUsers.tpl'); } else { Request::redirect(null, 'user'); } }
/** * Display a list of authors from which to choose a book reviewer. */ function selectBookForReviewAuthor($args = array(), &$request) { $this->setupTemplate(true); $journal =& $request->getJournal(); $journalId = $journal->getId(); $bfrPlugin =& PluginRegistry::getPlugin('generic', BOOKS_FOR_REVIEW_PLUGIN_NAME); $bookId = (int) $args[0]; $returnPage = $request->getUserVar('returnPage') == null ? null : $request->getUserVar('returnPage'); if ($returnPage != null) { $validPages =& $this->getValidReturnPages(); if (!in_array($returnPage, $validPages)) { $returnPage = null; } } $bfrDao =& DAORegistry::getDAO('BookForReviewDAO'); // Ensure book for review is for this journal if ($bfrDao->getBookForReviewJournalId($bookId) != $journalId) { $request->redirect(null, 'editor', 'booksForReview', $returnPage); } $templateMgr =& TemplateManager::getManager(); $roleDao =& DAORegistry::getDAO('RoleDAO'); $searchType = null; $searchMatch = null; $search = $searchQuery = $request->getUserVar('search'); $searchInitial = $request->getUserVar('searchInitial'); if (!empty($search)) { $searchType = $request->getUserVar('searchField'); $searchMatch = $request->getUserVar('searchMatch'); } else { if (isset($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } } $rangeInfo = Handler::getRangeInfo('users'); $users =& $roleDao->getUsersByRoleId(ROLE_ID_AUTHOR, $journalId, $searchType, $search, $searchMatch, $rangeInfo); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', $request->getUserVar('searchInitial')); import('classes.security.Validation'); $templateMgr->assign('isJournalManager', Validation::isJournalManager()); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign('helpTopicId', 'journal.roles.author'); $templateMgr->assign('bookId', $bookId); $templateMgr->assign('returnPage', $returnPage); $templateMgr->assign('alphaList', explode(' ', __('common.alphaList'))); $templateMgr->display($bfrPlugin->getTemplatePath() . 'editor' . '/' . 'authors.tpl'); }
public function testStrtoupperWhenAllIsUpperCaseShouldReturnAllUpper() { $expected = "DAFITI"; $actual = String::strtoupper("DAFITI"); $this->assertEquals($expected, $actual); }
/** * Search for users to enroll in a specific role. * @param $args array first parameter is the selected role ID */ function enrollSearch($args, &$request) { $this->validate(); $roleDao = DAORegistry::getDAO('RoleDAO'); $userDao = DAORegistry::getDAO('UserDAO'); $roleId = (int) (isset($args[0]) ? $args[0] : $request->getUserVar('roleId')); $templateMgr =& TemplateManager::getManager($request); $this->setupTemplate($request, true); $searchType = null; $searchMatch = null; $search = $request->getUserVar('search'); $searchInitial = $request->getUserVar('searchInitial'); if (isset($search)) { $searchType = $request->getUserVar('searchField'); $searchMatch = $request->getUserVar('searchMatch'); } else { if (isset($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } } $sort = $request->getUserVar('sort'); $sort = isset($sort) ? $sort : 'name'; $sortDirection = $request->getUserVar('sortDirection'); $rangeInfo = $this->getRangeInfo($request, 'users'); $users = $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo, $sort, $sortDirection); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $search); $templateMgr->assign('searchInitial', $request->getUserVar('searchInitial')); $templateMgr->assign('roleId', $roleId); $templateMgr->assign('roleName', $roleDao->getRoleName($roleId)); $fieldOptions = array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email'); $templateMgr->assign('fieldOptions', $fieldOptions); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign_by_ref('thisUser', $request->getUser()); $templateMgr->assign('alphaList', explode(' ', __('common.alphaList'))); $templateMgr->assign('sort', $sort); $templateMgr->assign('sortDirection', $sortDirection); $templateMgr->display('admin/people/searchUsers.tpl'); }
/** * Display a list of users from which to choose a subscriber. */ function selectSubscriber() { SubscriptionManagerHandler::validate(); $templateMgr =& TemplateManager::getManager(); SubscriptionManagerHandler::setupTemplate(); $templateMgr->append('pageHierarchy', array(Request::url(null, 'manager', 'subscriptions'), 'manager.subscriptions')); $userDao =& DAORegistry::getDAO('UserDAO'); $searchType = null; $searchMatch = null; $search = $searchQuery = Request::getUserVar('search'); $searchInitial = Request::getUserVar('searchInitial'); if (!empty($search)) { $searchType = Request::getUserVar('searchField'); $searchMatch = Request::getUserVar('searchMatch'); } else { if (isset($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } } $rangeInfo = Handler::getRangeInfo('users'); $users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); $templateMgr->assign('isJournalManager', false); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign('helpTopicId', 'journal.managementPages.subscriptions'); $templateMgr->assign('subscriptionId', Request::getUserVar('subscriptionId')); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->display('subscription/users.tpl'); }
/** * Allow the Journal Manager to merge user accounts, including attributed articles etc. */ function mergeUsers($args) { parent::validate(); parent::setupTemplate(true); $roleDao =& DAORegistry::getDAO('RoleDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $journal =& Request::getJournal(); $journalId = $journal->getJournalId(); $templateMgr =& TemplateManager::getManager(); $oldUserId = Request::getUserVar('oldUserId'); $newUserId = Request::getUserVar('newUserId'); // Ensure that we have administrative priveleges over the specified user(s). if (!empty($oldUserId) && !Validation::canAdminister($journalId, $oldUserId) || !empty($newUserId) && !Validation::canAdminister($journalId, $newUserId)) { $templateMgr->assign('pageTitle', 'manager.people'); $templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights'); $templateMgr->assign('backLink', Request::url(null, null, 'people', 'all')); $templateMgr->assign('backLinkLabel', 'manager.people.allUsers'); return $templateMgr->display('common/error.tpl'); } if (!empty($oldUserId) && !empty($newUserId)) { // Both user IDs have been selected. Merge the accounts. $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 $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); Request::redirect(null, 'manager'); } if (!empty($oldUserId)) { // Get the old username for the confirm prompt. $oldUser =& $userDao->getUser($oldUserId); $templateMgr->assign('oldUsername', $oldUser->getUsername()); unset($oldUser); } // The manager must select one or both IDs. if (Request::getUserVar('roleSymbolic') != null) { $roleSymbolic = Request::getUserVar('roleSymbolic'); } else { $roleSymbolic = isset($args[0]) ? $args[0] : 'all'; } if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) { $roleId = $roleDao->getRoleIdFromPath($matches[1]); if ($roleId == null) { Request::redirect(null, null, null, 'all'); } $roleName = $roleDao->getRoleName($roleId, true); } else { $roleId = 0; $roleName = 'manager.people.allUsers'; } $searchType = null; $searchMatch = null; $search = Request::getUserVar('search'); $searchInitial = Request::getUserVar('searchInitial'); if (isset($search)) { $searchType = Request::getUserVar('searchField'); $searchMatch = Request::getUserVar('searchMatch'); } else { if (isset($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } } $rangeInfo = Handler::getRangeInfo('users'); if ($roleId) { $users =& $roleDao->getUsersByRoleId($roleId, $journalId, $searchType, $search, $searchMatch, $rangeInfo); $templateMgr->assign('roleId', $roleId); } else { $users =& $roleDao->getUsersByJournalId($journalId, $searchType, $search, $searchMatch, $rangeInfo); } $templateMgr->assign('currentUrl', Request::url(null, null, 'people', 'all')); $templateMgr->assign('helpTopicId', 'journal.managementPages.mergeUsers'); $templateMgr->assign('roleName', $roleName); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign_by_ref('thisUser', Request::getUser()); $templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $search); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); if ($roleId == ROLE_ID_REVIEWER) { $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $templateMgr->assign('rateReviewerOnQuality', $journal->getSetting('rateReviewerOnQuality')); $templateMgr->assign('qualityRatings', $journal->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($journalId) : null); } $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests')); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->assign('oldUserId', $oldUserId); $templateMgr->assign('rolePath', $roleDao->getRolePath($roleId)); $templateMgr->assign('roleSymbolic', $roleSymbolic); $templateMgr->display('manager/people/selectMergeUser.tpl'); }
/** * Display a list of authors from which to choose an object reviewer. * @param $args array * @param $request PKPRequest */ function selectObjectForReviewAuthor($args, &$request) { $objectId = array_shift($args); $journal =& $request->getJournal(); $journalId = $journal->getId(); if (!$this->_ensureObjectExists($objectId, $journalId)) { $request->redirect(null, 'editor', 'objectsForReview'); } // Search $searchField = null; $searchMatch = null; $search = $request->getUserVar('search'); $searchInitial = $request->getUserVar('searchInitial'); if (!empty($search)) { $searchField = $request->getUserVar('searchField'); $searchMatch = $request->getUserVar('searchMatch'); } else { if (isset($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchField = USER_FIELD_INITIAL; $search = $searchInitial; } } $fieldOptions = array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email'); // Get all and those authors assigned to this object $rangeInfo = Handler::getRangeInfo('users'); $roleDao =& DAORegistry::getDAO('RoleDAO'); $users =& $roleDao->getUsersByRoleId(ROLE_ID_AUTHOR, $journalId, $searchField, $search, $searchMatch, $rangeInfo); $ofrAssignmentDao =& DAORegistry::getDAO('ObjectForReviewAssignmentDAO'); $usersAssigned = $ofrAssignmentDao->getUserIds($objectId); $this->setupTemplate($request, true); $templateMgr =& TemplateManager::getManager($request); $templateMgr->assign('objectId', $objectId); $templateMgr->assign('searchField', $searchField); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $search); $templateMgr->assign('searchInitial', $searchInitial); $templateMgr->assign('searchFieldOptions', $fieldOptions); $templateMgr->assign('alphaList', explode(' ', __('common.alphaList'))); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign_by_ref('usersAssigned', $usersAssigned); import('classes.security.Validation'); $templateMgr->assign('isJournalManager', Validation::isJournalManager()); $ofrPlugin =& $this->_getObjectsForReviewPlugin(); $templateMgr->display($ofrPlugin->getTemplatePath() . 'editor' . '/' . 'authors.tpl'); }
/** * Translate query keywords. * @param $searchPhrase string * @return The translated search phrase. */ function _translateSearchPhrase($searchPhrase, $backwards = false) { static $queryKeywords; if (is_null($queryKeywords)) { // Query keywords. $queryKeywords = array(String::strtoupper(__('search.operator.not')) => 'NOT', String::strtoupper(__('search.operator.and')) => 'AND', String::strtoupper(__('search.operator.or')) => 'OR'); } if ($backwards) { $translationTable = array_flip($queryKeywords); } else { $translationTable = $queryKeywords; } // Translate the search phrase. foreach ($translationTable as $translateFrom => $translateTo) { $searchPhrase = String::regexp_replace("/(^|\\s){$translateFrom}(\\s|\$)/i", "\\1{$translateTo}\\2", $searchPhrase); } return $searchPhrase; }
/** * Select Proofreader. * @param $args array ($articleId, $userId) * @param $request PKPRequest */ function selectProofreader($args, $request) { $articleId = (int) array_shift($args); $userId = (int) array_shift($args); $this->validate($articleId, SECTION_EDITOR_ACCESS_EDIT); $journal =& $request->getJournal(); $submission =& $this->submission; $roleDao =& DAORegistry::getDAO('RoleDAO'); $signoffDao =& DAORegistry::getDAO('SignoffDAO'); if ($userId && $articleId && $roleDao->userHasRole($journal->getId(), $userId, ROLE_ID_PROOFREADER)) { import('classes.submission.proofreader.ProofreaderAction'); ProofreaderAction::selectProofreader($userId, $submission, $request); $request->redirect(null, null, 'submissionEditing', $articleId); } else { $this->setupTemplate(true, $articleId, 'editing'); $searchType = null; $searchMatch = null; $search = $searchQuery = $request->getUserVar('search'); $searchInitial = $request->getUserVar('searchInitial'); if (!empty($search)) { $searchType = $request->getUserVar('searchField'); $searchMatch = $request->getUserVar('searchMatch'); } elseif (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } $proofreaders = $roleDao->getUsersByRoleId(ROLE_ID_PROOFREADER, $journal->getId(), $searchType, $search, $searchMatch); $sectionEditorSubmissionDao =& DAORegistry::getDAO('SectionEditorSubmissionDAO'); $proofreaderStatistics = $sectionEditorSubmissionDao->getProofreaderStatistics($journal->getId()); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); $templateMgr->assign_by_ref('users', $proofreaders); $proofSignoff = $signoffDao->getBySymbolic('SIGNOFF_PROOFREADING_PROOFREADER', ASSOC_TYPE_ARTICLE, $articleId); if ($proofSignoff) { $templateMgr->assign('currentUser', $proofSignoff->getUserId()); } $templateMgr->assign('statistics', $proofreaderStatistics); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign('articleId', $articleId); $templateMgr->assign('pageSubTitle', 'editor.article.selectProofreader'); $templateMgr->assign('pageTitle', 'user.role.proofreaders'); $templateMgr->assign('actionHandler', 'selectProofreader'); $templateMgr->assign('helpTopicId', 'journal.roles.proofreader'); $templateMgr->display('sectionEditor/selectUser.tpl'); } }
/** * Assigns the selected director to the submission. */ function assignDirector($args, $request) { $this->validate($request); Locale::requireComponents(array(LOCALE_COMPONENT_PKP_MANAGER)); // manager.people.noneEnrolled $schedConf =& $request->getSchedConf(); $paperId = $request->getUserVar('paperId'); $directorId = $request->getUserVar('directorId'); $roleDao =& DAORegistry::getDAO('RoleDAO'); $isDirector = $roleDao->userHasRole($schedConf->getConferenceId(), $schedConf->getId(), $directorId, ROLE_ID_DIRECTOR) || $roleDao->userHasRole($schedConf->getConferenceId(), 0, $directorId, ROLE_ID_DIRECTOR); $isTrackDirector = $roleDao->userHasRole($schedConf->getConferenceId(), $schedConf->getId(), $directorId, ROLE_ID_TRACK_DIRECTOR) || $roleDao->userHasRole($schedConf->getConferenceId(), 0, $directorId, ROLE_ID_TRACK_DIRECTOR); if (isset($directorId) && $directorId != null && ($isDirector || $isTrackDirector)) { // A valid track director has already been chosen; // either prompt with a modifiable email or, if this // has been done, send the email and store the director // selection. $this->setupTemplate($request, DIRECTOR_TRACK_SUBMISSIONS, $paperId, 'summary'); // FIXME: Prompt for due date. if (DirectorAction::assignDirector($paperId, $directorId, $isDirector, $request->getUserVar('send'))) { $request->redirect(null, null, null, 'submission', $paperId); } } else { // Allow the user to choose a track director or director. $this->setupTemplate($request, DIRECTOR_TRACK_SUBMISSIONS, $paperId, 'summary'); $searchType = null; $searchMatch = null; $search = $request->getUserVar('search'); $searchInitial = $request->getUserVar('searchInitial'); if (!empty($search)) { $searchType = $request->getUserVar('searchField'); $searchMatch = $request->getUserVar('searchMatch'); } elseif (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } $forDirectors = isset($args[0]) && $args[0] === 'director'; $rangeInfo =& Handler::getRangeInfo('directors', array($forDirectors, (string) $searchType, (string) $search, (string) $searchMatch)); $directorSubmissionDao =& DAORegistry::getDAO('DirectorSubmissionDAO'); if ($forDirectors) { $roleName = 'user.role.director'; $rolePath = 'director'; while (true) { $directors =& $directorSubmissionDao->getUsersNotAssignedToPaper($schedConf->getId(), $paperId, RoleDAO::getRoleIdFromPath('director'), $searchType, $search, $searchMatch, $rangeInfo); if ($directors->isInBounds()) { break; } unset($rangeInfo); $rangeInfo =& $directors->getLastPageRangeInfo(); unset($directors); } } else { $roleName = 'user.role.trackDirector'; $rolePath = 'trackDirector'; while (true) { $directors =& $directorSubmissionDao->getUsersNotAssignedToPaper($schedConf->getId(), $paperId, RoleDAO::getRoleIdFromPath('trackDirector'), $searchType, $search, $searchMatch, $rangeInfo); if ($directors->isInBounds()) { break; } unset($rangeInfo); $rangeInfo =& $directors->getLastPageRangeInfo(); unset($directors); } } $templateMgr =& TemplateManager::getManager(); $templateMgr->assign_by_ref('directors', $directors); $templateMgr->assign('roleName', $roleName); $templateMgr->assign('rolePath', $rolePath); $templateMgr->assign('paperId', $paperId); $trackDao =& DAORegistry::getDAO('TrackDAO'); $trackDirectorTracks =& $trackDao->getDirectorTracks($schedConf->getId()); $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO'); $directorStatistics = $editAssignmentDao->getDirectorStatistics($schedConf->getId()); $templateMgr->assign_by_ref('directorTracks', $trackDirectorTracks); $templateMgr->assign('directorStatistics', $directorStatistics); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $search); $templateMgr->assign('searchInitial', $request->getUserVar('searchInitial')); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->assign('helpTopicId', 'editorial.directorsRole.summaryPage.submissionManagement'); $templateMgr->display('director/selectTrackDirector.tpl'); } }
/** * Add group membership (or list users if none chosen). */ function addMembership($args) { $groupId = isset($args[0]) ? (int) $args[0] : 0; $userId = isset($args[1]) ? (int) $args[1] : null; $groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO'); // If a user has been selected, add them to the group. // Otherwise list users. if ($userId !== null) { $this->validate($groupId, $userId); $schedConf =& Request::getSchedConf(); $group =& $this->group; $user =& $this->user; // A valid user has been chosen. Add them to // the membership list and redirect. // Avoid duplicating memberships. $groupMembership =& $groupMembershipDao->getMembership($group->getId(), $user->getId()); if (!$groupMembership) { $groupMembership = new GroupMembership(); $groupMembership->setGroupId($group->getId()); $groupMembership->setUserId($user->getId()); // For now, all memberships are displayed in About $groupMembership->setAboutDisplayed(true); $groupMembershipDao->insertMembership($groupMembership); } Request::redirect(null, null, null, 'groupMembership', $group->getId()); } else { $this->validate($groupId); $groupDao =& DAORegistry::getDAO('GroupDAO'); $conference =& Request::getConference(); $schedConf =& Request::getSchedConf(); $group =& $this->group; $this->setupTemplate($group, true); $searchType = null; $searchMatch = null; $search = $searchQuery = Request::getUserVar('search'); $searchInitial = Request::getUserVar('searchInitial'); if (!empty($search)) { $searchType = Request::getUserVar('searchField'); $searchMatch = Request::getUserVar('searchMatch'); } elseif (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } $rangeInfo =& Handler::getRangeInfo('users', array($groupId, (string) $search, (string) $searchMatch, (string) $searchType)); $roleDao =& DAORegistry::getDAO('RoleDAO'); while (true) { $users = $roleDao->getUsersByRoleId(null, $conference->getId(), null, $searchType, $search, $searchMatch, $rangeInfo); if ($users->isInBounds()) { break; } unset($rangeInfo); $rangeInfo =& $users->getLastPageRangeInfo(); unset($users); } $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->assign_by_ref('group', $group); $templateMgr->display('manager/groups/selectUser.tpl'); } }
/** * Allow the Press Manager to merge user accounts, including attributed monographs etc. * @param $args array * @param $request PKPRequest */ function mergeUsers($args, &$request) { $this->setupTemplate(true); $userGroupDao =& DAORegistry::getDAO('UserGroupDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $press =& $request->getPress(); $pressId = $press->getId(); $templateMgr =& TemplateManager::getManager(); $oldUserIds = (array) $request->getUserVar('oldUserIds'); $newUserId = $request->getUserVar('newUserId'); // Ensure that we have administrative priveleges over the specified user(s). $canAdministerAll = true; foreach ($oldUserIds as $oldUserId) { if (!Validation::canAdminister($pressId, $oldUserId)) { $canAdministerAll = false; } } if (!empty($oldUserIds) && !$canAdministerAll || !empty($newUserId) && !Validation::canAdminister($pressId, $newUserId)) { $templateMgr->assign('pageTitle', 'manager.people'); $templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights'); $templateMgr->assign('backLink', $request->url(null, null, 'people', 'all')); $templateMgr->assign('backLinkLabel', 'manager.people.allUsers'); return $templateMgr->display('common/error.tpl'); } if (!empty($oldUserIds) && !empty($newUserId)) { import('classes.user.UserAction'); foreach ($oldUserIds as $oldUserId) { UserAction::mergeUsers($oldUserId, $newUserId); } $request->redirect(null, 'manager'); } // The manager must select one or both IDs. if ($request->getUserVar('userGroupId') != null) { $userGroupId = $request->getUserVar('userGroupId'); } else { $userGroupId = isset($args[0]) ? $args[0] : 'all'; } if ($userGroupId != 'all' && is_numeric($userGroupId)) { $userGroup =& $userGroupDao->getById($userGroupId); if ($userGroupId == null) { $request->redirect(null, null, null, 'all'); } } else { $userGroup = null; } $sort = $request->getUserVar('sort'); $sort = isset($sort) ? $sort : 'name'; $sortDirection = $request->getUserVar('sortDirection'); $searchType = null; $searchMatch = null; $search = $request->getUserVar('search'); $searchInitial = $request->getUserVar('searchInitial'); if (!empty($search)) { $searchType = $request->getUserVar('searchField'); $searchMatch = $request->getUserVar('searchMatch'); } else { if (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } } $rangeInfo = $this->getRangeInfo('users'); if ($userGroup) { $users =& $userGroupDao->getUsersById($userGroupId, $pressId, $searchType, $search, $searchMatch, $rangeInfo, $sort); $templateMgr->assign_by_ref('userGroup', $userGroup); $isReviewer = $userGroup->getRoleId() == ROLE_ID_REVIEWER; } else { $users =& $userGroupDao->getUsersByContextId($pressId, $searchType, $search, $searchMatch, $rangeInfo, $sort); $isReviewer = false; } //$templateMgr->assign_by_ref('roleSettings', $this->retrieveRoleAssignmentPreferences($press->getId())); $templateMgr->assign('currentUrl', $request->url(null, null, 'people', 'all')); $templateMgr->assign('helpTopicId', 'press.managementPages.mergeUsers'); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign_by_ref('thisUser', $request->getUser()); $templateMgr->assign('isReviewer', $isReviewer); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $search); $templateMgr->assign('searchInitial', $request->getUserVar('searchInitial')); if ($isReviewer) { $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $templateMgr->assign('rateReviewerOnQuality', $press->getSetting('rateReviewerOnQuality')); $templateMgr->assign('qualityRatings', $press->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($pressId) : null); } $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests')); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->assign('oldUserIds', $oldUserIds); $templateMgr->assign('userGroupId', $userGroupId); $templateMgr->assign('sort', $sort); $templateMgr->assign('sortDirection', $sortDirection); $templateMgr->display('manager/people/selectMergeUser.tpl'); }
/** * Display a list of users from which to choose a registrant. */ function selectRegistrant($args, &$request) { $this->validate(); $templateMgr =& TemplateManager::getManager($request); $this->setupTemplate($request); $templateMgr->append('pageHierarchy', array($request->url(null, null, 'manager', 'registration'), 'manager.registration')); $userDao = DAORegistry::getDAO('UserDAO'); $roleDao = DAORegistry::getDAO('RoleDAO'); $searchType = null; $searchMatch = null; $search = $searchQuery = $request->getUserVar('search'); $searchInitial = $request->getUserVar('searchInitial'); if (!empty($search)) { $searchType = $request->getUserVar('searchField'); $searchMatch = $request->getUserVar('searchMatch'); } elseif (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } $sort = $request->getUserVar('sort'); $sort = isset($sort) ? $sort : 'name'; $sortDirection = $request->getUserVar('sortDirection'); $rangeInfo =& $this->ggetRangeInfo($request, 'users', array((string) $search, (string) $searchMatch, (string) $searchType)); while (true) { $users =& $userDao->getUsersByField($searchType, $searchMatch, $search, true, $rangeInfo, $sort, $sortDirection); if ($users->isInBounds()) { break; } unset($rangeInfo); $rangeInfo =& $users->getLastPageRangeInfo(); unset($users); } $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', $request->getUserVar('searchInitial')); $templateMgr->assign('isSchedConfManager', true); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign('helpTopicId', 'conference.currentConferences.registration'); $templateMgr->assign('registrationId', $request->getUserVar('registrationId')); $templateMgr->assign('alphaList', explode(' ', __('common.alphaList'))); $templateMgr->assign('sort', $sort); $templateMgr->assign('sortDirection', $sortDirection); $templateMgr->display('registration/users.tpl'); }
/** * Add group membership (or list users if none chosen). */ function addMembership($args) { $groupId = isset($args[0]) ? (int) $args[0] : 0; $userId = isset($args[1]) ? (int) $args[1] : null; $groupMembershipDao =& DAORegistry::getDAO('GroupMembershipDAO'); // If a user has been selected, add them to the group. // Otherwise list users. if ($userId !== null) { list($journal, $group, $user) = GroupHandler::validate($groupId, $userId); // A valid user has been chosen. Add them to // the membership list and redirect. // Avoid duplicating memberships. $groupMembership =& $groupMembershipDao->getMembership($group->getGroupId(), $user->getUserId()); if (!$groupMembership) { $groupMembership =& new GroupMembership(); $groupMembership->setGroupId($group->getGroupId()); $groupMembership->setUserId($user->getUserId()); // For now, all memberships are displayed in About $groupMembership->setAboutDisplayed(true); $groupMembershipDao->insertMembership($groupMembership); } Request::redirect(null, null, 'groupMembership', $group->getGroupId()); } else { list($journal, $group) = GroupHandler::validate($groupId); GroupHandler::setupTemplate($group, true); $searchType = null; $searchMatch = null; $search = $searchQuery = Request::getUserVar('search'); $searchInitial = Request::getUserVar('searchInitial'); if (isset($search)) { $searchType = Request::getUserVar('searchField'); $searchMatch = Request::getUserVar('searchMatch'); } else { if (isset($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } } $roleDao =& DAORegistry::getDAO('RoleDAO'); $users = $roleDao->getUsersByRoleId(null, $journal->getJournalId(), $searchType, $search, $searchMatch); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $searchQuery); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->assign_by_ref('group', $group); $templateMgr->display('manager/groups/selectUser.tpl'); } }
/** * Assigns the selected editor to the submission. */ function assignEditor($args, $request) { $this->validate(); AppLocale::requireComponents(LOCALE_COMPONENT_PKP_MANAGER); // manager.people.noneEnrolled $journal =& $request->getJournal(); $articleId = $request->getUserVar('articleId'); $editorId = $request->getUserVar('editorId'); $roleDao =& DAORegistry::getDAO('RoleDAO'); $isSectionEditor = $roleDao->userHasRole($journal->getId(), $editorId, ROLE_ID_SECTION_EDITOR); $isEditor = $roleDao->userHasRole($journal->getId(), $editorId, ROLE_ID_EDITOR); if (isset($editorId) && $editorId != null && ($isEditor || $isSectionEditor)) { // A valid section editor has already been chosen; // either prompt with a modifiable email or, if this // has been done, send the email and store the editor // selection. $this->setupTemplate(EDITOR_SECTION_SUBMISSIONS, $articleId, 'summary'); // FIXME: Prompt for due date. if (EditorAction::assignEditor($articleId, $editorId, $isEditor, $request->getUserVar('send'), $request)) { Request::redirect(null, null, 'submission', $articleId); } } else { // Allow the user to choose a section editor or editor. $this->setupTemplate(EDITOR_SECTION_SUBMISSIONS, $articleId, 'summary'); $searchType = null; $searchMatch = null; $search = $request->getUserVar('search'); $searchInitial = $request->getUserVar('searchInitial'); if (!empty($search)) { $searchType = $request->getUserVar('searchField'); $searchMatch = $request->getUserVar('searchMatch'); } elseif (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } $rangeInfo =& $this->getRangeInfo('editors'); $editorSubmissionDao =& DAORegistry::getDAO('EditorSubmissionDAO'); if (isset($args[0]) && $args[0] === 'editor') { $roleName = 'user.role.editor'; $rolePath = 'editor'; $editors =& $editorSubmissionDao->getUsersNotAssignedToArticle($journal->getId(), $articleId, RoleDAO::getRoleIdFromPath('editor'), $searchType, $search, $searchMatch, $rangeInfo); } else { $roleName = 'user.role.sectionEditor'; $rolePath = 'sectionEditor'; $editors =& $editorSubmissionDao->getUsersNotAssignedToArticle($journal->getId(), $articleId, RoleDAO::getRoleIdFromPath('sectionEditor'), $searchType, $search, $searchMatch, $rangeInfo); } $templateMgr =& TemplateManager::getManager(); $templateMgr->assign_by_ref('editors', $editors); $templateMgr->assign('roleName', $roleName); $templateMgr->assign('rolePath', $rolePath); $templateMgr->assign('articleId', $articleId); $sectionDao =& DAORegistry::getDAO('SectionDAO'); $sectionEditorSections =& $sectionDao->getEditorSections($journal->getId()); $editAssignmentDao =& DAORegistry::getDAO('EditAssignmentDAO'); $editorStatistics = $editAssignmentDao->getEditorStatistics($journal->getId()); $templateMgr->assign_by_ref('editorSections', $sectionEditorSections); $templateMgr->assign('editorStatistics', $editorStatistics); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $search); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email')); $templateMgr->assign('alphaList', explode(' ', __('common.alphaList'))); $templateMgr->assign('helpTopicId', 'editorial.editorsRole.submissionSummary.submissionManagement'); $templateMgr->display('editor/selectSectionEditor.tpl'); } }
/** * Allow the Conference Manager to merge user accounts, including attributed papers etc. */ function mergeUsers($args) { $this->validate(); $this->setupTemplate(true); $roleDao =& DAORegistry::getDAO('RoleDAO'); $userDao =& DAORegistry::getDAO('UserDAO'); $conference =& Request::getConference(); $schedConf =& Request::getSchedConf(); $schedConfId = isset($schedConf) ? $schedConf->getId() : null; $templateMgr =& TemplateManager::getManager(); $oldUserIds = (array) Request::getUserVar('oldUserIds'); $newUserId = Request::getUserVar('newUserId'); // Ensure that we have administrative priveleges over the specified user(s). $canAdministerAll = true; foreach ($oldUserIds as $oldUserId) { if (!Validation::canAdminister($conference->getId(), $oldUserId)) { $canAdministerAll = false; } } if (!empty($oldUserIds) && !$canAdministerAll || !empty($newUserId) && !Validation::canAdminister($conference->getId(), $newUserId)) { $templateMgr->assign('pageTitle', 'manager.people'); $templateMgr->assign('errorMsg', 'manager.people.noAdministrativeRights'); $templateMgr->assign('backLink', Request::url(null, null, null, 'people', 'all')); $templateMgr->assign('backLinkLabel', 'manager.people.allUsers'); return $templateMgr->display('common/error.tpl'); } if (!empty($oldUserIds) && !empty($newUserId)) { import('classes.user.UserAction'); foreach ($oldUserIds as $oldUserId) { UserAction::mergeUsers($oldUserId, $newUserId); } Request::redirect(null, null, 'manager'); } // The manager must select one or both IDs. if (Request::getUserVar('roleSymbolic') != null) { $roleSymbolic = Request::getUserVar('roleSymbolic'); } else { $roleSymbolic = isset($args[0]) ? $args[0] : 'all'; } if ($roleSymbolic != 'all' && String::regexp_match_get('/^(\\w+)s$/', $roleSymbolic, $matches)) { $roleId = $roleDao->getRoleIdFromPath($matches[1]); if ($roleId == null) { Request::redirect(null, null, null, null, 'all'); } $roleName = $roleDao->getRoleName($roleId, true); } else { $roleId = 0; $roleName = 'manager.people.allUsers'; } $sort = Request::getUserVar('sort'); $sort = isset($sort) ? $sort : 'name'; $sortDirection = Request::getUserVar('sortDirection'); $searchType = null; $searchMatch = null; $search = Request::getUserVar('search'); $searchInitial = Request::getUserVar('searchInitial'); if (!empty($search)) { $searchType = Request::getUserVar('searchField'); $searchMatch = Request::getUserVar('searchMatch'); } elseif (!empty($searchInitial)) { $searchInitial = String::strtoupper($searchInitial); $searchType = USER_FIELD_INITIAL; $search = $searchInitial; } $rangeInfo =& Handler::getRangeInfo('users', array($roleId, (string) $search, (string) $searchMatch, (string) $searchType)); if ($roleId) { while (true) { $users =& $roleDao->getUsersByRoleId($roleId, $conference->getId(), $schedConfId, $searchType, $search, $searchMatch, $rangeInfo, $sort); if ($users->isInBounds()) { break; } unset($rangeInfo); $rangeInfo =& $users->getLastPageRangeInfo(); unset($users); } $templateMgr->assign('roleId', $roleId); } else { while (true) { $users =& $roleDao->getUsersByConferenceId($conference->getId(), $searchType, $search, $searchMatch, $rangeInfo, $sort); if ($users->isInBounds()) { break; } unset($rangeInfo); $rangeInfo =& $users->getLastPageRangeInfo(); unset($users); } } $templateMgr->assign('currentUrl', Request::url(null, null, null, 'people', 'all')); $templateMgr->assign('helpTopicId', 'conference.users.mergeUsers'); $templateMgr->assign('roleName', $roleName); $templateMgr->assign_by_ref('users', $users); $templateMgr->assign_by_ref('thisUser', Request::getUser()); $templateMgr->assign('isReviewer', $roleId == ROLE_ID_REVIEWER); $templateMgr->assign('searchField', $searchType); $templateMgr->assign('searchMatch', $searchMatch); $templateMgr->assign('search', $search); $templateMgr->assign('searchInitial', Request::getUserVar('searchInitial')); if ($roleId == ROLE_ID_REVIEWER) { $reviewAssignmentDao =& DAORegistry::getDAO('ReviewAssignmentDAO'); $templateMgr->assign('rateReviewerOnQuality', $conference->getSetting('rateReviewerOnQuality')); $templateMgr->assign('qualityRatings', $conference->getSetting('rateReviewerOnQuality') ? $reviewAssignmentDao->getAverageQualityRatings($conference->getId()) : null); } $templateMgr->assign('fieldOptions', array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_EMAIL => 'user.email', USER_FIELD_INTERESTS => 'user.interests')); $templateMgr->assign('alphaList', explode(' ', Locale::translate('common.alphaList'))); $templateMgr->assign('oldUserIds', $oldUserIds); $templateMgr->assign('rolePath', $roleDao->getRolePath($roleId)); $templateMgr->assign('roleSymbolic', $roleSymbolic); $templateMgr->assign('sort', $sort); $templateMgr->assign('sortDirection', $sortDirection); $templateMgr->display('manager/people/selectMergeUser.tpl'); }
/** * Returns a JSON list for the autocomplete field. Fetches a list of possible spotlight options * based on the spotlight type chosen. * @param $args array * @param $request PKPRequest * @return JSONMessage JSON object */ function itemAutocomplete($args, $request) { $name = $request->getUserVar('name'); $press = $this->getPress(); $itemList = array(); // get the items that match. $matches = array(); $publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO'); $publishedMonographs = $publishedMonographDao->getByPressId($press->getId()); while ($monograph = $publishedMonographs->next()) { if ($name == '' || preg_match('/' . preg_quote($name, '/') . '/i', $monograph->getLocalizedTitle())) { $matches[] = array('label' => $monograph->getLocalizedTitle(), 'value' => $monograph->getId() . ':' . SPOTLIGHT_TYPE_BOOK); } } if (!empty($matches)) { $itemList[] = array('label' => String::strtoupper(__('submission.monograph')), 'value' => ''); $itemList = array_merge($itemList, $matches); } $matches = array(); $seriesDao = DAORegistry::getDAO('SeriesDAO'); $allSeries = $seriesDao->getByPressId($press->getId()); while ($series = $allSeries->next()) { if ($name == '' || preg_match('/' . preg_quote($name, '/') . '/i', $series->getLocalizedTitle())) { $matches[] = array('label' => $series->getLocalizedTitle(), 'value' => $series->getId() . ':' . SPOTLIGHT_TYPE_SERIES); } } if (!empty($matches)) { $itemList[] = array('label' => String::strtoupper(__('manager.series.book')), 'value' => ''); $itemList = array_merge($itemList, $matches); } $matches = array(); $authorDao = DAORegistry::getDAO('AuthorDAO'); $authors = $authorDao->getAuthorsAlphabetizedByPress($press->getId()); while ($author = $authors->next()) { if ($name == '' || preg_match('/' . preg_quote($name, '/') . '/i', $author->getFullName())) { $publishedMonograph = $publishedMonographDao->getById($author->getSubmissionId()); if ($publishedMonograph) { // only include Authors if they are authors on published monographs. $matches[] = array('label' => $author->getFullName() . ' (' . $publishedMonograph->getLocalizedTitle() . ')', 'value' => $author->getId() . ':' . SPOTLIGHT_TYPE_AUTHOR); } } } if (!empty($matches)) { $itemList[] = array('label' => String::strtoupper(__('user.role.author')), 'value' => ''); $itemList = array_merge($itemList, $matches); } if (count($itemList) == 0) { return $this->noAutocompleteResults(); } return new JSONMessage(true, $itemList); }