Пример #1
0
 /**
  * Sets application in installed state (disables installer)
  */
 public static function setInstalled()
 {
     // Set App secret
     Yii::$app->config->set(Enum::APP_SECRET, md5(uniqid(time(), TRUE)));
     $param = Configuration::getParam();
     $param[Enum::APP_INSTALLED] = TRUE;
     Configuration::setParam($param);
 }
Пример #2
0
 /**
  * Rewrites the configuration file
  */
 public static function rewriteConfiguration()
 {
     // Get Current Configuration
     $config = Configuration::get();
     // Add Application Name to Configuration
     $config['name'] = Yii::$app->config->get(Enum::APP_NAME);
     // Add Caching
     $cacheClass = Yii::$app->config->get(Enum::CACHE_CLASS);
     if (!$cacheClass) {
         $cacheClass = FileCache::className();
     }
     $config['components']['cache'] = ['class' => $cacheClass];
     // Add Auth Clients
     $config['components']['authClientCollection']['class'] = 'yii\\authclient\\Collection';
     Configuration::set($config);
 }
Пример #3
0
 /**
  * Last Step, finish up the installation
  */
 public function actionFinished()
 {
     // Rewrite whole configuration file, also sets application
     // in installed state.
     Configuration::rewriteConfiguration();
     // Set to installed
     InstallerModule::setInstalled();
     return $this->render('finished');
 }
 public function actionInstall()
 {
     $model = new InstallerForm();
     $param = Configuration::getParam();
     if ($model->load(Yii::$app->request->post())) {
         $model->install = $model->install === '0' ? TRUE : FALSE;
         $param['installed'] = $model->install;
         Configuration::setParam($param);
     }
     return $this->render('install', ['model' => $model]);
 }
Пример #5
0
 /**
  * @return array|string|\yii\web\Response
  */
 public function actionMailer()
 {
     $config = Configuration::get();
     $param = Configuration::getParam();
     $mailer = new MailerForm();
     if ($mailer->load(Yii::$app->request->post())) {
         if (Yii::$app->request->isAjax) {
             Yii::$app->response->format = Response::FORMAT_JSON;
             return ActiveForm::validate($mailer);
         }
         if ($mailer->validate()) {
             if ($mailer->useTransport === '0') {
                 $mailer->useTransport = FALSE;
             } else {
                 $mailer->useTransport = TRUE;
             }
             // Write Config
             $config['components']['mail']['class'] = Mailer::className();
             $config['components']['mail']['useTransport'] = $mailer->useTransport;
             $config['components']['mail']['transport']['class'] = 'Swift_SmtpTransport';
             $config['components']['mail']['transport']['host'] = $mailer->host;
             $config['components']['mail']['transport']['username'] = $mailer->username;
             $config['components']['mail']['transport']['password'] = $mailer->password;
             $config['components']['mail']['transport']['port'] = $mailer->port;
             $config['components']['mail']['transport']['encryption'] = $mailer->encryption;
             // Write config for future use
             $param['installer']['mail']['useTransport'] = $mailer->useTransport;
             $param['installer']['mail']['transport']['host'] = $mailer->host;
             $param['installer']['mail']['transport']['username'] = $mailer->username;
             $param['installer']['mail']['transport']['password'] = $mailer->password;
             $param['installer']['mail']['transport']['port'] = $mailer->port;
             $param['installer']['mail']['transport']['encryption'] = $mailer->encryption;
             Configuration::set($config);
             Configuration::setParam($param);
             return $this->redirect(Yii::$app->urlManager->createUrl('//installer/setup/init'));
         }
     } else {
         if (isset($param['installer']['mail']['transport']['host'])) {
             $mailer->host = $param['installer']['mail']['transport']['host'];
         }
         if (isset($param['installer']['mail']['transport']['username'])) {
             $mailer->username = $param['installer']['mail']['transport']['username'];
         }
         if (isset($param['installer']['mail']['transport']['password'])) {
             $mailer->password = $param['installer']['mail']['transport']['password'];
         }
         if (isset($param['installer']['mail']['transport']['port'])) {
             $mailer->port = $param['installer']['mail']['transport']['port'];
         }
         if (isset($param['installer']['mail']['transport']['encryption'])) {
             $mailer->encryption = $param['installer']['mail']['transport']['encryption'];
         }
     }
     return $this->render('mailer', ['model' => $mailer]);
 }
Пример #6
0
 public function actionAuthClient()
 {
     $model = new SettingsForm();
     $model->googleClientId = Yii::$app->config->get(Enum::GOOGLE_CLIENT_ID);
     $model->googleClientSecret = Yii::$app->config->get(Enum::GOOGLE_CLIENT_SECRET);
     $model->facebookClientId = Yii::$app->config->get(Enum::FACEBOOK_CLIENT_ID);
     $model->facebookClientSecret = Yii::$app->config->get(Enum::FACEBOOK_CLIENT_SECRET);
     $model->linkedInClientId = Yii::$app->config->get(Enum::LINKED_IN_CLIENT_ID);
     $model->linkedInClientSecret = Yii::$app->config->get(Enum::LINKED_IN_CLIENT_SECRET);
     $model->githubClientId = Yii::$app->config->get(Enum::GITHUB_CLIENT_ID);
     $model->githubClientSecret = Yii::$app->config->get(Enum::GITHUB_CLIENT_SECRET);
     $model->liveClientId = Yii::$app->config->get(Enum::LIVE_CLIENT_ID);
     $model->liveClientSecret = Yii::$app->config->get(Enum::LIVE_CLIENT_SECRET);
     $model->twitterConsumerKey = Yii::$app->config->get(Enum::TWITTER_CONSUMER_KEY);
     $model->twitterConsumerSecret = Yii::$app->config->get(Enum::TWITTER_CONSUMER_SECRET);
     $config = Configuration::get();
     if ($model->load(Yii::$app->request->post())) {
         Yii::$app->config->set(Enum::GOOGLE_CLIENT_ID, $model->googleClientId);
         Yii::$app->config->set(Enum::GOOGLE_CLIENT_SECRET, $model->googleClientSecret);
         Yii::$app->config->set(Enum::FACEBOOK_CLIENT_ID, $model->facebookClientId);
         Yii::$app->config->set(Enum::FACEBOOK_CLIENT_SECRET, $model->facebookClientSecret);
         Yii::$app->config->set(Enum::LINKED_IN_CLIENT_ID, $model->linkedInClientId);
         Yii::$app->config->set(Enum::LINKED_IN_CLIENT_SECRET, $model->linkedInClientSecret);
         Yii::$app->config->set(Enum::GITHUB_CLIENT_ID, $model->githubClientId);
         Yii::$app->config->set(Enum::GITHUB_CLIENT_SECRET, $model->githubClientSecret);
         Yii::$app->config->set(Enum::LIVE_CLIENT_ID, $model->liveClientId);
         Yii::$app->config->set(Enum::LIVE_CLIENT_SECRET, $model->liveClientSecret);
         Yii::$app->config->set(Enum::TWITTER_CONSUMER_KEY, $model->twitterConsumerKey);
         Yii::$app->config->set(Enum::TWITTER_CONSUMER_SECRET, $model->twitterConsumerSecret);
         $config['components']['authClientCollection']['class'] = Collection::className();
         if (!empty($model->googleClientId) && !empty($model->googleClientSecret)) {
             Yii::$app->config->set(Enum::GOOGLE_AUTH, GoogleOAuth::className());
             Yii::$app->config->set(Enum::GOOGLE_CLIENT_ID, $model->googleClientId);
             Yii::$app->config->set(Enum::GOOGLE_CLIENT_SECRET, $model->googleClientSecret);
             $config['components']['authClientCollection']['clients']['google']['class'] = GoogleOAuth::className();
             $config['components']['authClientCollection']['clients']['google']['clientId'] = $model->googleClientId;
             $config['components']['authClientCollection']['clients']['google']['clientSecret'] = $model->googleClientSecret;
         } else {
             Yii::$app->config->set(Enum::GOOGLE_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['google']);
         }
         if (!empty($model->facebookClientId) && !empty($model->facebookClientSecret)) {
             Yii::$app->config->set(Enum::FACEBOOK_AUTH, Facebook::className());
             Yii::$app->config->set(Enum::FACEBOOK_CLIENT_ID, $model->facebookClientId);
             Yii::$app->config->set(Enum::FACEBOOK_CLIENT_SECRET, $model->facebookClientSecret);
             $config['components']['authClientCollection']['clients']['facebook']['class'] = Facebook::className();
             $config['components']['authClientCollection']['clients']['facebook']['clientId'] = $model->facebookClientId;
             $config['components']['authClientCollection']['clients']['facebook']['clientSecret'] = $model->facebookClientSecret;
         } else {
             Yii::$app->config->set(Enum::FACEBOOK_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['facebook']);
         }
         if (!empty($model->linkedInClientId) && !empty($model->linkedInClientSecret)) {
             Yii::$app->config->set(Enum::LINKED_IN_AUTH, LinkedIn::className());
             Yii::$app->config->set(Enum::LINKED_IN_CLIENT_ID, $model->linkedInClientId);
             Yii::$app->config->set(Enum::LINKED_IN_CLIENT_SECRET, $model->linkedInClientSecret);
             $config['components']['authClientCollection']['clients']['linkedin']['class'] = LinkedIn::className();
             $config['components']['authClientCollection']['clients']['linkedin']['clientId'] = $model->linkedInClientId;
             $config['components']['authClientCollection']['clients']['linkedin']['clientSecret'] = $model->linkedInClientSecret;
         } else {
             Yii::$app->config->set(Enum::LINKED_IN_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['linkedin']);
         }
         if (!empty($model->githubClientId) && !empty($model->githubClientSecret)) {
             Yii::$app->config->set(Enum::GITHUB_AUTH, GitHub::className());
             Yii::$app->config->set(Enum::GITHUB_CLIENT_ID, $model->githubClientId);
             Yii::$app->config->set(Enum::GITHUB_CLIENT_SECRET, $model->githubClientSecret);
             $config['components']['authClientCollection']['clients']['github']['class'] = GitHub::className();
             $config['components']['authClientCollection']['clients']['github']['clientId'] = $model->githubClientId;
             $config['components']['authClientCollection']['clients']['github']['clientSecret'] = $model->githubClientSecret;
         } else {
             Yii::$app->config->set(Enum::GITHUB_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['github']);
         }
         if (!empty($model->liveClientId) && !empty($model->liveClientSecret)) {
             Yii::$app->config->set(Enum::LIVE_AUTH, Live::className());
             Yii::$app->config->set(Enum::LIVE_CLIENT_ID, $model->liveClientId);
             Yii::$app->config->set(Enum::LIVE_CLIENT_SECRET, $model->liveClientSecret);
             $config['components']['authClientCollection']['clients']['live']['class'] = Live::className();
             $config['components']['authClientCollection']['clients']['live']['clientId'] = $model->liveClientId;
             $config['components']['authClientCollection']['clients']['live']['clientSecret'] = $model->liveClientSecret;
         } else {
             Yii::$app->config->set(Enum::LIVE_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['live']);
         }
         if (!empty($model->twitterConsumerKey) && !empty($model->twitterConsumerSecret)) {
             Yii::$app->config->set(Enum::TWITTER_AUTH, Twitter::className());
             Yii::$app->config->set(Enum::TWITTER_CONSUMER_KEY, $model->twitterConsumerKey);
             Yii::$app->config->set(Enum::TWITTER_CONSUMER_SECRET, $model->twitterConsumerSecret);
             $config['components']['authClientCollection']['clients']['twitter']['class'] = Twitter::className();
             $config['components']['authClientCollection']['clients']['twitter']['consumerKey'] = $model->twitterConsumerKey;
             $config['components']['authClientCollection']['clients']['twitter']['consumerSecret'] = $model->twitterConsumerSecret;
         } else {
             Yii::$app->config->set(Enum::TWITTER_AUTH, NULL);
             unset($config['components']['authClientCollection']['clients']['twitter']);
         }
         Configuration::set($config);
         Yii::$app->getSession()->setFlash('success', Yii::t('user', 'User module settings saved successfully'));
     }
     return $this->render('authClient', ['model' => $model]);
 }