本文整理汇总了PHP中Setting::save方法的典型用法代码示例。如果您正苦于以下问题:PHP Setting::save方法的具体用法?PHP Setting::save怎么用?PHP Setting::save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Setting
的用法示例。
在下文中一共展示了Setting::save方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: add
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: executeSave
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: save
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: run
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();
}
示例5: actionIndex
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));
}
示例6: getInstall
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.";
}
示例7: postEkle
/**
* @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.'));
}
}
示例8: up
/**
* (non-PHPdoc)
* @see yii/db/CDbMigration#up()
*/
public function up()
{
$setting = new Setting();
$setting->name = Setting::FORCE_SSL;
$setting->value = 0;
$setting->save();
}
示例9: postIndex
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'));
}
示例10: setup
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: updateProfile
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);
}
示例12: store
/**
* 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: update
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: up
/**
* (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();
}
示例15: set
/**
* 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();
}