Beispiel #1
0
 /**
  * Creates a node providing its internal type value. Doesn't check parent node existence.
  * @param {String} $type text type for the new node
  * @returns {Integer} the new node id on success, false otherwise
  */
 static function create($keys)
 {
     $query = "INSERT INTO node ( ) VALUES ( );";
     if ($result = mysql_query($query)) {
         $id = mysql_insert_id();
         model::update($id, $keys);
         return $id;
     }
     return $result;
 }
 public function postEdit($id, ContactFormRequest $request)
 {
     $request->merge(['id' => $id]);
     if ($this->model->update($request->all())) {
         Notification::container()->success(trans('contacts::global.update.success'));
         return Redirect::to('/admin/contacts/' . $id . '/edit');
     } else {
         Notification::container()->error(trans('contacts::global.update.error'));
         return Redirect::to('/admin/contacts/' . $id . '/edit');
     }
 }
 public function batchUpdate()
 {
     $request = Request::instance();
     $content = $request->getContent();
     $items = json_decode($content);
     $result = array();
     if (!empty($items)) {
         foreach ($items as $item) {
             $updated = $this->model->update((array) $item);
             if ($updated) {
                 $result[] = $item;
             }
         }
     }
     return Response::json($result);
 }
Beispiel #4
0
 function update($array)
 {
     if ($array['f_user_password']) {
         // encode password before updating
         $array['f_user_password'] = $GLOBALS['auth']->encoder->Encrypt_Text($array['f_user_password']);
     }
     if (parent::update($array)) {
         if ($GLOBALS['site']->params['f_group_id'] == $this->conf['admin_group_id'] && $this->data['group_id'] != $this->conf['admin_group_id']) {
             // user group changed to Admin. remove any previous enabled secretaria
             $sql = "delete ";
             $sql .= "from ";
             $sql .= " {$this->conf['tb_usuarios_secretarias']} ";
             $sql .= "where ";
             $sql .= " user_id='{$this->id}' ";
             return $this->db->query($sql);
         } else {
             return TRUE;
         }
     } else {
         return FALSE;
     }
 }
Beispiel #5
0
 public function upd(array $data = NULL)
 {
     $where = "id = " . $data['id'];
     return parent::update('clientes', $data, $where);
 }
Beispiel #6
0
 /**
  * Increment the asset after a successful backup and commit sequence
  * @param {Integer} asset node index
  * @param {String} user message for the new version
  */
 static function version_increment($id, $message)
 {
     model::update($id, array("version" => model::getKey($id, 'version') + 1, "user" => getUser(), "text" => $message, "time" => time()));
     #global $assetsLCL;
     #if( !model::setKey( $id, "sha1", sha1_file( $assetsLCL . model::getKey( $id, 'file' ) ) ) )
     #	return false;
     return true;
 }
 public function updateEstoqueProduto($id_evento_cliente)
 {
     $model = new model();
     $resProdutoEstoque = $model->readSQL("SELECT " . "ep.id_evento, " . "ep.qtd_produto, " . "p.id_produto, " . "p.qtd_produto as qtd_estoque " . "FROM evento_cliente ec " . "LEFT JOIN evento_produto ep ON (ep.id_evento = ec.id_evento) " . "LEFT JOIN produto p ON (p.id_produto = ep.id_produto) " . "WHERE ec.id_evento_cliente = {$id_evento_cliente}");
     foreach ($resProdutoEstoque as $value) {
         $data['qtd_produto'] = $value['qtd_estoque'] + $value['qtd_produto'];
         $result = $model->update('produto', $data, "id_produto = '" . $value['id_produto'] . "'");
     }
 }
Beispiel #8
0
         if (!$ret) {
             header('HTTP/1.1: 404 Not Found');
             exit;
         }
         echo json_encode(array($ret));
     } else {
         echo json_encode(model_json::multi(explode(",", arg("id"))));
     }
     break;
 case "update":
     if (is_null(arg('id')) || is_null(arg('keys'))) {
         header("HTTP/1.1: 400 Bad Request");
         echo "Bad command";
         exit;
     }
     $id = model::update(arg("id"), json_decode(arg("keys")));
     echo json_encode(model_json::node(arg("id"), 1, $NODE_TAG | $NODE_PRM));
     break;
 case "delete":
     if (is_null(arg('id'))) {
         header("HTTP/1.1: 400 Bad Request");
         echo "Bad command";
         exit;
     }
     if (!model::delete(arg("id"))) {
         header("HTTP/1.1: 409 Conflict");
         echo "delete Error, please change your values";
         exit;
     }
     break;
     /* other operations */
Beispiel #9
0
 public function update()
 {
     parent::update('presence', 'status');
 }
Beispiel #10
0
            exit;
        }
        echo json_encode(array($ret));
    } else {
        echo json_encode(model_json::multi(explode(",", $_GET['id'])));
    }
    exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'PUT') {
    damas_service::allowed("model::update");
    if (!isset($_PUT['id']) || !isset($_PUT['keys']) || ($_PUT['id'] == '' || $_PUT['keys'] == '')) {
        header("HTTP/1.1: 400 Bad Request");
        echo "Bad command";
        exit;
    }
    $id = model::update($_PUT['id'], json_decode($_PUT['keys']));
    echo json_encode(model_json::node(arg("id"), 1, $NODE_TAG | $NODE_PRM));
    damas_service::log_event();
    exit;
}
if ($_SERVER['REQUEST_METHOD'] == 'DELETE') {
    damas_service::allowed("model::delete");
    if (!isset($_DELETE['id']) || $_DELETE['id'] == '') {
        header("HTTP/1.1: 400 Bad Request");
        echo "Bad command";
        exit;
    }
    if (!model::delete($_DELETE['id'])) {
        header("HTTP/1.1: 409 Conflict");
        echo "delete Error, please change your values";
        exit;
Beispiel #11
0
 function setAction()
 {
     $model = new model();
     $model->table('seven_set');
     $data['start'] = strtotime($_POST['start']);
     $data['end'] = strtotime($_POST['end']);
     $data['rule'] = $_POST['rule'];
     if ($model->has(array('id' => 1))) {
         $rs = $model->update($data, array('id' => 1));
     } else {
         $rs = $model->insert($data);
     }
     if ($rs) {
         $this->json('操作成功');
     } else {
         $this->json('操作失败', 0);
     }
 }
 /**
  * Update an entity by id
  *
  * @param $id
  * @param array $data
  * @return mixed
  */
 public function update($id, array $data)
 {
     return $this->model->update($data);
 }
Beispiel #13
0
error_reporting(E_ERROR);
session_start();
if (!$_SESSION['name'] || !$_POST['guess'] || $_POST['guess'] !== md5(sha1($_SESSION['name'] . "wechat") . "youchat")) {
    echo "不合法的来路!";
    die;
}
//获取提交数据
$id = $_POST['id'];
$title = $_POST['title'];
$content = $_POST['content'];
$img = upload();
require "../model/model.php";
$news = new model("news");
//更新并返回结果
if ($news->update($id, $title, $content, $img)) {
    $data['status'] = 1;
    $data['msg'] = "更新成功";
} else {
    $data['status'] = 0;
    $data['msg'] = "更新失败";
}
echo json_encode($data);
//上传文件
function upload()
{
    if (($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/png") && $_FILES["file"]["size"] < 2000000) {
        if ($_FILES["file"]["error"] > 0) {
            //"Return Code: " . $_FILES["file"]["error"] . "<br />";
            return false;
        } else {
 public function produto_delete()
 {
     $id_evento = $this->getParam('id_evento');
     $id_produto = $this->getParam('id_produto');
     $dados['id_evento'] = $id_evento;
     $dados['id_produto'] = $id_produto;
     $dados['stat'] = 0;
     $model = new model();
     $model->update("evento_produto", $dados, "id_produto={$id_produto} AND id_evento={$id_evento} AND stat<>0");
     header('Location: /evento');
 }