Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix deprecated submission functions #5

Merged
merged 1 commit into from
Dec 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 11 additions & 12 deletions SwordServerPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ function getPolicies($request) {
* Serve a SWORD Service Document
*/
function serviceDocument() {
$journal = $this->request->getJournal();
$journal = $this->request->getContext();
$sections = iterator_to_array(Repo::section()->getCollector()->filterByContextIds([$journal->getId()])->getMany(), true);

// Exclude inactive sections
Expand Down Expand Up @@ -145,7 +145,7 @@ function serviceDocument() {
* @param $opts array
*/
function deposit($opts) {
$journal = $this->request->getJournal();
$journal = $this->request->getContext();
$locale = $journal->getPrimaryLocale();
$user = $this->request->getUser();

Expand Down Expand Up @@ -183,14 +183,13 @@ function deposit($opts) {

// Populate a Submission object
$submission = Repo::submission()->newDataObject();
$submission->setContextId($journal->getId());
$submission->setDateSubmitted (Core::getCurrentDate());
$submission->setLastModified (Core::getCurrentDate());
$submission->setSubmissionProgress($isManager ? 0 : 1); // Force non-editor users to review submission steps.
$submission->setStageId(WORKFLOW_STAGE_ID_SUBMISSION);
$submission->setLocale($locale);
$submission->setStatus(STATUS_QUEUED);
$submission->setContextId($journal->getId());
$submission->setData('contextId', $journal->getId());
$submission->setData('dateSubmitted', Core::getCurrentDate());
$submission->stampModified();
$submission->setData('submissionProgress', $isManager ? 0 : 1); // Force non-editor users to review submission steps.
$submission->setData('stageId', WORKFLOW_STAGE_ID_SUBMISSION);
$submission->setData('locale', $locale);
$submission->setData('status', STATUS_QUEUED);
Repo::submission()->add($submission, $publication, $journal);

$match = $metsDoc->xpath("//epdcx:statement[@epdcx:propertyURI='http://purl.org/dc/elements/1.1/title']/epdcx:valueString");
Expand Down Expand Up @@ -257,7 +256,7 @@ function deposit($opts) {

// Create and send the deposit receipt
$depositReceipt = new DepositReceipt([
'title' => $submission->getTitle($locale),
'title' => $publication->getData('title', $locale),
'edit-iri' => $this->request->getRouter()->url($this->request, null, null, null, ['swordServer', 'submissions', $submission->getId()]),
'stmt-iri' => $this->request->getRouter()->url($this->request, null, null, null, ['swordServer', 'submissions', $submission->getId(), 'statement']),
'alternateLink' => $this->request->getRouter()->url($this->request, null, 'submission', 'wizard', [1], ['submissionId' => $submission->getId()]),
Expand Down Expand Up @@ -309,7 +308,7 @@ function statement($opts) {
$submission = Repo::submission()->get($opts['id']);

// Ensure that the requested submission is in the appropriate journal
if ($submission->getContextId() != $this->getRequest()->getJournal()->getId()) {
if ($submission->getData('contextId') != $this->getRequest()->getContext()->getId()) {
throw new Exception('The specified submission is not allowed!');
}
$section = Repo::section()->get($submission->getSectionId());
Expand Down