Ejemplo n.º 1
0
 /**
  * Display the database configuration form.
  */
 public function config_db()
 {
     // We need to know if the db is already configured. If so, just redirect back, otherwise it could be maliciously overwritten.
     $messages = array();
     config_test::check_db($messages, true);
     if (count($messages) == 0) {
         url::redirect('setup_check');
     } else {
         // Db does indeed need to be configured.
         $this->template->title = 'Database Configuration';
         $this->template->content = new View('fixers/config_db');
         $this->template->content->error = $this->error;
         // init and default values of view vars
         $this->view_var = array();
         $description = str_replace(array('*code*', '*code_user*', '*code_perm*'), array('<span class="code">CREATE DATABASE indicia TEMPLATE=template_postgis;</span>', '<span class="code">CREATE USER indicia_user WITH PASSWORD \'indicia\';<br/>' . 'GRANT ALL PRIVILEGES ON DATABASE indicia TO indicia_user;</span>', '<span class="code">GRANT ALL PRIVILEGES ON TABLE geometry_columns TO indicia_user;<br/>' . 'GRANT ALL PRIVILEGES ON TABLE spatial_ref_sys TO indicia_user;<br/>' . 'GRANT EXECUTE ON FUNCTION st_astext(geometry) TO indicia_user;<br/>' . 'GRANT EXECUTE ON FUNCTION st_geomfromtext(text, integer) TO indicia_user;<br/>' . 'GRANT EXECUTE ON FUNCTION st_transform(geometry, integer) TO indicia_user;</span>'), Kohana::lang('setup.description'));
         $this->template->content->description = $description;
         // Assign default settings if the user has not yet updated the db config
         $db_config = kohana::config('database');
         if ($db_config['default']['connection']['type'] == 'mysql') {
             $this->template->content->host = 'localhost';
             $this->template->content->port = '5432';
             $this->template->content->user = '';
             $this->template->content->password = '';
             $this->template->content->reportuser = '';
             $this->template->content->reportpassword = '';
             $this->template->content->schema = '';
             $this->template->content->database = '';
         } else {
             $this->template->content->host = $db_config['default']['connection']['host'];
             $this->template->content->port = $db_config['default']['connection']['port'];
             $this->template->content->user = $db_config['default']['connection']['user'];
             $this->template->content->password = $db_config['default']['connection']['pass'];
             $this->template->content->reportuser = $db_config['report']['connection']['user'];
             $this->template->content->reportpassword = $db_config['report']['connection']['pass'];
             $this->template->content->schema = $db_config['default']['schema'];
             $this->template->content->database = $db_config['default']['connection']['database'];
         }
     }
 }