Saving works now
这个提交包含在:
父节点
5dc5adb4bb
当前提交
1bf2840e27
共有 3 个文件被更改,包括 22 次插入 和 4 次删除
|
|
@ -0,0 +1,19 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
class User_Options extends CI_Controller {
|
||||||
|
|
||||||
|
function __construct() {
|
||||||
|
parent::__construct();
|
||||||
|
$this->load->model('user_model');
|
||||||
|
$this->load->model('user_options_model');
|
||||||
|
if(!$this->user_model->authorize(2)) { $this->session->set_flashdata('notice', 'You\'re not allowed to do that!'); redirect('dashboard'); }
|
||||||
|
}
|
||||||
|
|
||||||
|
public function add_edit_fav() {
|
||||||
|
$obj = json_decode(file_get_contents("php://input"), true);
|
||||||
|
$this->user_options_model->set_option('Favourite',$obj);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
?>
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class User_options extends CI_Model
|
class User_options_model extends CI_Model
|
||||||
{
|
{
|
||||||
public function options($option_type) {
|
public function options($option_type) {
|
||||||
$this->db->where('user_id', $this->session->userdata('user_id'));
|
$this->db->where('user_id', $this->session->userdata('user_id'));
|
||||||
|
|
@ -11,8 +11,7 @@ class User_options extends CI_Model
|
||||||
public function set_option($option_type, $option_array) {
|
public function set_option($option_type, $option_array) {
|
||||||
$uid=$this->session->userdata('user_id');
|
$uid=$this->session->userdata('user_id');
|
||||||
$sql='insert into user_options (user_id,option_type,option_key,option_value) values (?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?';
|
$sql='insert into user_options (user_id,option_type,option_key,option_value) values (?,?,?,?) ON DUPLICATE KEY UPDATE option_value=?';
|
||||||
$query = $this->db->query($sql);
|
foreach($option_array as $option_key => $option_value) {
|
||||||
foreach ($option_array() as $one_option) {
|
|
||||||
$query = $this->db->query($sql, array($uid, $option_type, $option_key, $option_value, $option_value));
|
$query = $this->db->query($sql, array($uid, $option_type, $option_key, $option_value, $option_value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -15,7 +15,7 @@ $( document ).ready(function() {
|
||||||
payload.prop_mode=$('#prop_mode').val();
|
payload.prop_mode=$('#prop_mode').val();
|
||||||
payload.mode=$('#mode').val();
|
payload.mode=$('#mode').val();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: base_url+'index.php/user_options/set_options',
|
url: base_url+'index.php/user_options/add_edit_fav',
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
contentType: "application/json; charset=utf-8",
|
contentType: "application/json; charset=utf-8",
|
||||||
|
|
|
||||||
正在加载…
在新工单中引用