/**
  * Test SetConfig
  */
 public function testSetConfig()
 {
     $output = $this->_cliHelper('setconfig', array('--setconfig', '--', 'configkey=allowedJsonOrigins', 'configvalue=' . '["foo","bar"]'));
     $this->assertContains('OK - Updated configuration option allowedJsonOrigins for application Tinebase', $output);
     $result = Tinebase_Config_Abstract::factory('Tinebase')->get('allowedJsonOrigins');
     $this->assertEquals("foo", $result[0]);
     $this->assertEquals("bar", $result[1]);
 }
 /**
  * Test SetBoolConfig
  */
 public function testSetBoolConfig()
 {
     $this->_oldConfigs[Tinebase_Config::MAINTENANCE_MODE] = Tinebase_Config::getInstance()->get(Tinebase_Config::MAINTENANCE_MODE);
     $values = array(1, "true");
     foreach ($values as $configValue) {
         $output = $this->_cliHelper('setconfig', array('--setconfig', '--', 'configkey=maintenanceMode', 'configvalue=' . $configValue));
         $this->assertContains('OK - Updated configuration option maintenanceMode for application Tinebase', $output);
         $result = Tinebase_Config_Abstract::factory('Tinebase')->get(Tinebase_Config::MAINTENANCE_MODE);
         $this->assertTrue($result);
     }
 }
 /**
  * get config for client registry
  * 
  * @return Tinebase_Config_Struct
  */
 public function getClientRegistryConfig()
 {
     // get all config names to be included in registry
     $clientProperties = new Tinebase_Config_Struct(array());
     $userApplications = Tinebase_Core::getUser()->getApplications(TRUE);
     foreach ($userApplications as $application) {
         $config = Tinebase_Config_Abstract::factory($application->name);
         if ($config) {
             $clientProperties[$application->name] = new Tinebase_Config_Struct(array());
             $properties = $config->getProperties();
             foreach ((array) $properties as $name => $definition) {
                 if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
                     Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($definition, TRUE));
                 }
                 if ((isset($definition['clientRegistryInclude']) || array_key_exists('clientRegistryInclude', $definition)) && $definition['clientRegistryInclude'] === TRUE) {
                     // add definition here till we have a better place
                     try {
                         $configRegistryItem = new Tinebase_Config_Struct(array('value' => $config->{$name}, 'definition' => new Tinebase_Config_Struct($definition)));
                         if (Tinebase_Core::isLogLevel(Zend_Log::TRACE)) {
                             Tinebase_Core::getLogger()->trace(__METHOD__ . '::' . __LINE__ . ' ' . print_r($configRegistryItem->toArray(), TRUE));
                         }
                         $clientProperties[$application->name][$name] = $configRegistryItem;
                     } catch (Exception $e) {
                         Tinebase_Exception::log($e);
                     }
                 }
             }
             if (Tinebase_Core::isLogLevel(Zend_Log::DEBUG)) {
                 Tinebase_Core::getLogger()->debug(__METHOD__ . '::' . __LINE__ . ' Got ' . count($clientProperties[$application->name]) . ' config items for ' . $application->name . '.');
             }
         }
     }
     return $clientProperties;
 }
 /**
  * save config option in db
  *
  * @param string $key
  * @param string|array $value
  * @param string $applicationName
  * @return void
  */
 public function setConfigOption($key, $value, $applicationName = 'Tinebase')
 {
     $config = Tinebase_Config_Abstract::factory($applicationName);
     if ($config) {
         $config->set($key, $value);
     }
 }
 /**
  * get config
  *
  */
 protected function _getConfig(Zend_Console_Getopt $_opts)
 {
     $options = $this->_parseRemainingArgs($_opts->getRemainingArgs());
     $applicationName = isset($options['app']) ? $options['app'] : 'Tinebase';
     $config = Tinebase_Config_Abstract::factory($applicationName);
     $errors = array();
     if (empty($options['configkey'])) {
         $errors[] = 'Missing argument: configkey';
         $errors[] = 'Available config settings:';
         $errors[] = print_r($config::getProperties(), true);
     }
     $configKey = (string) $options['configkey'];
     if (empty($errors)) {
         $value = $config->get($configKey);
         $value = is_string($value) ? $value : Zend_Json::encode($value);
         echo $value . " \n";
     } else {
         echo "ERRORS - The following errors occured: \n";
         foreach ($errors as $error) {
             echo "- " . $error . "\n";
         }
     }
 }