Skip to content

Commit

Permalink
Merge pull request #55 from ewhanson/section_change_bug
Browse files Browse the repository at this point in the history
Reflect section change in stored submission and remove deprecated DAO call
  • Loading branch information
bozana authored Mar 26, 2024
2 parents 15b5ea2 + 1b9ae3f commit bfb43a2
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions QuickSubmitForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,25 @@ function __construct($plugin, $request) {
}

if ($submissionId = $request->getUserVar('submissionId')) {
$submissionDao = Application::getSubmissionDAO();
$submissionDao = DAORegistry::getDAO('SubmissionDAO');
$publicationDao = DAORegistry::getDAO('PublicationDAO'); /* @var $publicationDao PublicationDAO */

$this->_submission = $submissionDao->getById($submissionId);
if ($this->_submission->getContextId() != $this->_context->getId()) throw new Exeption('Submission not in context!');

$this->_submission->setLocale($this->getDefaultFormLocale());
$publication = $this->_submission->getCurrentPublication();
$publication->setData('locale', $this->getDefaultFormLocale());
$publication->setData('language', PKPString::substr($this->getDefaultFormLocale(), 0, 2));

$sectionId = $request->getUserVar('sectionId');
if (!empty($sectionId)) {
$this->_submission->setSectionId($sectionId);
}

$submissionDao->updateObject($this->_submission);
$publicationDao->updateObject($publication);

$this->_metadataFormImplem->addChecks($this->_submission);
}

Expand Down Expand Up @@ -217,7 +225,7 @@ function initData() {
$sectionOptions = $sectionDao->getTitlesByContextId($this->_context->getId());

// Create and insert a new submission
$submissionDao = Application::getSubmissionDAO();
$submissionDao = DAORegistry::getDAO('SubmissionDAO');
$this->_submission = $submissionDao->newDataObject();
$this->_submission->setContextId($this->_context->getId());
$this->_submission->setStatus(STATUS_QUEUED);
Expand Down Expand Up @@ -306,7 +314,7 @@ function readInputData() {
* cancel submit
*/
function cancel() {
$submissionDao = Application::getSubmissionDAO();
$submissionDao = DAORegistry::getDAO('SubmissionDAO');
$submission = $submissionDao->getById($this->getData('submissionId'));
if ($this->_submission->getContextId() != $this->_context->getId()) throw new Exeption('Submission not in context!');
if ($submission) $submissionDao->deleteById($submission->getId());
Expand Down

0 comments on commit bfb43a2

Please sign in to comment.