Esempio n. 1
0
<?php

include_once '../../base.php';
if (!Yike\AccessControl::roleAllow(array(Yike\AccessControl::USER))) {
    //检查权限
    header('HTTP/1.1 403 Forbidden');
    header("location: /app/user/login.php");
    exit;
}
$id = intval($_REQUEST['id']);
$unuse = Model\OwnedThing::findUnuse($id);
if (!$unuse) {
    header('HTTP/1.1 404 Not Found');
    exit;
}
$catalogues = Model\Catalogue::all();
?>
<!DOCTYPE html >
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title>修改闲置物品  <?php 
echo $unuse->ownthing_name;
?>
</title>
<?php 
echo View\Home::$styles . "\n";
echo View\Home::addStyle("unuse/new.css");
?>

</head>
Esempio n. 2
0
<?php

include_once '../../base.php';
if (Yike\AccessControl::roleAllow(array(Yike\AccessControl::USER))) {
    //检查权限
    $data = array_map("trim", $_REQUEST);
    $json['status'] = 0;
    if (Model\Catalogue::exists(intval($data['cat']))) {
        //检查分类是否存在
        $require = new Model\DemandThing();
        $require->init(array('demandthing_title' => strip_tags($data['thingtitle']), 'demandthing_detail' => $data['thingdetail'], 'catalogue_id' => $data['cat'], 'demandthing_pic' => strip_tags($data['cover']), 'demandthing_money' => intval($data['value'])));
        $result = $require->save();
        if ($result) {
            $json['status'] = 1;
            $json['message'] = "需求 {$require->demandthing_title} 发布成功。";
        } else {
            $json['message'] = "保存失败,请重试。";
        }
    } else {
        $json['message'] = "分类选择错误哦~";
    }
} else {
    $json['message'] = "请登陆哦~亲";
}
echo json_encode($json);
Esempio n. 3
0
include '../../base.php';
if (!Yike\AccessControl::roleAllow(array(Yike\AccessControl::USER))) {
    $json['status'] = 0;
    $json['message'] = "请登陆";
} else {
    $json['status'] = 0;
    $data = array_map('trim', $_REQUEST);
    $id = intval($data['id']);
    $title = strip_tags($data['thingtitle']);
    $cat = intval($data['cat']);
    $detail = $data['thingdetail'];
    $cover = strip_tags($data['cover']);
    $money = intval($data['money']);
    //过滤输入
    if (Model\Catalogue::exists($cat)) {
        $unuse = Model\OwnedThing::findUnuse($id);
        if ($unuse) {
            if ($unuse->ownner->user_id == CURRENT_YIKE) {
                //只能修改自己物品的状态
                $unuse->ownthing_details = $detail;
                $unuse->ownthing_money = $money;
                $unuse->ownthing_name = $title;
                $unuse->catalogue_id = $cat;
                $unuse->ownthing_pic = $cover;
                $unuse->save();
                $json['status'] = 1;
                $json['message'] = "物品{$unuse->ownthing_name}修改成功。";
            } else {
                $json['message'] = "无权限删除该物品";
            }