Example #1
0
 /**
  * Sets application in installed state (disables installer)
  */
 public function setInstalled()
 {
     $config = HSetting::getConfiguration();
     $config['params']['installed'] = true;
     HSetting::setConfiguration($config);
 }
Example #2
0
 /**
  * Rewrites the configuration file
  */
 public static function rewriteConfiguration()
 {
     // Get Current Configuration
     $config = HSetting::getConfiguration();
     // Add Application Name to Configuration
     $config['name'] = HSetting::Get('name');
     // Add Default language
     $defaultLanguage = HSetting::Get('defaultLanguage');
     if ($defaultLanguage !== null && $defaultLanguage != "") {
         $config['language'] = HSetting::Get('defaultLanguage');
     } else {
         $config['language'] = Yii::app()->getLanguage();
     }
     // Add Caching
     $cacheClass = HSetting::Get('type', 'cache');
     if (!$cacheClass) {
         $cacheClass = "CDummyCache";
     }
     $config['components']['cache'] = array('class' => $cacheClass);
     // Add User settings
     $config['components']['user'] = array();
     if (HSetting::Get('defaultUserIdleTimeoutSec', 'authentication_internal')) {
         $config['components']['user']['authTimeout'] = HSetting::Get('defaultUserIdleTimeoutSec', 'authentication_internal');
     }
     // Install Mail Component
     $mail = array('class' => 'ext.yii-mail.YiiMail', 'transportType' => HSetting::Get('transportType', 'mailing'), 'viewPath' => 'application.views.mail', 'logging' => true, 'dryRun' => false);
     if (HSetting::Get('transportType', 'mailing') == 'smtp') {
         $mail['transportOptions'] = array();
         if (HSetting::Get('hostname', 'mailing')) {
             $mail['transportOptions']['host'] = HSetting::Get('hostname', 'mailing');
         }
         if (HSetting::Get('username', 'mailing')) {
             $mail['transportOptions']['username'] = HSetting::Get('username', 'mailing');
         }
         if (HSetting::Get('password', 'mailing')) {
             $mail['transportOptions']['password'] = HSetting::Get('password', 'mailing');
         }
         if (HSetting::Get('encryption', 'mailing')) {
             $mail['transportOptions']['encryption'] = HSetting::Get('encryption', 'mailing');
         }
         if (HSetting::Get('port', 'mailing')) {
             $mail['transportOptions']['port'] = HSetting::Get('port', 'mailing');
         }
         if (HSetting::Get('allowSelfSignedCerts', 'mailing')) {
             $mail['transportOptions']['options']['ssl']['allow_self_signed'] = true;
             $mail['transportOptions']['options']['ssl']['verify_peer'] = false;
         }
     }
     $config['components']['mail'] = $mail;
     // Add Theme
     $theme = HSetting::Get('theme');
     if ($theme && $theme != "") {
         $config['theme'] = $theme;
     } else {
         unset($config['theme']);
     }
     HSetting::setConfiguration($config);
 }
Example #3
0
 /**
  * Rewrites the configuration file
  */
 public static function rewriteConfiguration()
 {
     // Get Current Configuration
     $config = HSetting::getConfiguration();
     // Add Application Name to Configuration
     $config['name'] = HSetting::Get('name');
     // Add Default language
     $config['language'] = HSetting::Get('defaultLanguage');
     // Add Caching
     $cacheClass = HSetting::Get('type', 'cache');
     if (!$cacheClass) {
         $cacheClass = "CDummyCache";
     }
     $config['components']['cache'] = array('class' => $cacheClass);
     // Install Mail Component
     $mail = array('class' => 'ext.yii-mail.YiiMail', 'transportType' => HSetting::Get('transportType', 'mailing'), 'viewPath' => 'application.views.mail', 'logging' => true, 'dryRun' => false);
     if (HSetting::Get('transportType', 'mailing') == 'smtp') {
         $mail['transportOptions'] = array();
         if (HSetting::Get('hostname', 'mailing')) {
             $mail['transportOptions']['host'] = HSetting::Get('hostname', 'mailing');
         }
         if (HSetting::Get('username', 'mailing')) {
             $mail['transportOptions']['username'] = HSetting::Get('username', 'mailing');
         }
         if (HSetting::Get('password', 'mailing')) {
             $mail['transportOptions']['password'] = HSetting::Get('password', 'mailing');
         }
         if (HSetting::Get('encryption', 'mailing')) {
             $mail['transportOptions']['encryption'] = HSetting::Get('encryption', 'mailing');
         }
         if (HSetting::Get('port', 'mailing')) {
             $mail['transportOptions']['port'] = HSetting::Get('port', 'mailing');
         }
     }
     $config['components']['mail'] = $mail;
     // Add Theme
     $theme = HSetting::Get('theme');
     if ($theme && $theme != "") {
         $config['theme'] = $theme;
     } else {
         unset($config['theme']);
     }
     HSetting::setConfiguration($config);
 }
Example #4
0
 /**
  * Database action is responsible for all database related stuff.
  * Checking given database settings, writing them into a config file.
  *
  * (Step 3)
  */
 public function actionDatabase()
 {
     Yii::import('installer.forms.*');
     $success = false;
     $errorMessage = "";
     $config = HSetting::getConfiguration();
     $form = new DatabaseForm();
     if (isset($_POST['ajax']) && $_POST['ajax'] === 'database-form') {
         echo CActiveForm::validate($form);
         Yii::app()->end();
     }
     if (isset($_POST['DatabaseForm'])) {
         $_POST['DatabaseForm'] = Yii::app()->input->stripClean($_POST['DatabaseForm']);
         $form->attributes = $_POST['DatabaseForm'];
         if ($form->validate()) {
             $connectionString = "mysql:host=" . $form->hostname . ";dbname=" . $form->database;
             $password = $form->password;
             if ($password == self::PASSWORD_PLACEHOLDER) {
                 $password = $config['components']['db']['password'];
             }
             // Create Test DB Connection
             Yii::app()->setComponent('db', array('connectionString' => $connectionString, 'username' => $form->username, 'password' => $password, 'class' => 'CDbConnection', 'charset' => 'utf8'));
             try {
                 // Check DB Connection
                 Yii::app()->db->getServerVersion();
                 // Write Config
                 $config['components']['db']['connectionString'] = $connectionString;
                 $config['params']['installer']['db']['installer_hostname'] = $form->hostname;
                 $config['params']['installer']['db']['installer_database'] = $form->database;
                 $config['components']['db']['username'] = $form->username;
                 if ($form->password != self::PASSWORD_PLACEHOLDER) {
                     $config['components']['db']['password'] = $form->password;
                 }
                 HSetting::setConfiguration($config);
                 $success = true;
                 $this->redirect(array('init'));
             } catch (Exception $e) {
                 $errorMessage = $e->getMessage();
             }
         }
     } else {
         if (isset($config['params']['installer']['db']['installer_hostname'])) {
             $form->hostname = $config['params']['installer']['db']['installer_hostname'];
         }
         if (isset($config['params']['installer']['db']['installer_database'])) {
             $form->database = $config['params']['installer']['db']['installer_database'];
         }
         if (isset($config['components']['db']['username'])) {
             $form->username = $config['components']['db']['username'];
         }
         if (isset($config['components']['db']['password'])) {
             $form->password = self::PASSWORD_PLACEHOLDER;
         }
     }
     // Render Template
     $this->render('database', array('model' => $form, 'success' => $success, 'submitted' => isset($_POST['DatabaseForm']), 'errorMessage' => $errorMessage));
 }