public function indexAction()
 {
     $config = Zend_Registry::get('config');
     /* @var $config Zend_Config */
     if ($config->gandi->api->key) {
         return $this->_helper->redirector('index', 'index');
     }
     $configFile = APPLICATION_PATH . '/configs/application.ini';
     $config = new Zend_Config_Ini($configFile, null, array('skipExtends' => true, 'allowModifications' => true));
     $request = $this->getRequest();
     $form = new Application_Form_Install();
     if ($this->getRequest()->isPost()) {
         if ($form->isValid($request->getPost())) {
             $formValues = $form->getValues();
             // DEBUG
             //Zend_Debug::dump($formValues); die();
             $apiKey = $formValues['apikey'];
             try {
                 if (!$apiKey) {
                     throw new Exception('Gandi API key can\'t be empty!');
                 }
                 if (!is_writable($configFile)) {
                     throw new Exception(sprintf('Config file is not writeable! Please check write right to %s file!', $configFile));
                 }
                 $config->development->gandi = array('api' => array('key' => $apiKey), 'account' => array('showdetails' => '0'), 'vm' => array('showdetails' => '0'));
                 $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => $configFile));
                 $writer->write();
                 return $this->_helper->redirector('index', 'index');
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
         }
     }
     $this->view->form = $form;
 }
Ejemplo n.º 2
0
 private function configure()
 {
     $zend_console = new Zend_Console_Getopt(array('create|c' => 'Create database configureation', 'adapter|a=w' => 'Database adapter (mysql)', 'host|h=w' => 'Default to localhost', 'username|u=w' => 'Username to connect to database', 'password|p=w' => 'Password to connect to database', 'database|d=w' => 'Database Name', 'port|o-i' => '(optional) Port for connecting to database', 'socket|s-w' => '(optional) Location for database socket'), $this->argv);
     try {
         echo $a = $zend_console->getOption('a');
         echo $h = $zend_console->getOption('h');
         // Load all sections from an existing config file, while skipping the extends.
         $config = new Zend_Config_Ini(SMCONFIG_DIRECTORY . DIRECTORY_SEPARATOR . 'database.ini', null, array('skipExtends' => true, 'allowModifications' => true));
         // Modify values
         $config->database->doctrine_adapter = $zend_console->getOption('a');
         $config->database->params->host = $zend_console->getOption('h');
         $config->database->params->username = $zend_console->getOption('u');
         $config->database->params->password = $zend_console->getOption('p');
         $config->database->params->dbname = $zend_console->getOption('d');
         $config->database->params->port = $zend_console->getOption('h');
         $config->database->params->socket = $zend_console->getOption('h');
         // Write the config file
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => 'config.ini'));
         $writer->write();
         //*/
     } catch (Zend_Console_Getopt_Exception $e) {
         fwrite(STDOUT, "Connection Failed\n");
         echo $e->getUsageMessage();
         exit;
     }
 }
Ejemplo n.º 3
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, $config->get('dcm2xml', DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, $config->get('dcmj2pnm', DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, $config->get('dcmftest', DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, $config->get('dcmdictpath', DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->dcm2xml);
         unset($config->global->dcmj2pnm);
         unset($config->global->dcmftest);
         unset($config->global->dcmdictpath);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(DICOMEXTRACTOR_DCM2XML_COMMAND_KEY, DICOMEXTRACTOR_DCM2XML_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMJ2PNM_COMMAND_KEY, DICOMEXTRACTOR_DCMJ2PNM_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMFTEST_COMMAND_KEY, DICOMEXTRACTOR_DCMFTEST_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(DICOMEXTRACTOR_DCMDICTPATH_KEY, DICOMEXTRACTOR_DCMDICTPATH_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 4
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var RandomComponent $randomComponent */
     $randomComponent = MidasLoader::loadComponent('Random');
     $securityKey = $randomComponent->generateString(32);
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SECURITY_KEY_KEY, $config->get('securitykey', $securityKey), $this->moduleName);
         $showButton = $config->get('showbutton');
         if ($showButton === 'true') {
             $showButton = 1;
         } elseif ($showButton === 'false') {
             $showButton = 0;
         } else {
             $showButton = MIDAS_REMOTEPROCESSING_SHOW_BUTTON_DEFAULT_VALUE;
         }
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SHOW_BUTTON_KEY, $showButton, $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->securitykey->securitykey);
         unset($config->showbutton->showbutton);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SECURITY_KEY_KEY, $securityKey, $this->moduleName);
         $settingModel->setConfig(MIDAS_REMOTEPROCESSING_SHOW_BUTTON_KEY, MIDAS_REMOTEPROCESSING_SHOW_BUTTON_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 5
0
 public function indexAction()
 {
     $registry = Zend_Registry::getInstance();
     $translate = $registry->get("Zend_Translate");
     $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/manager.ini', null, true);
     $validationErrors = array();
     if ($this->getRequest()->isPost()) {
         $c = $this->_getParam('config');
         if (empty($c['manager_host'])) {
             $validationErrors['manager_host'] = $translate->translate("Manager host is required");
         }
         if (empty($c['gateway_host'])) {
             $validationErrors['gateway_host'] = $translate->translate("Gateway host is required");
         }
         if (empty($validationErrors)) {
             $config->manager_host = $c['manager_host'];
             $config->gateway_host = $c['gateway_host'];
             $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => APPLICATION_PATH . '/configs/manager.ini'));
             $writer->write();
             $this->view->flashMessage = $translate->translate("Preferences Updated");
         }
     }
     $this->view->config = $config;
     $this->view->validationErrors = $validationErrors;
 }
Ejemplo n.º 6
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $piwikUrl = isset($config->piwik->url) ? $config->piwik->url : STATISTICS_PIWIK_URL_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_URL_KEY, $piwikUrl, $this->moduleName);
         $piwikId = isset($config->piwik->id) ? $config->piwik->id : STATISTICS_PIWIK_SITE_ID_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_SITE_ID_KEY, $piwikId, $this->moduleName);
         $piwikApiKey = isset($config->piwik->apikey) ? $config->piwik->apikey : STATISTICS_PIWIK_API_KEY_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_PIWIK_API_KEY_KEY, $piwikApiKey, $this->moduleName);
         $ipInfoDbApiKey = isset($config->ipinfodb->apikey) ? $config->ipinfodb->apikey : STATISTICS_IP_INFO_DB_API_KEY_DEFAULT_VALUE;
         $settingModel->setConfig(STATISTICS_IP_INFO_DB_API_KEY_KEY, $ipInfoDbApiKey, $this->moduleName);
         $settingModel->setConfig(STATISTICS_SEND_DAILY_REPORTS_KEY, $config->get('report', STATISTICS_SEND_DAILY_REPORTS_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->piwik->url);
         unset($config->global->piwik->id);
         unset($config->global->piwik->pikey);
         unset($config->global->ipinfodb->apikey);
         unset($config->global->report);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(STATISTICS_PIWIK_URL_KEY, STATISTICS_PIWIK_URL_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_PIWIK_SITE_ID_KEY, STATISTICS_PIWIK_SITE_ID_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_PIWIK_API_KEY_KEY, STATISTICS_PIWIK_API_KEY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_IP_INFO_DB_API_KEY_KEY, STATISTICS_IP_INFO_DB_API_KEY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(STATISTICS_SEND_DAILY_REPORTS_KEY, STATISTICS_SEND_DAILY_REPORTS_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 7
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_PROVIDER_KEY, MIDAS_THUMBNAILCREATOR_PROVIDER_PHMAGICK, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_FORMAT_KEY, MIDAS_THUMBNAILCREATOR_FORMAT_JPG, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_KEY, $config->get('imagemagick', MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_KEY, $config->get('useThumbnailer', MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_THUMBNAILER_KEY, $config->get('thumbnailer', MIDAS_THUMBNAILCREATOR_THUMBNAILER_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->imageFormats);
         unset($config->global->imagemagick);
         unset($config->global->thumbnailer);
         unset($config->global->useThumbnailer);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_PROVIDER_KEY, MIDAS_THUMBNAILCREATOR_PROVIDER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_FORMAT_KEY, MIDAS_THUMBNAILCREATOR_FORMAT_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_KEY, MIDAS_THUMBNAILCREATOR_IMAGE_MAGICK_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_KEY, MIDAS_THUMBNAILCREATOR_USE_THUMBNAILER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_THUMBNAILCREATOR_THUMBNAILER_KEY, MIDAS_THUMBNAILCREATOR_THUMBNAILER_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 8
0
    /**
     * @param string $type
     */
    public function create()
    {
        /* @var $userConfig Zend_Tool_Framework_Client_Config */
        $userConfig = $this->_registry->getConfig();

        $resp = $this->_registry->getResponse();
        if ($userConfig->exists()) {
            require_once "Zend/Tool/Framework/Exception.php";
            throw new Zend_Tool_Framework_Exception(
                "A configuration already exists, cannot create a new one.");
        }

        $homeDirectory = $this->_detectHomeDirectory();

        $writer = new Zend_Config_Writer_Ini();
        $writer->setRenderWithoutSections();
        $filename = $homeDirectory."/.zf.ini";

        $config = array(
            'php' => array(
                'include_path' => get_include_path(),
            ),
        );
        $writer->write($filename, new Zend_Config($config));

        $resp = $this->_registry->getResponse();
        $resp->appendContent("Successfully written Zend Tool config.");
        $resp->appendContent("It is located at: ".$filename);
    }
Ejemplo n.º 9
0
 protected function _doInsert(\Application\Entity\Entity $model)
 {
     $data = array("tax_free_allowance" => $model->taxFreeAllowance, "tax_percent" => $model->taxPercent, "incaso_parts" => $model->incasoParts, "storno_interval" => $model->stornoInterval, "storno_first_part_percent" => $model->stornoFirstPartPercent, "storno_second_part_percent" => $model->stornoSecondPartPercent);
     $filename = APPLICATION_PATH . "/configs/configuration.ini";
     $configWriter = new \Zend_Config_Writer_Ini();
     $configWriter->write($filename, new \Zend_Config($data));
 }
Ejemplo n.º 10
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $config = new Zend_Config_Ini(APPLICATION_CONFIG, 'global');
     $settingModel->setConfig('address_verification', $config->get('verifyemail', 0), 'mail');
     if ($config->get('smtpfromaddress')) {
         $fromAddress = $config->get('smtpfromaddress');
     } elseif (ini_get('sendmail_from')) {
         $fromAddress = ini_get('sendmail_from');
     } else {
         $fromAddress = '*****@*****.**';
         // RFC2606
     }
     $settingModel->setConfig('from_address', $fromAddress, 'mail');
     if ($config->get('smtpserver')) {
         $components = parse_url($config->get('smtpserver'));
         if (isset($components['host'])) {
             $settingModel->setConfig('smtp_host', $components['host'], 'mail');
         }
         if (isset($components['port'])) {
             $settingModel->setConfig('smtp_port', $components['port'], 'mail');
             if ($components['port'] === 587) {
                 $settingModel->setConfig('smtp_use_ssl', 1, 'mail');
             }
         }
         if (isset($components['user'])) {
             $settingModel->setConfig('smtp_username', $components['user'], 'mail');
         }
         if (isset($components['pass'])) {
             $settingModel->setConfig('smtp_password', $components['pass'], 'mail');
         }
     }
     if ($config->get('smtpuser')) {
         $settingModel->setConfig('smtp_username', $config->get('smtpuser'), 'mail');
     }
     if ($config->get('smtppassword')) {
         $settingModel->setConfig('smtp_password', $config->get('smtppassword'), 'mail');
     }
     if ($settingModel->getValueByName('smtp_host', 'mail')) {
         $provider = 'smtp';
     } else {
         $provider = 'mail';
     }
     $settingModel->setConfig('provider', $provider, 'mail');
     /** @var UtilityComponent $utilityComponent */
     $utilityComponent = MidasLoader::loadComponent('Utility');
     $utilityComponent->installModule('mail');
     $config = new Zend_Config_Ini(APPLICATION_CONFIG, null, true);
     unset($config->global->smtpfromaddress);
     unset($config->global->smtpserver);
     unset($config->global->smtpuser);
     unset($config->global->smtppassword);
     unset($config->global->verifyemail);
     $writer = new Zend_Config_Writer_Ini();
     $writer->setConfig($config);
     $writer->setFilename(APPLICATION_CONFIG);
     $writer->write();
 }
Ejemplo n.º 11
0
 public static function setIsInstalled()
 {
     try {
         $writer = new Zend_Config_Writer_Ini();
         $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/app.ini', null, array('skipExtends' => true, 'allowModifications' => true));
         $config->production->isInstalled = "1";
         $writer->setConfig($config)->setFilename(APPLICATION_PATH . '/configs/app.ini')->write();
         return true;
     } catch (Exception $e) {
         return false;
     }
 }
Ejemplo n.º 12
0
 public function saveConfig()
 {
     if (!is_dir(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/form/")) {
         mkdir(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/form/");
     }
     if (file_exists(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/form/form_" . $this->id . ".ini")) {
         unlink(PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/form/form_" . $this->id . ".ini");
     }
     $config = new Zend_Config($this->config, true);
     $writer = new Zend_Config_Writer_Ini(array("config" => $config, "filename" => PIMCORE_PLUGINS_PATH . "/Zendformbuilder/data/form/form_" . $this->id . ".ini"));
     $writer->write();
 }
 function myIndexAction()
 {
     if ($_SERVER['REQUEST_METHOD']) {
         $form = new VF_Import_Settings();
         $form->populate($_POST);
         $config = $form->getConfig();
         $config->importer->allowMissingFields = $form->getValue('allowMissingFields');
         $config->importer->Y2KMode = $form->getValue('Y2KMode');
         $config->importer->Y2KThreshold = $form->getValue('Y2KThreshold');
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => ELITE_CONFIG));
         echo $writer->write();
     }
 }
 function myIndexAction()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $form = new Elite_Vaf_Model_Settings_Category();
         $form->populate($_POST);
         $config = $form->getConfig();
         $config->category->disable = $form->getValue('disable');
         $config->category->mode = $form->getValue('mode');
         $config->category->whitelist = $form->getValue('whitelist');
         $config->category->blacklist = $form->getValue('blacklist');
         $config->category->requireVehicle = $form->getValue('requireVehicle');
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => ELITE_CONFIG));
         echo $writer->write();
     }
 }
Ejemplo n.º 15
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCM2XML_COMMAND_KEY, $config->get('dcm2xml', MIDAS_DICOMSERVER_DCM2XML_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_COMMAND_KEY, $config->get('storescp', MIDAS_DICOMSERVER_STORESCP_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_PORT_KEY, $config->get('storescp_port', MIDAS_DICOMSERVER_STORESCP_PORT_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_STUDY_TIMEOUT_KEY, $config->get('storescp_study_timeout', MIDAS_DICOMSERVER_STORESCP_STUDY_TIMEOUT_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_RECEPTION_DIRECTORY_KEY, $config->get('receptiondir', MIDAS_DICOMSERVER_RECEPTION_DIRECTORY_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DESTINATION_FOLDER_KEY, $config->get('pydas_dest_folder', MIDAS_DICOMSERVER_DESTINATION_FOLDER_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRSCP_COMMAND_KEY, $config->get('dcmqrscp', MIDAS_DICOMSERVER_DCMQRSCP_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRSCP_PORT_KEY, $config->get('dcmqrscp_port', MIDAS_DICOMSERVER_DCMQRSCP_PORT_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRIDX_COMMAND_KEY, $config->get('dcmqridx', MIDAS_DICOMSERVER_DCMQRIDX_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_SERVER_AE_TITLE_KEY, $config->get('server_ae_title', MIDAS_DICOMSERVER_SERVER_AE_TITLE_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_PEER_AES_KEY, $config->get('peer_aes', MIDAS_DICOMSERVER_PEER_AES_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->dcm2xml);
         unset($config->global->storescp);
         unset($config->global->storescp_port);
         unset($config->global->storescp_study_timeout);
         unset($config->global->receptiondir);
         unset($config->global->pydas_dest_folder);
         unset($config->global->dcmqrscp);
         unset($config->global->dcmqrscp_port);
         unset($config->global->dcmqridx);
         unset($config->global->server_ae_title);
         unset($config->global->peer_aes);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCM2XML_COMMAND_KEY, MIDAS_DICOMSERVER_DCM2XML_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_COMMAND_KEY, MIDAS_DICOMSERVER_STORESCP_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_PORT_KEY, MIDAS_DICOMSERVER_STORESCP_PORT_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_STORESCP_STUDY_TIMEOUT_KEY, MIDAS_DICOMSERVER_STORESCP_STUDY_TIMEOUT_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_RECEPTION_DIRECTORY_KEY, MIDAS_DICOMSERVER_RECEPTION_DIRECTORY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DESTINATION_FOLDER_KEY, MIDAS_DICOMSERVER_DESTINATION_FOLDER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRSCP_COMMAND_KEY, MIDAS_DICOMSERVER_DCMQRSCP_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRSCP_PORT_KEY, MIDAS_DICOMSERVER_DCMQRSCP_PORT_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_DCMQRIDX_COMMAND_KEY, MIDAS_DICOMSERVER_DCMQRIDX_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_SERVER_AE_TITLE_KEY, MIDAS_DICOMSERVER_SERVER_AE_TITLE_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(MIDAS_DICOMSERVER_PEER_AES_KEY, MIDAS_DICOMSERVER_PEER_AES_DEFAULT_VALUE, $this->moduleName);
     }
 }
 function myIndexAction()
 {
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $form = new Elite_Vaf_Model_Settings_Garage();
         $form->populate($_POST);
         $config = $form->getConfig();
         foreach ($form->getElements() as $name => $element) {
             if ($name == 'save') {
                 continue;
             }
             $config->mygarage->{$name} = $element->getValue();
         }
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => ELITE_CONFIG));
         echo $writer->write();
     }
 }
Ejemplo n.º 17
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(CLEANUP_DAYS_TO_KEEP_PARTIAL_FILES_KEY, $config->get('days', CLEANUP_DAYS_TO_KEEP_PARTIAL_FILES_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->days);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(CLEANUP_DAYS_TO_KEEP_PARTIAL_FILES_KEY, CLEANUP_DAYS_TO_KEEP_PARTIAL_FILES_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 18
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(API_METHOD_PREFIX_KEY, $config->get('methodprefix', API_METHOD_PREFIX_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->methodprefix);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(API_METHOD_PREFIX_KEY, API_METHOD_PREFIX_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 19
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(METADATAEXTRACTOR_HACHOIR_METADATA_COMMAND_KEY, $config->get('hachoir', METADATAEXTRACTOR_HACHOIR_METADATA_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->hachoir);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(METADATAEXTRACTOR_HACHOIR_METADATA_COMMAND_KEY, METADATAEXTRACTOR_HACHOIR_METADATA_COMMAND_DEFAULT_VALUE, $this->moduleName);
     }
 }
 function doIndexAction()
 {
     $config = $this->getConfig();
     $this->block->setTemplate('vf/vaf/vfdata.phtml');
     $form = $this->form();
     $this->block->form = $form;
     if ($this->getRequest()->getParam('download')) {
         $download_url = 'http://data.vehiclefits.com/api/download?token=' . $config->vfdata->api_token;
         $local_file = sys_get_temp_dir() . '/' . uniqid();
         $local_stream = fopen($local_file, 'w');
         $download_stream = fopen($download_url, 'r');
         while (!feof($download_stream)) {
             $buffer = fread($download_stream, 512);
             // use a buffer of 512 bytes
             fwrite($local_stream, $buffer);
         }
         fclose($download_stream);
         fclose($local_stream);
         $importer = new VF_Import_VehiclesList_CSV_Import($local_file);
         $importer->import();
         $this->block->downloaded = true;
         return;
     }
     if ($this->getRequest()->getParam('upload')) {
         $upload_url = 'http://data.vehiclefits.com/api/upload?token=' . $config->vfdata->api_token;
         $local_file = sys_get_temp_dir() . '/' . uniqid();
         $local_stream = fopen($local_file, 'w');
         $exporter = new VF_Import_VehiclesList_CSV_Export();
         $exporter->export($local_stream);
         $ch = curl_init($upload_url);
         curl_setopt($ch, CURLOPT_POST, 1);
         curl_setopt($ch, CURLOPT_POSTFIELDS, file_get_contents($local_file));
         curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
         curl_setopt($ch, CURLOPT_HEADER, 0);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $response = curl_exec($ch);
         $this->block->uploaded = $response;
     }
     if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getParams())) {
         $config->vfdata->api_token = $form->getValue('api_token');
         $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => ELITE_CONFIG));
         echo $writer->write();
     }
 }
Ejemplo n.º 21
0
 private function writeModulesIni()
 {
     // Load all sections from an existing config file, while skipping the extends.
     $filename = ZfApplication::$_data_path . '/etc/modules.ini';
     $config = new Zend_Config_Ini($filename, null, array('skipExtends' => true, 'allowModifications' => true));
     $config->production = array();
     $config->setExtend('staging', 'production');
     $config->setExtend('cli', 'production');
     // Modify a value
     $directory = new DirectoryIterator(ZfApplication::$_base_path . "/app");
     $config->production->modules = array();
     foreach ($directory as $dir) {
         $name = strtolower($dir->getFilename());
         if (!$dir->isDot() && $dir->isDir() && !in_array($name[0], array(".", "_"))) {
             $config->production->modules->{$name} = '/app/' . $dir->getFilename() . '/Controllers';
         }
     }
     // Write the config file
     $writer = new Zend_Config_Writer_Ini();
     $writer->write($filename, $config);
 }
Ejemplo n.º 22
0
 protected function _createIni(array $params)
 {
     if ($this->_checkConnection($params)) {
         try {
             $writer = new Zend_Config_Writer_Ini();
             if (!@copy(APPLICATION_PATH . '/configs/app.sample.ini', APPLICATION_PATH . '/configs/app.ini')) {
                 throw new Exception("The file /app/configs/app.ini is not writable. Please check the write permissions of the /app/configs folder and try again.");
             }
             $config = new Zend_Config_Ini(APPLICATION_PATH . '/configs/app.ini', null, array('skipExtends' => true, 'allowModifications' => true));
             $config->production->resources->db->params->host = $params['host'];
             $config->production->resources->db->params->dbname = $params['dbname'];
             $config->production->resources->db->params->username = $params['username'];
             $config->production->resources->db->params->password = $params['password'];
             $writer->setConfig($config)->setFilename(APPLICATION_PATH . '/configs/app.ini')->write();
             return true;
         } catch (Exception $e) {
             $this->_error = $e->getMessage();
         }
     }
     return false;
 }
Ejemplo n.º 23
0
 /**
  * Create configs for project
  *
  * Configs will be created by asking user to answer some questions
  * and saved in the config file (~/.mtool.ini)
  *
  * @param  string $configFileName config file name, basically it's ~/.mtool.ini
  * @return null
  */
 protected function _createConfig($configFileName)
 {
     // id of the last project
     $maxProjectId = 0;
     // create config file if it's not exists
     if (!file_exists($configFileName)) {
         if (!($configFileHandle = fopen($configFileName, 'a+'))) {
             throw new Mtool_Codegen_Exception_Filesystem("Cannot create config file {$configFileName}.  Maybe permissions problem?");
         } else {
             fclose($configFileHandle);
         }
     }
     // if file already exists, try to find other projects configs
     $iniConfig = new Zend_Config_Ini($configFileName, null, array('skipExtends' => true, 'allowModifications' => true));
     if (!is_null($iniConfig->projects)) {
         $projects = $iniConfig->projects->toArray();
         $maxProjectId = max(array_keys($projects));
     }
     // access to _ask()/_anwer() methods
     $author = $this->_ask("Please, enter data for the @author string\n" . "For example, Dan Kocherga <*****@*****.**>");
     $copyright = $this->_ask("Please, enter data for the copyright owner\n" . "For example, Oggetto Web ltd (http://oggettoweb.com/)");
     $licensePath = $this->_ask("Please, enter path to the license file\n" . "For example, /home/user/project/license.lic\n" . "Or press Enter to use the same as in the Magento");
     $moduleOwner = $this->_ask("Please, enter module owner\n" . "For example, Oggetto Web\n" . "It will be used to generate a short file description string");
     $projectId = $maxProjectId + 1;
     $newProject = array($projectId => array('copyright_company' => $copyright, 'path' => Mtool_Magento::getRoot(), 'author' => $author, 'module_owner' => $moduleOwner));
     if ($licensePath) {
         $newProject[$projectId]['license_path'] = $licensePath;
     }
     if (!isset($projects) || !is_array($projects)) {
         $projects = array();
     }
     $iniConfig->projects = array_merge($projects, $newProject);
     // save configurations to the config file
     $options = array('config' => $iniConfig, 'filename' => $configFileName);
     $writer = new Zend_Config_Writer_Ini($options);
     $writer->write();
     return $iniConfig;
 }
Ejemplo n.º 24
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(VISUALIZE_TEMPORARY_DIRECTORY_KEY, $config->get('customtmp', VISUALIZE_TEMPORARY_DIRECTORY_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_PARAVIEW_WEB_KEY, $config->get('useparaview', VISUALIZE_USE_PARAVIEW_WEB_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_WEB_GL_KEY, $config->get('userwebgl', VISUALIZE_USE_WEB_GL_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_SYMLINKS_KEY, $config->get('usesymlinks', VISUALIZE_USE_SYMLINKS_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_TOMCAT_ROOT_URL_KEY, $config->get('pwapp', VISUALIZE_TOMCAT_ROOT_URL_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_PVBATCH_COMMAND_KEY, $config->get('pvbatch', VISUALIZE_PVBATCH_COMMAND_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(VISUALIZE_PARAVIEW_WEB_WORK_DIRECTORY_KEY, $config->get('paraviewworkdir', VISUALIZE_PARAVIEW_WEB_WORK_DIRECTORY_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->customtmp);
         unset($config->global->useparaview);
         unset($config->global->userwebgl);
         unset($config->global->usesymlinks);
         unset($config->global->pwapp);
         unset($config->global->pvbatch);
         unset($config->global->paraviewworkdir);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(VISUALIZE_TEMPORARY_DIRECTORY_KEY, VISUALIZE_TEMPORARY_DIRECTORY_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_PARAVIEW_WEB_KEY, VISUALIZE_USE_PARAVIEW_WEB_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_WEB_GL_KEY, VISUALIZE_USE_WEB_GL_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_USE_SYMLINKS_KEY, VISUALIZE_USE_SYMLINKS_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_TOMCAT_ROOT_URL_KEY, VISUALIZE_TOMCAT_ROOT_URL_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_PVBATCH_COMMAND_KEY, VISUALIZE_PVBATCH_COMMAND_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(VISUALIZE_PARAVIEW_WEB_WORK_DIRECTORY_KEY, VISUALIZE_PARAVIEW_WEB_WORK_DIRECTORY_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 25
0
 /** Post database upgrade. */
 public function postUpgrade()
 {
     /** @var SettingModel $settingModel */
     $settingModel = MidasLoader::loadModel('Setting');
     $configPath = LOCAL_CONFIGS_PATH . DIRECTORY_SEPARATOR . $this->moduleName . '.local.ini';
     if (file_exists($configPath)) {
         $config = new Zend_Config_Ini($configPath, 'global');
         $settingModel->setConfig(OAI_REPOSITORY_IDENTIFIER_KEY, $config->get('repositoryidentifier', OAI_REPOSITORY_IDENTIFIER_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(OAI_REPOSITORY_NAME_KEY, $config->get('repositoryname', OAI_REPOSITORY_NAME_DEFAULT_VALUE), $this->moduleName);
         $settingModel->setConfig(OAI_ADMIN_EMAIL_KEY, $config->get('adminemail', OAI_ADMIN_EMAIL_DEFAULT_VALUE), $this->moduleName);
         $config = new Zend_Config_Ini($configPath, null, true);
         unset($config->global->repositoryidentifier);
         unset($config->global->repositoryname);
         unset($config->global->adminemail);
         $writer = new Zend_Config_Writer_Ini();
         $writer->setConfig($config);
         $writer->setFilename($configPath);
         $writer->write();
     } else {
         $settingModel->setConfig(OAI_REPOSITORY_IDENTIFIER_KEY, OAI_REPOSITORY_IDENTIFIER_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(OAI_REPOSITORY_NAME_KEY, OAI_REPOSITORY_NAME_DEFAULT_VALUE, $this->moduleName);
         $settingModel->setConfig(OAI_ADMIN_EMAIL_KEY, OAI_ADMIN_EMAIL_DEFAULT_VALUE, $this->moduleName);
     }
 }
Ejemplo n.º 26
0
 /**
  * Get the config writer that corresponds to the current config file type.
  *
  * @return Zend_Config_Writer_FileAbstract
  */
 protected function getConfigWriter()
 {
     $suffix = substr($this->getConfigFilepath(), -4);
     switch ($suffix) {
         case '.ini':
             // require_once "Zend/Config/Writer/Ini.php";
             $writer = new Zend_Config_Writer_Ini();
             $writer->setRenderWithoutSections();
             break;
         case '.xml':
             // require_once "Zend/Config/Writer/Xml.php";
             $writer = new Zend_Config_Writer_Xml();
             break;
         case '.php':
             // require_once "Zend/Config/Writer/Array.php";
             $writer = new Zend_Config_Writer_Array();
             break;
         default:
             // require_once 'Zend/Tool/Framework/Client/Exception.php';
             throw new Zend_Tool_Framework_Client_Exception('Unknown config file type ' . $suffix . ' at location ' . $this->getConfigFilepath());
     }
     return $writer;
 }
 /**
  * Set the upgrade level for the given $context to a certain level
  *
  * Will only update when the $level is higher than the achieved level, unless
  * when $force = true when it will always update.
  *
  * @param string $context
  * @param int $level
  * @param boolean $force
  */
 protected function setLevel($context, $level = null, $force = false)
 {
     if (!is_null($level) && $this->_info->{$context} != $level && ($force || $this->_info->{$context} < $level)) {
         $this->_info->{$context} = $level;
         $writer = new \Zend_Config_Writer_Ini();
         $writer->write($this->upgradeFile, $this->_info);
     }
 }
Ejemplo n.º 28
0
 /** index */
 public function indexAction()
 {
     $this->requireAdminPrivileges();
     $this->view->header = 'Administration';
     $options = array('allowModifications' => true);
     $config = new Zend_Config_Ini(APPLICATION_CONFIG, null, $options);
     $configForm = $this->Form->Admin->createConfigForm();
     $formArray = $this->getFormAsArray($configForm);
     $formArray['description']->setValue($config->global->application->description);
     $formArray['lang']->setValue($config->global->application->lang);
     $formArray['name']->setValue($config->global->application->name);
     $formArray['timezone']->setValue($config->global->default->timezone);
     if (isset($config->global->allow_password_reset)) {
         $formArray['allow_password_reset']->setValue($config->global->allow_password_reset);
     }
     if (isset($config->global->closeregistration)) {
         $formArray['closeregistration']->setValue($config->global->closeregistration);
     }
     if (isset($config->global->dynamichelp)) {
         $formArray['dynamichelp']->setValue($config->global->dynamichelp);
     }
     if (isset($config->global->gravatar)) {
         $formArray['gravatar']->setValue($config->global->gravatar);
     }
     if (isset($config->global->httpproxy)) {
         $formArray['httpProxy']->setValue($config->global->httpproxy);
     }
     $this->view->configForm = $formArray;
     $this->view->selectedLicense = $config->global->defaultlicense;
     try {
         $this->view->allLicenses = $this->License->getAll();
     } catch (Exception $e) {
         $this->view->allLicenses = array();
     }
     $allModules = $this->Component->Utility->getAllModules();
     $this->view->extraTabs = Zend_Registry::get('notifier')->callback('CALLBACK_CORE_ADMIN_TABS');
     if ($this->_request->isPost()) {
         $this->_helper->layout->disableLayout();
         $this->_helper->viewRenderer->setNoRender();
         $submitConfig = $this->getParam('submitConfig');
         $submitModule = $this->getParam('submitModule');
         if (isset($submitConfig)) {
             $config->global->application->name = $this->getParam('name');
             $config->global->application->description = $this->getParam('description');
             $config->global->application->lang = $this->getParam('lang');
             $config->global->default->timezone = $this->getParam('timezone');
             $config->global->defaultlicense = $this->getParam('licenseSelect');
             $config->global->allow_password_reset = $this->getParam('allow_password_reset');
             $config->global->closeregistration = $this->getParam('closeregistration');
             $config->global->dynamichelp = $this->getParam('dynamichelp');
             $config->global->gravatar = $this->getParam('gravatar');
             $config->global->httpproxy = $this->getParam('httpProxy');
             $writer = new Zend_Config_Writer_Ini();
             $writer->setConfig($config);
             $writer->setFilename(APPLICATION_CONFIG);
             $writer->write();
             echo JsonComponent::encode(array(true, 'Changes saved'));
         }
         if (isset($submitModule)) {
             $moduleName = $this->getParam('modulename');
             $modulevalue = $this->getParam('modulevalue');
             $moduleConfigLocalFile = LOCAL_CONFIGS_PATH . '/' . $moduleName . '.local.ini';
             $moduleConfigFile = BASE_PATH . '/modules/' . $moduleName . '/configs/module.ini';
             $moduleConfigPrivateFile = BASE_PATH . '/privateModules/' . $moduleName . '/configs/module.ini';
             if (!file_exists($moduleConfigLocalFile) && file_exists($moduleConfigFile)) {
                 copy($moduleConfigFile, $moduleConfigLocalFile);
                 $this->Component->Utility->installModule($moduleName);
             } elseif (!file_exists($moduleConfigLocalFile) && file_exists($moduleConfigPrivateFile)) {
                 copy($moduleConfigPrivateFile, $moduleConfigLocalFile);
                 $this->Component->Utility->installModule($moduleName);
             } elseif (!file_exists($moduleConfigLocalFile)) {
                 throw new Zend_Exception('Unable to find config file');
             }
             $config->module->{$moduleName} = $modulevalue;
             $writer = new Zend_Config_Writer_Ini();
             $writer->setConfig($config);
             $writer->setFilename(APPLICATION_CONFIG);
             $writer->write();
             echo JsonComponent::encode(array(true, 'Changes saved'));
         }
     }
     $defaultAssetStoreId = $this->Assetstore->getDefault()->getKey();
     // get assetstore data
     $assetstores = $this->Assetstore->getAll();
     $defaultSet = false;
     foreach ($assetstores as $key => $assetstore) {
         if ($assetstore->getKey() == $defaultAssetStoreId) {
             $assetstores[$key]->default = true;
             $defaultSet = true;
         } else {
             $assetstores[$key]->default = false;
         }
         // Check if we can access the path
         if (file_exists($assetstore->getPath())) {
             $assetstores[$key]->totalSpace = UtilityComponent::diskTotalSpace($assetstore->getPath());
             $assetstores[$key]->totalSpaceText = $this->Component->Utility->formatSize($assetstores[$key]->totalSpace);
             $assetstores[$key]->freeSpace = UtilityComponent::diskFreeSpace($assetstore->getPath());
             $assetstores[$key]->freeSpaceText = $this->Component->Utility->formatSize($assetstores[$key]->freeSpace);
         } else {
             $assetstores[$key]->totalSpaceText = false;
         }
     }
     if (!$defaultSet) {
         foreach ($assetstores as $key => $assetstore) {
             $assetstores[$key]->default = true;
             $this->Setting->setConfig('default_assetstore', $assetstores[$key]->getKey());
             $writer = new Zend_Config_Writer_Ini();
             $writer->setConfig($config);
             $writer->setFilename(APPLICATION_CONFIG);
             $writer->write();
             break;
         }
     }
     $this->view->assetstores = $assetstores;
     $this->view->assetstoreForm = $this->Form->Assetstore->createAssetstoreForm();
     // get modules
     $enabledModules = Zend_Registry::get('modulesEnable');
     $adapter = Zend_Registry::get('configDatabase')->database->adapter;
     foreach ($allModules as $key => $module) {
         if (file_exists(BASE_PATH . '/modules/' . $key . '/controllers/ConfigController.php')) {
             $allModules[$key]->configPage = 'config';
         } elseif (file_exists(BASE_PATH . '/privateModules/' . $key . '/controllers/ConfigController.php')) {
             $allModules[$key]->configPage = 'config';
         } elseif (file_exists(BASE_PATH . '/modules/' . $key . '/controllers/AdminController.php')) {
             $allModules[$key]->configPage = 'admin';
         } elseif (file_exists(BASE_PATH . '/privateModules/' . $key . '/controllers/AdminController.php')) {
             $allModules[$key]->configPage = 'admin';
         } else {
             $allModules[$key]->configPage = false;
         }
         if (isset($module->db->{$adapter})) {
             $allModules[$key]->dbOk = true;
         } else {
             $allModules[$key]->dbOk = false;
         }
         $allModules[$key]->dependenciesArray = array();
         $allModules[$key]->dependenciesExist = true;
         // check if dependencies exit
         if (isset($allModules[$key]->dependencies) && !empty($allModules[$key]->dependencies)) {
             $allModules[$key]->dependenciesArray = explode(',', trim($allModules[$key]->dependencies));
             foreach ($allModules[$key]->dependenciesArray as $dependency) {
                 if (!isset($allModules[$dependency])) {
                     $allModules[$key]->dependenciesExist = false;
                 }
             }
         }
     }
     $modulesList = array();
     $countModules = array();
     foreach ($allModules as $k => $module) {
         if (!isset($module->category) || empty($module->category)) {
             $category = 'Misc';
         } else {
             $category = ucfirst($module->category);
         }
         if (!isset($modulesList[$category])) {
             $modulesList[$category] = array();
             $countModules[$category] = array('visible' => 0, 'hidden' => 0);
         }
         $modulesList[$category][$k] = $module;
         if ($module->dbOk && $module->dependenciesExist) {
             ++$countModules[$category]['visible'];
         } else {
             ++$countModules[$category]['hidden'];
         }
     }
     foreach ($modulesList as $k => $l) {
         ksort($modulesList[$k]);
     }
     ksort($modulesList);
     $this->view->countModules = $countModules;
     $this->view->modulesList = $modulesList;
     $this->view->modulesEnable = $enabledModules;
     $this->view->databaseType = Zend_Registry::get('configDatabase')->database->adapter;
 }
Ejemplo n.º 29
0
    /**
     * @group ZF-6289
     */
    public function testZF6289_NonSectionElementsAndSectionJumbling()
    {
        $config = new Zend_Config(array('one' => 'element', 'two' => array('type' => 'section'), 'three' => 'element', 'four' => array('type' => 'section'), 'five' => 'element'));
        $writer = new Zend_Config_Writer_Ini();
        $iniString = $writer->setConfig($config)->render($config);
        $expected = <<<ECS
one = "element"
three = "element"
five = "element"
[two]
type = "section"

[four]
type = "section"


ECS;
        $this->assertEquals($expected, $iniString);
    }
Ejemplo n.º 30
0
 public function indexAction()
 {
     // Title
     $this->view->breadcrumb = Snep_Breadcrumb::renderPath(array($this->view->translate("Configure"), $this->view->translate("Parameters")));
     // Get configuration properties from Zend_Registry
     $config = Zend_Registry::get('config');
     // Include Inpector class, for permission test
     include_once $config->system->path->base . "/inspectors/Permissions.php";
     $test = new Permissions();
     $response = $test->getTests();
     // Verify if there's any error, and if it's related to the setup.conf file
     if ($response['error'] && strpos($response['message'], "setup.conf") > 0) {
         // seta variavel verificada no template
         $this->view->error = $this->view->translate("The File includes/setup.conf does not have permission to be modified.");
     }
     // Create object Snep_Form
     $form = new Snep_Form();
     // Set form action
     $form->setAction($this->getFrontController()->getBaseUrl() . '/parameters/index');
     $form_xml = new Zend_Config_Xml('./modules/default/forms/setup.conf.xml');
     // Section General
     $general = new Snep_Form_SubForm($this->view->translate("General Configuration"), $form_xml->general);
     // Setting propoertie values
     $empName = $general->getElement('emp_nome');
     $empName->setValue($config->ambiente->emp_nome);
     $debug = $general->getElement('debug');
     $debug->setValue($config->system->debug);
     $ipSock = $general->getElement('ip_sock');
     $ipSock->setValue($config->ambiente->ip_sock);
     $userSock = $general->getElement('user_sock');
     $userSock->setValue($config->ambiente->user_sock);
     $passSock = $general->getElement('pass_sock');
     $passSock->setValue($config->ambiente->pass_sock);
     $email = $general->getElement('mail');
     $email->setValue($config->system->mail);
     $lineLimit = $general->getElement('linelimit');
     $lineLimit->setValue($config->ambiente->linelimit);
     $dstExceptions = $general->getElement('dst_exceptions');
     $dstExceptions->setValue($config->ambiente->dst_exceptions);
     $conferenceApp = $general->getElement('conference_app');
     $conferenceApp->setValue($config->ambiente->conference_app);
     $form->addSubForm($general, "general");
     $locale_form = new Snep_Form_SubForm($this->view->translate("Locale Configuration"), $form_xml->locale);
     $locale = Snep_Locale::getInstance()->getZendLocale();
     $locales = array();
     foreach ($locale->getTranslationList("territory", Snep_Locale::getInstance()->getLanguage(), 2) as $ccode => $country) {
         $locales[$country] = $locale->getLocaleToTerritory($ccode);
     }
     ksort($locales, SORT_LOCALE_STRING);
     foreach ($locales as $country => $ccode) {
         $locale_form->getElement("locale")->addMultiOption($ccode, $country);
     }
     $locale_form->getElement("locale")->setValue(Snep_Locale::getInstance()->getLocale());
     foreach ($locale->getTranslationList("territorytotimezone", Snep_Locale::getInstance()->getLanguage()) as $timezone => $territory) {
         $locale_form->getElement("timezone")->addMultiOption($timezone, $timezone);
     }
     $locale_form->getElement("timezone")->setValue(Snep_Locale::getInstance()->getTimezone());
     $languages = array();
     $languageElement = $locale_form->getElement("language");
     $available_languages = Snep_Locale::getInstance()->getAvailableLanguages();
     foreach ($locale->getTranslationList("language", Snep_Locale::getInstance()->getLanguage()) as $lcode => $language) {
         if (in_array($lcode, $available_languages)) {
             $languageElement->addMultiOption($lcode, ucfirst($language));
         }
     }
     $languageElement->setValue(Snep_Locale::getInstance()->getLanguage());
     $form->addSubForm($locale_form, "locale");
     // Section Recording
     $recording = new Snep_Form_SubForm($this->view->translate("Call Recording Configuration"), $form_xml->recording);
     // Setting propoertie values
     $application = $recording->getElement('application');
     $application->setValue($config->general->record->application);
     $flag = $recording->getElement('flag');
     $flag->setValue($config->general->record->flag);
     $recordMp3 = $recording->getElement('record_mp3');
     $recordMp3->setValue($config->general->record_mp3);
     $pathVoice = $recording->getElement('path_voz');
     $pathVoice->setValue($config->ambiente->path_voz);
     $pathVoiceBkp = $recording->getElement('path_voz_bkp');
     $pathVoiceBkp->setValue($config->ambiente->path_voz_bkp);
     $form->addSubForm($recording, "gravacao");
     // Section Trunks
     $trunks = new Snep_Form_SubForm($this->view->translate("Trunks Configuration"), $form_xml->trunks);
     // Setting propoertie values
     $qualControlValue = $trunks->getElement('valor_controle_qualidade');
     $qualControlValue->setValue($config->ambiente->valor_controle_qualidade);
     $form->addSubForm($trunks, "troncos");
     // Verify if the request is a post
     if ($this->_request->getPost()) {
         $formIsValid = $form->isValid($_POST);
         $formData = $this->getRequest()->getParams();
         // Specific verification for propertie path_voice
         if (!file_exists($formData['gravacao']['path_voz'])) {
             $recording->getElement('path_voz')->addError($this->view->translate("Invalid path"));
             $formIsValid = false;
         }
         //Validates form, then sets propertie values and records it on the configuration file
         if ($formIsValid) {
             $configFile = APPLICATION_PATH . "/includes/setup.conf";
             $config = new Zend_Config_Ini($configFile, null, true);
             $config->ambiente->emp_nome = $formData['general']['emp_nome'];
             $config->system->debug = $formData['general']['debug'];
             $config->system->language = $formData['locale']['language'];
             $config->system->locale = $formData['locale']['locale'];
             $config->system->timezone = $formData['locale']['timezone'];
             $config->ambiente->ip_sock = $formData['general']['ip_sock'];
             $config->ambiente->user_sock = $formData['general']['user_sock'];
             $config->ambiente->pass_sock = $formData['general']['pass_sock'];
             $config->system->mail = $formData['general']['mail'];
             $config->ambiente->linelimit = $formData['general']['linelimit'];
             $config->ambiente->dst_exceptions = $formData['general']['dst_exceptions'];
             $config->ambiente->conference_app = $formData['general']['conference_app'];
             $config->general->record->application = $formData['gravacao']['application'];
             $config->general->record->flag = $formData['gravacao']['flag'];
             $config->general->record_mp3 = $formData['gravacao']['record_mp3'];
             $config->ambiente->path_voz = $formData['gravacao']['path_voz'];
             $config->ambiente->path_voz_bkp = $formData['gravacao']['path_voz_bkp'];
             $config->ambiente->valor_controle_qualidade = $formData['troncos']['valor_controle_qualidade'];
             $writer = new Zend_Config_Writer_Ini(array('config' => $config, 'filename' => $configFile));
             // Write file
             $writer->write();
             $this->_redirect('parameters');
         }
     }
     $this->view->form = $form;
 }