private function add()
 {
     $post = $this->request->getPost('Setting');
     if (empty($post)) {
         $this->response(404, '参数缺失');
     } else {
         $exists = Setting::model()->findByAttributes(['section' => $post['section'], 'name' => $post['name']]);
         if (empty($exists)) {
             $model = new Setting();
             $model->attributes = ['section' => $post['section'], 'name' => $post['name'], 'value' => CJSON::encode(explode(',', $post['value']))];
             if ($model->save()) {
                 $this->response(200, '添加成功');
             } else {
                 $this->response(500, '添加失败');
             }
         } else {
             $exists->value = CJSON::encode(explode(',', $post['value']));
             if ($exists->save()) {
                 $this->response(200, '修改成功');
             } else {
                 $this->response(500, '修改失败');
             }
         }
     }
 }
示例#2
0
 public function executeSave()
 {
     $settings = $this->post('setting', 'ARRAY', []);
     $oms = \Setting::findAll('setting_key');
     foreach ($this->form_cfg as $gk => $group) {
         foreach ($group['settings'] as $key => $options) {
             if (isset($settings[$key])) {
                 //form was set
                 if (isset($oms[$key])) {
                     $om = $oms[$key];
                 } else {
                     $om = new \Setting();
                     $om->setSettingKey($key);
                 }
                 $om->setSettingValue($settings[$key]);
                 $om->save();
             } else {
                 if ($options['control'] == 'checkbox') {
                     if (isset($oms[$key])) {
                         $om = $oms[$key];
                     } else {
                         $om = new \Setting();
                         $om->setSettingKey($key);
                     }
                     $om->setSettingValue('');
                     $om->save();
                 }
             }
             $this->dispatch('onAfterChangeSetting', new CMSBackendEvent($this, ['setting' => $om]));
         }
     }
     Session::getInstance()->setFlash('setting.message', t('Site\'s settings was saved!'));
     $this->redirect($this->createUrl('system_setting'));
 }
示例#3
0
    public function save()
    {
        $data = new Setting();
        $data->email_sender = Input::get('email');
        $data->protokol = Input::get('protokol');
        $data->port = Input::get('port');
        $data->host = Input::get('host');
        $data->user_email = Input::get('user');
        $data->pass_email = Input::get('pass');
        $data->enkripsi = Input::get('enkripsi');
        if ($data->save()) {
            Session::flash('messages', '
					<div class="alert alert-info alert-dismissable" id="notif">
                    		<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    		<strong>Keterangan</strong><br>
                    			Setting berhasil disimpan
                		</div>
				');
        } else {
            Session::flash('messages', '
					<div class="alert alert-danger alert-dismissable" id="notif">
                    		<button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
                    		<strong>Peringatan...</strong><br>
                    			Settig gagal disimpan
                		</div>
				');
        }
        return Redirect::to('admin/setting/email');
    }
示例#4
0
 public function run()
 {
     // A whole load of useful settings for Nginx can be found here: http://wiki.nginx.org/HttpUpstreamModule
     // Version of Turbine Appliance software.
     $setting = new Setting(array('name' => 'version', 'svalue' => '1.0.0', 'friendlyname' => 'Application version', 'description' => 'Stores the current software version of the Turbine application.', 'usersetting' => false));
     $setting->save();
     // Default max_fails
     $setting = new Setting(array('name' => 'node_maxfails', 'svalue' => '1', 'friendlyname' => 'Default node max fails', 'description' => 'The number of unsuccessful attempts at communicating with the backend server within the time period (assigned by parameter fail_timeout) after which it is considered inoperative. If not set, the number of attempts is one.', 'usersetting' => true));
     $setting->save();
     // Fail timeout (in seconds)
     $setting = new Setting(array('name' => 'node_failtimeout', 'svalue' => '30', 'friendlyname' => 'Default node fail timeout (in seconds)', 'description' => 'The time (in seconds) during which must occur *max_fails* number of unsuccessful attempts at communication with the backend server that would cause the server to be considered inoperative, and also the time for which the server will be considered inoperative (before another attempt is made). If not set the time is 10 seconds. fail_timeout has nothing to do with upstream response time, use proxy_connect_timeout and proxy_read_timeout for controlling this.', 'usersetting' => true));
     $setting->save();
     // Default node weight
     $setting = new Setting(array('name' => 'node_weight', 'svalue' => '1', 'friendlyname' => 'Default node weight', 'description' => 'The default node weight of the target server.', 'usersetting' => true));
     $setting->save();
     // Path to the root of where the Nginx configs are save too.
     $setting = new Setting(array('name' => 'nginxconfpath', 'svalue' => '/etc/turbine/configs', 'friendlyname' => 'Proxy configuration path', 'description' => 'The root path to where the Nginx virtual host configurations are stored. (No trailing slash)', 'usersetting' => true));
     $setting->save();
     // Enable the remote API or not.
     $setting = new Setting(array('name' => 'api_enabled', 'svalue' => 'false', 'friendlyname' => 'API remote access ', 'description' => 'Allow remote access to the Turbine RESTful API to add and ammend rules via. third-party applications.', 'usersetting' => true, 'type' => 'dropdown', 'options' => 'false|true'));
     $setting->save();
     // API key
     $setting = new Setting(array('name' => 'api_key', 'svalue' => '-- SET YOUR OWN API KEY HERE --', 'friendlyname' => 'API auth key', 'description' => 'Customise your own API key to prevent un-authorised access to the API.', 'usersetting' => true));
     $setting->save();
 }
 public function actionIndex($method)
 {
     if (isset($_POST[$method])) {
         $criteria = new CDbCriteria();
         $criteria->condition = 'setting_group=:group';
         $criteria->params = array(':group' => $method);
         Setting::model()->deleteAll($criteria);
         foreach ($_POST[$method] as $key => $value) {
             $payment = new Setting();
             $payment->setting_group = $method;
             $payment->key = $key;
             $payment->value = $value;
             $payment->serialized = 0;
             $payment->save();
         }
         Yii::app()->user->setFlash('success', $this->accept_param[$method] . ' payment method has been saved.');
         $this->redirect(Yii::app()->createUrl('payment/index', array('method' => $method)));
     }
     $models = $this->loadModel($method);
     $form_data = array();
     foreach ($models as $model) {
         $form_data[$model->attributes['key']] = $model->attributes['value'];
     }
     $order_statuses = array();
     $order_status_models = OrderStatus::model()->findAll();
     foreach ($order_status_models as $model) {
         $order_statuses[$model->order_status_id] = $model->name;
     }
     $this->render('index', array('title' => $this->accept_param[$method], 'method' => $method, 'form' => '_form_' . $method, 'form_data' => $form_data, 'order_statuses' => $order_statuses));
 }
 public function getInstall()
 {
     if (!Setting::has('support.from_name')) {
         Setting::set('support.from_name', '');
     }
     if (!Setting::has('support.from_email')) {
         Setting::set('support.from_email', '');
     }
     if (!Setting::has('support.reply_to_name')) {
         Setting::set('support.reply_to_name', '');
     }
     if (!Setting::has('support.reply_to_email')) {
         Setting::set('support.reply_to_email', '');
     }
     if (!Setting::has('support.default_department')) {
         Setting::set('support.default_department', '1');
     }
     if (!Setting::has('support.default_status')) {
         Setting::set('support.default_status', '1');
     }
     if (!Setting::has('support.auto_close_delay')) {
         Setting::set('support.auto_close_delay', '1');
     }
     Setting::save();
     echo "Support package installed.";
 }
 /**
  * @return mixed
  */
 public function postEkle()
 {
     $validation = Validator::make(Input::all(), ['name' => 'required|unique:settings', 'title' => 'required|max:255', 'description' => 'required|max:255', 'keywords' => 'required|max:255', 'favicon' => 'mimes:jpeg,ico,png,jpg|max:500']);
     if ($validation->fails()) {
         return Redirect::back()->withInput()->withErrors($validation->messages());
     }
     if (Input::hasFile('favicon')) {
         $file = Input::file('favicon');
         $extension = $file->getClientOriginalExtension();
         $filename = rand(11111, 99999) . '.' . $extension;
         $file->move('img', $filename);
     } else {
         $filename = "favicon.ico";
     }
     if (Input::get('active') == 1) {
         Setting::where('active', '=', 1)->update(['active' => 0]);
     }
     $settings = new Setting();
     $settings->name = Input::get('name');
     $settings->title = Input::get('title');
     $settings->description = Input::get('description');
     $settings->keywords = Input::get('keywords');
     $settings->active = Input::get('active');
     $settings->favicon = $filename;
     if ($settings->save()) {
         return Redirect::back()->withInput()->with(array('basarili' => 'Ayar başarı ile kaydedildi.'));
     } else {
         return Redirect::back()->withInput()->with(array('errors' => 'Ayar kaydedilemedi.'));
     }
 }
 /**
  * (non-PHPdoc)
  * @see yii/db/CDbMigration#up()
  */
 public function up()
 {
     $setting = new Setting();
     $setting->name = Setting::FORCE_SSL;
     $setting->value = 0;
     $setting->save();
 }
示例#9
0
 public function postIndex()
 {
     //dd(Input::all());
     // Load settings
     //$settings = new Setting();
     //$settings = $settings->getSettings();
     //$data = File::get(storage_path().'/settings.json');
     //dd($data);
     // HTML
     $status = Input::get('status');
     $color = Input::get('color');
     // Designs
     $design_names = Input::get('designs');
     $designs = array();
     foreach ($design_names as $name) {
         $designs[$name] = array('status' => $status[$name], 'color' => $color[$name]);
     }
     // Components
     $components_names = Input::get('components');
     $components = array();
     foreach ($components_names as $name) {
         $components[$name] = array('status' => $status[$name], 'color' => $color[$name]);
     }
     $data = array('designs' => $designs, 'components' => $components);
     //dd(storage_path().'/settings.json');
     //File::put(storage_path().'/settings.json', json_encode($data));
     $settings = new Setting();
     $settings->save($data);
     $components = load_components();
     $designs = load_designs();
     $message = 'Settings saved.';
     return View::make('boots::admin', compact('components', 'designs', 'message'));
 }
 public function setup()
 {
     $rules = array('first_name' => 'required|alpha_num|max:128', 'last_name' => 'required|alpha_num|max:128', 'email' => 'required|email|max:255|unique:users', 'password' => 'required|min:7|confirmed', 'sitename' => 'required|max:50');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Response::json($validator->messages());
     } else {
         $setting = new Setting();
         $setting->sitename = Input::get('sitename');
         $setting->save();
         $list = new Addressbook();
         $list->name = 'General';
         $list->save();
         try {
             $user = Sentry::register(array('email' => Input::get('email'), 'password' => Input::get('password'), 'first_name' => Input::get('first_name'), 'last_name' => Input::get('last_name')), true);
             $feedback = array('success' => 'Great! Your system is ready to roll! You will be redirected to login form in 3 seconds.');
             return Response::json($feedback);
         } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
             echo 'Login field is required.';
         } catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
             echo 'Password field is required.';
         } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
             echo 'User with this login already exists.';
         }
     }
 }
示例#11
0
 public function updateProfile($username)
 {
     $user = User::where('username', $username)->first();
     if (is_null($user)) {
         throw new Exception("User not found");
     }
     if ($user->id != Auth::id()) {
         throw new Exception("Don't have permision");
     }
     $addr = Input::get('location');
     $about = Input::get('bio');
     $homepage = Input::get('website');
     $email = Input::get('email');
     $language = Input::get('language');
     $settings = Input::get('settings');
     if (isset($addr)) {
         $user->location = $addr;
     }
     if (isset($about)) {
         $user->bio = $about;
     }
     if (isset($language)) {
         $user->language = $language;
     }
     if (isset($homepage)) {
         $user->website = $homepage;
     }
     if (isset($email)) {
         $user->email = $email;
     }
     if (isset($settings) && is_array($settings)) {
         foreach ($settings as $s) {
             $key = $s['key'];
             $value = $s['value'];
             /*$setting = Setting::firstOrCreate(array('key'=>$key,'created_by'=>$user->id));
             		$setting->value = $value;
             		$setting->save();*/
             $hasSetting = false;
             foreach ($user->settings as $setting) {
                 if ($setting->key == $key) {
                     $setting->value = $value;
                     $setting->save();
                     $hasSetting = true;
                     break;
                 }
             }
             if (!$hasSetting) {
                 $setting = new Setting();
                 $setting->created_by = $user->id;
                 $setting->key = $key;
                 $setting->value = $value;
                 $setting->save();
             }
         }
     }
     $user->save();
     return Response::json($user);
 }
 /**
  * Store a newly created setting in storage.
  *
  * @return Response
  */
 public function store()
 {
     $validator = Validator::make($data = Input::all(), Setting::$rules);
     // echo "<pre>"; print_r( $data ); echo "</pre>"; exit;
     foreach ($data['settings'] as $config => $value) {
         $settings = Setting::where('setting_name', $config)->where('setting_type', 'settings')->where('user_id', Confide::user()->id)->orderBy('id', 'DESC')->get();
         if (Config::has('settings.' . $config)) {
             if (empty($value)) {
                 foreach ($settings as $setting) {
                     $setting->delete();
                 }
             } else {
                 $setting = $settings->first();
                 $setting = !$setting ? new Setting() : $setting;
             }
             $setting->setting_type = 'settings';
             $setting->setting_name = $config;
             if (!empty($value) and $setting->setting_value != $value) {
                 $setting->setting_value = $value;
                 $setting->user_id = Confide::user()->id;
                 $setting->save();
             }
         }
     }
     if (isset($data['mail'])) {
         $data['mail']['pretend'] = @$data['mail']['pretend'] == 'on' ? true : false;
         foreach ($data['mail'] as $config => $value) {
             if (Config::has('mail.' . $config)) {
                 $setting = Setting::where('setting_name', $config)->where('setting_type', 'mail')->where('user_id', Confide::user()->id)->orderBy('id', 'DESC')->first();
                 if (!$setting) {
                     $setting = new Setting();
                     $setting->setting_type = 'mail';
                     $setting->setting_name = $config;
                 }
                 if (is_array($value)) {
                     $value = json_encode($value);
                 }
                 // echo "<pre>"; print_r( $value ); echo "</pre>"; exit;
                 if ($value != $setting->setting_value) {
                     $setting->setting_value = (string) $value;
                     $setting->user_id = Confide::user()->id;
                     $setting->save();
                 }
             }
             // echo "<pre>"; print_r( $setting ); echo "</pre>";
         }
         // echo "<pre>"; print_r( $data ); echo "</pre>";exit;
     }
     $alert[] = ['class' => 'alert-success', 'message' => '<strong><i class="fa fa-check"></i></strong> Configurações salvas!'];
     Session::flash('alerts', $alert);
     if (Request::header('referer')) {
         return Redirect::back();
     } else {
         return Redirect::route('settings.index');
     }
 }
示例#13
0
 public function update(Setting $setting, $values)
 {
     if (array_key_exists('email_notifications', $values)) {
         $setting->email_notifications = true;
     } else {
         $setting->email_notifications = false;
     }
     $setting->language = $values['language'];
     $setting->save();
 }
示例#14
0
 /**
  * (non-PHPdoc)
  * @see yii/db/CDbMigration#up()
  */
 public function up()
 {
     // create table
     $this->createTable('Setting', array('id' => 'pk', 'name' => 'string NOT NULL', 'value' => 'string NOT NULL'));
     // create init values
     $registrationEnabled = new Setting();
     $registrationEnabled->name = Setting::REGISTRATION_ENABLED;
     $registrationEnabled->value = 0;
     $registrationEnabled->save();
 }
 /**
  * PluginSettingTable::set()
  *
  * @param mixed $name
  * @param mixed $text
  */
 public static function set($name, $text)
 {
     $setting = self::getInstance()->findOneBySettingName($name);
     if (!$setting) {
         $setting = new Setting();
         $setting->setSettingName($name);
     }
     $setting->setText($text);
     $setting->save();
 }
示例#16
0
 public function set($name, $value)
 {
     $this->_map = null;
     $setting = Setting::model()->findByPk($name);
     if (!$setting) {
         $setting = new Setting();
         $setting->name = $name;
     }
     $setting->value = $value;
     $setting->save();
 }
示例#17
0
 /**
  * Sets value for given key name
  *
  * @param string $name
  * @param mixed $value
  * 
  */
 public static function setValue($name, $value)
 {
     $c = new Criteria();
     $c->add(SettingPeer::NAME, $name);
     if (!($setting = SettingPeer::doSelectOne($c))) {
         $setting = new Setting();
         $setting->setName($name);
     }
     $setting->setValue($value);
     $setting->save();
 }
示例#18
0
 public function post()
 {
     $settings = Input::get('settings');
     if (isset($settings) && is_array($settings)) {
         foreach ($settings as $var => $val) {
             Setting::set($var, $val);
         }
         Setting::save();
     }
     return Api::to(array('success', Lang::get('admin/settings/messages.update.success'))) ?: Redirect::to('admin/settings')->with('success', Lang::get('admin/settings/messages.update.success'));
 }
 public static function setByKey($key, $value, PropelPDO $con = null)
 {
     $c = new Criteria();
     $c->add(SettingPeer::KEY, $key);
     $s = SettingPeer::doSelectOne($c, $con);
     if (!$s) {
         $s = new Setting();
         $setting->setKey($key);
     }
     $s->setValue($value);
     return $s->save();
 }
 public function safeUp()
 {
     $this->addColumn('Entry', 'viewCount', 'int NOT NULL DEFAULT 0');
     $model = new Setting();
     $model->name = Setting::MOST_VIEWED_ENTRIES_WIDGET_COUNT;
     $model->value = 10;
     $model->save();
     $model = new Setting();
     $model->name = Setting::MOST_VIEWED_ENTRIES_WIDGET_ENABLED;
     $model->value = true;
     $model->save();
 }
示例#21
0
 public function setValue($settingName, $settingValue, $storeId = 0, $group = 'config')
 {
     $setting = Setting::model()->findByAttributes(array('key' => $settingName, 'store_id' => $storeId, 'group' => $group));
     if (is_null($setting)) {
         $setting = new Setting();
         $setting->key = $settingName;
         $setting->store_id = $storeId;
         $setting->group = $group;
     }
     $setting->value = $settingValue;
     $setting->save();
 }
示例#22
0
 public static function defaultSetting($user)
 {
     $settings = PrivacyHelper::defaultPrivacy();
     $settings += array('gadget_container_0_sort' => 'about,friends', 'gadget_container_1_sort' => 'scheduler,newpost');
     foreach ($settings as $key => $value) {
         $setting = new Setting();
         $setting->key = $key;
         $setting->value = $value;
         $setting->created_by = $user->id;
         $setting->save();
     }
 }
示例#23
0
 /**
  * Part of arrayaccess, see www.php.net/arrayaccess.
  */
 public function offsetSet($offset, $value)
 {
     if (!isset($this->vars[$offset])) {
         $setting = new Setting();
         $setting["name"] = $offset;
         $setting["value"] = $value;
         $setting->save();
     } else {
         Doctrine_Query::create()->update("Setting")->set("value", "?", $value)->where("name = ?", $offset)->execute();
     }
     $this->vars[$offset] = $value;
 }
示例#24
0
 /**
  * Creates a new model.
  * If creation is successful, the browser will be redirected to the 'view' page.
  */
 public function actionCreate()
 {
     $model = new Setting();
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['Setting'])) {
         $model->attributes = $_POST['Setting'];
         if ($model->save()) {
             $this->redirect(array('view', 'id' => $model->id_setting));
         }
     }
     $this->render('create', array('model' => $model));
 }
示例#25
0
 function config()
 {
     if ($this->input->post()) {
         $s = new Setting(1);
         $s->from_array($this->input->post(), array('appname', 'language', 'per_page', 'mail_protocol', 'mailpath', 'smtp_host', 'smtp_user', 'smtp_pass', 'port'));
         if ($s->save()) {
             $this->session->set_flashdata('msg', '<div class="alert alert-success">Settings applied succesfully.</div>');
             redirect('settings');
         } else {
             $this->data['errors'] = $s->error->all;
         }
     }
     $this->data['s'] = new Setting(1);
 }
示例#26
0
 public function save()
 {
     foreach ($this->attributes as $key => $value) {
         $setting = Settings::model()->find(array('condition' => 'key = :key', 'params' => array(':key' => $key)));
         if ($setting == null) {
             $setting = new Setting();
             $setting->key = $key;
         }
         $setting->value = $value;
         if (!$setting->save(false)) {
             return false;
         }
     }
     return true;
 }
 public function createBuilding()
 {
     $building = new Building();
     $building->name = Input::get('name');
     $building->slug = Input::get('name');
     $building->owner_id = Input::get('user');
     $building->save();
     $user = User::find(Input::get('user'));
     $building->users()->save($user);
     $setting = new Setting();
     $setting->email = $user->email;
     $setting->building_id = $building->id;
     $setting->save();
     return Redirect::to('buildings')->with('message', 'Building created');
 }
 /**
  * Update the specified resource in storage.
  *
  * @param $comment
  * @return Response
  */
 public function postIndex()
 {
     $rules = array();
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->passes()) {
         $settings = Input::get('settings');
         if (isset($settings) && is_array($settings)) {
             foreach ($settings as $var => $val) {
                 Setting::set($var, $val);
             }
             Setting::save();
         }
         return Api::to(array('success', Lang::get('admin/settings/messages.update.success'))) ?: Redirect::to('admin/settings')->with('success', Lang::get('admin/settings/messages.update.success'));
     } else {
         return Api::to(array('error', Lang::get('admin/settings/messages.update.error'))) ?: Redirect::to('admin/settings')->withInput()->withErrors($validator);
     }
 }
 public function postEdit()
 {
     if (Input::has('id')) {
         $validator = Validator::make(array('id' => Input::get('id')), $this->validate_id_arr);
         if ($validator->fails()) {
             return Redirect::back()->withInput()->with('msg', 'Invalid ID')->with('state', '-1');
         }
     }
     if (Input::hasFile('logo')) {
         $mime = array('image/gif', 'image/jpeg', 'image/jpg', 'image/png', 'image/bmp');
         $uploaded_mime = Input::file('logo')->getMimeType();
         $file = array('image' => Input::file('logo'));
         $validator2 = Validator::make($file, $this->validateImage);
         if ($validator2->fails()) {
             return Redirect::back()->withInput()->with('msg', 'Logo must be an image of type: jpeg, jpg, png, gif,bmp')->with('state', '-1');
         }
         if (!in_array($uploaded_mime, $mime)) {
             return Redirect::back()->with('msg', 'Logo must be an image of type: jpeg, jpg, png, gif,bmp')->with('state', '-1');
         }
         list($width, $height) = getimagesize(Input::file('logo'));
         if ($width != '115' && $height != '50 ') {
             return Redirect::back()->with('msg', 'Logo dimensions must be 115 * 50 px')->with('state', '-1');
         }
         $logo = Input::file('logo');
         $destination_path = base_path() . '/backend/images/';
         $file_name = $logo->getClientOriginalName();
         Input::file('logo')->move($destination_path, $file_name);
     } else {
         $file_name = Input::get('logo_name');
     }
     $setting = Setting::first();
     if (!$setting) {
         $setting = new Setting();
     }
     try {
         $setting->api_key = Input::get('api_key');
         $setting->logo = $file_name;
         $setting->site_name = Input::get('site_name');
         $setting->save();
         return Redirect::to('setting')->with('msg', 'Setting save successfully')->with('state', '1');
     } catch (Exception $e) {
         return Redirect::back()->withInput()->with('msg', 'Failed to save settings.')->with('state', '-1');
     }
 }
 /**
  * Update the specified resource in storage.
  *
  * @param $comment
  * @return Response
  */
 public function postIndex()
 {
     $rules = array();
     // Validate the inputs
     $validator = Validator::make(Input::all(), $rules);
     // Check if the form validates with success
     if ($validator->passes()) {
         $settings = Input::get('settings');
         if (isset($settings) && is_array($settings)) {
             foreach ($settings as $var => $val) {
                 Setting::set($var, $val);
             }
             Setting::save();
         }
         // Redirect to the comments post management page
         return Redirect::to('admin/settings')->with('success', Lang::get('admin/settings/messages.update.success'));
     }
     // Form validation failed
     return Redirect::to('admin/settings')->withInput()->withErrors($validator);
 }