Skip to content

Commit

Permalink
Merge pull request #77 from catalyst/support_moodle4.5
Browse files Browse the repository at this point in the history
Support MOODLE 4.5
  • Loading branch information
dmitriim authored Nov 13, 2024
2 parents 99a74ec + 89b4320 commit ec7142d
Show file tree
Hide file tree
Showing 10 changed files with 71 additions and 35 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ jobs:
ci:
uses: catalyst/catalyst-moodle-workflows/.github/workflows/ci.yml@main
with:
extra_plugin_runners: 'moodle-plugin-ci add-plugin catalyst/moodle-local_aws'
disable_phpcpd: true
12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,10 @@ The following sections outline the steps that need to be followed to install the
## Supported Moodle Versions
This plugin currently supports Moodle:

* 3.4
* 3.5
* 3.6
* 3.7
* 3.8
* 3.9
* 3.10
* 3.11
| Moodle version | Branch |
-----------------|-------------------|
| Moodle 3.4+ | MOODLE_34_STABLE |
| Moodle 4.5+ | MOODLE_405_STABLE |

## Plugin Installation
The following steps will help you install this plugin into your Moodle instance.
Expand Down
4 changes: 1 addition & 3 deletions classes/converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php');

use \core_files\conversion;
use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
Expand Down Expand Up @@ -108,7 +106,7 @@ public function create_client($handler=null) {

// Check if we are using the Moodle proxy.
if ($this->config->useproxy) {
$connectionoptions['http'] = ['proxy' => \local_aws\local\aws_helper::get_proxy_string()];
$connectionoptions['http'] = ['proxy' => helper::get_proxy_string()];
}

// Allow handler overriding for testing.
Expand Down
59 changes: 59 additions & 0 deletions classes/helper.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.

namespace fileconverter_librelambda;

/**
* AWS helpers.
*
* The core\aws\aws_helper is deprecated since Moodle 4.5, so this helper class is created to replace it.
*
* @package fileconverter_librelambda
* @copyright Catalyst IT 2024
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class helper {

/**
* This creates a proxy string suitable for use with the AWS SDK.
*
* @return string the string to use for proxy settings.
*/
public static function get_proxy_string(): string {
global $CFG;
$proxy = '';
if (empty($CFG->proxytype)) {
return $proxy;
}
if ($CFG->proxytype === 'SOCKS5') {
// If it is a SOCKS proxy, append the protocol info.
$protocol = 'socks5://';
} else {
$protocol = '';
}
if (!empty($CFG->proxyhost)) {
$proxy = $CFG->proxyhost;
if (!empty($CFG->proxyport)) {
$proxy .= ':'. $CFG->proxyport;
}
if (!empty($CFG->proxyuser) && !empty($CFG->proxypassword)) {
$proxy = $protocol . $CFG->proxyuser . ':' . $CFG->proxypassword . '@' . $proxy;
}
}
return $proxy;
}

}
6 changes: 2 additions & 4 deletions classes/provision.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php');

use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
use Aws\CloudFormation\CloudFormationClient;
Expand Down Expand Up @@ -173,7 +171,7 @@ protected function create_s3_client($handler=null) {

// Check if we are using the Moodle proxy.
if ($this->useproxy) {
$connectionoptions['http'] = ['proxy' => \local_aws\local\aws_helper::get_proxy_string()];
$connectionoptions['http'] = ['proxy' => helper::get_proxy_string()];
}

// Allow handler overriding for testing.
Expand Down Expand Up @@ -290,7 +288,7 @@ protected function create_cloudformation_client($handler=null) {

// Check if we are using the Moodle proxy.
if ($this->useproxy) {
$connectionoptions['http'] = ['proxy' => \local_aws\local\aws_helper::get_proxy_string()];
$connectionoptions['http'] = ['proxy' => helper::get_proxy_string()];
}

// Allow handler overriding for testing.
Expand Down
4 changes: 1 addition & 3 deletions classes/tester.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php');

use Aws\S3\S3Client;
use Aws\S3\Exception\S3Exception;
use Aws\Iam\Exception\IamException;
Expand Down Expand Up @@ -150,7 +148,7 @@ public function create_s3_client($handler=null) {

// Check if we are using the Moodle proxy.
if ($this->useproxy) {
$connectionoptions['http'] = ['proxy' => \local_aws\local\aws_helper::get_proxy_string()];
$connectionoptions['http'] = ['proxy' => helper::get_proxy_string()];
}

// Allow handler overriding for testing.
Expand Down
3 changes: 0 additions & 3 deletions tests/converter_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php');

use Aws\Result;
use Aws\MockHandler;
use Aws\CommandInterface;
Expand Down
3 changes: 0 additions & 3 deletions tests/events_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php');

use Aws\Result;
use Aws\MockHandler;
use Aws\CommandInterface;
Expand Down
3 changes: 0 additions & 3 deletions tests/provision_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,6 @@

defined('MOODLE_INTERNAL') || die();

global $CFG;
require_once($CFG->dirroot . '/local/aws/sdk/aws-autoloader.php');

use Aws\MockHandler;
use Aws\Result;
use Aws\CommandInterface;
Expand Down
11 changes: 4 additions & 7 deletions version.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,8 @@
defined('MOODLE_INTERNAL') || die();

$plugin->component = 'fileconverter_librelambda';
$plugin->release = 2023010900;
$plugin->version = 2023010900;
$plugin->requires = 2017111309;
$plugin->release = 2024111300;
$plugin->version = 2024111300;
$plugin->requires = 2024100700;
$plugin->maturity = MATURITY_STABLE;
$plugin->dependencies = array(
'local_aws' => 2023072100
);
$plugin->supported = [34, 401]; // A range of branch numbers of supported moodle versions.
$plugin->supported = [405, 405]; // A range of branch numbers of supported moodle versions.

0 comments on commit ec7142d

Please sign in to comment.