Skip to content

Commit

Permalink
Support 3.3
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnyga committed Feb 19, 2023
1 parent 52bffb0 commit d1b7783
Show file tree
Hide file tree
Showing 12 changed files with 77 additions and 118 deletions.
26 changes: 11 additions & 15 deletions ObjectsForReviewPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,6 @@ function getInstallEmailTemplatesFile() {
return ($this->getPluginPath() . '/emailTemplates.xml');
}

/**
* @see PKPPlugin::getInstallEmailTemplateDataFile()
*/
function getInstallEmailTemplateDataFile() {
return ($this->getPluginPath() . '/locale/{$installedLocale}/emailTemplates.xml');
}

/**
* @copydoc Plugin::getActions()
Expand All @@ -60,7 +54,7 @@ function getActions($request, $verb) {
$router = $request->getRouter();
import('lib.pkp.classes.linkAction.request.AjaxModal');
return array_merge(
$this->getEnabled()?array(
$this->getEnabled()?[
new LinkAction(
'settings',
new AjaxModal(
Expand All @@ -70,7 +64,7 @@ function getActions($request, $verb) {
__('manager.plugins.settings'),
null
),
):array(),
]:[],
parent::getActions($request, $verb)
);
}
Expand Down Expand Up @@ -108,6 +102,7 @@ function manage($args, $request) {
* @copydoc Plugin::register()
*/
function register($category, $path, $mainContextId = null) {

$success = parent::register($category, $path, $mainContextId);
if ($success && $this->getEnabled($mainContextId)) {

Expand Down Expand Up @@ -188,7 +183,7 @@ function setupGridHandler($hookName, $params) {
function addToPublicationForms($hookName, $params) {
$smarty =& $params[1];
$output =& $params[2];
$submission = $smarty->get_template_vars('submission');
$submission = $smarty->getTemplateVars('submission');
$smarty->assign([
'submissionId' => $submission->getId(),
]);
Expand Down Expand Up @@ -221,7 +216,7 @@ function addSubmissionDisplay($hookName, $params) {
$templateMgr = $params[1];
$output =& $params[2];

$submission = $templateMgr->get_template_vars('monograph') ? $templateMgr->get_template_vars('monograph') : $templateMgr->get_template_vars('article');
$submission = $templateMgr->getTemplateVars('monograph') ? $templateMgr->getTemplateVars('monograph') : $templateMgr->getTemplateVars('article');

$objectForReviewDao = DAORegistry::getDAO('ObjectForReviewDAO');
$objectsForReview = $objectForReviewDao->getBySubmissionId($submission->getId());
Expand Down Expand Up @@ -252,7 +247,7 @@ function addSubmissionDisplay($hookName, $params) {
* Hook to ArticleDAO::_fromRow and MonographDAO::_fromRow and display objectForReview as subtitle
* @param $hookName string
* @param $params array
*/
*/
function addSubtitleDisplay($hookName, $params) {
// NOTE Not working in 3.2, need to rewrite this
$submission =& $params[0];
Expand All @@ -275,10 +270,11 @@ function addSubtitleDisplay($hookName, $params) {
}

/**
* @copydoc Plugin::getInstallSchemaFile()
* @copydoc Plugin::getInstallMigration()
*/
function getInstallSchemaFile() {
return $this->getPluginPath() . '/schema.xml';
function getInstallMigration() {
$this->import('ObjectsForReviewSchemaMigration');
return new ObjectsForReviewSchemaMigration();
}

/**
Expand Down Expand Up @@ -443,7 +439,7 @@ function getMailTemplate($emailKey, $context = null) {
* Send mail to editor when object is reserved or cancelled
*
* @param User $user
* @param $object
* @param $object
* @param $template Send either the reserve or cancel mail
*/
public function notifyEditor($user, $objectDescription, $mailTemplate) {
Expand Down
49 changes: 49 additions & 0 deletions ObjectsForReviewSchemaMigration.inc.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/**
* @file ObjectsForReviewSchemaMigration.inc.php
*
* Copyright (c) 2014-2020 Simon Fraser University
* Copyright (c) 2000-2020 John Willinsky
* Distributed under the GNU GPL v3. For full terms see the file docs/COPYING.
*
* @class ObjectsForReviewSchemaMigration
* @brief Describe database table structures.
*/

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Builder;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Capsule\Manager as Capsule;

class ObjectsForReviewSchemaMigration extends Migration
{
/**
* Run the migrations.
*/
public function up()
{
Capsule::schema()->create('objects_for_review', function (Blueprint $table) {
$table->bigInteger('object_id')->autoIncrement();
$table->bigInteger('submission_id')->nullable();
$table->bigInteger('context_id');
$table->bigInteger('user_id')->nullable();
$table->string('identifier', 255);
$table->string('identifier_type', 255);
$table->string('resource_type', 255);
$table->string('creator', 255);
$table->datetime('date_created');
});

Capsule::schema()->create('objects_for_review_settings', function (Blueprint $table) {
$table->bigInteger('object_id');
$table->string('locale', 14)->default('');
$table->string('setting_name', 255);
$table->longText('setting_value')->nullable();
$table->string('setting_type', 6)->comment('(bool|int|float|string|object)');
$table->index(['object_id'], 'objects_for_review_settings_id');
$table->unique(['object_id', 'locale', 'setting_name'], 'objects_for_review_settings_pkey');
});
}

}
4 changes: 2 additions & 2 deletions ObjectsForReviewSettingsForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ function __construct($plugin, $journalId) {
* Initialize form data.
*/
function initData() {
$request = Application::getRequest();
$request = Application::get()->getRequest();
$context = $request->getContext();
$this->_data = array(
'displayAsSubtitle' => $this->_plugin->getSetting($this->_journalId, 'displayAsSubtitle'),
Expand Down Expand Up @@ -73,7 +73,7 @@ function fetch($request, $template = null, $display = false) {
* Save settings.
*/
function execute(...$functionArgs) {
$request = Application::getRequest();
$request = Application::get()->getRequest();
$context = $request->getContext();
$this->_plugin->updateSetting($this->_journalId, 'displayAsSubtitle', $this->getData('displayAsSubtitle'), 'bool');
$this->_plugin->updateSetting($this->_journalId, 'displayAsList', $this->getData('displayAsList'), 'bool');
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Objects for Review Plugin for OJS3
# Objects for Review Plugin for OJS 3.3


## About
Expand All @@ -15,4 +15,4 @@ The frontend object listing uses https://github.com/tristen/tablesort for table

This plugin is licensed under the GNU General Public License v3. See the file LICENSE for the complete terms of this license.

The license for https://github.com/tristen/tablesort included in the repository is MIT. See https://github.com/tristen/tablesort/blob/gh-pages/LICENCE
The license for https://github.com/tristen/tablesort included in the repository is MIT. See https://github.com/tristen/tablesort/blob/gh-pages/LICENCE
20 changes: 8 additions & 12 deletions classes/ObjectForReviewDAO.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class ObjectForReviewDAO extends DAO {
* @param $submissionId int (optional) Submission ID
*/
function getById($objectId, $submissionId = null) {
$params = array((int) $objectId);
$params = [(int) $objectId];
if ($submissionId) $params[] = (int) $submissionId;

$result = $this->retrieve(
Expand All @@ -33,12 +33,8 @@ function getById($objectId, $submissionId = null) {
$params
);

$returner = null;
if ($result->RecordCount() != 0) {
$returner = $this->_fromRow($result->GetRowAssoc(false));
}
$result->Close();
return $returner;
$row = $result->current();
return $row ? $this->_fromRow((array) $row) : null;
}

/**
Expand All @@ -47,7 +43,7 @@ function getById($objectId, $submissionId = null) {
* @param $contextId int (optional) context ID
*/
function getBySubmissionId($submissionId, $contextId = null) {
$params = array((int) $submissionId);
$params = [(int) $submissionId];
if ($contextId) $params[] = (int) $contextId;

$result = $this->retrieve(
Expand All @@ -66,7 +62,7 @@ function getBySubmissionId($submissionId, $contextId = null) {
* @param $withoutSubmissionOnly true if only objects without a submission should be included
*/
function getByUserId($userId, $contextId = null, $withoutSubmissionOnly = false) {
$params = array((int) $userId);
$params = [(int) $userId];
if ($contextId) $params[] = (int) $contextId;

$result = $this->retrieve(
Expand All @@ -91,7 +87,7 @@ function getAll($contextId, $withoutSubmissionOnly = false, $managerCreatedOnly
'SELECT * FROM objects_for_review WHERE context_id = ?'
. ($withoutSubmissionOnly?' AND submission_id IS NULL':'')
. ($managerCreatedOnly?" AND creator = 'manager'":""),
$contextId
[$contextId]
);
return new DAOResultFactory($result, $this, '_fromRow');
}
Expand Down Expand Up @@ -159,12 +155,12 @@ function updateObject($objectForReview) {
function deleteById($objectId) {
$this->update(
'DELETE FROM objects_for_review WHERE object_id = ?',
(int) $objectId
[(int) $objectId]
);

$this->update(
'DELETE FROM objects_for_review_settings WHERE object_id = ?',
(int) $objectId
[(int) $objectId]
);
}

Expand Down
1 change: 1 addition & 0 deletions controllers/grid/form/ObjectsForReviewForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ function execute(...$functionArgs) {
$objectForReview->setTitle($title);
$objectForReview->setYear($this->getData('year'));
$objectForReview->setPublisher($this->getData('publisher'));
$objectForReview->setCreator("workflow");

if ($objectId) {
$objectForReviewDao->updateObject($objectForReview);
Expand Down
4 changes: 2 additions & 2 deletions emailTemplates.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
* Email templates XML file.
-->
<emails>
<email key="OFR_NEW_RESERVATION" can_edit="1" can_disable="0"/>
<email key="OFR_CANCEL_RESERVATION" can_edit="1" can_disable="0"/>
<email key="OFR_NEW_RESERVATION" can_edit="1" can_disable="0" subject="emails.ofrNewReservation.subject" description="emails.ofrNewReservation.description" body="emails.ofrNewReservation.body"/>
<email key="OFR_CANCEL_RESERVATION" can_edit="1" can_disable="0" subject="emails.ofrCancelReservation.subject" description="emails.ofrCancelReservation.description" body="emails.ofrCancelReservation.body"/>
</emails>
File renamed without changes.
File renamed without changes.
File renamed without changes.
83 changes: 0 additions & 83 deletions schema.xml

This file was deleted.

4 changes: 2 additions & 2 deletions version.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
<version>
<application>objectsForReview</application>
<type>plugins.generic</type>
<release>3.0.1.0</release>
<date>2021-02-21</date>
<release>3.3.0.0</release>
<date>2023-02-19</date>
<lazy-load>1</lazy-load>
<class>ObjectsForReviewPlugin</class>
</version>

0 comments on commit d1b7783

Please sign in to comment.