public function storeSettingsLocal()
 {
     $net_name = !empty($this->settings['address']) ? $this->settings['address'] : PA::$network_info->address;
     $file_path = DIRECTORY_SEPARATOR . 'networks' . DIRECTORY_SEPARATOR . $net_name;
     if (is_dir(PA::$project_dir . $file_path)) {
         if (!is_writable(PA::$project_dir . $file_path)) {
             if (!chmod(PA::$project_dir . $file_path, 0777)) {
                 throw new PAException(NETWORK_DIRECTORY_PERMISSION_ERROR, "Can't change permissions - Directory \"" . PA::$project_dir . $file_path . "\" should be writtable.");
             }
         }
         $file_name = PA::$project_dir . $file_path . DIRECTORY_SEPARATOR . "{$net_name}.xml";
     } else {
         if (is_dir(PA::$core_dir . $file_path)) {
             if (!is_writable(PA::$core_dir . $file_path)) {
                 if (!chmod(PA::$core_dir . $file_path, 0777)) {
                     throw new PAException(NETWORK_DIRECTORY_PERMISSION_ERROR, "Can't change permissions - Directory \"" . PA::$core_dir . $file_path . "\" should be writtable.");
                 }
             }
             $file_name = PA::$core_dir . $file_path . DIRECTORY_SEPARATOR . "{$net_name}.xml";
         }
     }
     if (file_exists($file_name)) {
         unlink($file_name);
     }
     foreach ($this->settings['email_messages'] as &$message) {
         // put message subject and body in CDATA section
         $message['subject'] = "<![CDATA[" . htmlspecialchars_decode($message['subject']) . "]]>";
         $message['message'] = "<![CDATA[" . htmlspecialchars_decode($message['message']) . "]]>";
     }
     $store = new XmlConfig($file_name);
     $store->loadFromArray($this->settings, $store->root_node);
     $store->saveToFile();
     $this->settings_file = $file_name;
 }
 public function loadConfigFile($fname)
 {
     $this->pa_static_vars = array_keys(get_class_vars('PA'));
     if (file_exists(PA::$project_dir . $fname)) {
         // check for config data in paproject path
         $proj_conf = new XmlConfig(PA::$project_dir . $fname, 'application');
         $proj_conf = $proj_conf->asArray();
     } else {
         if (file_exists(PA::$project_dir . "{$fname}.distr")) {
             $proj_conf = new XmlConfig(PA::$project_dir . "{$fname}.distr", 'application');
             $proj_conf = $proj_conf->asArray();
             // but we SAVE it to project_dir!!!
             $export_config = new XmlConfig(PA::$project_dir . $fname, 'application');
             // and create AppConfig.xml
             $export_config->loadFromArray($proj_conf, $export_config->root_node);
             $export_config->saveToFile();
         } else {
             if (file_exists(PA::$core_dir . "{$fname}.distr")) {
                 $proj_conf = new XmlConfig(PA::$core_dir . "{$fname}.distr", 'application');
                 $proj_conf = $proj_conf->asArray();
                 // but we SAVE it to project_dir!!!
                 $export_config = new XmlConfig(PA::$project_dir . $fname, 'application');
                 // and create AppConfig.xml
                 $export_config->loadFromArray($proj_conf, $export_config->root_node);
                 $export_config->saveToFile();
             } else {
                 throw new BootStrapException("BootStrap::loadConfigFile() - Unable to load \"{$fname}\"config. file!", 1);
             }
         }
     }
     $this->configData = $proj_conf;
     $this->configObj = new XmlConfig(null, 'application');
     $this->configObj->loadFromArray($this->configData, $this->configObj->root_node);
     $this->parseConfigFile('configuration', $proj_conf['configuration']);
     $this->afterParse();
 }
 /** !!
  * saves the setting selected by the user
  * @param array $request_data information to be saved
  */
 private function handlePOST_saveConfSection($request_data)
 {
     global $app, $error_msg;
     $msg = __("Configuration data sucessfully stored.");
     $this->section = $request_data['section'];
     $form_data = $request_data['form_data'];
     $this->recursive_update_data_object($form_data[$this->section], "{$this->section}']['value");
     try {
         unlink(PA::$project_dir . APPLICATION_CONFIG_FILE);
         $conf = new XmlConfig(PA::$project_dir . APPLICATION_CONFIG_FILE, 'application');
         $conf->loadFromArray($app->configData, $conf->root_node);
         $conf->saveToFile();
         $app->configData = $conf->asArray();
         $app->configObj = $conf;
     } catch (Exception $e) {
         $msg = $e->getMessage();
     }
     $form = $this->getConfigSection($this->config_sect, $this->manage_mode);
     $this->set_inner_template('show_config_section.tpl.php');
     $this->inner_HTML = $this->generate_inner_html(array('data' => $form, 'mode_tag' => $this->mode_tag, 'sect_tag' => $this->sect_tag, 'message' => null));
     $error_msg = $msg;
 }
 public function exportMessages($file_name)
 {
     $obj = new XmlConfig($file_name, "email_messages");
     $obj->loadFromArray($this->messages, $obj->root_node);
     $obj->saveToFile();
 }
 private function updateSettings()
 {
     global $app;
     // We don't need to store the MySQL root un/pw, so un-set it from the config array.
     unset($this->config['database']['mysql_root_password'], $this->config['database']['mysql_root_username']);
     foreach ($this->config['database'] as $key => $value) {
         $app->configData['configuration']['database']['value'][$key]['value'] = $value;
     }
     $app->configData['configuration']['database']['value']['peepagg_dsn']['value'] = $this->config['peepagg_dsn'];
     $app->configData['configuration']['basic_network_settings']['value']['domain_prefix']['value'] = $this->subdomain;
     $app->configData['configuration']['basic_network_settings']['value']['enable_networks']['value'] = $this->allow_network_spawning;
     $app->configData['configuration']['basic_network_settings']['value']['enable_network_spawning']['value'] = $this->allow_network_spawning;
     $app->configData['configuration']['site_related']['value']['pa_installed']['value'] = 1;
     $app->configData['configuration']['api_keys']['value']['facebook_api_key']['value'] = $this->keys['key'];
     $app->configData['configuration']['api_keys']['value']['facebook_api_secret']['value'] = $this->keys['secret'];
     $app->configData['configuration']['api_keys']['value']['amazon_aws_key']['value'] = $this->keys['amazon_key'];
     $app->configData['configuration']['api_keys']['value']['amazon_aws_secret']['value'] = $this->keys['amazon_secret'];
     $app->configData['configuration']['api_keys']['value']['amazon_s3_bucket']['value'] = $this->keys['amazon_bucket'];
     $app->configData['configuration']['api_keys']['value']['hoptoad_key']['value'] = $this->keys['hoptoad_key'];
     $app->configData['configuration']['api_keys']['value']['hoptoad_environment']['value'] = $this->keys['hoptoad_env'];
     $app->configData['configuration']['civic_commons_settings']['value']['CC_APPLICATION_URL']['value'] = $this->keys['cc_application_url'];
     $app->configData['configuration']['site_related']['value']['PASSWORD_PEPPER']['value'] = $this->keys['pw_pepper'];
     unlink(PA::$project_dir . APPLICATION_CONFIG_FILE);
     $confObj = new XmlConfig(null, 'application');
     $confObj->loadFromArray($app->configData, $confObj->root_node);
     $confObj->saveToFile(PA::$project_dir . APPLICATION_CONFIG_FILE);
 }