/**
  * Gets a configured instance of a storage adapter.
  *
  * @param mixed $adapterName string of adapter configuration or array of settings
  * @param boolean $renewObject Creates a new instance of the given adapter in the configuration
  * @throws \RuntimeException
  * @return \Gaufrette\Filesystem
  */
 public static function adapter($adapterName, $renewObject = false)
 {
     $_this = StorageManager::getInstance();
     $isConfigured = true;
     if (is_string($adapterName)) {
         if (!empty($_this->_adapterConfig[$adapterName])) {
             $adapter = $_this->_adapterConfig[$adapterName];
         } else {
             throw new \RuntimeException(sprintf('Invalid Storage Adapter %s!', $adapterName));
         }
         if (!empty($_this->_adapterConfig[$adapterName]['object']) && $renewObject === false) {
             return $_this->_adapterConfig[$adapterName]['object'];
         }
     }
     if (is_array($adapterName)) {
         $adapter = $adapterName;
         $isConfigured = false;
     }
     $class = $adapter['adapterClass'];
     $Reflection = new \ReflectionClass($class);
     if (!is_array($adapter['adapterOptions'])) {
         throw new \InvalidArgumentException(sprintf('%s: The adapter options must be an array!', $adapterName));
     }
     $adapterObject = $Reflection->newInstanceArgs($adapter['adapterOptions']);
     $engineObject = new $adapter['class']($adapterObject);
     if ($isConfigured) {
         $_this->_adapterConfig[$adapterName]['object'] =& $engineObject;
     }
     return $engineObject;
 }
 function __construct()
 {
     $this->relationsManager = new RelationsManager();
     $this->provider = new SQLRelationsProvider();
     // This is hard-coded, maybe in the future it will use another provider
     $this->dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
 }
 /**
  * testProcessVersion
  *
  * @return void
  */
 public function testProcessVersion()
 {
     $this->Image->create();
     $result = $this->Image->save(array('foreign_key' => 'test-1', 'model' => 'Test', 'file' => array('name' => 'titus.jpg', 'size' => 332643, 'tmp_name' => CakePlugin::path('FileStorage') . DS . 'Test' . DS . 'Fixture' . DS . 'File' . DS . 'titus.jpg', 'error' => 0)));
     $result = $this->Image->find('first', array('conditions' => array('id' => $this->Image->getLastInsertId())));
     $this->assertTrue(!empty($result) && is_array($result));
     $this->assertTrue(file_exists($this->testPath . $result['ImageStorage']['path']));
     $path = $this->testPath . $result['ImageStorage']['path'];
     $Folder = new Folder($path);
     $folderResult = $Folder->read();
     $this->assertEqual(count($folderResult[1]), 3);
     Configure::write('Media.imageSizes.Test', array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200))));
     ClassRegistry::init('FileStorage.ImageStorage')->generateHashes();
     $Event = new CakeEvent('ImageVersion.createVersion', $this->Image, array('record' => $result, 'storage' => StorageManager::adapter('Local'), 'operations' => array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200)))));
     CakeEventManager::instance()->dispatch($Event);
     $path = $this->testPath . $result['ImageStorage']['path'];
     $Folder = new Folder($path);
     $folderResult = $Folder->read();
     $this->assertEqual(count($folderResult[1]), 4);
     $Event = new CakeEvent('ImageVersion.removeVersion', $this->Image, array('record' => $result, 'storage' => StorageManager::adapter('Local'), 'operations' => array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200)))));
     CakeEventManager::instance()->dispatch($Event);
     $path = $this->testPath . $result['ImageStorage']['path'];
     $Folder = new Folder($path);
     $folderResult = $Folder->read();
     $this->assertEqual(count($folderResult[1]), 3);
 }
 /**
  * testAdapter
  *
  * @todo more tests
  * @return void
  */
 public function testAdapter()
 {
     $result = StorageManager::adapter('Local');
     $this->assertEqual(get_class($result), 'Gaufrette\\Filesystem');
     $result = StorageManager::activeAdapter();
     $this->assertEqual($result, 'Local');
     $result = StorageManager::activeAdapter('invalid-adapter');
     $this->assertFalse($result);
     $result = StorageManager::config();
 }
 /**
  * Setup test folders and files
  *
  * @return void
  */
 public function setUp()
 {
     parent::setUp();
     $this->testPath = TMP . 'file-storage-test' . DS;
     Configure::write('Media.basePath', $this->testPath);
     if (!is_dir($this->testPath)) {
         $Folder = new Folder($this->testPath, true);
     }
     Configure::write('Media.imageSizes', array('Test' => array('t50' => array('thumbnail' => array('mode' => 'outbound', 'width' => 50, 'height' => 50)), 't150' => array('thumbnail' => array('mode' => 'outbound', 'width' => 150, 'height' => 150)))));
     ClassRegistry::init('FileStorage.ImageStorage')->generateHashes();
     StorageManager::config('Local', array('adapterOptions' => array($this->testPath, true), 'adapterClass' => '\\Gaufrette\\Adapter\\Local', 'class' => '\\Gaufrette\\Filesystem'));
 }
 private function getDao()
 {
     if (!isset(self::$dao)) {
         try {
             $dbHandler = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
         } catch (Exception $e) {
             throw new EyeDBException('An error occured while getting connection to the database.', 0, $e);
         }
         self::$dao = $dbHandler;
     }
     return self::$dao;
 }
 public function onBeforeDelete($Event)
 {
     if (!$this->_check($Event)) {
         return true;
     }
     $model = $Event->subject();
     $fields = array('adapter', 'filename');
     $data = $model->findById($model->id, $fields);
     $asset =& $data['AssetsAsset'];
     $adapter = StorageManager::adapter($asset['adapter']);
     if ($adapter->has($asset['filename'])) {
         $adapter->delete($asset['filename']);
     }
     return $model->deleteAll(array('parent_asset_id' => $model->id), true, true);
 }
 public function onBeforeDelete($Event)
 {
     $model = $Event->subject();
     if (!$this->_check($Event)) {
         return true;
     }
     $model = $Event->subject();
     $fields = array('adapter', 'path');
     $data = $model->findById($model->id, $fields);
     $asset =& $data['AssetsAsset'];
     $filesystem = StorageManager::adapter($asset['adapter']);
     $key = str_replace('/assets', '', $asset['path']);
     if ($filesystem->has($key)) {
         $filesystem->delete($key);
     }
     return $model->deleteAll(array('parent_asset_id' => $model->id), true, true);
 }
 /**
  * afterSave
  *
  * @param CakeEvent $Event
  * @return void
  */
 public function afterSave(CakeEvent $Event)
 {
     if ($this->_checkEvent($Event)) {
         $Model = $Event->subject();
         $record = $Model->data[$Model->alias];
         $Storage = StorageManager::adapter($record['adapter']);
         try {
             $id = $record[$Model->primaryKey];
             $filename = $Model->stripUuid($id);
             $file = $record['file'];
             $record['path'] = $Model->fsPath('files' . DS . $record['model'], $id);
             $result = $Storage->write($record['path'] . $filename . '.' . $record['extension'], file_get_contents($file['tmp_name']), true);
             $Model->save(array($Model->alias => $record), array('validate' => false, 'callbacks' => false));
         } catch (Exception $e) {
             $this->log($e->getMessage(), 'file_storage');
         }
     }
 }
 protected function __construct()
 {
     /**
      * establim la connexió a base de dades
      */
     $this->eyeosDAO = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
     /**
      * Connect to LDAP host
      */
     $this->eyeosLDAP = ldap_connect(LDAP_HOSTNAME, LDAP_PORT) or $this->sendError("Can't connect to " . LDAP_HOSTNAME . " LDAP Server.");
     /**
      * set LDAP version
      */
     ldap_set_option($this->eyeosLDAP, LDAP_OPT_PROTOCOL_VERSION, LDAP_OPT_PROTOCOL_VERSION_VALUE) or $this->sendError("Can't establish LDAP Protocol Version to " . LDAP_OPT_PROTOCOL_VERSION_VALUE);
     /**
      * If there is connection parms, link with them, if not, as anonimous
      */
     if (defined('LDAP_BIND_RDN')) {
         ldap_bind($this->eyeosLDAP, LDAP_BIND_RDN, LDAP_BIND_PASSWORD) or $this->sendError("Can't bind to " . LDAP_HOSTNAME . " LDAP Server with user " . LDAP_BIND_RDN);
     } else {
         ldap_bind($this->eyeosLDAP) or $this->sendError("Can't bind to " . LDAP_HOSTNAME . " LDAP Server.");
     }
 }
Esempio n. 11
0
function __start_test()
{
    $dbh = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
    // Drop tables
    try {
        $dbh->send('DROP TABLE `eyeosuserworkgroupassignation`');
    } catch (PDOException $e) {
    }
    try {
        $dbh->send('DROP TABLE `eyeosworkgroup`');
    } catch (PDOException $e) {
    }
    try {
        $dbh->send('DROP TABLE `eyeosprincipalgroupassignation`');
    } catch (PDOException $e) {
    }
    try {
        $dbh->send('DROP TABLE `eyeosuser`');
    } catch (PDOException $e) {
    }
    try {
        $dbh->send('DROP TABLE `eyeosgroup`');
    } catch (PDOException $e) {
    }
    // Create tables with initial content
    $initSqlScript = file_get_contents('./extras/EyeosUMSQL/EyeosUMSQL.sql');
    $dbh->send($initSqlScript);
    // Here we're using a test AuthConfiguration using FakeEyeosLoginModule, that allows to login
    // as root even without root user in the database so we can create... a real user root for
    // the rest of the tests :)
    // (the UM service is not accessible for writing by anyone, only root, members of "admin" or
    // "um" system groups)
    $originalConf = AuthConfiguration::getConfiguration();
    AuthConfiguration::setConfiguration(new XMLAuthConfiguration('./tests/system/conf/services/UM/AuthConfigurations/init_tests.xml'));
    // We need a valid login context to create test principals
    $myUManager = UMManager::getInstance();
    $subject = new Subject();
    $loginContext = new LoginContext('root', $subject);
    $subject->getPrivateCredentials()->append(new FakeEyeosCredential('root', 'root'));
    $loginContext->login();
    // Create "login" process
    $procManager = ProcManager::getInstance();
    $myProcess = new Process('login');
    $procManager->execute($myProcess);
    $procManager->setProcessLoginContext($myProcess->getPid(), $loginContext);
    // Delete pre-existing users because we need to create users in a clean way,
    // to trigger any action that is supposed to take place on user creation
    // (folder creation, default configuration files, etc.)
    try {
        $john = $myUManager->getUserByName('john');
        $myUManager->deletePrincipal($john);
    } catch (EyeNoSuchUserException $e) {
    }
    try {
        $root = $myUManager->getUserByName('root');
        $myUManager->deletePrincipal($root);
    } catch (EyeNoSuchUserException $e) {
    }
    // Create root
    $group = $myUManager->getGroupByName('root');
    $user = $myUManager->getNewUserInstance();
    $user->setName('root');
    $user->setPassword('root', true);
    $user->setPrimaryGroupId($group->getId());
    $myUManager->createUser($user);
    // Create john
    $group = $myUManager->getGroupByName(SERVICE_UM_DEFAULTUSERSGROUP);
    $user = $myUManager->getNewUserInstance();
    $user->setName('john');
    $user->setPassword('john', true);
    $user->setPrimaryGroupId($group->getId());
    $myUManager->createUser($user);
    // Now switch to a real authentication with root
    AuthConfiguration::setConfiguration($originalConf);
    $subject = new Subject();
    $loginContext = new LoginContext('init', $subject);
    $subject->getPrivateCredentials()->append(new EyeosPasswordCredential('root', 'root'));
    $loginContext->login();
    $procManager = ProcManager::getInstance();
    $procManager->setProcessLoginContext($myProcess->getPid(), $loginContext);
}
 public function updateCalendarPreferences(ICalendarPrefs $calendarPrefs)
 {
     $dao = StorageManager::getInstance()->getHandler('SQL/EyeosDAO');
     $calendarPrefs = $dao->update($calendarPrefs);
     unset($dao);
 }
<?php

require_once ROOT . DS . APP_DIR . DS . 'Plugin' . DS . 'FileStorage' . DS . 'Vendor' . DS . 'AWSsdk' . DS . 'aws-autoloader.php';
App::uses('S3StorageListener', 'FileStorage.Event');
App::uses('FileStorageUtils', 'FileStorage.Lib/Utility');
App::uses('StorageManager', 'FileStorage.Lib');
App::uses('ImageProcessingListener', 'FileStorage.Event');
App::uses('CakeEventManager', 'Event');
App::uses('ClassRegistry', 'Utility');
CakePlugin::load(array('Imagine' => array('bootstrap' => true)));
Configure::write('Imagine.salt', 'T!6stub6f=as5e4U#u8u7!ut9wRuphUS');
// Only required if you're *NOT* using composer or another autoloader!
spl_autoload_register(__NAMESPACE__ . '\\FileStorageUtils::gaufretteLoader');
// Attach the Image Processing Listener to the global CakeEventManager
$listener = new ImageProcessingListener();
CakeEventManager::instance()->attach($listener);
Configure::write('Media', array('imageSizes' => array('ImageStorage' => array('large' => array('thumbnail' => array('mode' => 'inbound', 'width' => 800, 'height' => 800)), 'medium' => array('thumbnail' => array('mode' => 'inbound', 'width' => 200, 'height' => 200)), 'small' => array('thumbnail' => array('mode' => 'inbound', 'width' => 80, 'height' => 80))))));
// This is very important! The hashes are needed to calculate the image versions!
ClassRegistry::init('FileStorage.ImageStorage')->generateHashes();
use Aws\S3;
App::uses('ConnectionManager', 'Model');
$dataSource = ConnectionManager::enumConnectionObjects();
if (isset($dataSource['aws'])) {
    // Attach the S3 Listener to the global CakeEventManager
    $listener = new S3StorageListener();
    CakeEventManager::instance()->attach($listener);
    $S3Client = \Aws\S3\S3Client::factory($dataSource['aws']);
    StorageManager::config('S3Storage', array('adapterOptions' => array($S3Client, 'isby', array(), true), 'adapterClass' => '\\Gaufrette\\Adapter\\AwsS3', 'class' => '\\Gaufrette\\Filesystem'));
}
Esempio n. 14
0
 function __construct()
 {
     $this->tagManager = new PeopleTagManager();
     $this->dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
 }
Esempio n. 15
0
 /**
  * Get a storage adapter from the StorageManager
  *
  * @param string $adapterName
  * @param boolean $renewObject
  * @return \Gaufrette\Adapter
  */
 public function getStorageAdapter($adapterName, $renewObject = false)
 {
     return StorageManager::adapter($adapterName, $renewObject);
 }
Esempio n. 16
0
 function __construct()
 {
     $this->contactManager = new ContactManager();
     $this->dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
 }
 public function retrieveCalendarPreferences($userId, $calendarId)
 {
     if (!is_string($userId) || $userId == '') {
         throw new EyeInvalidArgumentException('$userId must be a non-empty string.');
     }
     if (!is_string($calendarId) || $calendarId == '') {
         throw new EyeInvalidArgumentException('$calendarId must be a non-empty string.');
     }
     $dao = StorageManager::getInstance()->getHandler('SQL/EyeosDAO');
     $calendarPrefs = new CalendarPrefs();
     $calendarPrefs->setUserId($userId);
     $calendarPrefs->setCalendarId($calendarId);
     $calendarPrefs = $dao->search($calendarPrefs);
     unset($dao);
     if (count($calendarPrefs) === 0) {
         throw new EyeCalendarPrefsNotFoundException('Unknown calendar preferences with user ID "' . $userId . '" and calendar ID "' . $calendarId . '".');
     }
     return current($calendarPrefs);
 }
Esempio n. 18
0
spl_autoload_register(function ($class) {
    $defaultPath = CakePlugin::path('Assets') . 'Vendor' . DS . 'Gaufrette' . DS . 'src' . DS;
    $base = Configure::read('Assets.GaufretteLib');
    if (empty($base)) {
        $base = $defaultPath;
    }
    $class = str_replace('\\', DS, $class);
    if (file_exists($base . $class . '.php')) {
        include $base . $class . '.php';
    }
});
Configure::write('Wysiwyg.attachmentBrowseUrl', array('plugin' => 'assets', 'controller' => 'assets_attachments', 'action' => 'browse'));
Configure::write('Wysiwyg.uploadsPath', '');
Croogo::mergeConfig('Wysiwyg.actions', array('AssetsAttachments/admin_browse'));
App::uses('StorageManager', 'Assets.Lib');
StorageManager::config('LocalAttachment', array('description' => 'Local Attachment', 'adapterOptions' => array(WWW_ROOT . 'assets', true), 'adapterClass' => '\\Gaufrette\\Adapter\\Local', 'class' => '\\Gaufrette\\Filesystem'));
StorageManager::config('LegacyLocalAttachment', array('description' => 'Local Attachment (Legacy)', 'adapterOptions' => array(WWW_ROOT . 'uploads', true), 'adapterClass' => '\\Gaufrette\\Adapter\\Local', 'class' => '\\Gaufrette\\Filesystem'));
// TODO: make this configurable via backend
$actions = array('Nodes/admin_edit', 'Blocks/admin_edit', 'Types/admin_edit');
$tabTitle = __d('assets', 'Assets');
foreach ($actions as $action) {
    list($controller, ) = explode('/', $action);
    Croogo::hookAdminTab($action, $tabTitle, 'Assets.admin/asset_list');
    Croogo::hookHelper($controller, 'Assets.AssetsAdmin');
}
// TODO: make this configurable via backend
$models = array('Block', 'Node', 'Type');
foreach ($models as $model) {
    Croogo::hookBehavior($model, 'Assets.LinkedAssets', array('priority' => 9));
}
Croogo::hookHelper('*', 'Assets.AssetsFilter');
Esempio n. 19
0
 protected function getConnection()
 {
     if (!isset(self::$connection)) {
         $dbHandler = null;
         try {
             $dbHandler = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
             $dbHandler->send('CREATE TABLE IF NOT EXISTS ' . $this->params[self::PARAM_TABLENAME] . ' (' . 'id INT NOT NULL AUTO_INCREMENT, ' . self::METADATA_FIELD_CLASS . ' VARCHAR(128) NOT NULL, ' . self::METADATA_FIELD_ID . ' VARCHAR(128) NOT NULL, ' . self::METADATA_FIELD_KEY . ' TEXT NOT NULL, ' . self::METADATA_FIELD_DATA . ' TEXT NOT NULL, ' . 'PRIMARY KEY (id) ) ');
             self::$connection = $dbHandler;
         } catch (Exception $e) {
             throw new EyeDBException('An error occured while getting connection to the database.', 0, $e);
         }
     }
     return self::$connection;
 }
 protected function __construct()
 {
     $this->eyeosDAO = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
 }
 /**
  * afterSave
  *
  * @param CakeEvent $Event
  * @return void
  */
 public function afterSave($Event)
 {
     if ($this->_checkEvent($Event)) {
         $Model = $Event->subject();
         $Storage = StorageManager::adapter($Model->data[$Model->alias]['adapter']);
         $record = $Model->data[$Model->alias];
         try {
             $id = $record[$Model->primaryKey];
             $filename = $Model->stripUuid($id);
             $file = $record['file'];
             $format = $record['extension'];
             $sizes = Configure::read('Media.imageSizes.' . $record['model']);
             $record['path'] = $Model->fsPath('images' . DS . $record['model'], $id);
             $result = $Storage->write($record['path'] . $filename . '.' . $record['extension'], file_get_contents($file['tmp_name']), true);
             $data = $Model->save(array($Model->alias => $record), array('validate' => false, 'callbacks' => false));
             $operations = Configure::read('Media.imageSizes.' . $record['model']);
             if (!empty($operations)) {
                 $this->_createVersions($Model, $record, $operations);
             }
             $Model->data = $data;
         } catch (Exception $e) {
             $this->log($e->getMessage(), 'file_storage');
         }
     }
 }
Esempio n. 22
0
 public function __construct()
 {
     $this->dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
     $this->dao->send('SET NAMES utf8');
 }
 /**
  * Wrapper around the singleton call to StorageManager::config
  *
  * @param string $configName
  * @return Object
  */
 public function getAdapter($configName)
 {
     return StorageManager::adapter($configName);
 }
 /**
  * StorageAdapter
  *
  * @param mixed $adapterName string of adapter configuration or array of settings
  * @param boolean $renewObject Creates a new instance of the given adapter in the configuration
  * @throws RuntimeException
  * @return Gaufrette object as configured by first argument
  */
 public static function adapter($adapterName = null, $renewObject = false)
 {
     $_this = StorageManager::getInstance();
     if (empty($adapterName)) {
         $adapterName = $_this->_activeAdapter;
     }
     $isConfigured = true;
     if (is_string($adapterName)) {
         if (!empty($_this->_adapterConfig[$adapterName])) {
             $adapter = $_this->_adapterConfig[$adapterName];
         } else {
             throw new RuntimeException(__d('file_storage', 'Invalid Storage Adapter %s', $adapterName));
         }
         if (!empty($_this->_adapterConfig[$adapterName]['object']) && $renewObject === false) {
             return $_this->_adapterConfig[$adapterName]['object'];
         }
     }
     if (is_array($adapterName)) {
         $adapter = $adapterName;
         $isConfigured = false;
     }
     $class = $adapter['adapterClass'];
     $Reflection = new ReflectionClass($class);
     $adapterObject = $Reflection->newInstanceArgs($adapter['adapterOptions']);
     $engineObject = new $adapter['class']($adapterObject);
     if ($isConfigured) {
         $_this->_adapterConfig[$adapterName]['object'] =& $engineObject;
     }
     return $engineObject;
 }
 function __construct()
 {
     $this->impressionsManager = new ImpressionsManager();
     $this->dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
 }
Esempio n. 26
0
 /**
  * Copy an existing attachment and resize with width: $w and height: $h
  *
  * @param integer $id Attachment Id
  * @param integer $w New Width
  * @param integer $h New Height
  * @param array $options Options array
  */
 public function createResized($id, $w, $h, $options = array())
 {
     $options = Hash::merge(array('uploadsDir' => 'assets'), $options);
     $imagine = $this->imagineObject();
     $this->recursive = -1;
     $this->contain(array('AssetsAsset'));
     $attachment = $this->findById($id);
     $asset =& $attachment['AssetsAsset'];
     $path = rtrim(WWW_ROOT, '/') . $asset['path'];
     $image = $imagine->open($path);
     $size = $image->getSize();
     $width = $size->getWidth();
     $height = $size->getHeight();
     if (empty($h) && !empty($w)) {
         $scale = $w / $width;
         $newSize = $size->scale($scale);
     } elseif (empty($w) && !empty($h)) {
         $scale = $h / $height;
         $newSize = $size->scale($scale);
     } else {
         $scaleWidth = $w / $width;
         $scaleHeight = $h / $height;
         $scale = $scaleWidth > $scaleHeight ? $scaleWidth : $scaleHeight;
         $newSize = $size->scale($scale);
     }
     $newWidth = $newSize->getWidth();
     $newHeight = $newSize->getHeight();
     $image->resize($newSize);
     $tmpName = tempnam('/tmp', 'qq');
     $image->save($tmpName, array('format' => $asset['extension']));
     $fp = fopen($tmpName, 'r');
     $stat = fstat($fp);
     fclose($fp);
     $raw = file_get_contents($tmpName);
     unlink($tmpName);
     $info = pathinfo($asset['path']);
     $ind = sprintf('.resized-%dx%d.', $newWidth, $newHeight);
     $uploadsDir = str_replace('/' . $options['uploadsDir'] . '/', '', dirname($asset['path'])) . '/';
     $filename = $info['filename'] . $ind . $info['extension'];
     $writePath = $uploadsDir . $filename;
     $adapter = $asset['adapter'];
     $filesystem = StorageManager::adapter($adapter);
     $filesystem->write($writePath, $raw);
     $data = $this->AssetsAsset->create(array('filename' => $filename, 'path' => dirname($asset['path']) . '/' . $filename, 'model' => $asset['model'], 'extension' => $asset['extension'], 'parent_asset_id' => $asset['id'], 'foreign_key' => $asset['foreign_key'], 'adapter' => $adapter, 'mime_type' => $asset['mime_type'], 'width' => $newWidth, 'height' => $newHeight, 'filesize' => $stat[7]));
     $asset = $this->AssetsAsset->save($data);
     return $asset;
 }
 public function __construct()
 {
     $this->db = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
 }
 public function tearDown()
 {
     if (self::$ClassTearDownToRun) {
         $this->loginAsRoot();
         try {
             UMManager::getInstance()->deletePrincipal(UMManager::getUserByName('alice'));
         } catch (EyeNoSuchPrincipalException $e) {
         }
         try {
             UMManager::getInstance()->deletePrincipal(UMManager::getUserByName('bob'));
         } catch (EyeNoSuchPrincipalException $e) {
         }
         try {
             UMManager::getInstance()->deletePrincipal(UMManager::getUserByName('charlie'));
         } catch (EyeNoSuchPrincipalException $e) {
         }
         try {
             UMManager::getInstance()->deletePrincipal(UMManager::getGroupByName('wonderland'));
         } catch (EyeNoSuchPrincipalException $e) {
         }
         $conf = SharingManager::getConfiguration('SharingManager');
         $providerClassName = (string) $conf->providerClassName[0];
         if ($providerClassName == 'DefaultSQLiteShareInfoProvider') {
             if (is_file(USERS_PATH . '/' . $this->owner->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) {
                 unlink(USERS_PATH . '/' . $this->owner->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db');
             }
             if (is_file(USERS_PATH . '/' . $this->collaborator1->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) {
                 unlink(USERS_PATH . '/' . $this->collaborator1->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db');
             }
             if (is_file(USERS_PATH . '/' . $this->collaborator2->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) {
                 unlink(USERS_PATH . '/' . $this->collaborator2->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db');
             }
             if (is_file(USERS_PATH . '/' . $this->collaborator3->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db')) {
                 unlink(USERS_PATH . '/' . $this->collaborator3->getName() . '/' . USERS_CONF_DIR . '/' . USERS_SHARE_DIR . '/shares.db');
             }
         } else {
             if ($providerClassName == 'DefaultMySQLShareInfoProvider') {
                 require_once SERVICE_SHARING_SHARINGMANAGERS_PROVIDERS_PATH . '/DefaultMySQLShareInfoProvider.php';
                 $dao = StorageManager::getInstance()->getHandler(SQL_DAOHANDLER);
                 $dao->send('TRUNCATE TABLE ' . DefaultMySQLShareInfoProvider::SHAREINFO_TABLE_NAME);
                 $dao->send('TRUNCATE TABLE ShareableVirtualFilesHandler');
             }
         }
         try {
             ProcManager::getInstance()->kill(ProcManager::getInstance()->getProcessByPid(self::$MyProcPid));
         } catch (EyeProcException $e) {
         }
         ProcManager::getInstance()->setCurrentProcess(self::$InitProcessToRestore);
     }
 }
 /**
  * Gets the adapter class name from the adapter configuration key
  *
  * @param string
  * @return void
  */
 public function getAdapterClassName($adapterConfigName)
 {
     $config = StorageManager::config($adapterConfigName);
     switch ($config['adapterClass']) {
         case '\\Gaufrette\\Adapter\\Local':
             $this->adapterClass = 'Local';
             return $this->adapterClass;
         case '\\Gaufrette\\Adapter\\AwsS3':
             $this->adapterClass = 'AwsS3';
             return $this->adapterClass;
         case '\\Gaufrette\\Adapter\\AmazonS3':
             $this->adapterClass = 'AwsS3';
             return $this->adapterClass;
         case '\\Gaufrette\\Adapter\\AwsS3':
             $this->adapterClass = 'AwsS3';
             return $this->adapterClass;
         default:
             return false;
     }
 }
Esempio n. 30
0
 public static function configured()
 {
     $_this = StorageManager::getInstance();
     $config = array();
     foreach ($_this->_adapterConfig as $k => $v) {
         if (empty($v['description'])) {
             continue;
         }
         $config[$k] = $v['description'];
     }
     return $config;
 }