mirror of
https://github.com/moodle/moodle.git
synced 2025-01-29 11:46:19 +01:00
MDL-43752 repository_s3: added endpoint select box to settings page
This commit is contained in:
parent
4c27f52d91
commit
9b71e3aff0
@ -25,6 +25,7 @@
|
||||
|
||||
$string['access_key'] = 'Access key';
|
||||
$string['configplugin'] = 'Amazon S3 settings';
|
||||
$string['endpoint'] = 'Amazon S3 Endpoint';
|
||||
$string['needaccesskey'] = 'Access key must be provided';
|
||||
$string['pluginname'] = 'Amazon S3';
|
||||
$string['secret_key'] = 'Secret key';
|
||||
|
21
repository/s3/lib.php
Normal file → Executable file
21
repository/s3/lib.php
Normal file → Executable file
@ -46,7 +46,11 @@ class repository_s3 extends repository {
|
||||
parent::__construct($repositoryid, $context, $options);
|
||||
$this->access_key = get_config('s3', 'access_key');
|
||||
$this->secret_key = get_config('s3', 'secret_key');
|
||||
$this->s = new S3($this->access_key, $this->secret_key);
|
||||
$this->endpoint = get_config('s3', 'endpoint');
|
||||
if ($this->endpoint === false) { // If no endpoint has been set, use the default.
|
||||
$this->endpoint = 's3.amazonaws.com';
|
||||
}
|
||||
$this->s = new S3($this->access_key, $this->secret_key, false, $this->endpoint);
|
||||
$this->s->setExceptions(true);
|
||||
}
|
||||
|
||||
@ -235,10 +239,25 @@ class repository_s3 extends repository {
|
||||
public static function type_config_form($mform, $classname = 'repository') {
|
||||
parent::type_config_form($mform);
|
||||
$strrequired = get_string('required');
|
||||
$endpointselect = array( // List of possible Amazon S3 Endpoints.
|
||||
"s3.amazonaws.com" => "s3.amazonaws.com",
|
||||
"s3-external-1.amazonaws.com" => "s3-external-1.amazonaws.com",
|
||||
"s3-us-west-2.amazonaws.com" => "s3-us-west-2.amazonaws.com",
|
||||
"s3-us-west-1.amazonaws.com" => "s3-us-west-1.amazonaws.com",
|
||||
"s3-eu-west-1.amazonaws.com" => "s3-eu-west-1.amazonaws.com",
|
||||
"s3.eu-central-1.amazonaws.com" => "s3.eu-central-1.amazonaws.com",
|
||||
"s3-eu-central-1.amazonaws.com" => "s3-eu-central-1.amazonaws.com",
|
||||
"s3-ap-southeast-1.amazonaws.com" => "s3-ap-southeast-1.amazonaws.com",
|
||||
"s3-ap-southeast-2.amazonaws.com" => "s3-ap-southeast-2.amazonaws.com",
|
||||
"s3-ap-northeast-1.amazonaws.com" => "s3-ap-northeast-1.amazonaws.com",
|
||||
"s3-sa-east-1.amazonaws.com" => "s3-sa-east-1.amazonaws.com"
|
||||
);
|
||||
$mform->addElement('text', 'access_key', get_string('access_key', 'repository_s3'));
|
||||
$mform->setType('access_key', PARAM_RAW_TRIMMED);
|
||||
$mform->addElement('text', 'secret_key', get_string('secret_key', 'repository_s3'));
|
||||
$mform->setType('secret_key', PARAM_RAW_TRIMMED);
|
||||
$endpointselected = $mform->addElement('select', 'endpoint', get_string('endpoint', 'repository_s3'), $endpointselect);
|
||||
$endpointselected->setSelected('s3.amazonaws.com'); // Default to US Endpoint.
|
||||
$mform->addRule('access_key', $strrequired, 'required', null, 'client');
|
||||
$mform->addRule('secret_key', $strrequired, 'required', null, 'client');
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user