Commit ca922c24 authored by Andrew Nicols's avatar Andrew Nicols
Browse files

Merge branch 'MDL-51710-master' of git://github.com/FMCorz/moodle

parents 9ef63865 2a5920c3
......@@ -43,6 +43,7 @@ class repository_s3 extends repository {
* @param array $options
*/
public function __construct($repositoryid, $context = SYSCONTEXTID, $options = array()) {
global $CFG;
parent::__construct($repositoryid, $context, $options);
$this->access_key = get_config('s3', 'access_key');
$this->secret_key = get_config('s3', 'secret_key');
......@@ -52,6 +53,26 @@ class repository_s3 extends repository {
}
$this->s = new S3($this->access_key, $this->secret_key, false, $this->endpoint);
$this->s->setExceptions(true);
// Port of curl::__construct().
if (!empty($CFG->proxyhost)) {
if (empty($CFG->proxyport)) {
$proxyhost = $CFG->proxyhost;
} else {
$proxyhost = $CFG->proxyhost . ':' . $CFG->proxyport;
}
$proxytype = CURLPROXY_HTTP;
$proxyuser = null;
$proxypass = null;
if (!empty($CFG->proxyuser) and !empty($CFG->proxypassword)) {
$proxyuser = $CFG->proxyuser;
$proxypass = $CFG->proxypassword;
}
if (!empty($CFG->proxytype) && $CFG->proxytype == 'SOCKS5') {
$proxytype = CURLPROXY_SOCKS5;
}
$this->s->setProxy($proxyhost, $proxyuser, $proxypass, $proxytype);
}
}
/**
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment