Exemplo n.º 1
0
 public function put_update()
 {
     $post_data = Input::get('order');
     if (isset($post_data) and !empty($post_data)) {
         $order_items = explode(',', $post_data);
         foreach ($order_items as $order_position => $slug) {
             $affected = Settings\Model\Setting::where_slug($slug)->update(array('order' => $order_position));
         }
         return;
     }
     $settings = Input::all();
     foreach ($settings as $slug => $value) {
         // Update runtime configurations.
         $setting = Config::get('settings::core.' . $slug);
         if ($setting != null) {
             Config::set('settings::core.' . $slug, $value);
         }
         // Update database configurations
         $affected = Settings\Model\Setting::where_slug($slug)->update(array('value' => $value));
     }
     $this->data['message'] = Lang::line('splashscreen::lang.Settings were successfully updated')->get(ADM_LANG);
     $this->data['message_type'] = 'success';
     // redirect back to the module
     return Redirect::back()->with($this->data);
 }
Exemplo n.º 2
0
 public function uninstall()
 {
     //
     // REMOVE SETTINGS
     //
     $settings = Settings\Model\Setting::where_module_slug('email')->get();
     if (isset($settings) and !empty($settings)) {
         foreach ($settings as $setting) {
             $setting->delete();
         }
     }
     $emal_admin_new_user = Settings\Model\Setting::where_slug('email_admin_on_registration')->first();
     if (isset($settings) and !empty($settings)) {
         $emal_admin_new_user->delete();
     }
 }
Exemplo n.º 3
0
 public function put_update()
 {
     $post_data = Input::get('order');
     if (isset($post_data) and !empty($post_data)) {
         $order_items = explode(',', $post_data);
         foreach ($order_items as $order_position => $slug) {
             $affected = Settings\Model\Setting::where_slug($slug)->update(array('order' => $order_position));
         }
         return;
     }
     $settings = Input::all();
     // If we are saving settings for other module
     // other then settings module this value will
     // not be sent
     $adm_uri = Input::get('administration_uri');
     if (isset($adm_uri) and !empty($adm_uri)) {
         Session::put('ADM_URI', Input::get('administration_uri'));
     } else {
         Session::put('ADM_URI', ADM_URI);
     }
     foreach ($settings as $slug => $value) {
         // Update runtime configurations.
         $setting = Config::get('settings::core.' . $slug);
         if ($setting != null) {
             Config::set('settings::core.' . $slug, $value);
         }
         // Update database configurations
         $affected = Settings\Model\Setting::where_slug($slug)->update(array('value' => $value));
     }
     $this->data['message'] = Lang::line('settings::lang.Settings were successfully updated')->get(ADM_LANG);
     $this->data['message_type'] = 'success';
     // if we are changing the administration
     // uri it must be from settings module
     // redirect there with the new uri
     $redirect = Input::get('administration_uri');
     if (isset($redirect) and !empty($redirect)) {
         return Redirect::to(URL::base() . '/' . Session::get('ADM_URI') . '/settings')->with($this->data);
     }
     // we are not changing the administration
     // uri, it must be from another module
     // redirect back to the module
     return Redirect::back()->with($this->data);
 }
Exemplo n.º 4
0
 public function put_update()
 {
     $settings = Input::all();
     $raw_rules = Settings\Model\Setting::where_in('slug', array_keys($settings))->where_module_slug('opensim')->get();
     $rules = array();
     foreach ($raw_rules as $setting) {
         if (isset($setting->validation) and !empty($setting->validation)) {
             $rules[$setting->slug] = $setting->validation;
         }
     }
     $validation = \Opensim\Validator::make($settings, $rules)->speaks(ADM_LANG);
     if ($validation->fails()) {
         return Redirect::back()->with_errors($validation->errors);
     }
     if (isset($settings['database_driver'])) {
         $credentials = array('driver' => $settings['database_driver'], 'host' => $settings['database_host'], 'database' => $settings['database_name'], 'username' => $settings['database_user'], 'password' => $settings['database_password'], 'charset' => 'utf8', 'prefix' => $settings['database_table_prefix'], 'port' => $settings['database_port']);
         $db = null;
         switch ($credentials['driver']) {
             case 'sqlite':
                 $db = new \Laravel\Database\Connectors\SQLite();
                 break;
             case 'mysql':
                 $db = new \Laravel\Database\Connectors\MySQL();
                 break;
             case 'pgsql':
                 $db = new \Laravel\Database\Connectors\Postgres();
                 break;
             case 'sqlsrv':
                 $db = new \Laravel\Database\Connectors\SQLServer();
                 break;
         }
         \Config::set('error.detail', false);
         \Event::listen('500', function ($message) {
             \Settings\Config::set('settings::core.passes_db_settings', 0, true);
             $this->data['message'] = $message;
             $this->data['message_type'] = 'error';
             $this->data['settings'] = Settings\Model\Setting::where_module_slug('opensim')->where_section('opensim_db_settings')->get();
             $this->data['section_bar_active'] = Lang::line('opensim::lang.Database Settings')->get(ADM_LANG);
             $content = $this->theme->render('opensim::backend.settings.index', $this->data);
             echo $content;
             die;
         });
         // If we get an exception when
         // trying to connect to the db
         // the event above will catch it
         // and return our view with the
         // error message
         $db->connect($credentials);
         // Set database flag
         Settings\Config::set('settings::core.passes_db_settings', 1, true);
         foreach ($settings as $slug => $value) {
             // Update database configurations
             if (!empty($value)) {
                 $affected = Settings\Model\Setting::where_slug($slug)->where_module_slug('opensim')->update(array('value' => $value));
             }
         }
         $this->data['message'] = Lang::line('opensim::lang.Opensim settings were successfully updated')->get(ADM_LANG);
         $this->data['message_type'] = 'success';
         return Redirect::back()->with($this->data);
     } else {
         $db_is_ready = Config::get('settings::core.passes_db_settings');
         if ((bool) $db_is_ready) {
             foreach ($settings as $slug => $value) {
                 // Update database configurations
                 if (strlen($value) > 0) {
                     $affected = Settings\Model\Setting::where_slug($slug)->where_module_slug('opensim')->update(array('value' => $value));
                 }
             }
             $this->data['message'] = Lang::line('opensim::lang.Opensim settings were successfully updated')->get(ADM_LANG);
             $this->data['message_type'] = 'success';
             return Redirect::back()->with($this->data);
         } else {
             Session::flash('message_type', 'error');
             Session::flash('message', Lang::line('opensim::lang.Your opensim database needs to be configured!')->get(ADM_LANG));
             return Redirect::back()->with($this->data);
         }
     }
 }