public function isValid($data) { $valid = parent::isValid($data); // Custom valid if ($valid) { // Check auth try { $testService = new Zend_Service_Amazon_S3($data['accessKey'], $data['secretKey'], $data['region']); $buckets = $testService->getBuckets(); } catch (Exception $e) { $this->addError('Please double check your access keys.'); return false; } // Check bucket try { if (!in_array($data['bucket'], $buckets)) { if (!$testService->createBucket($data['bucket'], $data['region'])) { throw new Exception('Could not create or find bucket'); } } } catch (Exception $e) { $this->addError('Bucket name is already taken and could not be created.'); return false; } } return $valid; }
public function isValid($data) { $valid = parent::isValid($data); // Custom valid if ($valid) { $params = array(); foreach ($data as $key => $value) { if (false !== strpos($key, '_')) { list($p, $c) = explode('_', $key, 2); if ($p == 'params') { $params[$c] = $value; } } } try { $vfs = Engine_Vfs::factory($data['adapter'], $params); $vfs->getSystemType(); // Used to test connection } catch (Exception $e) { $this->addError('Could not create VFS connection. Error was:'); $this->addError($e->getMessage()); return false; } } return $valid; }
public function init() { // Element: path $this->addElement('Text', 'path', array('label' => 'Path Prefix', 'description' => 'This is prepended to the file path on upload. Defaults ' . 'to "public". Must be relative to the SocialEngine path.')); // Element: baseUrl $this->addElement('Text', 'baseUrl', array('label' => 'Base URL', 'description' => 'This is the base URL used for generating the file ' . 'URLs. Should only be used for pull-type CDNs.', 'filters' => array('StringTrim'))); parent::init(); }
public function isValid($data) { $valid = parent::isValid($data); // Custom valid if ($valid) { if (count($this->getElement('services')->options) < 1) { $this->addError('Requires at least one other enabled service.'); } } return $valid; }
public function isValid($data) { $valid = parent::isValid($data); // Custom valid if ($valid) { // Check auth $config = $data; if (!empty($config['host']) && !empty($config['username']) && !empty($config['password'])) { try { $defaultAdapter = Engine_Api::_()->getDbtable('chunks', 'storage')->getAdapter(); $adapterName = strtolower(!empty($config['adapter']) ? $config['adapter'] : array_pop(explode('_', get_class($defaultAdapter)))); $adapterNamespace = $adapterName == 'mysql' ? 'Engine_Db_Adapter' : 'Zend_Db_Adapter'; $adapter = Zend_Db::factory($adapterName, array('host' => $config['host'], 'username' => $config['username'], 'password' => $config['password'], 'dbname' => $config['dbname'], 'adapterNamespace' => $adapterNamespace)); $table = new Storage_Model_DbTable_Chunks(array('adapter' => $adapter)); $table->info(); } catch (Exception $e) { $this->addError('Could not connect to database.'); $this->addError($e->getMessage()); return false; } } } return $valid; }