diff --git a/make.php b/make.php index 48afa3f..6aceaae 100644 --- a/make.php +++ b/make.php @@ -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( diff --git a/storage-s3/config.php b/storage-s3/config.php index 116b96f..e655240 100644 --- a/storage-s3/config.php +++ b/storage-s3/config.php @@ -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; }, diff --git a/storage-s3/plugin.php b/storage-s3/plugin.php index 373b27e..4a99fc4 100644 --- a/storage-s3/plugin.php +++ b/storage-s3/plugin.php @@ -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', @@ -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', diff --git a/storage-s3/storage.php b/storage-s3/storage.php index 01cb978..3a717bb 100644 --- a/storage-s3/storage.php +++ b/storage-s3/storage.php @@ -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']; @@ -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'); } }