Skip to content

Commit

Permalink
ru_RU plugin updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mtub committed Jan 23, 2017
2 parents a777c9d + 140c1fb commit 2599acb
Show file tree
Hide file tree
Showing 129 changed files with 1,207 additions and 3,230 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,6 @@
[submodule "plugins/blocks/makeSubmission"]
path = plugins/blocks/makeSubmission
url = https://github.com/pkp/makeSubmission.git
[submodule "plugins/reports/reviewReport"]
path = plugins/reports/reviewReport
url = https://github.com/pkp/reviewReport
18 changes: 0 additions & 18 deletions classes/article/Article.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -227,24 +227,6 @@ function setFastTracked($fastTracked) {
return $this->setData('fastTracked',$fastTracked);
}

/**
* Get starting page of an article.
* @return int
*/
function getStartingPage() {
preg_match('/^[^\d]*(\d+)\D*(.*)$/', $this->getPages(), $pages);
return $pages[1];
}

/**
* Get ending page of an article.
* @return int
*/
function getEndingPage() {
preg_match('/^[^\d]*(\d+)\D*(.*)$/', $this->getPages(), $pages);
return $pages[2];
}

/**
* Get the localized cover page server-side file name
* @return string
Expand Down
7 changes: 6 additions & 1 deletion classes/article/ArticleGalley.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,12 @@ function __construct() {
*/
function getViews() {
$application = PKPApplication::getApplication();
return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_GALLEY, $this->getId());
$fileId = $this->getFileId();
if ($fileId) {
return $application->getPrimaryMetricByAssoc(ASSOC_TYPE_SUBMISSION_FILE, $fileId);
} else {
return 0;
}
}

/**
Expand Down
31 changes: 20 additions & 11 deletions classes/install/Upgrade.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,12 @@ function migrateUserRoles() {
// First, do Admins.
// create the admin user group.
$userGroupDao->update('INSERT INTO user_groups (context_id, role_id, is_default) VALUES (?, ?, ?)', array(CONTEXT_SITE, ROLE_ID_SITE_ADMIN, 1));
$userGroupId = $userGroupDao->getInsertId();

$userResult = $userGroupDao->retrieve('SELECT user_id FROM roles WHERE journal_id = ? AND role_id = ?', array(CONTEXT_SITE, ROLE_ID_SITE_ADMIN));
while (!$userResult->EOF) {
$row = $userResult->GetRowAssoc(false);
$userGroupDao->update('INSERT INTO user_user_groups (user_group_id, user_id) VALUES (?, ?)', array($userGroupDao->getInsertId(), (int) $row['user_id']));
$userGroupDao->update('INSERT INTO user_user_groups (user_group_id, user_id) VALUES (?, ?)', array($userGroupId, (int) $row['user_id']));
$userResult->MoveNext();
}

Expand Down Expand Up @@ -697,7 +699,7 @@ function fixReviewForms() {
$newOptions[$key] = $option['content'];
}
$row['setting_value'] = serialize($newOptions);
$reviewFormDao->Replace('review_form_element_settings', $row, array('review_form_id', 'locale', 'setting_name'));
$reviewFormDao->Replace('review_form_element_settings', $row, array('review_form_element_id', 'locale', 'setting_name'));
$result->MoveNext();
}
$result->Close();
Expand Down Expand Up @@ -857,6 +859,17 @@ function migrateFiles($upgrade, $params) {
$site = $siteDao->getSite();
$adminEmail = $site->getLocalizedContactEmail();

// get file names form OJS 2.4.x table article_files i.e.
// from the temporary table article_files_migration
$ojs2FileNames = array();
$result = $submissionFileDao->retrieve('SELECT file_id, revision, file_name FROM article_files_migration');
while (!$result->EOF) {
$row = $result->GetRowAssoc(false);
$ojs2FileNames[$row['file_id']][$row['revision']] = $row['file_name'];
$result->MoveNext();
}
$result->Close();

import('lib.pkp.classes.file.SubmissionFileManager');

$contexts = $journalDao->getAll();
Expand All @@ -868,11 +881,7 @@ function migrateFiles($upgrade, $params) {
foreach ($submissionFiles as $submissionFile) {
$generatedFilename = $submissionFile->getServerFileName();
$basePath = $submissionFileManager->getBasePath() . '/';
$globPattern = $submissionFile->getSubmissionId() . '-' .
$submissionFile->getFileId() . '-' .
$submissionFile->getRevision() . '-' .
'??' .
'.' . strtolower_codesafe($submissionFile->getExtension());
$globPattern = $ojs2FileNames[$submissionFile->getFileId()][$submissionFile->getRevision()];

$matchedResults = array_merge(
glob($basePath . '*/*/' . $globPattern),
Expand Down Expand Up @@ -921,7 +930,7 @@ function setFileUploader() {
$submissionFileDao->update('UPDATE submission_files sf, submissions s SET sf.uploader_user_id = ?, sf.user_group_id = ? WHERE sf.uploader_user_id IS NULL AND sf.user_group_id IS NULL AND sf.submission_id = s.submission_id AND s.context_id = ?', array($creatorUserId, $managerUserGroup->getId(), $journal->getId()));
break;
case 'postgres':
$submissionFileDao->update('UPDATE submission_files SET uploader_user_id = ?, user_group_id = ? FROM submission_files sf, submissions s WHERE sf.uploader_user_id IS NULL AND sf.user_group_id IS NULL AND sf.submission_id = s.submission_id AND s.context_id = ?', array($creatorUserId, $managerUserGroup->getId(), $journal->getId()));
$submissionFileDao->update('UPDATE submission_files SET uploader_user_id = ?, user_group_id = ? FROM submissions s WHERE submission_files.uploader_user_id IS NULL AND submission_files.user_group_id IS NULL AND submission_files.submission_id = s.submission_id AND s.context_id = ?', array($creatorUserId, $managerUserGroup->getId(), $journal->getId()));
break;
default: fatalError('Unknown database type!');
}
Expand All @@ -939,7 +948,7 @@ function setFileUploader() {
$submissionFileDao->update('UPDATE submission_files sf, submissions s SET sf.user_group_id = ? WHERE sf.uploader_user_id = ? AND sf.user_group_id IS NULL AND sf.submission_id = s.submission_id AND s.context_id = ?', array($userGroupId, $uploaderUserId, $journal->getId()));
break;
case 'postgres':
$submissionFileDao->update('UPDATE submission_files SET user_group_id = ? FROM submission_files sf, submissions s WHERE sf.uploader_user_id = ? AND sf.user_group_id IS NULL AND sf.submission_id = s.submission_id AND s.context_id = ?', array($userGroupId, $uploaderUserId, $journal->getId()));
$submissionFileDao->update('UPDATE submission_files SET user_group_id = ? FROM submissions s WHERE submission_files.uploader_user_id = ? AND submission_files.user_group_id IS NULL AND submission_files.submission_id = s.submission_id AND s.context_id = ?', array($userGroupId, $uploaderUserId, $journal->getId()));
break;
default: fatalError('Unknown database type!');
}
Expand Down Expand Up @@ -1248,7 +1257,7 @@ function convertSupplementaryFiles() {

// Set genres for files
$submissionFiles = $submissionFileDao->getAllRevisions($row['file_id']);
foreach ($submissionFiles as $submissionFile) {
foreach ((array) $submissionFiles as $submissionFile) {
$submissionFile->setGenreId($genre->getId());
$submissionFile->setUploaderUserId($creatorUserId);
$submissionFile->setUserGroupId($managerUserGroup->getId());
Expand All @@ -1258,7 +1267,7 @@ function convertSupplementaryFiles() {

// Reload the files now that they're cast; set metadata
$submissionFiles = $submissionFileDao->getAllRevisions($row['file_id']);
foreach ($submissionFiles as $submissionFile) {
foreach ((array) $submissionFiles as $submissionFile) {
$suppFileSettingsResult = $submissionFileDao->retrieve('SELECT * FROM article_supp_file_settings WHERE supp_id = ? AND setting_value IS NOT NULL', array($row['supp_id']));
$extraSettings = $extraGalleySettings = array();
while (!$suppFileSettingsResult->EOF) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function fetch($request) {
$publicationFeeEnabled = $paymentManager->publicationEnabled();
$templateMgr->assign('publicationFeeEnabled', $publicationFeeEnabled);
if ($publicationFeeEnabled) {
$templateMgr->assign('publicationPayment', $completedPaymentDao->getPublicationCompletedPayment($context->getId(), $this->getSubission()->getId()));
$templateMgr->assign('publicationPayment', $completedPaymentDao->getPublicationCompletedPayment($context->getId(), $this->getSubmission()->getId()));
}

$templateMgr->assign('submission', $this->getSubmission());
Expand Down
30 changes: 11 additions & 19 deletions dbscripts/xml/indexes.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,24 +14,16 @@

<data>
<sql>
<query driver="mysql">
CREATE INDEX issue_settings_name_value ON issue_settings (setting_name(50), setting_value(150))
</query>
<query driver="mysql">
CREATE INDEX submission_settings_name_value ON submission_settings (setting_name(50), setting_value(150))
</query>
<query driver="mysql">
CREATE INDEX submission_galley_settings_name_value ON submission_galley_settings (setting_name(50), setting_value(150))
</query>

<query driver="postgres7">
CREATE INDEX issue_settings_name_value ON issue_settings (setting_name, setting_value) WHERE setting_name IN ('medra::registeredDoi', 'datacite::registeredDoi')
</query>
<query driver="postgres7">
CREATE INDEX submission_settings_name_value ON submission_settings (setting_name, setting_value) WHERE setting_name IN ('indexingState', 'medra::registeredDoi', 'datacite::registeredDoi')
</query>
<query driver="postgres7">
CREATE INDEX submission_galley_settings_name_value ON submission_galley_settings (setting_name, setting_value)
</query>
<query driver="mysql">CREATE INDEX issue_settings_name_value ON issue_settings (setting_name(50), setting_value(150))</query>
<query driver="mysql">CREATE INDEX submission_settings_name_value ON submission_settings (setting_name(50), setting_value(150))</query>
<query driver="mysql">CREATE INDEX submission_galley_settings_name_value ON submission_galley_settings (setting_name(50), setting_value(150))</query>

<query driver="mysqli">CREATE INDEX issue_settings_name_value ON issue_settings (setting_name(50), setting_value(150))</query>
<query driver="mysqli">CREATE INDEX submission_settings_name_value ON submission_settings (setting_name(50), setting_value(150))</query>
<query driver="mysqli">CREATE INDEX submission_galley_settings_name_value ON submission_galley_settings (setting_name(50), setting_value(150))</query>

<query driver="postgres7">CREATE INDEX issue_settings_name_value ON issue_settings (setting_name, setting_value) WHERE setting_name IN ('medra::registeredDoi', 'datacite::registeredDoi')</query>
<query driver="postgres7">CREATE INDEX submission_settings_name_value ON submission_settings (setting_name, setting_value) WHERE setting_name IN ('indexingState', 'medra::registeredDoi', 'datacite::registeredDoi')</query>
<query driver="postgres7">CREATE INDEX submission_galley_settings_name_value ON submission_galley_settings (setting_name, setting_value)</query>
</sql>
</data>
6 changes: 6 additions & 0 deletions dbscripts/xml/upgrade.xml
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<data file="dbscripts/xml/upgrade/3.0.0_postupgrade_metrics.xml" />
<data file="dbscripts/xml/upgrade/3.0.0_issue_settings.xml" />
<data file="dbscripts/xml/upgrade/3.0.0_submission_settings.xml" />
<data file="dbscripts/xml/upgrade/3.0.0_review_method.xml" />
</upgrade>

<upgrade minversion="3.0.0.0" maxversion="3.0.0.9">
Expand All @@ -115,6 +116,11 @@
<data file="dbscripts/xml/upgrade/3.0.0_issue_settings.xml" />
<data file="dbscripts/xml/upgrade/3.0.0_submission_settings.xml" />
<code function="installEmailTemplate" key="SUBMISSION_ACK_NOT_USER" locales="en_US,ca_ES,el_GR,es_ES,fr_CA,pt_BR" />
<data file="dbscripts/xml/upgrade/3.0.0_review_method.xml" />
</upgrade>

<upgrade minversion="3.0.1.0" maxversion="3.0.1.9">
<data file="dbscripts/xml/upgrade/3.0.0_review_method.xml" />
</upgrade>

<upgrade minversion="3.0.0.0" maxversion="3.0.9.9">
Expand Down
3 changes: 2 additions & 1 deletion dbscripts/xml/upgrade/3.0.0_postupgrade_galley_files.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
<sql>
<!-- ASSOC_TYPE_GALLEY i.e. ASSOC_TYPE_REPRESENTATION = 521 -->
<query driver="mysql">UPDATE submission_files sf, submission_galleys sg SET sf.assoc_type = 521, sf.assoc_id = sg.galley_id WHERE sf.file_id = sg.file_id AND sf.submission_id = sg.submission_id</query>
<query driver="postgres7">UPDATE submission_files SET assoc_type = 521, assoc_id = sg.galley_id FROM submission_files sf, submission_galleys sg WHERE sf.file_id = sg.file_id AND sf.submission_id = sg.submission_id</query>
<query driver="mysqli">UPDATE submission_files sf, submission_galleys sg SET sf.assoc_type = 521, sf.assoc_id = sg.galley_id WHERE sf.file_id = sg.file_id AND sf.submission_id = sg.submission_id</query>
<query driver="postgres7">UPDATE submission_files SET assoc_type = 521, assoc_id = sg.galley_id FROM submission_galleys sg WHERE submission_files.file_id = sg.file_id AND submission_files.submission_id = sg.submission_id</query>
</sql>
</data>
18 changes: 12 additions & 6 deletions dbscripts/xml/upgrade/3.0.0_postupgrade_metrics.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,28 @@
<!-- update the supp file ids to the new file ids, ASSOC_TYPE_SUBMISSION_FILE = 515 -->
<sql>
<query driver="mysql">UPDATE metrics m, submission_file_settings sfs SET m.assoc_id = sfs.file_id WHERE m.assoc_type = 515 AND sfs.setting_name = 'old-supp-id' AND sfs.setting_value = m.assoc_id</query>
<query driver="postgres7">UPDATE metrics SET assoc_id = sfs.file_id FROM metrics m, submission_file_settings sfs WHERE m.assoc_type = 515 AND sfs.setting_name = 'old-supp-id' AND CAST(nullif(sfs.setting_value, '') AS integer) = m.assoc_id</query>
<query driver="mysqli">UPDATE metrics m, submission_file_settings sfs SET m.assoc_id = sfs.file_id WHERE m.assoc_type = 515 AND sfs.setting_name = 'old-supp-id' AND sfs.setting_value = m.assoc_id</query>
<query driver="postgres7">UPDATE metrics SET assoc_id = sfs.file_id FROM submission_file_settings sfs WHERE metrics.assoc_type = 515 AND sfs.setting_name = 'old-supp-id' AND CAST(nullif(sfs.setting_value, '') AS integer) = metrics.assoc_id</query>
</sql>

<!-- fill the new metrics columns (assoc_object_type, assoc_object_id, pkp_section_id and representation_id) appropriately: -->
<!-- insert section id for articles, article galleys and files - they all have submission_id in the table -->
<sql>
<query driver="mysql">UPDATE metrics m, submissions s SET m.pkp_section_id = s.section_id WHERE m.submission_id IS NOT NULL AND s.submission_id = m.submission_id</query>
<query driver="postgres7">UPDATE metrics SET pkp_section_id = s.section_id FROM metrics m, submissions s WHERE m.submission_id IS NOT NULL AND s.submission_id = m.submission_id</query>
<query driver="mysqli">UPDATE metrics m, submissions s SET m.pkp_section_id = s.section_id WHERE m.submission_id IS NOT NULL AND s.submission_id = m.submission_id</query>
<query driver="postgres7">UPDATE metrics SET pkp_section_id = s.section_id FROM submissions s WHERE metrics.submission_id IS NOT NULL AND s.submission_id = metrics.submission_id</query>
</sql>
<!-- insert issue id for articles, article galleys and files - they all have submission_id in the table, ASSOC_TYPE_ISSUE = 259 -->
<sql>
<query driver="mysql">UPDATE metrics m, published_submissions p SET m.assoc_object_type = 259, m.assoc_object_id = p.issue_id WHERE m.submission_id IS NOT NULL AND p.submission_id = m.submission_id</query>
<query driver="postgres7">UPDATE metrics SET assoc_object_type = 259, assoc_object_id = p.issue_id FROM metrics m, published_submissions p WHERE m.submission_id IS NOT NULL AND p.submission_id = m.submission_id</query>
<query driver="mysqli">UPDATE metrics m, published_submissions p SET m.assoc_object_type = 259, m.assoc_object_id = p.issue_id WHERE m.submission_id IS NOT NULL AND p.submission_id = m.submission_id</query>
<query driver="postgres7">UPDATE metrics SET assoc_object_type = 259, assoc_object_id = p.issue_id FROM published_submissions p WHERE metrics.submission_id IS NOT NULL AND p.submission_id = metrics.submission_id</query>
</sql>
<!-- insert issue id for issue galleys, ASSOC_TYPE_ISSUE = 259, ASSOC_TYPE_ISSUE_GALLEY = 261 -->
<sql>
<query driver="mysql">UPDATE metrics m, issue_galleys ig SET m.assoc_object_type = 259, m.assoc_object_id = ig.issue_id WHERE m.assoc_type = 261 AND ig.issue_id = m.assoc_id</query>
<query driver="postgres7">UPDATE metrics SET assoc_object_type = 259, assoc_object_id = ig.issue_id FROM metrics m, issue_galleys ig WHERE m.assoc_type = 261 AND ig.issue_id = m.assoc_id</query>
<query driver="mysqli">UPDATE metrics m, issue_galleys ig SET m.assoc_object_type = 259, m.assoc_object_id = ig.issue_id WHERE m.assoc_type = 261 AND ig.issue_id = m.assoc_id</query>
<query driver="postgres7">UPDATE metrics SET assoc_object_type = 259, assoc_object_id = ig.issue_id FROM issue_galleys ig WHERE metrics.assoc_type = 261 AND ig.issue_id = metrics.assoc_id</query>
</sql>
<!-- insert representation id for article galleys, ASSOC_TYPE_REPRESENTATION = 521 -->
<sql>
Expand All @@ -48,12 +52,14 @@
<!-- insert representation id for galley files, ASSOC_TYPE_SUBMISSION_FILE = 515, ASSOC_TYPE_REPRESENTATION = 521 -->
<sql>
<query driver="mysql">UPDATE metrics m, submission_files sf SET m.representation_id = sf.assoc_id WHERE m.assoc_type = 515 AND sf.file_id = m.assoc_id AND sf.assoc_type = 521</query>
<query driver="postgres7">UPDATE metrics SET representation_id = sf.assoc_id FROM metrics m, submission_files sf WHERE m.assoc_type = 515 AND sf.file_id = m.assoc_id AND sf.assoc_type = 521</query>
<query driver="mysqli">UPDATE metrics m, submission_files sf SET m.representation_id = sf.assoc_id WHERE m.assoc_type = 515 AND sf.file_id = m.assoc_id AND sf.assoc_type = 521</query>
<query driver="postgres7">UPDATE metrics SET representation_id = sf.assoc_id FROM submission_files sf WHERE metrics.assoc_type = 515 AND sf.file_id = metrics.assoc_id AND sf.assoc_type = 521</query>
</sql>

<!-- issue #1933, ASSOC_TYPE_REPRESENTATION = 521 should be accordingly replaced by ASSOC_TYPE_SUBMISSION_FILE = 515 -->
<sql>
<query driver="mysql">UPDATE metrics m, submission_galleys sg SET m.assoc_type = 515, m.assoc_id = sg.file_id WHERE m.assoc_type = 521 AND sg.galley_id = m.assoc_id AND ((sg.remote_url IS NULL) OR (sg.remote_url = ''))</query>
<query driver="postgres7">UPDATE metrics SET assoc_type = 515, assoc_id = sg.file_id FROM metrics m, submission_galleys sg WHERE m.assoc_type = 521 AND sg.galley_id = m.assoc_id AND ((sg.remote_url IS NULL) OR (sg.remote_url = ''))</query>
<query driver="mysqli">UPDATE metrics m, submission_galleys sg SET m.assoc_type = 515, m.assoc_id = sg.file_id WHERE m.assoc_type = 521 AND sg.galley_id = m.assoc_id AND ((sg.remote_url IS NULL) OR (sg.remote_url = ''))</query>
<query driver="postgres7">UPDATE metrics SET assoc_type = 515, assoc_id = sg.file_id FROM submission_galleys sg WHERE metrics.assoc_type = 521 AND sg.galley_id = metrics.assoc_id AND ((sg.remote_url IS NULL) OR (sg.remote_url = ''))</query>
</sql>
</data>
18 changes: 18 additions & 0 deletions dbscripts/xml/upgrade/3.0.0_review_method.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE data SYSTEM "../../../lib/pkp/dtd/xmlData.dtd">

<!--
* 3.0.0_review_method.xml
*
* Copyright (c) 2014-2016 Simon Fraser University Library
* Copyright (c) 2003-2016 John Willinsky
* Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
*
* 3.0.0.0 review_method update.
-->
<data>
<sql><!-- #2195 set review_method = 2 (SUBMISSION_REVIEW_METHOD_DOUBLEBLIND) where review_method = 0 i.e. for those migrated from OJS 2.4.x -->
<query>UPDATE review_assignments SET review_method = 2 WHERE review_method = 0</query>
</sql>
</data>

Loading

0 comments on commit 2599acb

Please sign in to comment.