Skip to content

Commit

Permalink
*8212* Standardization in prep for OJS pub format/galley reconciliation
Browse files Browse the repository at this point in the history
  • Loading branch information
asmecher committed May 31, 2013
1 parent a5422dc commit 73bfc83
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 67 deletions.
5 changes: 2 additions & 3 deletions classes/log/SubmissionEventLogDAO.inc.php
Expand Up @@ -38,9 +38,8 @@ function newDataObject() {
* @param $submissionId int
* @return DAOResultFactory
*/
function &getByMonographId($submissionId) {
$returner =& $this->getByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
return $returner;
function getBySubmissionId($submissionId) {
return $this->getByAssoc(ASSOC_TYPE_SUBMISSION, $submissionId);
}
}

Expand Down
8 changes: 4 additions & 4 deletions classes/monograph/PublishedMonograph.inc.php
Expand Up @@ -126,16 +126,16 @@ function setAudienceRangeExact($audienceRangeExact) {
}

/**
* Retrieves the assigned publication formats for this mongraph
* @param $onlyApproved boolean whether to fetch only those that are in the catalog.
* Retrieves the assigned publication formats for this submission
* @param $onlyApproved boolean whether to fetch only those that are approved for publication.
* @return array PublicationFormat
*/
function getPublicationFormats($onlyApproved = false) {
$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
if ($onlyApproved) {
$formats = $publicationFormatDao->getApprovedByMonographId($this->getId());
$formats = $publicationFormatDao->getApprovedBySubmissionId($this->getId());
} else {
$formats = $publicationFormatDao->getByMonographId($this->getId());
$formats = $publicationFormatDao->getBySubmissionId($this->getId());
}
return $formats->toArray();
}
Expand Down
16 changes: 8 additions & 8 deletions classes/publicationFormat/PublicationFormatDAO.inc.php
Expand Up @@ -54,16 +54,16 @@ function getById($publicationFormatId, $monographId = null, $pressId = null) {
}

/**
* Retrieves a list of publication formats for a published monograph
* @param int $monographId
* Retrieves a list of publication formats for a submission
* @param int $submissionId int
* @return DAOResultFactory (PublicationFormat)
*/
function getByMonographId($monographId) {
function getBySubmissionId($submissionId) {
$result = $this->retrieve(
'SELECT *
FROM publication_formats
WHERE submission_id = ?',
(int) $monographId
(int) $submissionId
);

return new DAOResultFactory($result, $this, '_fromRow');
Expand All @@ -88,16 +88,16 @@ function getByPressId($pressId) {
}

/**
* Retrieves a list of approved publication formats for a published monograph
* @param int $monographId
* Retrieves a list of approved publication formats for a published submission
* @param int $submissionId
* @return DAOResultFactory (PublicationFormat)
*/
function getApprovedByMonographId($monographId) {
function getApprovedBySubmissionId($submissionId) {
$result = $this->retrieve(
'SELECT *
FROM publication_formats
WHERE submission_id = ? AND is_approved = 1',
(int) $monographId
(int) $submissionId
);

return new DAOResultFactory($result, $this, '_fromRow');
Expand Down
68 changes: 34 additions & 34 deletions controllers/grid/catalogEntry/PublicationFormatGridHandler.inc.php
Expand Up @@ -24,8 +24,8 @@
import('lib.pkp.classes.linkAction.request.AjaxModal');

class PublicationFormatGridHandler extends GridHandler {
/** @var Monograph */
var $_monograph;
/** @var Submission */
var $_submission;

/** @var boolean */
var $_inCatalogEntryModal;
Expand All @@ -50,19 +50,19 @@ function PublicationFormatGridHandler() {
// Getters/Setters
//
/**
* Get the monograph associated with this publication format grid.
* @return Monograph
* Get the submission associated with this publication format grid.
* @return Submission
*/
function &getMonograph() {
return $this->_monograph;
function getSubmission() {
return $this->_submission;
}

/**
* Set the Monograph
* @param Monograph
* Set the submission
* @param $submission Submission
*/
function setMonograph($monograph) {
$this->_monograph =& $monograph;
function setSubmission($submission) {
$this->_submission = $submission;
}

/**
Expand Down Expand Up @@ -101,8 +101,8 @@ function initialize($request) {
$this->setInstructions('editor.monograph.production.publicationFormatDescription');
$this->_inCatalogEntryModal = (boolean) $request->getUserVar('inCatalogEntryModal');

// Retrieve the authorized monograph.
$this->setMonograph($this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH));
// Retrieve the authorized submission.
$this->setSubmission($this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION));

// Load submission-specific translations
AppLocale::requireComponents(
Expand Down Expand Up @@ -131,8 +131,8 @@ function initialize($request) {
);

// Columns
$monograph = $this->getMonograph();
$cellProvider = new PublicationFormatGridCellProvider($monograph->getId(), $this->getInCatalogEntryModal());
$submission = $this->getSubmission();
$cellProvider = new PublicationFormatGridCellProvider($submission->getId(), $this->getInCatalogEntryModal());
$this->addColumn(
new GridColumn(
'name',
Expand Down Expand Up @@ -181,19 +181,19 @@ function initialize($request) {
* @return PublicationFormatGridRow
*/
function getRowInstance() {
return new PublicationFormatGridRow($this->getMonograph());
return new PublicationFormatGridRow($this->getSubmission());
}

/**
* Get the arguments that will identify the data in the grid
* In this case, the monograph.
* In this case, the submission.
* @return array
*/
function getRequestArgs() {
$monograph = $this->getMonograph();
$submission = $this->getSubmission();

return array(
'submissionId' => $monograph->getId(),
'submissionId' => $submission->getId(),
'inCatalogEntryModal' => $this->getInCatalogEntryModal()
);
}
Expand All @@ -202,9 +202,9 @@ function getRequestArgs() {
* @see GridHandler::loadData
*/
function loadData($request, $filter = null) {
$monograph = $this->getMonograph();
$submission = $this->getSubmission();
$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$data = $publicationFormatDao->getByMonographId($monograph->getId());
$data = $publicationFormatDao->getBySubmissionId($submission->getId());
return $data->toAssociativeArray();
}

Expand All @@ -226,14 +226,14 @@ function addFormat($args, $request) {
function editFormat($args, $request) {
// Identify the format to be updated
$publicationFormatId = (int) $request->getUserVar('publicationFormatId');
$monograph = $this->getMonograph();
$submission = $this->getSubmission();

$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$publicationFormat = $publicationFormatDao->getById($publicationFormatId);

// Form handling
import('controllers.grid.catalogEntry.form.PublicationFormatForm');
$publicationFormatForm = new PublicationFormatForm($monograph, $publicationFormat);
$publicationFormatForm = new PublicationFormatForm($submission, $publicationFormat);
$publicationFormatForm->initData();

$json = new JSONMessage(true, $publicationFormatForm->fetch($request));
Expand All @@ -249,14 +249,14 @@ function editFormat($args, $request) {
function updateFormat($args, $request) {
// Identify the format to be updated
$publicationFormatId = (int) $request->getUserVar('publicationFormatId');
$monograph = $this->getMonograph();
$submission = $this->getSubmission();

$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$publicationFormat = $publicationFormatDao->getById($publicationFormatId);

// Form handling
import('controllers.grid.catalogEntry.form.PublicationFormatForm');
$publicationFormatForm = new PublicationFormatForm($monograph, $publicationFormat);
$publicationFormatForm = new PublicationFormatForm($submission, $publicationFormat);
$publicationFormatForm->readInputData();
if ($publicationFormatForm->validate()) {
$publicationFormatId = $publicationFormatForm->execute($request);
Expand Down Expand Up @@ -299,12 +299,12 @@ function updateFormat($args, $request) {
* @return string Serialized JSON object
*/
function deleteFormat($args, $request) {
$press = $request->getPress();
$context = $request->getContext();
$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$publicationFormat = $publicationFormatDao->getById(
$request->getUserVar('publicationFormatId'),
null, // $pressId
$press->getId() // Make sure to validate the press context
null, // $submissionId
$context->getId() // Make sure to validate the context
);
$result = false;
if ($publicationFormat) {
Expand All @@ -315,7 +315,7 @@ function deleteFormat($args, $request) {
// Create a tombstone for this publication format.
import('classes.publicationFormat.PublicationFormatTombstoneManager');
$publicationFormatTombstoneMgr = new PublicationFormatTombstoneManager();
$publicationFormatTombstoneMgr->insertTombstoneByPublicationFormat($publicationFormat, $press);
$publicationFormatTombstoneMgr->insertTombstoneByPublicationFormat($publicationFormat, $context);

$currentUser = $request->getUser();
$notificationMgr = new NotificationManager();
Expand All @@ -324,7 +324,7 @@ function deleteFormat($args, $request) {
// log the deletion of the format.
import('lib.pkp.classes.log.SubmissionLog');
import('classes.log.SubmissionEventLogEntry');
SubmissionLog::logEvent($request, $this->getMonograph(), SUBMISSION_LOG_PUBLICATION_FORMAT_REMOVE, 'submission.event.publicationFormatRemoved', array('formatName' => $publicationFormat->getLocalizedName()));
SubmissionLog::logEvent($request, $this->getSubmission(), SUBMISSION_LOG_PUBLICATION_FORMAT_REMOVE, 'submission.event.publicationFormatRemoved', array('formatName' => $publicationFormat->getLocalizedName()));

return DAO::getDataChangedEvent();
} else {
Expand All @@ -341,12 +341,12 @@ function deleteFormat($args, $request) {
* @return string Serialized JSON object
*/
function setAvailable($args, $request) {
$press = $request->getPress();
$context = $request->getContext();
$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$publicationFormat =& $publicationFormatDao->getById(
$request->getUserVar('publicationFormatId'),
null, // $monographId
$press->getId() // Make sure to validate the context.
null, // $submissionId
$context->getId() // Make sure to validate the context.
);

if ($publicationFormat) {
Expand All @@ -358,7 +358,7 @@ function setAvailable($args, $request) {
import('lib.pkp.classes.log.SubmissionLog');
import('classes.log.SubmissionEventLogEntry');
SubmissionLog::logEvent(
$request, $this->getMonograph(),
$request, $this->getSubmission(),
$newAvailableState?SUBMISSION_LOG_PUBLICATION_FORMAT_AVAILABLE:SUBMISSION_LOG_PUBLICATION_FORMAT_UNAVAILABLE,
$newAvailableState?'submission.event.publicationFormatMadeAvailable':'submission.event.publicationFormatMadeUnavailable',
array('publicationFormatName' => $publicationFormat->getLocalizedName())
Expand All @@ -373,7 +373,7 @@ function setAvailable($args, $request) {
$publicationFormatTombstoneMgr->deleteTombstonesByPublicationFormats(array($publicationFormat));
} else {
// Create a tombstone for this publication format.
$publicationFormatTombstoneMgr->insertTombstoneByPublicationFormat($publicationFormat, $press);
$publicationFormatTombstoneMgr->insertTombstoneByPublicationFormat($publicationFormat, $context);
}

return DAO::getDataChangedEvent($publicationFormat->getId());
Expand Down
Expand Up @@ -58,9 +58,9 @@ function getRequestArgs() {
* @see GridDataProvider::loadData()
*/
function loadData() {
$monograph = $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
$submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$publicationFormatFactory =& $publicationFormatDao->getByMonographId($monograph->getId());
$publicationFormatFactory = $publicationFormatDao->getBySubmissionId($submission->getId());

return $publicationFormatFactory->toAssociativeArray();
}
Expand Down
Expand Up @@ -67,10 +67,10 @@ function fetch($args, $request) {

// load in any publication formats assigned to this published monograph
$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$formats =& $publicationFormatDao->getByMonographId($submission->getId());
$formats = $publicationFormatDao->getBySubmissionId($submission->getId());
$publicationFormats = array();
while ($publicationFormat =& $formats->next()) {
$publicationFormats[] =& $publicationFormat;
while ($publicationFormat = $formats->next()) {
$publicationFormats[] = $publicationFormat;
}

$templateMgr->assign_by_ref('publicationFormats', $publicationFormats);
Expand Down Expand Up @@ -103,7 +103,7 @@ function fetchFormatInfo($args, $request) {
$json = new JSONMessage();

$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$formats = $publicationFormatDao->getByMonographId($submission->getId());
$formats = $publicationFormatDao->getBySubmissionId($submission->getId());
$publicationFormats = array();
while ($format = $formats->next()) {
$publicationFormats[$format->getId()] = $format->getLocalizedName();
Expand Down
Expand Up @@ -56,8 +56,8 @@ function execute($request) {
$publicationFormatTombstoneMgr = new PublicationFormatTombstoneManager();
$press = $request->getPress();
$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$publicationFormatFactory =& $publicationFormatDao->getByMonographId($monograph->getId());
$publicationFormats =& $publicationFormatFactory->toAssociativeArray();
$publicationFormatFactory = $publicationFormatDao->getBySubmissionId($monograph->getId());
$publicationFormats = $publicationFormatFactory->toAssociativeArray();
$notificationMgr = new NotificationManager();

if ($this->getData('confirm')) {
Expand Down
6 changes: 3 additions & 3 deletions controllers/tab/catalogEntry/CatalogEntryTabHandler.inc.php
Expand Up @@ -131,10 +131,10 @@ function _getFormFromCurrentTab(&$form, &$notificationKey, $request) {
// perform some validation to make sure this format is enabled and assigned to this monograph
$publishedMonographDao = DAORegistry::getDAO('PublishedMonographDAO');
$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$publishedMonograph =& $publishedMonographDao->getById($submission->getId());
$formats =& $publicationFormatDao->getByMonographId($submission->getId());
$publishedMonograph = $publishedMonographDao->getById($submission->getId());
$formats = $publicationFormatDao->getBySubmissionId($submission->getId());
$form = null;
while ($format =& $formats->next()) {
while ($format = $formats->next()) {
if ($format->getId() == $publicationFormatId) {
$form = new CatalogEntryFormatMetadataForm($submission->getId(), $publicationFormatId, $format->getId(), $this->getStageId(), array('displayedInContainer' => true, 'tabPos' => $this->getTabPosition()));
$notificationKey = 'notification.savedPublicationFormatMetadata';
Expand Down
14 changes: 7 additions & 7 deletions pages/workflow/WorkflowHandler.inc.php
Expand Up @@ -71,9 +71,9 @@ function production(&$args, $request) {
);

$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
$publicationFormats =& $publicationFormatDao->getByMonographId($monograph->getId());
$templateMgr->assign_by_ref('publicationFormats', $publicationFormats->toAssociativeArray());
$submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
$publicationFormats = $publicationFormatDao->getBySubmissionId($submission->getId());
$templateMgr->assign('publicationFormats', $publicationFormats->toAssociativeArray());

$templateMgr->assign('productionNotificationRequestOptions', $notificationRequestOptions);
$templateMgr->display('workflow/production.tpl');
Expand All @@ -87,10 +87,10 @@ function production(&$args, $request) {
function productionFormatsTab(&$args, $request) {
$templateMgr = TemplateManager::getManager($request);
$publicationFormatDao = DAORegistry::getDAO('PublicationFormatDAO');
$monograph =& $this->getAuthorizedContextObject(ASSOC_TYPE_MONOGRAPH);
$publicationFormats =& $publicationFormatDao->getByMonographId($monograph->getId());
$templateMgr->assign_by_ref('submission', $monograph);
$templateMgr->assign_by_ref('publicationFormats', $publicationFormats->toAssociativeArray());
$submission = $this->getAuthorizedContextObject(ASSOC_TYPE_SUBMISSION);
$publicationFormats = $publicationFormatDao->getBySubmissionId($submission->getId());
$templateMgr->assign('submission', $submission);
$templateMgr->assign('publicationFormats', $publicationFormats->toAssociativeArray());
$templateMgr->assign('currentFormatTabId', (int) $request->getUserVar('currentFormatTabId'));

return $templateMgr->fetchJson('workflow/productionFormatsTab.tpl');
Expand Down

0 comments on commit 73bfc83

Please sign in to comment.