Skip to content

Commit

Permalink
storage-s3: v1.17 Compatibility Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
protich committed Sep 30, 2022
1 parent 68b8eca commit 3fd8112
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 5 deletions.
2 changes: 2 additions & 0 deletions make.php
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,8 @@ function _build($plugin, $options) {
if (!isset($info['map']))
continue;
foreach ($info['map'] as $lib=>$local) {
if (preg_match('/{+(.*?)}/', $lib))
$lib = dirname($lib);
$phar_path = trim($local, '/').'/';
$full = rtrim(dirname(__file__).'/lib/'.$lib,'/').'/';
$files = new RecursiveIteratorIterator(
Expand Down
2 changes: 1 addition & 1 deletion storage-s3/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ class S3StoragePluginConfig extends PluginConfig {

// Provide compatibility function for versions of osTicket prior to
// translation support (v1.9.4)
function translate() {
static function translate() {
if (!method_exists('Plugin', 'translate')) {
return array(
function($x) { return $x; },
Expand Down
6 changes: 4 additions & 2 deletions storage-s3/plugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

return array(
'id' => 'storage:s3',
'version' => '0.3',
'version' => '0.5',
'ost_version' => '1.17', # Require osTicket v1.17+
'name' => /* trans */ 'Attachments hosted in Amazon S3',
'author' => 'Jared Hancock, Kevin Thorne',
'description' => /* trans */ 'Enables storing attachments in Amazon S3',
Expand All @@ -11,7 +12,8 @@
"aws/aws-sdk-php" => array(
'version' => "3.*",
'map' => array(
'aws/aws-sdk-php/src/{S3*,*.php}' => 'lib/Aws',
'aws/aws-sdk-php/src/{Api*,Arn*,ClientSideMonitoring*,Credentials*,DefaultsMode*,Endpoint*,Exception*,Handler*,Retry*,S3*,Signature*,*.php}' => 'lib/Aws',
'aws/aws-sdk-php/src/data' => 'lib/Aws',
'guzzlehttp/guzzle/src' => 'lib/GuzzleHttp',
'guzzlehttp/promises/src' => 'lib/GuzzleHttp/Promise',
'guzzlehttp/psr7/src/' => 'lib/GuzzleHttp/Psr7',
Expand Down
12 changes: 10 additions & 2 deletions storage-s3/storage.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function __construct($meta) {
$credentials['credentials'] = array(
'key' => static::$config['aws-key-id'],
'secret' => Crypto::decrypt(static::$config['secret-access-key'],
SECRET_SALT, static::getConfig()->getNamespace()),
SECRET_SALT, $this->getConfig()->getNamespace())
);
if (static::$config['aws-region'])
$credentials['region'] = static::$config['aws-region'];
Expand Down Expand Up @@ -248,10 +248,18 @@ function getAttrs() {
class S3StoragePlugin extends Plugin {
var $config_class = 'S3StoragePluginConfig';

function isMultiInstance() {
return false;
}

function bootstrap() {
require_once 'storage.php';

//TODO: This needs to target a specific instance
$bucketPath = sprintf('%s%s', $this->getConfig()->get('bucket'),
$this->getConfig()->get('folder') ? '/'. $this->getConfig()->get('folder') : '');
S3StorageBackend::setConfig($this->getConfig());
S3StorageBackend::$desc = sprintf('S3 (%s)', $this->getConfig()->get('bucket'));
S3StorageBackend::$desc = sprintf('S3 (%s)', $bucketPath);
FileStorageBackend::register('3', 'S3StorageBackend');
}
}
Expand Down

0 comments on commit 3fd8112

Please sign in to comment.