Skip to content

Commit

Permalink
Support 3.4
Browse files Browse the repository at this point in the history
  • Loading branch information
ajnyga committed Feb 20, 2023
1 parent aa9931a commit 376418e
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 13 deletions.
19 changes: 13 additions & 6 deletions AllowedUploadsPlugin.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@
* @brief Allowed Uploads plugin class
*/

import('lib.pkp.classes.plugins.GenericPlugin');
use APP\core\Application;
use APP\template\TemplateManager;
use PKP\core\JSONMessage;
use PKP\plugins\GenericPlugin;
use PKP\plugins\PluginRegistry;
use PKP\validation\ValidatorFactory;


class AllowedUploadsPlugin extends GenericPlugin {
/**
Expand Down Expand Up @@ -79,7 +85,6 @@ function manage($args, $request) {
case 'settings':
$context = $request->getContext();

AppLocale::requireComponents(LOCALE_COMPONENT_APP_COMMON, LOCALE_COMPONENT_PKP_MANAGER);
$templateMgr = TemplateManager::getManager($request);
$templateMgr->registerPlugin('function', 'plugin_url', array($this, 'smartyPluginUrl'));

Expand All @@ -104,11 +109,11 @@ function manage($args, $request) {
* Check the uploaded file in wizard
*/
function checkUploadWizard($hookName, $params) {
$props = $params[2];
$locale = $params[4];

if ($params[1] == 'add'){
if ($fileName = $props['name'][$locale]){
$errors =& $params[0];
$props = $params[2];
$locale = $params[4];
$request = Application::get()->getRequest();
$context = $request->getContext();

Expand All @@ -121,9 +126,11 @@ function checkUploadWizard($hookName, $params) {
if ($allowedExtensions){
$allowedExtensionsArray = array_filter(array_map('trim', explode(';', $allowedExtensions )), 'strlen');
if (!in_array($extension, $allowedExtensionsArray)){
$errors['allowedExtensions'] = __('plugins.generic.allowedUploads.error', array('allowedExtensions' => $allowedExtensions));
$errors['allowedExtensions'][$locale] = __('plugins.generic.allowedUploads.error', array('allowedExtensions' => $allowedExtensions));
}
}


}
}

Expand Down
7 changes: 4 additions & 3 deletions AllowedUploadsSettingsForm.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @brief Form for managers to modify Allowed Uploads plugin settings
*/

import('lib.pkp.classes.form.Form');
use PKP\form\Form;

class AllowedUploadsSettingsForm extends Form {

Expand All @@ -34,8 +34,9 @@ function __construct($plugin, $contextId) {

parent::__construct($plugin->getTemplateResource('settingsForm.tpl'));

$this->addCheck(new FormValidatorPost($this));
$this->addCheck(new FormValidatorCSRF($this));
$this->addCheck(new \PKP\form\validation\FormValidatorPost($this));
$this->addCheck(new \PKP\form\validation\FormValidatorCSRF($this));

}

/**
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
Allowed Uploads
===============

For OJS/OMP 3.3.0
For OJS/OMP/OPS 3.4.0

The plugin enables the editor to choose which file extensions are allowed in their journal. NOTE! This is *not* a security plugin. Make sure that your files directory is not a subdirectory of your OJS installation. For more details read the OJS installation instructions.
The plugin enables the editor to choose which file extensions are allowed in their journal. NOTE! This is *not* a security plugin. Make sure that your files directory is not a subdirectory of your OJS/OMP/OPS installation. For more details read the OJS/OMP/OPS installation instructions.

Copy the plugin folder to plugins/generic/ and enable it. Edit the plugin settings and add a list semicolon separated list of allowed filetypes, for example **doc; docx; pdf; gif; jpg;**.

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
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>allowedUploads</application>
<type>plugins.generic</type>
<release>1.1.1.0</release>
<date>2022-07-27</date>
<release>3.4.0.0</release>
<date>2023-02-17</date>
<lazy-load>1</lazy-load>
<class>AllowedUploadsPlugin</class>
</version>

0 comments on commit 376418e

Please sign in to comment.