Skip to content

Commit

Permalink
pkp/pkp-lib#2072 Fix tests and whitespace
Browse files Browse the repository at this point in the history
  • Loading branch information
NateWr committed Sep 4, 2019
1 parent 6d1dbc7 commit 02c8182
Show file tree
Hide file tree
Showing 27 changed files with 306 additions and 543 deletions.
36 changes: 18 additions & 18 deletions classes/components/forms/publication/CatalogEntryForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ public function __construct($action, $locales, $publication, $submission, $baseU
$this->successMessage = __('publication.catalogEntry.success');
$this->locales = $locales;

// Series options
$seriesOptions = [['value' => '', 'label' => '']];
$result = DAORegistry::getDAO('SeriesDAO')->getByContextId($submission->getData('contextId'));
while (!$result->eof()) {
$series = $result->next();
$seriesOptions[] = [
'value' => (int) $series->getId(),
'label' => $series->getLocalizedTitle(),
];
// Series options
$seriesOptions = [['value' => '', 'label' => '']];
$result = DAORegistry::getDAO('SeriesDAO')->getByContextId($submission->getData('contextId'));
while (!$result->eof()) {
$series = $result->next();
$seriesOptions[] = [
'value' => (int) $series->getId(),
'label' => $series->getLocalizedTitle(),
];
}

// Category options
Expand All @@ -73,26 +73,26 @@ public function __construct($action, $locales, $publication, $submission, $baseU
->addField(new FieldSelect('seriesId', [
'label' => __('series.series'),
'value' => $publication->getData('seriesId'),
'options' => $seriesOptions,
'options' => $seriesOptions,
]))
->addField(new FieldText('seriesPosition', [
'label' => __('submission.submit.seriesPosition'),
'description' => __('submission.submit.seriesPosition.description'),
'label' => __('submission.submit.seriesPosition'),
'description' => __('submission.submit.seriesPosition.description'),
'value' => $publication->getData('seriesPosition'),
]))
->addField(new FieldOptions('categoryIds', [
'label' => __('submission.submit.placement.categories'),
'value' => (array) $publication->getData('categoryIds'),
'options' => $categoryOptions,
'options' => $categoryOptions,
]))
->addField(new FieldUploadImage('coverImage', [
'label' => __('monograph.coverImage'),
'value' => $publication->getData('coverImage'),
'isMultilingual' => true,
->addField(new FieldUploadImage('coverImage', [
'label' => __('monograph.coverImage'),
'value' => $publication->getData('coverImage'),
'isMultilingual' => true,
'baseUrl' => $baseUrl,
'options' => [
'url' => $temporaryFileApiUrl,
],
]));
}
}
}
11 changes: 11 additions & 0 deletions classes/monograph/ChapterAuthorDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ function deleteChapterAuthorById($authorId, $chapterId = null) {
);
}

/**
* Remove all authors from a chapter
* @param $chapterId int
*/
function deleteChapterAuthorsByChapterId($chapterId) {
$this->update(
'DELETE FROM submission_chapter_authors WHERE chapter_id = ?',
[(int) $chapterId]
);
}

/**
* Construct and return a new data object.
* @return ChapterAuthor
Expand Down
6 changes: 3 additions & 3 deletions classes/publication/Publication.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ public function getEditorString() {
}
}

// Spaces are stripped from the locale strings, so we have to add the
// space in here.
return join(__('common.commaListSeparator') . ' ', $editorNames);
// Spaces are stripped from the locale strings, so we have to add the
// space in here.
return join(__('common.commaListSeparator') . ' ', $editorNames);
}

}
2 changes: 1 addition & 1 deletion classes/publication/PublicationDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PublicationDAO extends PKPPublicationDAO {
* @copydoc SchemaDAO::_fromRow()
*/
public function _fromRow($primaryRow) {
$publication = parent::_fromRow($primaryRow);
$publication = parent::_fromRow($primaryRow);

$publication->setData('publicationFormats', Application::getRepresentationDao()->getByPublicationId($publication->getId())->toArray());
$publication->setData('chapters', DAORegistry::getDAO('ChapterDAO')->getByPublicationId($publication->getId())->toArray());
Expand Down
7 changes: 5 additions & 2 deletions classes/search/MonographSearchDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,24 @@ function getPhraseResults($press, $phrase, $publishedFrom = null, $publishedTo =
$params[] = $press->getId();
}

import('classes.submission.Submission'); // import STATUS_PUBLISHED constant
$params[] = STATUS_PUBLISHED;

$result = $this->retrieveCached(
$sql = 'SELECT
o.submission_id,
s.context_id as press_id,
s.date_published as s_pub,
p.date_published as s_pub,
COUNT(*) AS count
FROM
submissions s,
publications p,
submission_search_objects o NATURAL JOIN ' . $sqlFrom . '
WHERE o.submission_id = s.submission_id
AND s.current_publication_id = p.publication_id
AND ' . $sqlWhere . '
AND s.status = ?
GROUP BY o.submission_id, s.context_id, s.date_published
GROUP BY o.submission_id, s.context_id, p.date_published
ORDER BY count DESC
LIMIT ' . $limit,
$params,
Expand Down
21 changes: 10 additions & 11 deletions classes/services/PublicationFormatService.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
* @class PublicationFormatService
* @ingroup services
*
* @brief Extends the base publication format service class with app-specific
* requirements.
* @brief A service class with methods to handle publication formats
*/
namespace APP\Services;

Expand All @@ -29,17 +28,17 @@ class PublicationFormatService {
*/
public function deleteFormat($publicationFormat, $submission, $context) {

Application::getRepresentationDAO()->deleteById($publicationFormat->getId());
Application::getRepresentationDAO()->deleteById($publicationFormat->getId());

// Delete publication format metadata
$metadataDaos = ['IdentificationCodeDAO', 'MarketDAO', 'PublicationDateDAO', 'SalesRightsDAO'];
foreach ($metadataDaos as $metadataDao) {
$result = DAORegistry::getDAO($metadataDao)->getByPublicationFormatId($publicationFormat->getId());
while (!$result->eof()) {
// Delete publication format metadata
$metadataDaos = ['IdentificationCodeDAO', 'MarketDAO', 'PublicationDateDAO', 'SalesRightsDAO'];
foreach ($metadataDaos as $metadataDao) {
$result = DAORegistry::getDAO($metadataDao)->getByPublicationFormatId($publicationFormat->getId());
while (!$result->eof()) {
$object = $result->next();
DAORegistry::getDAO($metadataDao)->deleteObject($object);
}
}
DAORegistry::getDAO($metadataDao)->deleteObject($object);
}
}

// Create a tombstone for this publication format.
import('classes.publicationFormat.PublicationFormatTombstoneManager');
Expand Down
2 changes: 1 addition & 1 deletion classes/submission/reviewer/ReviewerSubmissionDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ function getReviewerSubmission($reviewId) {
$primaryLocale = AppLocale::getPrimaryLocale();
$locale = AppLocale::getLocale();
$result = $this->retrieve(
'SELECT m.*, pm.date_published,
'SELECT m.*, p.date_published,
r.*,
COALESCE(stl.setting_value, stpl.setting_value) AS series_title
FROM submissions m
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,7 @@ function setProofFileCompletion($args, $request) {
$request->getUserVar('fileId'),
$request->getUserVar('revision'),
SUBMISSION_FILE_PROOF,
$submission->getId(),
$submission->getId()
);
$confirmationText = __('editor.submission.proofreading.confirmRemoveCompletion');
if ($request->getUserVar('approval')) {
Expand Down Expand Up @@ -557,7 +557,7 @@ function selectFiles($args, $request) {
$representation = $this->getAuthorizedContextObject(ASSOC_TYPE_REPRESENTATION);

import('lib.pkp.controllers.grid.files.proof.form.ManageProofFilesForm');
$manageProofFilesForm = new ManageProofFilesForm($this->getSubmission()->getId(), $representation->getId());
$manageProofFilesForm = new ManageProofFilesForm($this->getSubmission()->getId(), $this->getPublication()->getId(), $representation->getId());
$manageProofFilesForm->initData();
return new JSONMessage(true, $manageProofFilesForm->fetch($request));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class RepresentativesGridHandler extends CategoryGridHandler {
function __construct() {
parent::__construct();
$this->addRoleAssignment(
array(ROLE_ID_MANAGER),
array(ROLE_ID_MANAGER, ROLE_ID_SUB_EDITOR, ROLE_ID_ASSISTANT),
array('fetchGrid', 'fetchCategory', 'fetchRow', 'addRepresentative', 'editRepresentative',
'updateRepresentative', 'deleteRepresentative'));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,14 @@ class PublicationFormatMetadataForm extends Form {
* @param $formParams array
*/
function __construct($submission, $publication, $representation, $isPhysicalFormat = true, $remoteURL = null, $stageId = null, $formParams = null) {
parent::__construct('controllers/tab/catalogEntry/form/publicationMetadataFormFields.tpl');
$this->_submission = $submission;
$this->_publication = $publication;
$this->_publicationFormat = $representation;
parent::__construct('controllers/tab/catalogEntry/form/publicationMetadataFormFields.tpl');
$this->_submission = $submission;
$this->_publication = $publication;
$this->_publicationFormat = $representation;

if (!$this->_submission || !$this->_publication || !$this->_publicationFormat) {
throw new Exception('PublicationFormatMetadataForm was instantiated without required dependencies.');
}
if (!$this->_submission || !$this->_publication || !$this->_publicationFormat) {
throw new Exception('PublicationFormatMetadataForm was instantiated without required dependencies.');
}

$this->_pubIdPluginHelper = new PKPPubIdPluginHelper();

Expand Down Expand Up @@ -271,7 +271,7 @@ function execute() {
*/
function getSubmission() {
return $this->_submission;
}
}

/**
* Get the Publication
Expand Down
26 changes: 13 additions & 13 deletions controllers/grid/users/author/form/AuthorForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ class AuthorForm extends PKPAuthorForm {
* @copydoc Form::initData()
*/
function initData() {
parent::initData();
if ($this->getAuthor()) {
$this->_data['isVolumeEditor'] = $this->getAuthor()->getIsVolumeEditor();
}
parent::initData();
if ($this->getAuthor()) {
$this->_data['isVolumeEditor'] = $this->getAuthor()->getIsVolumeEditor();
}
}

/**
Expand All @@ -42,21 +42,21 @@ function fetch($request, $template = null, $display = false) {
* @copydoc Form::readInputData()
*/
function readInputData() {
parent::readInputData();
$this->readUserVars(['isVolumeEditor']);
parent::readInputData();
$this->readUserVars(['isVolumeEditor']);
}

/**
* @copydoc Form::execute()
*/
function execute() {
$authorId = parent::execute();
$author = Services::get('author')->get($authorId);
if ($author) {
$author->setIsVolumeEditor($this->getData('isVolumeEditor'));
DAORegistry::getDAO('AuthorDAO')->updateObject($author);
}
return $author->getId();
$authorId = parent::execute();
$author = Services::get('author')->get($authorId);
if ($author) {
$author->setIsVolumeEditor($this->getData('isVolumeEditor'));
DAORegistry::getDAO('AuthorDAO')->updateObject($author);
}
return $author->getId();
}
}

Expand Down
2 changes: 1 addition & 1 deletion controllers/grid/users/chapter/ChapterGridHandler.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ function initialize($request, $args = null) {

// Columns
// reuse the cell providers for the AuthorGrid
$cellProvider = new PKPAuthorGridCellProvider();
$cellProvider = new PKPAuthorGridCellProvider($this->getPublication());
$this->addColumn(
new GridColumn(
'name',
Expand Down
Loading

0 comments on commit 02c8182

Please sign in to comment.