예제 #1
0
 /**
  * Display list of people in the selected role.
  * @param $args array first parameter is the role ID to display
  */
 function people($args, &$request)
 {
     $this->validate();
     $this->setupTemplate($request, true);
     $roleDao = DAORegistry::getDAO('RoleDAO');
     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, 'all');
         }
         $roleName = $roleDao->getRoleName($roleId, true);
     } else {
         $roleId = 0;
         $roleName = 'admin.people.allUsers';
     }
     $sort = $request->getUserVar('sort');
     $sort = isset($sort) ? $sort : 'name';
     $sortDirection = $request->getUserVar('sortDirection');
     $templateMgr =& TemplateManager::getManager($request);
     $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 = $this->getRangeInfo($request, 'users');
     $users = $roleDao->getUsersByRoleId($roleId, $searchType, $search, $searchMatch, $rangeInfo, $sort, $sortDirection);
     $templateMgr->assign('roleId', $roleId);
     $templateMgr->assign('currentUrl', $request->url(null, 'people', 'all'));
     $templateMgr->assign('roleName', $roleName);
     $templateMgr->assign_by_ref('users', $users);
     $templateMgr->assign_by_ref('thisUser', $request->getUser());
     $templateMgr->assign('searchField', $searchType);
     $templateMgr->assign('searchMatch', $searchMatch);
     $templateMgr->assign('search', $search);
     $templateMgr->assign('searchInitial', $request->getUserVar('searchInitial'));
     $fieldOptions = array(USER_FIELD_FIRSTNAME => 'user.firstName', USER_FIELD_LASTNAME => 'user.lastName', USER_FIELD_USERNAME => 'user.username', USER_FIELD_INTERESTS => 'user.interests', USER_FIELD_EMAIL => 'user.email');
     $templateMgr->assign('fieldOptions', $fieldOptions);
     $role =& $roleDao->newDataObject();
     $role->setId($roleId);
     $templateMgr->assign('rolePath', $role->getPath());
     $templateMgr->assign('alphaList', explode(' ', __('common.alphaList')));
     $templateMgr->assign('roleSymbolic', $roleSymbolic);
     $templateMgr->assign('sort', $sort);
     $templateMgr->assign('sortDirection', $sortDirection);
     $templateMgr->display('admin/people/enrollment.tpl');
 }
 /**
  * Submit a submission.
  */
 protected function submitSubmission()
 {
     $this->logAuthorIn();
     $submissionPage = self::$baseUrl . '/index.php/publicknowledge/submission/wizard/';
     //
     // First submission page.
     //
     $this->verifyAndOpen($submissionPage . '1');
     $this->waitForElementPresent('css=button.submitFormButton');
     $this->doActionsOnStep1();
     // Accept submission conditions.
     $checkboxId = 0;
     while ($this->isElementPresent("checklist-{$checkboxId}")) {
         $this->check("checklist-{$checkboxId}");
         $checkboxId++;
     }
     $this->clickAndWait('css=button.submitFormButton');
     //
     // Second submission page.
     //
     $this->waitForLocation($submissionPage . '2*');
     $this->waitForElementPresent('css=div.plupload_buttons');
     // We should now have the submission ID in the URL.
     $url = $this->getLocation();
     $matches = null;
     String::regexp_match_get('/submissionId=([0-9]+)#/', $url, $matches);
     self::assertTrue(count($matches) == 2);
     $submissionId = $matches[1];
     self::assertTrue(is_numeric($submissionId));
     $submissionId = (int) $submissionId;
     // Close the upload file modal.
     $this->click('id=cancelButton');
     // Save the second step without uploading a file.
     $this->waitForElementNotPresent('css=div.plupload_buttons');
     $this->waitForElementPresent($selector = '//button[contains(., \'Save and continue\')]');
     $this->click($selector);
     //
     // Third submission page.
     //
     $this->waitForElementPresent('css=button.submitFormButton');
     $title = 'test book';
     $this->waitForElementPresent("css=[id^=title]");
     $this->type("css=[id^=title]", $title);
     $this->verifyElementPresent('css=iframe[id^=abstract]');
     if ($this->verified()) {
         // TinyMCE hack.
         $jsScript = "selenium.browserbot.getCurrentWindow().document" . ".querySelector('iframe[id^=abstract]').contentDocument.body.innerHTML = " . "'{$title} abstract'";
         $this->getEval($jsScript);
     } else {
         $this->type('css=[id^=abstract]', $title . ' abstract');
     }
     $this->click("css=#submitStep3Form .submitFormButton");
     $this->waitForElementPresent($selector = 'link=OK');
     $this->click($selector);
     $authorDashboardLink = self::$baseUrl . '/index.php/publicknowledge/authorDashboard/submission/' . $submissionId;
     $this->waitForElementPresent("css=a[href='" . $authorDashboardLink . "']");
     $this->assertTrue(is_int($submissionId));
     return $submissionId;
 }
 /**
  * Retrieve the export as an XML string.
  * @param $pluginUrl string the url to be requested for export.
  * @param $postParams array additional post parameters
  * @return string
  */
 protected function getXmlOnExport($pluginUrl, $postParams = array())
 {
     // Prepare HTTP session.
     $curlCh = curl_init();
     curl_setopt($curlCh, CURLOPT_POST, true);
     // Create a cookie file (required for log-in).
     $cookies = tempnam(sys_get_temp_dir(), 'curlcookies');
     // Log in.
     $loginUrl = $this->baseUrl . '/index.php/test/login/signIn';
     // Bug #8518 safety work-around
     if ($this->password[0] == '@') {
         die('CURL parameters may not begin with @.');
     }
     $loginParams = array('username' => 'admin', 'password' => $this->password);
     curl_setopt($curlCh, CURLOPT_URL, $loginUrl);
     curl_setopt($curlCh, CURLOPT_POSTFIELDS, $loginParams);
     curl_setopt($curlCh, CURLOPT_COOKIEJAR, $cookies);
     self::assertTrue(curl_exec($curlCh));
     // Request export document.
     $exportUrl = $this->baseUrl . '/index.php/test/manager/importexport/plugin/' . $pluginUrl;
     curl_setopt($curlCh, CURLOPT_URL, $exportUrl);
     // Bug #8518 safety work-around
     foreach ($postParams as $paramValue) {
         if ($paramValue[0] == '@') {
             die('CURL parameters may not begin with @.');
         }
     }
     curl_setopt($curlCh, CURLOPT_POSTFIELDS, $postParams);
     curl_setopt($curlCh, CURLOPT_HTTPHEADER, array('Accept: application/xml, application/x-gtar, */*'));
     curl_setopt($curlCh, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curlCh, CURLOPT_HEADER, true);
     $response = curl_exec($curlCh);
     do {
         list($header, $response) = explode("\r\n\r\n", $response, 2);
     } while (String::regexp_match('#HTTP/.*100#', $header));
     // Check whether we got a tar file.
     if (String::regexp_match('#Content-Type: application/x-gtar#', $header)) {
         // Save the data to a temporary file.
         $tempfile = tempnam(sys_get_temp_dir(), 'tst');
         file_put_contents($tempfile, $response);
         // Recursively extract tar file.
         $result = $this->extractTarFile($tempfile);
         unlink($tempfile);
     } else {
         $matches = null;
         String::regexp_match_get('#filename="([^"]+)"#', $header, $matches);
         self::assertTrue(isset($matches[1]));
         $result = array($matches[1] => $response);
     }
     // Destroy HTTP session.
     curl_close($curlCh);
     unlink($cookies);
     return $result;
 }
예제 #4
0
 /**
  * Extract and validate a plugin (prior to installation)
  * @param $filePath string Full path to plugin archive
  * @param $originalFileName string Original filename of plugin archive
  * @return string|null Extracted plugin path on success; null on error
  */
 function extractPlugin($filePath, $originalFileName, &$errorMsg)
 {
     // tar archive basename (less potential version number) must
     // equal plugin directory name and plugin files must be in a
     // directory named after the plug-in (potentially with version)
     $matches = array();
     String::regexp_match_get('/^[a-zA-Z0-9]+/', basename($originalFileName, '.tar.gz'), $matches);
     $pluginShortName = array_pop($matches);
     if (!$pluginShortName) {
         $errorMsg = __('manager.plugins.invalidPluginArchive');
         return null;
     }
     // Create random dirname to avoid symlink attacks.
     $pluginExtractDir = dirname($filePath) . DIRECTORY_SEPARATOR . $pluginShortName . substr(md5(mt_rand()), 0, 10);
     mkdir($pluginExtractDir);
     // Test whether the tar binary is available for the export to work
     $tarBinary = Config::getVar('cli', 'tar');
     if (!empty($tarBinary) && file_exists($tarBinary)) {
         exec($tarBinary . ' -xzf ' . escapeshellarg($filePath) . ' -C ' . escapeshellarg($pluginExtractDir));
     } else {
         $errorMsg = __('manager.plugins.tarCommandNotFound');
     }
     if (empty($errorMsg)) {
         // Look for a directory named after the plug-in's short
         // (alphanumeric) name within the extracted archive.
         if (is_dir($tryDir = $pluginExtractDir . '/' . $pluginShortName)) {
             return $tryDir;
             // Success
         }
         // Failing that, look for a directory named after the
         // archive. (Typically also contains the version number
         // e.g. with github generated release archives.)
         String::regexp_match_get('/^[a-zA-Z0-9.-]+/', basename($originalFileName, '.tar.gz'), $matches);
         if (is_dir($tryDir = $pluginExtractDir . '/' . array_pop($matches))) {
             // We found a directory named after the archive
             // within the extracted archive. (Typically also
             // contains the version number, e.g. github
             // generated release archives.)
             return $tryDir;
         }
         $errorMsg = __('manager.plugins.invalidPluginArchive');
     }
     return null;
 }
 /**
  * Normalize incoming date string.
  * @see Filter::process()
  * @param $input string
  * @return string
  */
 function &process(&$input)
 {
     // FIXME: We have to i18nize this when expanding citation parsing to other languages
     static $monthNames = array('Jan' => '01', 'Feb' => '02', 'Mar' => '03', 'Apr' => '04', 'May' => '05', 'Jun' => '06', 'Jul' => '07', 'Aug' => '08', 'Sep' => '09', 'Oct' => '10', 'Nov' => '11', 'Dec' => '12');
     $dateExpressions = array('/(?P<year>\\d{4})-(?P<month>\\d{2})-(?P<day>\\d{2})/', '/(?P<year>\\d{4})\\s*(?P<monthName>[a-z]\\w+)?\\s*(?P<day>\\d+)?/i');
     $normalizedDate = null;
     foreach ($dateExpressions as $dateExpression) {
         if (String::regexp_match_get($dateExpression, $input, $parsedDate)) {
             if (isset($parsedDate['year'])) {
                 $normalizedDate = $parsedDate['year'];
                 $month = '';
                 if (isset($parsedDate['monthName'])) {
                     $monthName = substr($parsedDate['monthName'], 0, 3);
                     if (isset($monthNames[$monthName])) {
                         // Convert the month name to a two digit numeric month representation
                         // before adding it to the normalized date string.
                         $month = $monthNames[$monthName];
                     }
                 }
                 if (isset($parsedDate['month'])) {
                     $monthInt = (int) $parsedDate['month'];
                     if ($monthInt >= 1 && $monthInt <= 12) {
                         $month = str_pad((string) $monthInt, 2, '0', STR_PAD_LEFT);
                     }
                 }
                 if (!empty($month)) {
                     $normalizedDate .= '-' . $month;
                     if (isset($parsedDate['day'])) {
                         $normalizedDate .= '-' . str_pad($parsedDate['day'], 2, '0', STR_PAD_LEFT);
                     }
                 }
             }
             if (!empty($normalizedDate)) {
                 break;
             }
         }
     }
     return $normalizedDate;
 }
 /**
  * Submit a new test article.
  * @param $title string
  * @return integer the id of the new article
  */
 protected function submitArticle($title = 'Editing test article')
 {
     // We need to be logged in to submit an article.
     $this->logIn();
     $submissionPage = $this->baseUrl . '/index.php/lucene-test/author/submit/';
     //
     // First submission page.
     //
     $this->verifyAndOpen($submissionPage . '1');
     $this->waitForElementPresent('css=input.defaultButton');
     // Set Section.
     $this->select('sectionId', 'value=3');
     // Accept submission conditions.
     $checkboxId = 1;
     while ($this->isElementPresent("checklist-{$checkboxId}")) {
         $this->check("checklist-{$checkboxId}");
         $checkboxId++;
     }
     // Submit first submission page.
     $this->clickAndWait('css=input.defaultButton');
     //
     // Second submission page.
     //
     $this->waitForLocation($submissionPage . '2*');
     $this->waitForElementPresent('css=input.defaultButton');
     // We should now have the article ID in the URL.
     $url = $this->getLocation();
     $matches = null;
     String::regexp_match_get('/articleId=([0-9]+)/', $url, $matches);
     self::assertTrue(count($matches) == 2);
     $articleId = $matches[1];
     self::assertTrue(is_numeric($articleId));
     $articleId = (int) $articleId;
     // Submit the second submission page.
     $this->clickAndWait('css=input.defaultButton');
     $this->waitForConfirmation('*Are you sure you wish to continue*');
     //
     // Third submission page.
     //
     $this->waitForLocation($submissionPage . '3*');
     $this->waitForElementPresent('css=input.defaultButton');
     // Fill in article metadata.
     $this->type('authors-0-firstName', 'Arthur');
     $this->type('authors-0-lastName', 'McAutomatic');
     $this->type('title', $title);
     $this->verifyElementPresent('id=abstract_ifr');
     if ($this->verified()) {
         // TinyMCE hack.
         $jsScript = "selenium.browserbot.getCurrentWindow().document" . ".getElementById('abstract_ifr').contentDocument.body.innerHTML = " . "'{$title} abstract'";
         $this->getEval($jsScript);
     } else {
         $this->type('abstract', $title . ' abstract');
     }
     // Submit metadata.
     $this->clickAndWait('css=input.defaultButton');
     //
     // Fourth and fifth submission page.
     //
     $this->waitForLocation($submissionPage . '4*');
     $this->waitForElementPresent('css=input.defaultButton');
     // Do not upload any supplementary file and continue.
     $this->clickAndWait('css=input.defaultButton');
     $this->waitForLocation($submissionPage . '5*');
     $this->waitForElementPresent('css=input.defaultButton');
     // Confirm the submission.
     $this->clickAndWait('css=input.defaultButton');
     return $articleId;
 }
예제 #7
0
 /**
  * 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');
 }
예제 #8
0
 /**
  * @see Validator::isValid()
  * @param $value mixed
  * @return boolean
  */
 function isValid($value)
 {
     return (bool) String::regexp_match_get($this->_regExp, $value, $this->_matches);
 }
예제 #9
0
 /**
  * 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');
 }
예제 #10
0
 /**
  * @see OAIMetadataFormat#toXml
  * TODO:
  *  <copyright-holder>
  *  In Isabelle's mapping document:
  *   Article order in the issue's Table of Contents
  */
 function toXml(&$record, $format = null)
 {
     $article =& $record->getData('article');
     $journal =& $record->getData('journal');
     $section =& $record->getData('section');
     $issue =& $record->getData('issue');
     $galleys =& $record->getData('galleys');
     $articleId = $article->getId();
     // Cache issue ordering information.
     static $issueId;
     static $sectionSeq;
     if (!isset($issueId) || $issueId != $issue->getId()) {
         $sectionDao =& DAORegistry::getDAO('SectionDAO');
         $issueId = $issue->getId();
         $sections =& $sectionDao->getSectionsForIssue($issueId);
         $sectionSeq = array();
         $i = 0;
         foreach ($sections as $thisSection) {
             $sectionSeq[$thisSection->getSectionId()] = $i++;
         }
         unset($sections);
     }
     $abbreviation = $journal->getLocalizedSetting('abbreviation');
     $printIssn = $journal->getSetting('printIssn');
     $onlineIssn = $journal->getSetting('onlineIssn');
     $primaryLocale = $journal->getPrimaryLocale();
     $publisherInstitution = $journal->getSetting('publisherInstitution');
     $datePublished = strtotime($article->getDatePublished());
     $response = "<article\n" . "\txmlns=\"http://dtd.nlm.nih.gov/publishing/2.3\"\n" . "\txmlns:xlink=\"http://www.w3.org/1999/xlink\"\n" . "\txmlns:mml=\"http://www.w3.org/1998/Math/MathML\"\n" . "\txmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n" . "\txsi:schemaLocation=\"http://dtd.nlm.nih.gov/publishing/2.3\n" . "\thttp://dtd.nlm.nih.gov/publishing/2.3/xsd/journalpublishing.xsd\"\n" . (($s = $section->getSectionIdentifyType()) != '' ? "\tarticle-type=\"" . htmlspecialchars(Core::cleanVar($s)) . "\"" : '') . "\txml:lang=\"" . strtoupper(substr($primaryLocale, 0, 2)) . "\">\n" . "\t<front>\n" . "\t\t<journal-meta>\n" . "\t\t\t<journal-id journal-id-type=\"other\">" . htmlspecialchars(Core::cleanVar(($s = Config::getVar('oai', 'nlm_journal_id')) != '' ? $s : $journal->getPath())) . "</journal-id>\n" . "\t\t\t<journal-title>" . htmlspecialchars(Core::cleanVar($journal->getJournalTitle())) . "</journal-title>\n";
     // Include translated journal titles
     foreach ($journal->getTitle(null) as $locale => $title) {
         if ($locale == $primaryLocale) {
             continue;
         }
         $response .= "\t\t\t<trans-title xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">" . htmlspecialchars(Core::cleanVar($title)) . "</trans-title>\n";
     }
     $response .= (!empty($onlineIssn) ? "\t\t\t<issn pub-type=\"epub\">" . htmlspecialchars(Core::cleanVar($onlineIssn)) . "</issn>" : '') . (!empty($printIssn) ? "\t\t\t<issn pub-type=\"ppub\">" . htmlspecialchars(Core::cleanVar($printIssn)) . "</issn>" : '') . ($publisherInstitution != '' ? "\t\t\t<publisher><publisher-name>" . htmlspecialchars(Core::cleanVar($publisherInstitution)) . "</publisher-name></publisher>\n" : '') . "\t\t</journal-meta>\n" . "\t\t<article-meta>\n" . "\t\t\t<article-id pub-id-type=\"other\">" . htmlspecialchars(Core::cleanVar($article->getBestArticleId())) . "</article-id>\n" . (($s = $article->getDOI()) != '' ? "\t\t\t<article-id pub-id-type=\"doi\">" . htmlspecialchars(Core::cleanVar($s)) . "</article-id>\n" : '') . "\t\t\t<article-categories><subj-group subj-group-type=\"heading\"><subject>" . htmlspecialchars(Core::cleanVar($section->getSectionTitle())) . "</subject></subj-group></article-categories>\n" . "\t\t\t<title-group>\n" . "\t\t\t\t<article-title>" . htmlspecialchars(Core::cleanVar(strip_tags($article->getArticleTitle()))) . "</article-title>\n";
     // Include translated journal titles
     foreach ($article->getTitle(null) as $locale => $title) {
         if ($locale == $primaryLocale) {
             continue;
         }
         $response .= "\t\t\t\t<trans-title xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">" . htmlspecialchars(Core::cleanVar(strip_tags($title))) . "</trans-title>\n";
     }
     $response .= "\t\t\t</title-group>\n" . "\t\t\t<contrib-group>\n";
     // Include authors
     foreach ($article->getAuthors() as $author) {
         $response .= "\t\t\t\t<contrib " . ($author->getPrimaryContact() ? 'corresp="yes" ' : '') . "contrib-type=\"author\">\n" . "\t\t\t\t\t<name name-style=\"western\">\n" . "\t\t\t\t\t\t<surname>" . htmlspecialchars(Core::cleanVar($author->getLastName())) . "</surname>\n" . "\t\t\t\t\t\t<given-names>" . htmlspecialchars(Core::cleanVar($author->getFirstName()) . (($s = $author->getMiddleName()) != '' ? " {$s}" : '')) . "</given-names>\n" . "\t\t\t\t\t</name>\n" . (($s = $author->getAffiliation()) != '' ? "\t\t\t\t\t<aff>" . htmlspecialchars(Core::cleanVar($s)) . "</aff>\n" : '') . "\t\t\t\t\t<email>" . htmlspecialchars(Core::cleanVar($author->getEmail())) . "</email>\n" . (($s = $author->getUrl()) != '' ? "\t\t\t\t\t<uri>" . htmlspecialchars(Core::cleanVar($s)) . "</uri>\n" : '') . "\t\t\t\t</contrib>\n";
     }
     // Include editorships (optimized)
     $response .= $this->getEditorialInfo($journal->getId());
     $response .= "\t\t\t</contrib-group>\n" . "\t\t\t<pub-date pub-type=\"epub\">\n" . "\t\t\t\t<day>" . strftime('%d', $datePublished) . "</day>\n" . "\t\t\t\t<month>" . strftime('%m', $datePublished) . "</month>\n" . "\t\t\t\t<year>" . strftime('%Y', $datePublished) . "</year>\n" . "\t\t\t</pub-date>\n" . ($issue->getShowYear() ? "\t\t\t<pub-date pub-type=\"collection\"><year>" . htmlspecialchars(Core::cleanVar($issue->getYear())) . "</year></pub-date>\n" : '') . ($issue->getShowVolume() ? "\t\t\t<volume>" . htmlspecialchars(Core::cleanVar($issue->getVolume())) . "</volume>\n" : '') . ($issue->getShowNumber() ? "\t\t\t<issue seq=\"" . htmlspecialchars(Core::cleanVar($sectionSeq[$section->getId()] * 100 + $article->getSeq())) . "\">" . htmlspecialchars(Core::cleanVar($issue->getNumber())) . "</issue>\n" : '') . "\t\t\t<issue-id pub-id-type=\"other\">" . htmlspecialchars(Core::cleanVar($issue->getBestIssueId())) . "</issue-id>\n" . ($issue->getShowTitle() ? "\t\t\t<issue-title>" . htmlspecialchars(Core::cleanVar($issue->getIssueTitle())) . "</issue-title>\n" : '');
     // Include page info, if available and parseable.
     $matches = null;
     if (String::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)$/', $article->getPages(), $matches)) {
         $matchedPage = htmlspecialchars(Core::cleanVar($matches[1]));
         $response .= "\t\t\t\t<fpage>{$matchedPage}</fpage><lpage>{$matchedPage}</lpage>\n";
         $pageCount = 1;
     } elseif (String::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)[ ]?-[ ]?([Pp][Pp]?[.]?[ ]?)?(\\d+)$/', $article->getPages(), $matches)) {
         $matchedPageFrom = htmlspecialchars(Core::cleanVar($matches[1]));
         $matchedPageTo = htmlspecialchars(Core::cleanVar($matches[3]));
         $response .= "\t\t\t\t<fpage>{$matchedPageFrom}</fpage>\n" . "\t\t\t\t<lpage>{$matchedPageTo}</lpage>\n";
         $pageCount = $matchedPageTo - $matchedPageFrom + 1;
     }
     $response .= "\t\t\t<permissions>\n" . (($s = $journal->getLocalizedSetting('copyrightNotice')) != '' ? "\t\t\t\t<copyright-statement>" . htmlspecialchars(Core::cleanVar($s)) . "</copyright-statement>\n" : '') . "\t\t\t\t<copyright-year>" . strftime('%Y', $datePublished) . "</copyright-year>\n" . "\t\t\t</permissions>\n" . "\t\t\t<self-uri xlink:href=\"" . htmlspecialchars(Core::cleanVar(Request::url($journal->getPath(), 'article', 'view', $article->getBestArticleId()))) . "\" />\n";
     // Include galley links
     foreach ($article->getGalleys() as $galley) {
         $response .= "\t\t\t<self-uri content-type=\"" . htmlspecialchars(Core::cleanVar($galley->getFileType())) . "\" xlink:href=\"" . htmlspecialchars(Core::cleanVar(Request::url($journal->getPath(), 'article', 'view', array($article->getBestArticleId(), $galley->getId())))) . "\" />\n";
     }
     // Include abstract(s)
     $abstract = htmlspecialchars(Core::cleanVar(strip_tags($article->getArticleAbstract())));
     if (!empty($abstract)) {
         $abstract = "<p>{$abstract}</p>";
         // $abstract = '<p>' . String::regexp_replace('/\n+/', '</p><p>', $abstract) . '</p>';
         $response .= "\t\t\t<abstract xml:lang=\"" . strtoupper(substr($primaryLocale, 0, 2)) . "\">{$abstract}</abstract>\n";
     }
     if (is_array($article->getAbstract(null))) {
         foreach ($article->getAbstract(null) as $locale => $abstract) {
             if ($locale == $primaryLocale || empty($abstract)) {
                 continue;
             }
             $abstract = htmlspecialchars(Core::cleanVar(strip_tags($abstract)));
             if (empty($abstract)) {
                 continue;
             }
             $abstract = "<p>{$abstract}</p>";
             //$abstract = '<p>' . String::regexp_replace('/\n+/', '</p><p>', $abstract) . '</p>';
             $response .= "\t\t\t<abstract-trans xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">{$abstract}</abstract-trans>\n";
         }
     }
     $subjects = array();
     if (is_array($article->getSubject(null))) {
         foreach ($article->getSubject(null) as $locale => $subject) {
             $s = array_map('trim', explode(';', Core::cleanVar($subject)));
             if (!empty($s)) {
                 $subjects[$locale] = $s;
             }
         }
     }
     if (!empty($subjects)) {
         foreach ($subjects as $locale => $s) {
             $response .= "\t\t\t<kwd-group xml:lang=\"" . strtoupper(substr($locale, 0, 2)) . "\">\n";
             foreach ($s as $subject) {
                 $response .= "\t\t\t\t<kwd>" . htmlspecialchars($subject) . "</kwd>\n";
             }
             $response .= "\t\t\t</kwd-group>\n";
         }
     }
     $response .= (isset($pageCount) ? "\t\t\t<counts><page-count count=\"" . (int) $pageCount . "\" /></counts>\n" : '') . "\t\t</article-meta>\n" . "\t</front>\n";
     // Include body text (for search indexing only)
     import('search.ArticleSearchIndex');
     $text = '';
     $galleys = $article->getGalleys();
     // Give precedence to HTML galleys, as they're quickest to parse
     usort($galleys, create_function('$a, $b', 'return $a->isHtmlGalley()?-1:1;'));
     // Determine any access limitations. If there are, do not
     // provide the full-text.
     import('issue.IssueAction');
     $subscriptionRequired = IssueAction::subscriptionRequired($issue);
     $isSubscribedDomain = IssueAction::subscribedDomain($journal, $issue->getId(), $article->getId());
     if (!$subscriptionRequired || $isSubscribedDomain) {
         foreach ($galleys as $galley) {
             $parser =& SearchFileParser::fromFile($galley);
             if ($parser && $parser->open()) {
                 while (($s = $parser->read()) !== false) {
                     $text .= $s;
                 }
                 $parser->close();
             }
             if ($galley->isHtmlGalley()) {
                 $text = strip_tags($text);
             }
             unset($galley);
             // Use the first parseable galley.
             if (!empty($text)) {
                 break;
             }
         }
     }
     if (!empty($text)) {
         $response .= "\t<body><p>" . htmlspecialchars(Core::cleanVar(Core::cleanVar($text))) . "</p></body>\n";
     }
     $response .= "</article>";
     return $response;
 }
예제 #11
0
 /**
  * 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');
 }
    /**
     * Authenticate against the AnthroNET portal.
     * @return String the auth token if successful
     */
    function _doAuthenticate()
    {
        // Build the multipart SOAP message from scratch.
        $journal =& Request::getJournal();
        $ofrPlugin =& $this->_getObjectsForReviewPlugin();
        $soapMessage = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="http://www.avectra.com/2005/">
			<soapenv:Header />
			<soapenv:Body>
				<ns:Authenticate>
					<ns:userName>' . $ofrPlugin->getSetting($journal->getId(), 'anthroNetUsername') . '</ns:userName>
					<ns:password><![CDATA[' . $ofrPlugin->getSetting($journal->getId(), 'anthroNetPassword') . ']]></ns:password>
				</ns:Authenticate>
			</soapenv:Body>
		</soapenv:Envelope>';
        // Prepare HTTP session.
        $curlCh = curl_init();
        curl_setopt($curlCh, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curlCh, CURLOPT_POST, true);
        // Set up SSL.
        curl_setopt($curlCh, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($curlCh, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1);
        // Make SOAP request.
        curl_setopt($curlCh, CURLOPT_URL, $ofrPlugin->getSetting($journal->getId(), 'anthroNetSoapURL'));
        $extraHeaders = array('Host: avectra.aaanet.org', 'SOAPAction: "http://www.avectra.com/2005/Authenticate"', 'Content-Type: text/xml;charset=UTF-8');
        curl_setopt($curlCh, CURLOPT_HTTPHEADER, $extraHeaders);
        curl_setopt($curlCh, CURLOPT_POSTFIELDS, $soapMessage);
        $result = true;
        $response = curl_exec($curlCh);
        // We do not localize our error messages as they are all
        // fatal errors anyway and must be analyzed by technical staff.
        if ($response === false) {
            $result = 'OJS-OFR: Expected string response.';
        }
        if ($result === true && ($status = curl_getinfo($curlCh, CURLINFO_HTTP_CODE)) != OFR_WS_RESPONSE_OK) {
            $result = 'OJS-OFR: Expected ' . OFR_WS_RESPONSE_OK . ' response code, got ' . $status . ' instead.';
        }
        curl_close($curlCh);
        // Check SOAP response by simple string manipulation rather
        // than instantiating a DOM.
        if (is_string($response)) {
            $matches = array();
            String::regexp_match_get('#<Token>([^<]*)</Token>#', $response, $matches);
            if (!empty($matches)) {
                $result = $matches[1];
            } else {
                $result = 'OFR: ' . $status . ' - ' . $matches[1];
            }
        } else {
            $result = 'OJS-OFR: Expected string response.';
        }
        return $result;
    }
예제 #13
0
 /**
  * Processes form-submitted addresses for inclusion in
  * the recipient list
  * @param $currentList array Current recipient/cc/bcc list
  * @param $newAddresses array "Raw" form parameter for additional addresses
  */
 function &processAddresses($currentList, &$newAddresses)
 {
     foreach ($newAddresses as $newAddress) {
         $regs = array();
         // Match the form "My Name <*****@*****.**>"
         if (String::regexp_match_get('/^([^<>' . "\n" . ']*[^<> ' . "\n" . '])[ ]*<(?P<email>' . PCRE_EMAIL_ADDRESS . ')>$/i', $newAddress, $regs)) {
             $currentList[] = array('name' => $regs[1], 'email' => $regs['email']);
         } elseif (String::regexp_match_get('/^<?(?P<email>' . PCRE_EMAIL_ADDRESS . ')>?$/i', $newAddress, $regs)) {
             $currentList[] = array('name' => '', 'email' => $regs['email']);
         } elseif ($newAddress != '') {
             $this->errorMessages[] = array('type' => MAIL_ERROR_INVALID_EMAIL, 'address' => $newAddress);
         }
     }
     return $currentList;
 }
예제 #14
0
 /**
  * Handle fetch requests for this plugin.
  */
 function fetch($args, $request)
 {
     if (!$this->getEnabled()) {
         return false;
     }
     $scheme = array_shift($args);
     switch ($scheme) {
         case 'doi':
             $doi = implode('/', $args);
             $journal =& $request->getJournal();
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $articles =& $publishedArticleDao->getPublishedArticlesByDOI($doi, $journal ? $journal->getId() : null);
             while ($article =& $articles->next()) {
                 $request->redirect(null, 'article', 'view', $article->getBestArticleId());
             }
             break;
         case 'vnp':
             // Volume, number, page
         // Volume, number, page
         case 'ynp':
             // Volume, number, year, page
             // This can only be used from within a journal context
             $journal =& Request::getJournal();
             if (!$journal) {
                 break;
             }
             if ($scheme == 'vnp') {
                 $volume = (int) array_shift($args);
                 $year = null;
             } elseif ($scheme == 'ynp') {
                 $year = (int) array_shift($args);
                 $volume = null;
             }
             $number = array_shift($args);
             $page = (int) array_shift($args);
             $issueDao =& DAORegistry::getDAO('IssueDAO');
             $issues =& $issueDao->getPublishedIssuesByNumber($journal->getId(), $volume, $number, $year);
             // Ensure only one issue matched, and fetch it.
             $issue =& $issues->next();
             if (!$issue || $issues->next()) {
                 break;
             }
             unset($issues);
             $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
             $articles =& $publishedArticleDao->getPublishedArticles($issue->getId());
             foreach ($articles as $article) {
                 // Look for the correct page in the list of articles.
                 $matches = null;
                 if (String::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)$/', $article->getPages(), $matches)) {
                     $matchedPage = $matches[1];
                     if ($page == $matchedPage) {
                         Request::redirect(null, 'article', 'view', $article->getBestArticleId());
                     }
                 }
                 if (String::regexp_match_get('/^[Pp][Pp]?[.]?[ ]?(\\d+)[ ]?-[ ]?([Pp][Pp]?[.]?[ ]?)?(\\d+)$/', $article->getPages(), $matches)) {
                     $matchedPageFrom = $matches[1];
                     $matchedPageTo = $matches[3];
                     if ($page >= $matchedPageFrom && ($page < $matchedPageTo || $page == $matchedPageTo && ($matchedPageFrom = $matchedPageTo))) {
                         Request::redirect(null, 'article', 'view', $article->getBestArticleId());
                     }
                 }
                 unset($article);
             }
     }
     // Failure.
     header("HTTP/1.0 500 Internal Server Error");
     $templateMgr =& TemplateManager::getManager();
     Locale::requireComponents(array(LOCALE_COMPONENT_APPLICATION_COMMON));
     $templateMgr->assign('message', 'plugins.gateways.resolver.errors.errorMessage');
     $templateMgr->display('common/message.tpl');
     exit;
 }
 /**
  * Fills the given citation object with
  * meta-data retrieved from PubMed.
  * @param $pmid string
  * @return MetadataDescription
  */
 function &_lookup($pmid)
 {
     $nullVar = null;
     // Use eFetch to get XML metadata for the given PMID
     $lookupParams = array('db' => 'pubmed', 'mode' => 'xml', 'tool' => 'pkp-wal', 'id' => $pmid);
     if (!is_null($this->getEmail())) {
         $lookupParams['email'] = $this->getEmail();
     }
     // Call the eFetch URL and get an XML result
     if (is_null($resultDOM = $this->callWebService(PUBMED_WEBSERVICE_EFETCH, $lookupParams))) {
         return $nullVar;
     }
     $articleTitleNodes =& $resultDOM->getElementsByTagName("ArticleTitle");
     $articleTitleFirstNode =& $articleTitleNodes->item(0);
     $medlineTaNodes =& $resultDOM->getElementsByTagName("MedlineTA");
     $medlineTaFirstNode =& $medlineTaNodes->item(0);
     $metadata = array('pub-id[@pub-id-type="pmid"]' => $pmid, 'article-title' => $articleTitleFirstNode->textContent, 'source' => $medlineTaFirstNode->textContent);
     $volumeNodes =& $resultDOM->getElementsByTagName("Volume");
     $issueNodes =& $resultDOM->getElementsByTagName("Issue");
     if ($volumeNodes->length > 0) {
         $volumeFirstNode =& $volumeNodes->item(0);
     }
     $metadata['volume'] = $volumeFirstNode->textContent;
     if ($issueNodes->length > 0) {
         $issueFirstNode =& $issueNodes->item(0);
     }
     $metadata['issue'] = $issueFirstNode->textContent;
     // Get list of author full names
     foreach ($resultDOM->getElementsByTagName("Author") as $authorNode) {
         if (!isset($metadata['person-group[@person-group-type="author"]'])) {
             $metadata['person-group[@person-group-type="author"]'] = array();
         }
         // Instantiate an NLM name description
         $authorDescription = new MetadataDescription('lib.pkp.plugins.metadata.nlm30.schema.Nlm30NameSchema', ASSOC_TYPE_AUTHOR);
         // Surname
         $lastNameNodes =& $authorNode->getElementsByTagName("LastName");
         $lastNameFirstNode =& $lastNameNodes->item(0);
         $authorDescription->addStatement('surname', $lastNameFirstNode->textContent);
         // Given names
         $givenNamesString = '';
         $firstNameNodes =& $authorNode->getElementsByTagName("FirstName");
         if ($firstNameNodes->length > 0) {
             $firstNameFirstNode =& $firstNameNodes->item(0);
             $givenNamesString = $firstNameFirstNode->textContent;
         } else {
             $foreNameNodes =& $authorNode->getElementsByTagName("ForeName");
             if ($foreNameNodes->length > 0) {
                 $foreNameFirstNode =& $foreNameNodes->item(0);
                 $givenNamesString = $foreNameFirstNode->textContent;
             }
         }
         if (!empty($givenNamesString)) {
             foreach (explode(' ', $givenNamesString) as $givenName) {
                 $authorDescription->addStatement('given-names', String::trimPunctuation($givenName));
             }
         }
         // Suffix
         $suffixNodes =& $authorNode->getElementsByTagName("Suffix");
         if ($suffixNodes->length > 0) {
             $suffixFirstNode =& $suffixNodes->item(0);
             $authorDescription->addStatement('suffix', $suffixFirstNode->textContent);
         }
         // Include collective names
         // FIXME: This corresponds to an NLM-citation <collab> tag and should be part of the Metadata implementation
         /*if ($resultDOM->getElementsByTagName("CollectiveName")->length > 0 && $authorNode->getElementsByTagName("CollectiveName")->item(0)->textContent != '') {
         		}*/
         $metadata['person-group[@person-group-type="author"]'][] =& $authorDescription;
         unset($authorDescription);
     }
     // Extract pagination
     $medlinePgnNodes =& $resultDOM->getElementsByTagName("MedlinePgn");
     $medlinePgnFirstNode =& $medlinePgnNodes->item(0);
     if (String::regexp_match_get("/^[:p\\.\\s]*(?P<fpage>[Ee]?\\d+)(-(?P<lpage>\\d+))?/", $medlinePgnFirstNode->textContent, $pages)) {
         $fPage = (int) $pages['fpage'];
         $metadata['fpage'] = $fPage;
         if (!empty($pages['lpage'])) {
             $lPage = (int) $pages['lpage'];
             // Deal with shortcuts like '382-7'
             if ($lPage < $fPage) {
                 $lPage = (int) (String::substr($pages['fpage'], 0, -String::strlen($pages['lpage'])) . $pages['lpage']);
             }
             $metadata['lpage'] = $lPage;
         }
     }
     // Get publication date (can be in several places in PubMed).
     $dateNode = null;
     $articleDateNodes =& $resultDOM->getElementsByTagName("ArticleDate");
     if ($articleDateNodes->length > 0) {
         $dateNode =& $articleDateNodes->item(0);
     } else {
         $pubDateNodes =& $resultDOM->getElementsByTagName("PubDate");
         if ($pubDateNodes->length > 0) {
             $dateNode =& $pubDateNodes->item(0);
         }
     }
     // Retrieve the data parts and assemble date.
     if (!is_null($dateNode)) {
         $publicationDate = '';
         $requiresNormalization = false;
         foreach (array('Year' => 4, 'Month' => 2, 'Day' => 2) as $dateElement => $padding) {
             $dateElementNodes =& $dateNode->getElementsByTagName($dateElement);
             if ($dateElementNodes->length > 0) {
                 if (!empty($publicationDate)) {
                     $publicationDate .= '-';
                 }
                 $dateElementFirstNode =& $dateElementNodes->item(0);
                 $datePart = str_pad($dateElementFirstNode->textContent, $padding, '0', STR_PAD_LEFT);
                 if (!is_numeric($datePart)) {
                     $requiresNormalization = true;
                 }
                 $publicationDate .= $datePart;
             } else {
                 break;
             }
         }
         // Normalize the date to NLM standard if necessary.
         if ($requiresNormalization) {
             $dateFilter = new DateStringNormalizerFilter();
             $publicationDate = $dateFilter->execute($publicationDate);
         }
         if (!empty($publicationDate)) {
             $metadata['date'] = $publicationDate;
         }
     }
     // Get publication type
     $publicationTypeNodes =& $resultDOM->getElementsByTagName("PublicationType");
     if ($publicationTypeNodes->length > 0) {
         foreach ($publicationTypeNodes as $publicationType) {
             // The vast majority of items on PubMed are articles so catch these...
             if (String::strpos(String::strtolower($publicationType->textContent), 'article') !== false) {
                 $metadata['[@publication-type]'] = NLM30_PUBLICATION_TYPE_JOURNAL;
                 break;
             }
         }
     }
     // Get DOI if it exists
     $articleIdNodes =& $resultDOM->getElementsByTagName("ArticleId");
     foreach ($articleIdNodes as $idNode) {
         if ($idNode->getAttribute('IdType') == 'doi') {
             $metadata['pub-id[@pub-id-type="doi"]'] = $idNode->textContent;
         }
     }
     // Use eLink utility to find fulltext links
     $lookupParams = array('dbfrom' => 'pubmed', 'cmd' => 'llinks', 'tool' => 'pkp-wal', 'id' => $pmid);
     if (!is_null($resultDOM = $this->callWebService(PUBMED_WEBSERVICE_ELINK, $lookupParams))) {
         // Get a list of possible links
         foreach ($resultDOM->getElementsByTagName("ObjUrl") as $linkOut) {
             $attributes = '';
             foreach ($linkOut->getElementsByTagName("Attribute") as $attribute) {
                 $attributes .= String::strtolower($attribute->textContent) . ' / ';
             }
             // Only add links to open access resources
             if (String::strpos($attributes, "subscription") === false && String::strpos($attributes, "membership") === false && String::strpos($attributes, "fee") === false && $attributes != "") {
                 $urlNodes =& $linkOut->getElementsByTagName("Url");
                 $urlFirstNode =& $urlNodes->item(0);
                 $links[] = $urlFirstNode->textContent;
             }
         }
         // Take the first link if we have any left (presumably pubmed returns them in preferential order)
         if (isset($links[0])) {
             $metadata['uri'] = $links[0];
         }
     }
     return $this->getNlm30CitationDescriptionFromMetadataArray($metadata);
 }
예제 #16
0
 /**
  * Given a locale string, get the list of parameter references of the
  * form {$myParameterName}.
  * @param $source string
  * @return array
  */
 function getParameterNames($source)
 {
     $matches = null;
     String::regexp_match_get('/({\\$[^}]+})/', $source, $matches);
     array_shift($matches);
     // Knock the top element off the array
     return $matches;
 }
예제 #17
0
 /**
  * Do the actual web service request.
  * @param $action string
  * @param $arg string
  * @param $attachment array
  * @return boolean|string True for success, an error message otherwise.
  */
 function _doRequest($action, $arg, $attachment = null)
 {
     // Build the multipart SOAP message from scratch.
     $soapMessage = '<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" ' . 'xmlns:med="http://www.medra.org">' . '<SOAP-ENV:Header/>' . '<SOAP-ENV:Body>' . "<med:{$action}>{$arg}</med:{$action}>" . '</SOAP-ENV:Body>' . '</SOAP-ENV:Envelope>';
     $soapMessageId = $this->_getContentId($action);
     if ($attachment) {
         assert(count($attachment) == 1);
         $request = "--MIME_boundary\r\n" . $this->_getMimePart($soapMessageId, $soapMessage) . "--MIME_boundary\r\n" . $this->_getMimePart(key($attachment), current($attachment)) . "--MIME_boundary--\r\n";
         $contentType = 'multipart/related; type="text/xml"; boundary="MIME_boundary"';
     } else {
         $request = $soapMessage;
         $contentType = 'text/xml';
     }
     // Prepare HTTP session.
     $curlCh = curl_init();
     curl_setopt($curlCh, CURLOPT_RETURNTRANSFER, true);
     curl_setopt($curlCh, CURLOPT_POST, true);
     // Set up basic authentication.
     curl_setopt($curlCh, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
     curl_setopt($curlCh, CURLOPT_USERPWD, $this->_auth);
     // Set up SSL.
     curl_setopt($curlCh, CURLOPT_SSLVERSION, 3);
     curl_setopt($curlCh, CURLOPT_SSL_VERIFYPEER, false);
     // Make SOAP request.
     curl_setopt($curlCh, CURLOPT_URL, $this->_endpoint);
     $extraHeaders = array('SOAPAction: "' . $action . '"', 'Content-Type: ' . $contentType, 'UserAgent: OJS-mEDRA');
     curl_setopt($curlCh, CURLOPT_HTTPHEADER, $extraHeaders);
     curl_setopt($curlCh, CURLOPT_POSTFIELDS, $request);
     $result = true;
     $response = curl_exec($curlCh);
     // We do not localize our error messages as they are all
     // fatal errors anyway and must be analyzed by technical staff.
     if ($response === false) {
         $result = 'OJS-mEDRA: Expected string response.';
     }
     if ($result === true && ($status = curl_getinfo($curlCh, CURLINFO_HTTP_CODE)) != MEDRA_WS_RESPONSE_OK) {
         $result = 'OJS-mEDRA: Expected ' . MEDRA_WS_RESPONSE_OK . ' response code, got ' . $status . ' instead.';
     }
     curl_close($curlCh);
     // Check SOAP response by simple string manipulation rather
     // than instantiating a DOM.
     if (is_string($response)) {
         $matches = array();
         String::regexp_match_get('#<faultstring>([^<]*)</faultstring>#', $response, $matches);
         if (empty($matches)) {
             if ($attachment) {
                 assert(String::regexp_match('#<returnCode>success</returnCode>#', $response));
             } else {
                 $parts = explode("\r\n\r\n", $response);
                 $result = array_pop($parts);
                 $result = String::regexp_replace('/>[^>]*$/', '>', $result);
             }
         } else {
             $result = 'mEDRA: ' . $status . ' - ' . $matches[1];
         }
     } else {
         $result = 'OJS-mEDRA: Expected string response.';
     }
     return $result;
 }
 /**
  * Converts a string with a single person
  * to an NLM name description.
  *
  * TODO: add initials from all given names to initials
  *       element
  *
  * @param $personString string
  * @param $title boolean true to parse for title
  * @param $degrees boolean true to parse for degrees
  * @return MetadataDescription an NLM name description or null
  *  if the string could not be converted
  */
 function &_parsePersonString($personString, $title, $degrees)
 {
     // Expressions to parse person strings, ported from CiteULike person
     // plugin, see http://svn.citeulike.org/svn/plugins/person.tcl
     static $personRegex = array('title' => '(?:His (?:Excellency|Honou?r)\\s+|Her (?:Excellency|Honou?r)\\s+|The Right Honou?rable\\s+|The Honou?rable\\s+|Right Honou?rable\\s+|The Rt\\.? Hon\\.?\\s+|The Hon\\.?\\s+|Rt\\.? Hon\\.?\\s+|Mr\\.?\\s+|Ms\\.?\\s+|M\\/s\\.?\\s+|Mrs\\.?\\s+|Miss\\.?\\s+|Dr\\.?\\s+|Sir\\s+|Dame\\s+|Prof\\.?\\s+|Professor\\s+|Doctor\\s+|Mister\\s+|Mme\\.?\\s+|Mast(?:\\.|er)?\\s+|Lord\\s+|Lady\\s+|Madam(?:e)?\\s+|Priv\\.-Doz\\.\\s+)+', 'degrees' => '(,\\s+(?:[A-Z\\.]+))+', 'initials' => '(?:(?:[A-Z]\\.){1,3}[A-Z]\\.?)|(?:(?:[A-Z]\\.\\s){1,3}[A-Z]\\.?)|(?:[A-Z]{1,4})|(?:(?:[A-Z]\\.-?){1,4})|(?:(?:[A-Z]\\.-?){1,3}[A-Z]\\.?)|(?:(?:[A-Z]-){1,3}[A-Z])|(?:(?:[A-Z]\\s){1,3}[A-Z]\\.?)|(?:(?:[A-Z]-){1,3}[A-Z]\\.?)', 'prefix' => 'Dell(?:[a|e])?(?:\\s|$)|Dalle(?:\\s|$)|D[a|e]ll\'(?:\\s|$)|Dela(?:\\s|$)|Del(?:\\s|$)|[Dd]e(?:\\s|$)(?:La(?:\\s|$)|Los(?:\\s|$))?|[Dd]e(?:\\s|$)|[Dd][a|i|u](?:\\s|$)|L[a|e|o](?:\\s|$)|[D|L|O]\'|St\\.?(?:\\s|$)|San(?:\\s|$)|[Dd]en(?:\\s|$)|[Vv]on(?:\\s|$)(?:[Dd]er(?:\\s|$))?|(?:[Ll][ea](?:\\s|$))?[Vv]an(?:\\s|$)(?:[Dd]e(?:n|r)?(?:\\s|$))?', 'givenName' => '(?:[^ \\t\\n\\r\\f\\v,.;()]{2,}|[^ \\t\\n\\r\\f\\v,.;()]{2,}\\-[^ \\t\\n\\r\\f\\v,.;()]{2,})');
     // The expressions for given name, suffix and surname are the same
     $personRegex['surname'] = $personRegex['suffix'] = $personRegex['givenName'];
     $personRegex['double-surname'] = "(?:" . $personRegex['surname'] . "\\s)*" . $personRegex['surname'];
     // Shortcut for prefixed surname
     $personRegexPrefixedSurname = "(?P<prefix>(?:" . $personRegex['prefix'] . ")?)(?P<surname>" . $personRegex['surname'] . ")";
     $personRegexPrefixedDoubleSurname = "(?P<prefix>(?:" . $personRegex['prefix'] . ")?)(?P<surname>" . $personRegex['double-surname'] . ")";
     // Instantiate the target person description
     $personDescription = new MetadataDescription('lib.pkp.plugins.metadata.nlm30.schema.Nlm30NameSchema', $this->_assocType);
     // Clean the person string
     $personString = trim($personString);
     // 1. Extract title and degree from the person string and use this as suffix
     $suffixString = '';
     $results = array();
     if ($title && String::regexp_match_get('/^(' . $personRegex['title'] . ')/i', $personString, $results)) {
         $suffixString = trim($results[1], ',:; ');
         $personString = String::regexp_replace('/^(' . $personRegex['title'] . ')/i', '', $personString);
     }
     if ($degrees && String::regexp_match_get('/(' . $personRegex['degrees'] . ')$/i', $personString, $results)) {
         $degreesArray = explode(',', trim($results[1], ','));
         foreach ($degreesArray as $key => $degree) {
             $degreesArray[$key] = String::trimPunctuation($degree);
         }
         $suffixString .= ' - ' . implode('; ', $degreesArray);
         $personString = String::regexp_replace('/(' . $personRegex['degrees'] . ')$/i', '', $personString);
     }
     if (!empty($suffixString)) {
         $personDescription->addStatement('suffix', $suffixString);
     }
     // Space initials when followed by a given name or last name.
     $personString = String::regexp_replace('/([A-Z])\\.([A-Z][a-z])/', '\\1. \\2', $personString);
     // 2. Extract names and initials from the person string
     // The parser expressions are ordered by specificity. The most specific expressions
     // come first. Only if these specific expressions don't work will we turn to less
     // specific ones. This avoids parsing errors. It also explains why we don't use the
     // ?-quantifier for optional elements like initials or middle name where they could
     // be misinterpreted.
     $personExpressions = array('/^' . $personRegexPrefixedSurname . '$/i', '/^(?P<initials>' . $personRegex['initials'] . ')\\s' . $personRegexPrefixedSurname . '$/', '/^' . $personRegexPrefixedSurname . ',?\\s(?P<initials>' . $personRegex['initials'] . ')$/', '/^' . $personRegexPrefixedDoubleSurname . ',\\s(?P<givenName>' . $personRegex['givenName'] . ')\\s(?P<initials>' . $personRegex['initials'] . ')$/', '/^(?P<givenName>' . $personRegex['givenName'] . ')\\s(?P<initials>' . $personRegex['initials'] . ')\\s' . $personRegexPrefixedSurname . '$/', '/^' . $personRegexPrefixedDoubleSurname . ',\\s(?P<givenName>(?:' . $personRegex['givenName'] . '\\s)+)(?P<initials>' . $personRegex['initials'] . ')$/', '/^(?P<givenName>(?:' . $personRegex['givenName'] . '\\s)+)(?P<initials>' . $personRegex['initials'] . ')\\s' . $personRegexPrefixedSurname . '$/', '/^' . $personRegexPrefixedDoubleSurname . ',(?P<givenName>(?:\\s' . $personRegex['givenName'] . ')+)$/', '/^(?P<givenName>(?:' . $personRegex['givenName'] . '\\s)+)' . $personRegexPrefixedSurname . '$/', '/^\\s*(?P<surname>' . $personRegex['surname'] . ')(?P<suffix>(?:\\s+' . $personRegex['suffix'] . ')?)\\s*,\\s*(?P<initials>(?:' . $personRegex['initials'] . ')?)\\s*\\((?P<givenName>(?:\\s*' . $personRegex['givenName'] . ')+)\\s*\\)\\s*(?P<prefix>(?:' . $personRegex['prefix'] . ')?)$/', '/^(?P<givenName>' . $personRegex['givenName'] . ')\\.(?P<surname>' . $personRegex['double-surname'] . ')$/', '/^(?P<surname>.*)$/');
     $results = array();
     foreach ($personExpressions as $expressionId => $personExpression) {
         if ($nameFound = String::regexp_match_get($personExpression, $personString, $results)) {
             // Given names
             if (!empty($results['givenName'])) {
                 // Split given names
                 $givenNames = explode(' ', trim($results['givenName']));
                 foreach ($givenNames as $givenName) {
                     $personDescription->addStatement('given-names', $givenName);
                     unset($givenName);
                 }
             }
             // Initials (will also be saved as given names)
             if (!empty($results['initials'])) {
                 $results['initials'] = str_replace(array('.', '-', ' '), array('', '', ''), $results['initials']);
                 for ($initialNum = 0; $initialNum < String::strlen($results['initials']); $initialNum++) {
                     $initial = $results['initials'][$initialNum];
                     $personDescription->addStatement('given-names', $initial);
                     unset($initial);
                 }
             }
             // Surname
             if (!empty($results['surname'])) {
                 // Correct all-upper surname
                 if (strtoupper($results['surname']) == $results['surname']) {
                     $results['surname'] = ucwords(strtolower($results['surname']));
                 }
                 $personDescription->addStatement('surname', $results['surname']);
             }
             // Prefix/Suffix
             foreach (array('prefix', 'suffix') as $propertyName) {
                 if (!empty($results[$propertyName])) {
                     $results[$propertyName] = trim($results[$propertyName]);
                     $personDescription->addStatement($propertyName, $results[$propertyName]);
                 }
             }
             break;
         }
     }
     return $personDescription;
 }
 /**
  * @see Filter::process()
  * @param $citationString string
  * @return MetadataDescription
  */
 function &process($citationString)
 {
     // Initialize the parser result array
     $matches = array();
     $metadata = array();
     // Parse out any embedded URLs
     $urlPattern = '(<?(https?://([-\\w\\.]+)+(:\\d+)?(/([\\w/_\\.,]*(\\?[^\\s>]+)?)?)?)>?)';
     if (String::regexp_match_get($urlPattern, $citationString, $matches)) {
         // Assume that the URL is a link to the resource.
         $metadata['uri'] = $matches[1];
         // Remove the URL from the citation string
         $citationString = String::regexp_replace($urlPattern, '', $citationString);
         // If the URL is a link to PubMed, save the PMID
         $pmIdExpressions = array('/list_uids=(?P<pmId>\\d+)/i', '/pubmed.*details_term=(?P<pmId>\\d+)/i', '/pubmedid=(?P<pmId>\\d+)/i');
         foreach ($pmIdExpressions as $pmIdExpression) {
             if (String::regexp_match_get($pmIdExpression, $matches[1], $pmIdMatches)) {
                 $metadata['pub-id[@pub-id-type="pmid"]'] = $pmIdMatches['pmId'];
                 break;
             }
         }
     }
     // Parse out an embedded PMID and remove from the citation string
     $pmidPattern = '/pmid:?\\s*(\\d+)/i';
     if (String::regexp_match_get($pmidPattern, $citationString, $matches)) {
         $metadata['pub-id[@pub-id-type="pmid"]'] = $matches[1];
         $citationString = String::regexp_replace($pmidPattern, '', $citationString);
     }
     // Parse out an embedded DOI and remove it from the citation string
     $doiPattern = '/doi:?\\s*(\\S+)/i';
     if (String::regexp_match_get($doiPattern, $citationString, $matches)) {
         $metadata['pub-id[@pub-id-type="doi"]'] = $matches[1];
         $citationString = String::regexp_replace($doiPattern, '', $citationString);
     }
     // Parse out the access date if we have one and remove it from the citation string
     $accessDatePattern = '/accessed:?\\s*([\\s\\w]+)/i';
     if (String::regexp_match_get($accessDatePattern, $citationString, $matches)) {
         $metadata['access-date'] = $matches[1];
         $citationString = String::regexp_replace($accessDatePattern, '', $citationString);
     }
     // Clean out square brackets
     $citationString = String::regexp_replace('/\\[(\\s*(pubmed|medline|full text)\\s*)*]/i', '', $citationString);
     // Book citation
     $unparsedTail = '';
     if (String::regexp_match_get("/\\s*(?P<authors>[^\\.]+)\\.\\s*(?P<source>.*?)\\s*(?P<publisherLoc>[^\\.]*):\\s*(?P<publisherName>[^:]*?);\\s*(?P<date>\\d\\d\\d\\d.*?)(?P<tail>.*)/", $citationString, $matches)) {
         $metadata['[@publication-type]'] = NLM30_PUBLICATION_TYPE_BOOK;
         $metadata['author'] = $matches['authors'];
         $metadata['source'] = $matches['source'];
         $metadata['publisher-loc'] = $matches['publisherLoc'];
         $metadata['publisher-name'] = $matches['publisherName'];
         $metadata['date'] = $matches['date'];
         $unparsedTail = $matches['tail'];
         // Journal citation
     } elseif (String::regexp_match_get("/\\s*(?P<authors>[^\\.]+)\\.\\s*(?P<titleSource>.*)\\s*(?P<date>\\d\\d\\d\\d.*?);(?P<volumeAndIssue>[^:]+):(?P<tail>.*)/", $citationString, $matches)) {
         $metadata['[@publication-type]'] = NLM30_PUBLICATION_TYPE_JOURNAL;
         $metadata['author'] = $matches['authors'];
         $titleSource = array();
         if (String::regexp_match_get("/(.*[\\.!\\?])(.*)/", trim($matches['titleSource'], " ."), $titleSource)) {
             $metadata['article-title'] = $titleSource[1];
             $metadata['source'] = $titleSource[2];
         }
         $metadata['date'] = $matches['date'];
         $volumeAndIssue = array();
         if (String::regexp_match_get("/([^\\(]+)(\\(([^\\)]+)\\))?/", $matches['volumeAndIssue'], $volumeAndIssue)) {
             $metadata['volume'] = $volumeAndIssue[1];
             if (isset($volumeAndIssue[3])) {
                 $metadata['issue'] = $volumeAndIssue[3];
             }
         }
         $unparsedTail = $matches['tail'];
         // Web citation with or without authors
     } elseif (String::regexp_match_get("/\\s*(?P<citationSource>.*?)\\s*URL:\\s*(?P<tail>.*)/", $citationString, $matches)) {
         $unparsedTail = $matches['tail'];
         $citationParts = explode(".", trim($matches['citationSource'], '. '));
         switch (count($citationParts)) {
             case 0:
                 // This case should never occur...
                 assert(false);
                 break;
             case 1:
                 // Assume this to be a title for the web site.
                 $metadata['article-title'] = $citationParts[0];
                 break;
             case 2:
                 // Assume the format: Authors. Title.
                 $metadata['author'] = $citationParts[0];
                 $metadata['article-title'] = $citationParts[1];
                 break;
             default:
                 // Assume the format: Authors. Article Title. Journal Title.
                 $metadata['author'] = array_shift($citationParts);
                 // The last part is assumed to be the journal title
                 $metadata['source'] = array_pop($citationParts);
                 // Everything in between is assumed to belong to the article title
                 $metadata['article-title'] = implode('.', $citationParts);
         }
     }
     // TODO: Handle in-ref titles, eg. with editor lists
     // Extract page numbers if possible
     $pagesPattern = "/^[:p\\.\\s]*(?P<fpage>[Ee]?\\d+)(-(?P<lpage>\\d+))?/";
     if (!empty($unparsedTail) && String::regexp_match_get($pagesPattern, $unparsedTail, $matches)) {
         $metadata['fpage'] = $matches['fpage'];
         if (isset($matches['lpage'])) {
             $metadata['lpage'] = $matches['lpage'];
         }
         // Add the unparsed part of the citation string as a comment so it doesn't get lost.
         $comment = String::trimPunctuation(String::regexp_replace($pagesPattern, '', $unparsedTail));
         if (!empty($comment)) {
             $metadata['comment'] = $comment;
         }
     }
     // Make the meta-data fully NLM citation compliant
     $metadata =& $this->postProcessMetadataArray($metadata);
     // Create the NLM citation description
     return $this->getNlm30CitationDescriptionFromMetadataArray($metadata);
 }
 /**
  * Decompress uploaded plugin and install in the correct plugin directory.
  * @param $function string type of operation to perform after upload ('upgrade' or 'install')
  * @param $category string the category of the uploaded plugin (upgrade only)
  * @param $plugin string the name of the uploaded plugin (upgrade only)
  */
 function uploadPlugin($function, $category = null, $plugin = null)
 {
     $this->validate();
     $templateMgr =& TemplateManager::getManager();
     $this->setupTemplate(true);
     $templateMgr->assign('error', false);
     $templateMgr->assign('uploaded', false);
     $templateMgr->assign('path', $function);
     $errorMsg = '';
     if (Request::getUserVar('uploadPlugin')) {
         import('classes.file.TemporaryFileManager');
         $temporaryFileManager = new TemporaryFileManager();
         $user =& Request::getUser();
     } else {
         $errorMsg = 'manager.plugins.fileSelectError';
     }
     if (empty($errorMsg)) {
         if ($temporaryFile = $temporaryFileManager->handleUpload('newPlugin', $user->getId())) {
             // tar archive basename (less potential version number) must equal plugin directory name
             // and plugin files must be in a directory named after the plug-in.
             $matches = array();
             String::regexp_match_get('/^[a-zA-Z0-9]+/', basename($temporaryFile->getOriginalFileName(), '.tar.gz'), $matches);
             $pluginName = array_pop($matches);
             // Create random dirname to avoid symlink attacks.
             $pluginDir = dirname($temporaryFile->getFilePath()) . DIRECTORY_SEPARATOR . $pluginName . substr(md5(mt_rand()), 0, 10);
             mkdir($pluginDir);
         } else {
             $errorMsg = 'manager.plugins.uploadError';
         }
     }
     if (empty($errorMsg)) {
         // Test whether the tar binary is available for the export to work
         $tarBinary = Config::getVar('cli', 'tar');
         if (!empty($tarBinary) && file_exists($tarBinary)) {
             exec($tarBinary . ' -xzf ' . escapeshellarg($temporaryFile->getFilePath()) . ' -C ' . escapeshellarg($pluginDir));
         } else {
             $errorMsg = 'manager.plugins.tarCommandNotFound';
         }
     }
     if (empty($errorMsg)) {
         // We should now find a directory named after the
         // plug-in within the extracted archive.
         $pluginDir .= DIRECTORY_SEPARATOR . $pluginName;
         if (is_dir($pluginDir)) {
             if ($function == 'install') {
                 $this->installPlugin($pluginDir, $templateMgr);
             } else {
                 if ($function == 'upgrade') {
                     $this->upgradePlugin($pluginDir, $templateMgr, $category, $plugin);
                 }
             }
         } else {
             $errorMsg = 'manager.plugins.invalidPluginArchive';
         }
     }
     if (!empty($errorMsg)) {
         $templateMgr->assign('error', true);
         $templateMgr->assign('message', $errorMsg);
     }
     $templateMgr->display('manager/plugins/managePlugins.tpl');
 }
 /**
  * Fills the given citation object with
  * meta-data retrieved from PubMed.
  * @param $pmid string
  * @param $citationDescription MetadataDescription
  * @return MetadataDescription
  */
 function &_lookup($pmid, &$citationDescription)
 {
     $nullVar = null;
     // Use eFetch to get XML metadata for the given PMID
     $lookupParams = array('db' => 'pubmed', 'mode' => 'xml', 'tool' => 'pkp-wal', 'id' => $pmid);
     if (!is_null($this->getEmail())) {
         $lookupParams['email'] = $this->getEmail();
     }
     // Call the eFetch URL and get an XML result
     if (is_null($resultDOM = $this->callWebService(PUBMED_WEBSERVICE_EFETCH, $lookupParams))) {
         return $nullVar;
     }
     $metadata = array('pub-id[@pub-id-type="pmid"]' => $pmid, 'article-title' => $resultDOM->getElementsByTagName("ArticleTitle")->item(0)->textContent, 'source' => $resultDOM->getElementsByTagName("MedlineTA")->item(0)->textContent);
     if ($resultDOM->getElementsByTagName("Volume")->length > 0) {
         $metadata['volume'] = $resultDOM->getElementsByTagName("Volume")->item(0)->textContent;
     }
     if ($resultDOM->getElementsByTagName("Issue")->length > 0) {
         $metadata['issue'] = $resultDOM->getElementsByTagName("Issue")->item(0)->textContent;
     }
     // get list of author full names
     $nlmNameSchema = new NlmNameSchema();
     foreach ($resultDOM->getElementsByTagName("Author") as $authorNode) {
         if (!isset($metadata['person-group[@person-group-type="author"]'])) {
             $metadata['person-group[@person-group-type="author"]'] = array();
         }
         // Instantiate an NLM name description
         $authorDescription = new MetadataDescription($nlmNameSchema, ASSOC_TYPE_AUTHOR);
         // Surname
         $authorDescription->addStatement('surname', $authorNode->getElementsByTagName("LastName")->item(0)->textContent);
         // Given names
         $givenNamesString = '';
         if ($authorNode->getElementsByTagName("FirstName")->length > 0) {
             $givenNamesString = $authorNode->getElementsByTagName("FirstName")->item(0)->textContent;
         } elseif ($authorNode->getElementsByTagName("ForeName")->length > 0) {
             $givenNamesString = $authorNode->getElementsByTagName("ForeName")->item(0)->textContent;
         }
         if (!empty($givenNamesString)) {
             foreach (explode(' ', $givenNamesString) as $givenName) {
                 $authorDescription->addStatement('given-names', String::trimPunctuation($givenName));
             }
         }
         // Suffix
         if ($authorNode->getElementsByTagName("Suffix")->length > 0) {
             $authorDescription->addStatement('suffix', $authorNode->getElementsByTagName("Suffix")->item(0)->textContent);
         }
         // Include collective names
         /*if ($resultDOM->getElementsByTagName("CollectiveName")->length > 0 && $authorNode->getElementsByTagName("CollectiveName")->item(0)->textContent != '') {
         			// FIXME: This corresponds to an NLM-citation <collab> tag and should be part of the Metadata implementation
         		}*/
         $metadata['person-group[@person-group-type="author"]'][] =& $authorDescription;
         unset($authorDescription);
     }
     // Extract pagination
     if (String::regexp_match_get("/^[:p\\.\\s]*(?P<fpage>[Ee]?\\d+)(-(?P<lpage>\\d+))?/", $resultDOM->getElementsByTagName("MedlinePgn")->item(0)->textContent, $pages)) {
         $fPage = (int) $pages['fpage'];
         $metadata['fpage'] = $fPage;
         if (!empty($pages['lpage'])) {
             $lPage = (int) $pages['lpage'];
             // Deal with shortcuts like '382-7'
             if ($lPage < $fPage) {
                 $lPage = (int) (String::substr($pages['fpage'], 0, -String::strlen($pages['lpage'])) . $pages['lpage']);
             }
             $metadata['lpage'] = $lPage;
         }
     }
     // Get publication date
     // TODO: The publication date could be in multiple places
     if ($resultDOM->getElementsByTagName("ArticleDate")->length > 0) {
         $publicationDate = $resultDOM->getElementsByTagName("ArticleDate")->item(0)->getElementsByTagName("Year")->item(0)->textContent . '-' . $resultDOM->getElementsByTagName("ArticleDate")->item(0)->getElementsByTagName("Month")->item(0)->textContent . '-' . $resultDOM->getElementsByTagName("ArticleDate")->item(0)->getElementsByTagName("Day")->item(0)->textContent;
         $metadata['date'] = $publicationDate;
     }
     // Get publication type
     if ($resultDOM->getElementsByTagName("PublicationType")->length > 0) {
         foreach ($resultDOM->getElementsByTagName("PublicationType") as $publicationType) {
             // The vast majority of items on PubMed are articles so catch these...
             if (String::strpos(String::strtolower($publicationType->textContent), 'article') !== false) {
                 $metadata['[@publication-type]'] = NLM_PUBLICATION_TYPE_JOURNAL;
                 break;
             }
         }
     }
     // Get DOI if it exists
     foreach ($resultDOM->getElementsByTagName("ArticleId") as $idNode) {
         if ($idNode->getAttribute('IdType') == 'doi') {
             $metadata['pub-id[@pub-id-type="doi"]'] = $idNode->textContent;
         }
     }
     // Use eLink utility to find fulltext links
     $lookupParams = array('dbfrom' => 'pubmed', 'cmd' => 'llinks', 'tool' => 'pkp-wal', 'id' => $pmid);
     if (!is_null($resultDOM = $this->callWebService(PUBMED_WEBSERVICE_ELINK, $lookupParams))) {
         // Get a list of possible links
         foreach ($resultDOM->getElementsByTagName("ObjUrl") as $linkOut) {
             $attributes = '';
             foreach ($linkOut->getElementsByTagName("Attribute") as $attribute) {
                 $attributes .= String::strtolower($attribute->textContent) . ' / ';
             }
             // Only add links to open access resources
             if (String::strpos($attributes, "subscription") === false && String::strpos($attributes, "membership") === false && String::strpos($attributes, "fee") === false && $attributes != "") {
                 $links[] = $linkOut->getElementsByTagName("Url")->item(0)->textContent;
             }
         }
         // Take the first link if we have any left (presumably pubmed returns them in preferential order)
         if (isset($links[0])) {
             $metadata['uri'] = $links[0];
         }
     }
     return $this->addMetadataArrayToNlmCitationDescription($metadata, $citationDescription);
 }
예제 #22
0
 /**
  * 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');
 }
예제 #23
0
/**
 * Convert a Windows path to a cygwin path.
 * @param string $path Windows path
 * @return string Cygwin path.
 */
function cygwinConversion($path)
{
    $path = str_replace('\\', '/', $path);
    $matches = null;
    String::regexp_match_get('/^([A-Z]):/i', $path, $matches);
    if (isset($matches[1]) && strlen($matches[1]) === 1) {
        $path = String::regexp_replace('/^[A-Z]:/i', '/cygdrive/' . strtolower($matches[1]), $path);
    }
    return $path;
}