/** * 商品移除 */ function remove($id) { $productimgModel = $this->model('productimg'); $result = $productimgModel->where('pid=?', array($id))->select(); foreach ($result as $img) { filesystem::unlink($img['base_path']); filesystem::unlink($img['small_path']); filesystem::unlink($img['thumbnail_path']); } $productimgModel->where('pid=?', array($id))->delete(); return $this->where('id=?', array($id))->delete(); }
/** * 用户设置自己昵称和头像 */ function setnamegravatar() { if (login::user()) { $username = $this->post->username; $gravatar = $this->file->file; $userModel = $this->model('user'); if (empty($username) && !is_file($gravatar)) { return json_encode(array('code' => 0, 'result' => '参数错误')); } if ($username !== NULL) { if (!$userModel->setName($this->session->id, $username)) { return json_encode(array('code' => 0, 'result' => '用户名修改失败')); } } if (is_file($gravatar)) { $image = new image(); $file = $image->resizeImage($gravatar, 200, 200); filesystem::unlink($gravatar); if (!$userModel->setGravatar($this->session->id, $file)) { return json_encode(array('code' => 0, 'result' => '头像上传失败')); } } return json_encode(array('code' => 1, 'result' => 'ok')); } return json_encode(array('code' => 2, 'result' => '尚未登陆')); }
/** * 删除图像信息 * @param unknown $id * @return \system\core\Ambigous */ function remove($id) { $result = $this->where('id=?', array($id))->select(); if (!empty($result)) { $result = $result[0]; filesystem::unlink($result['small_path']); filesystem::unlink($result['base_path']); filesystem::unlink($result['thumbnail_path']); return $this->where('id=?', array($id))->delete(); } return false; }
/** * 删除评论 */ function del() { $roleModel = $this->model('role'); if (login::admin() && $roleModel->checkPower($this->session->role, 'comment', roleModel::POWER_DELETE)) { $id = filter::int($this->post->id); if (!empty($id)) { $commentModel = $this->model('comment'); if ($commentModel->remove($id)) { //删除磁盘图片 $comment_picModel = $this->model('comment_pic'); $comment_pic = $comment_picModel->getByCid($id, 'path'); foreach ($comment_pic as $pic) { filesystem::unlink($pic); } $this->model('log')->write($this->session->username, '删除了一条评论'); //删除图片记录 $comment_picModel->removeByCid($id); return json_encode(array('code' => 1, 'result' => 'ok')); } return json_encode(array('code' => 0, 'result' => 'failed')); } return json_encode(array('code' => 2, 'result' => '参数错误')); } return json_encode(array('code' => 3, 'result' => '没有权限')); }