Пример #1
0
 function all()
 {
     if (!($settings = Settings::first())) {
         $settings = new Settings();
         $settings->save();
     }
     $whereis_node = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whereis node')));
     $whereis_nodejs = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whereis nodejs')));
     $whoami = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('whoami')));
     $home = trim(preg_replace('/\\s\\s+/', ' ', shell_exec('echo $HOME')));
     $pw = @posix_getpwuid(@posix_getuid());
     $detectedHome = is_array($pw) && isset($pw['dir']) ? trim(preg_replace('/\\s\\s+/', ' ', $pw['dir'])) : '';
     $defaultNodeJsPath = false;
     if (empty($settings->nodejs_path)) {
         if (!empty($whereis_nodejs)) {
             $parts = explode(' ', $whereis_nodejs);
             if (isset($parts[0]) && $parts[0] == 'nodejs:' && isset($parts[1])) {
                 $defaultNodeJsPath = $parts[1];
             }
         }
         if (!$defaultNodeJsPath && !empty($whereis_nodejs)) {
             $parts = explode(' ', $whereis_node);
             if (isset($parts[0]) && $parts[0] == 'node:' && isset($parts[1])) {
                 $defaultNodeJsPath = $parts[1];
             }
         }
     }
     return view('settings', ['settings' => $settings, 'whereis_node' => $whereis_node, 'whereis_nodejs' => $whereis_nodejs, 'whoami' => $whoami, 'home' => $home, 'detectedHome' => $detectedHome, 'defaultNodeJsPath' => $defaultNodeJsPath]);
 }
Пример #2
0
 /**
  * Run the database seeds.
  *
  * @return void
  */
 public function run()
 {
     $settings = new Settings();
     $settings->url = 'http://localhost';
     $settings->email = '*****@*****.**';
     $settings->title = 'CMS';
     $settings->desc = 'CMS';
     $settings->keys = 'CMS';
     $settings->save();
 }
Пример #3
0
 /**
  * Creates a new Settings model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  * @return mixed
  */
 public function actionCreate()
 {
     $model = new Settings();
     if ($model->load(Yii::$app->request->post())) {
         $model->name = UrlHelp::translateUrl($model->name, true);
         if ($model->validate()) {
             $model->save();
             return $this->redirect(['view', 'id' => $model->id]);
         }
     }
     return $this->render('create', ['model' => $model]);
 }
Пример #4
0
 public static function setValue($parameterID, $value)
 {
     $parameter = self::findByParameterID($parameterID);
     if (!$parameter) {
         $parameter = new Settings();
         $parameter->user_id = Yii::$app->user->id;
         $parameter->parameter_id = $parameterID;
     }
     $parameter->value = $value;
     if (!$parameter->save()) {
         throw new Exception('Не удалось сохранить параметр');
     }
 }
Пример #5
0
 public function savesettings()
 {
     /* Get Post */
     $rules = array();
     if (Input::has('ldapon')) {
         $rules = array('ldapserver' => 'required', 'ldapdomain' => 'required', 'ldapuser' => 'required', 'ldappassword' => 'required', 'ldapbasedn' => 'required');
     }
     // Check Validation
     $validation = Validator::make(Input::all(), $rules);
     if ($validation->fails()) {
         //failed to validate
         //let's go back to that form with errors, input
         $messages = $validation->messages();
         $html = '<div class="response"><div class="alert alert-error">';
         foreach ($messages->all() as $message) {
             $html .= ' ' . $message . '<br>';
         }
         $html .= '</div></div>';
         Former::withErrors($validation);
         echo json_encode(array('html' => $html));
     } else {
         $settings = Settings::find(1);
         if ($settings === null) {
             $settings = new Settings();
         }
         $settings->id = '1';
         $settings->ldapon = "0";
         $settings->ldapserver = "";
         $settings->ldapdomain = "";
         $settings->ldapuser = "";
         $settings->ldappassword = "";
         $settings->servername = Input::get('servername', '');
         $settings->adminemail = Input::get('adminemail', '');
         $settings->confdir = Input::get('confdir', '');
         if (Input::has('ldapon')) {
             $settings->ldapon = Input::get('ldapon');
             $settings->ldapserver = Input::get('ldapserver', '');
             $settings->ldapdomain = Input::get('ldapdomain', '');
             $settings->ldapuser = Input::get('ldapuser', '');
             $settings->ldappassword = Input::get('ldappassword', '');
             $settings->ldapbasedn = Input::get('ldapbasedn', '');
             $settings->ldapport = Input::get('ldapport', '');
         }
         $settings->save();
         /* Check if Conf Dir is writables */
         echo json_encode(array('html' => '<div class="response"><div class="alert alert-success"> Settings Sucessufull Updated </div><div class="response"></div>'));
     }
 }
Пример #6
0
 private function warehouseSave($id)
 {
     $model = Settings::findOne("company." . $this->id . ".warehouse");
     if ($model === null) {
         $model = new Settings();
         $model->id = "company." . $this->id . ".warehouse";
         $model->eavType = 'integer';
         $model->hidden = 1;
     }
     $model->value = $id;
     $this->warehouse = $model->value;
     $model->save();
 }
Пример #7
0
 /**
  * @param Settings $settings
  */
 protected function upgradeSettings(Settings $settings)
 {
     $defaultFieldValues = (array) $settings->default_field_values;
     foreach ($defaultFieldValues as $defaultFieldValueIndex => $defaultFieldValue) {
         $defaultFieldValues[$defaultFieldValueIndex]['humanitarian'] = "0";
     }
     !$defaultFieldValues ?: ($settings->default_field_values = $defaultFieldValues);
     $settings->save();
 }