/** * 新增或更新一个文档 * @param array $data 手动传入的数据 * @return boolean fasle 失败 , int 成功 返回完整的数据 * @author huajie <*****@*****.**> */ public function update($data = null) { /* 获取数据对象 */ $data = $this->token(false)->create($data); if (empty($data)) { return false; } /* 添加或新增基础内容 */ if (empty($data['id'])) { //新增数据 $id = $this->add($_POST); //添加基础内容 if (!$id) { $this->error = '新增基础内容出错!'; return false; } } else { //更新数据 $status = $this->save(); //更新基础内容 if (false === $status) { $this->error = '更新基础内容出错!'; return false; } } hook('documentSaveComplete', array('model_id' => $data['model_id'])); //行为记录 if ($id) { action_log('add_document', 'document', $id, UID); } //内容添加或更新完成 return $data; }
public function addLZLReply($post_id, $to_f_reply_id, $to_reply_id, $to_uid, $content, $p, $send_message = true) { //新增一条回复 $data = array('uid' => is_login(), 'post_id' => $post_id, 'to_f_reply_id' => $to_f_reply_id, 'to_reply_id' => $to_reply_id, 'to_uid' => $to_uid, 'content' => $content); $data = $this->create($data); if (!$data) { return false; } $result = $this->add($data); action_log('add_post_reply', 'ForumLzlReply', $result, is_login()); S('post_replylist_' . $post_id, null); S('post_replylzllist_' . $to_f_reply_id, null); $postModel = D('ForumPost'); //增加帖子的回复数 $postModel->where(array('id' => $post_id))->setInc('reply_count'); //更新最后回复时间 $postModel->where(array('id' => $post_id))->setField('last_reply_time', time()); $post = $postModel->find($post_id); D('Forum')->where(array('id' => $post['forum_id']))->setField('last_reply_time', time()); if ($send_message) { $this->sendReplyMessage(is_login(), $post_id, $content, $to_uid, $to_f_reply_id, $result, $p); } $this->handleAt($post_id, $to_f_reply_id, $content, $p, $map); //返回结果 return $result; }
function save() { $Brand = D('Brand'); $data = $Brand->create(); if ($data) { $id = $Brand->add(); if ($id) { // S('DB_CONFIG_DATA',null); //记录行为 action_log('update_menu', 'Menu', $id, UID); $this->success('新增成功', Cookie('__forward__')); } else { $this->error('新增失败'); } } else { $this->error($Brand->getError()); } // if(IS_POST){ // // } else { // $this->assign('info',array('pid'=>I('pid'))); // $menus = M('Menu')->field(true)->select(); // $menus = D('Common/Tree')->toFormatTree($menus); // $menus = array_merge(array(0=>array('id'=>0,'title_show'=>'顶级菜单')), $menus); // $this->assign('Menus', $menus); // $this->meta_title = '新增菜单'; // $this->display('edit'); // } }
public function logout() { get_user() && action_log('系统', '退出'); D('User')->logout(); session('[destroy]'); $this->success('退出成功!', U('login')); }
/** * 编辑 * @author 烟消云散 <*****@*****.**> */ public function edit($id = 0) { if (IS_POST) { $Form = D('records'); if ($_POST["id"]) { $id = $_POST["id"]; /*更新时间*/ $Form->time = NOW_TIME; /* 编辑后新增系统反馈信息*/ $Form->info = $_POST["info"]; $result = $Form->where("id='{$id}'")->save(); if ($result) { //记录行为 action_log('update_backlist', 'backlist', $data['id'], UID); $this->success('更新成功', Cookie('__forward__')); } else { $this->error('更新失败' . $id); } } else { $this->error($Config->getError()); } } else { $info = array(); /* 获取数据 */ $info = M('records')->find($id); $list = M('records')->where("id='{$id}'")->select(); if (false === $info) { $this->error('获取订单信息错误'); } $this->assign('list', $list); $this->assign('info', $info); $this->meta_title = '编辑订单'; $this->display(); } }
public function editData($data) { $contentHandler = new ContentHandlerModel(); if (isset($data['content'])) { $data['content'] = $contentHandler->filterHtmlContent($data['content']); } if ($data['id']) { $data['update_time'] = time(); $res = $this->save($data); if ($res) { action_log('edit_answer', 'question_answer', $data['id'], get_uid()); } } else { $data['support'] = $data['oppose'] = 0; $data['status'] = 1; $data['uid'] = get_uid(); $data['create_time'] = $data['update_time'] = time(); $res = $this->add($data); if ($res) { D('Question/Question')->where(array('id' => $data['question_id']))->setInc('answer_num'); action_log('add_answer', 'question_answer', $res, get_uid()); } } return $res; }
/** * 新增或更新一个文档 * @return boolean fasle 失败 , int 成功 返回完整的数据 * @author Rocks */ public function update() { /* 获取数据对象 */ $data = $this->create(); if (empty($data)) { return false; } /* 添加或新增基础内容 */ if (empty($data['id'])) { //新增数据 $id = $this->add(); //添加基础内容 if (!$id) { $this->error = '新增模型出错!'; return false; } } else { //更新数据 $status = $this->save(); //更新基础内容 if (false === $status) { $this->error = '更新模型出错!'; return false; } } // 清除模型缓存数据 S('DOCUMENT_MODEL_LIST', null); //记录行为 action_log('update_model', 'model', $data['id'] ? $data['id'] : $id, UID); //内容添加或更新完成 return $data; }
/** * 新增或更新一个文档 * @param array $data 手动传入的数据 * @return boolean fasle 失败 , int 成功 返回完整的数据 * @author huajie <*****@*****.**> */ public function update($data = null) { /* 获取数据对象 */ $data = $this->create($data); if (empty($data)) { return false; } /* 添加或新增基础内容 */ if (empty($data['id'])) { //新增数据 $id = $this->add(); //添加基础内容 if (!$id) { $this->error = '新增基础内容出错!'; return false; } } else { //更新数据 $status = $this->save(); //更新基础内容 if (false === $status) { $this->error = '更新基础内容出错!'; return false; } } //行为记录 if ($id) { action_log('update_shipping', 'shipping', $id, UID); } //内容添加或更新完成 return $data; }
/** * 编辑订单 * @author 烟消云散 <*****@*****.**> */ public function edit($id = 0) { if (IS_POST) { $Form = D('change'); if ($_POST["id"]) { $id = $_POST["id"]; $Form->create(); $result = $Form->where("id='{$id}'")->save(); if ($result) { //记录行为 action_log('update_change', 'change', $data['id'], UID); $this->success('更新成功', Cookie('__forward__')); } else { $this->error('更新失败,换货单' . $id); } } else { $this->error($Config->getError()); } } else { $info = array(); /* 获取数据 */ $info = M('change')->find($id); $list = M('change')->where("shopid='{$id}'")->select(); if (false === $info) { $this->error('获取订单信息错误'); } $this->assign('list', $list); $this->assign('info', $info); $this->meta_title = '编辑订单'; $this->display(); } }
public function doSendInfo() { $this->checkAuth('Cat/Center/doSendInfo', -1, '你没有发送消息的权限!'); $this->checkActionLimit('cat_center_send_info', 'cat_center'); $send = D('cat_send')->create(); $recStr = I('post.receiver', 'op_t'); $array = explode(' ', str_replace('@', '', $recStr)); $array = array_unique($array); $send['send_uid'] = is_login(); $send['create_time'] = time(); $send['content'] = I('post.content', '', 'op_t'); $rs = 1; foreach ($array as $v) { if ($array != '') { $v = trim($v); $v = str_replace("\r", '', $v); $user = D('member')->where(array('nickname' => $v))->find(); if ($user) { $t_send = $send; $t_send['rec_uid'] = $user['uid']; $rs = $rs && D('cat_send')->add($t_send); } } } if ($rs) { action_log('cat_center_send_info', 'cat_center'); $this->success('发送成功。'); } else { $this->error('发送失败。'); } }
public function login() { if (IS_POST) { $code = I('post.code'); $code_check = $this->check_verify($code); if ($code_check != 1) { $this->error('验证码不正确'); } $username = I('post.username'); $password = I('post.password'); $password = md5(md5($password)); $info = get_info(D('Common/MemberView'), array('username' => $username, 'password' => $password)); if ($info['is_admin'] != 1) { $this->error("管理员帐号不存在"); } if ($info['member_status'] != 1) { $this->error("管理员帐号已被禁用或删除"); } if ($info) { if ($info['member_rules']) { $info['rules'] .= ',' . $info['member_rules']; } $info['rules'] = implode(',', array_unique(explode(',', $info['rules']))); session('rules', $info['rules']); session('username', $info['username']); session('member_id', $info['member_id']); action_log('member', $info['member_id'], 'id,username as title'); $this->success('登录成功', __ROOT__ . "/Backend"); } else { $this->error('用户名或密码错误'); } } else { header("location:" . __ROOT__ . "/Backend"); } }
/** * 登录指定用户 * @param integer $uid 用户ID * @return boolean ture-登录成功,false-登录失败 */ public function login($uid) { /* 检测是否在当前应用注册 */ $user = $this->field(true)->find($uid); if (!$user) { //未注册 /* 在当前应用中注册用户 */ $Api = new UserApi(); $info = $Api->info($uid); $user = $this->create(array("nickname" => $info[1], "status" => 1)); $user["uid"] = $uid; if (!$this->add($user)) { $this->error = "前台用户信息注册失败,请重试!"; return false; } } elseif (1 != $user["status"]) { $this->error = "用户未激活或已禁用!"; //应用级别禁用 return false; } /* 登录用户 */ $this->autoLogin($user); /* 登录历史 */ history($uid); /* 登录购物车处理函数 */ addintocart($uid); //记录行为 action_log("user_login", "member", $uid, $uid); return true; }
/** * 登录指定用户 * @param integer $uid 用户ID * @return boolean ture-登录成功,false-登录失败 */ public function login($uid) { /* 检测是否在当前应用注册 */ $user = $this->field(true)->find($uid); if (!$user) { //未注册 /* 在当前应用中注册用户 */ $Api = new UserApi(); $info = $Api->info($uid); $user = $this->create(array('nickname' => $info[1], 'status' => 1)); $user['uid'] = $uid; if (!$this->add($user)) { $this->error = '前台用户信息注册失败,请重试!'; return false; } } elseif (1 != $user['status']) { $this->error = '用户未激活或已禁用!'; //应用级别禁用 return false; } /* 登录用户 */ $this->autoLogin($user); //记录行为 action_log('user_login', 'member', $uid, $uid); return true; }
public function editData($data) { if ($data['id']) { $res = $this->save($data); } else { $data['addtime'] = time(); $res = $this->add($data); action_log('add_atlas_collection', 'Atlas', $res, is_login()); } return $res; }
/** * 新增或更新一个文档 * @return boolean fasle 失败 , int 成功 返回完整的数据 * @author huajie <*****@*****.**> */ public function update() { /* 获取数据对象 */ $data = $this->create(); if (empty($data)) { return false; } /* 添加或新增基础内容 */ if (empty($data['id'])) { //新增数据 $id = $this->add(); //添加基础内容 if (!$id) { $this->error = '新增模型出错!'; return false; } } else { //更新数据 $model = $this->find($data['id']); //先取旧的模型名 $status = $this->save($data); //更新基础内容 if (false === $status) { $this->error = '更新模型出错!'; return false; } elseif ($model['name'] != $data['name']) { // 同时更新模型对应的数据表,先判断数据表是否存在 if ($model['extend'] == 0) { // 独立模型表名 $table_name = C('DB_PREFIX') . strtolower($model['name']); $new_table_name = C('DB_PREFIX') . strtolower($data['name']); } else { // 继承模型表名 $extend_model = $this->where(array('id' => $model['extend']))->field('name,extend')->find(); $table_name = C('DB_PREFIX') . strtolower($extend_model['name']) . '_' . strtolower($model['name']); $new_table_name = C('DB_PREFIX') . strtolower($extend_model['name']) . '_' . strtolower($data['name']); } $sql = "SHOW TABLES LIKE '{$table_name}'"; $res = M()->query($sql); if (count($res)) { $sql = "ALTER TABLE `{$table_name}` RENAME TO `{$new_table_name}`"; $this->execute($sql); } } } // 清除模型缓存数据 S('DOCUMENT_MODEL_LIST', null); //记录行为 action_log('update_model', 'model', $data['id'] ? $data['id'] : $id, UID); //内容添加或更新完成 return $data; }
public function addOrder($data) { $data = $this->create($data); if (!$data) { return false; } $result = $this->add($data); if (!$result) { return false; } action_log('create_order', 'RechargeOrder', $result, is_login()); return $result; }
public function addWithdraw($data) { $data = $this->create($data); if (!$data) { return false; } $result = $this->add($data); if (!$result) { return false; } action_log('create_withdraw', 'RechargeWithdraw', $result, is_login()); return $result; }
public function delLZLReply($id) { $this->requireLogin(); $this->checkAuth('Forum/Lzl/delLZLReply', get_expect_ids($id), '你没有删除回复的权限!'); $this->checkActionLimit('forum_lzl_del_reply', 'Forum', null, get_uid()); $Lzlreply = D('ForumLzlReply')->where('id=' . $id)->find(); $data['post_reply_id'] = $Lzlreply['to_f_reply_id']; $res = D('ForumLzlReply')->delLZLReply($id); $data['lzl_reply_count'] = D('ForumLzlReply')->where('is_del=0 and to_f_reply_id=' . $data['post_reply_id'])->count(); action_log('forum_lzl_del_reply', 'Forum', $id, get_uid()); $res && $this->success($res, '', $data); !$res && $this->error(''); }
/** * 新增或更新一个属性 * @return boolean fasle 失败 , int 成功 返回完整的数据 * @author huajie <*****@*****.**> */ public function update($data = null, $create = true) { /* 获取数据对象 */ $data = empty($data) ? $_POST : $data; $data = $this->create($data); if (empty($data)) { return false; } /* 添加或新增属性 */ if (empty($data['id'])) { //新增属性 $id = $this->add(); if (!$id) { $this->error = '新增属性出错!'; return false; } if ($create) { //新增表字段 $res = $this->addField($data); if (!$res) { $this->error = '新建字段出错!'; //删除新增数据 $this->delete($id); return false; } } } else { //更新数据 if ($create) { //更新表字段 $res = $this->updateField($data); if (!$res) { $this->error = '更新字段出错!'; return false; } } $status = $this->save(); if (false === $status) { $this->error = '更新属性出错!'; return false; } } //删除字段缓存文件 $model_name = M('Model')->field('name')->find($data['model_id']); $cache_name = C('DB_NAME') . '.' . preg_replace('/\\W+|\\_+/', '', $model_name['name']); F($cache_name, null, DATA_PATH . '_fields/'); //记录行为 action_log('update_attribute', 'attribute', $data['id'] ? $data['id'] : $id, UID); //内容添加或更新完成 return $data; }
public function logout() { if (!is_login()) { $this->error("尚未登录", U(C('AUTH_USER_GATEWAY'))); } else { action_log('Admin_Logout', 'User', is_login()); session(null); if (session(C('AUTH_KEY'))) { $this->error("退出失败", U(C('AUTH_USER_INDEX'))); } else { $this->success("退出成功!", U(C('AUTH_USER_GATEWAY'))); } } }
public function del() { $user_id = array_unique((array) I('user_id', 0)); if (empty($user_id)) { $this->error('请选择要操作的数据!'); } $map = array('user_id' => array('in', $user_id)); if ($this->db->where($map)->delete()) { action_log(); $this->success('删除成功'); } else { $this->error('删除失败!'); } }
public function editPost($data) { $data = $this->create($data); if (!$data) { return false; } $result = $this->save($data); if (!$result) { return false; } action_log('edit_group_post', 'GroupPost', $data['id'], is_login()); S('group_post_' . $data['id'], null); return $result; }
/** * 登录指定用户 * @param integer $uid 用户ID * @return boolean ture-登录成功,false-登录失败 */ public function login($uid) { /* 检测是否在当前应用注册 */ $user = $this->field(true)->find($uid); if (!$user || 1 != $user['status']) { $this->error = L('_USERS_DO_NOT_EXIST_OR_HAVE_BEEN_DISABLED_WITH_EXCLAMATION_'); //应用级别禁用 return false; } //记录行为 action_log('user_login', 'member', $uid, $uid); /* 登录用户 */ $this->autoLogin($user); return true; }
/** * 登录指定用户 * @param integer $uid 用户ID * @return boolean ture-登录成功,false-登录失败 */ public function login($uid) { /* 检测是否在当前应用注册 */ $user = $this->field(true)->find($uid); if (!$user || 1 != $user['status']) { $this->error = '用户不存在或已被禁用!'; //应用级别禁用 return false; } //记录行为 action_log('user_login', 'member', $uid, $uid); /* 登录用户 */ $this->autoLogin($user); return true; }
/** * 更新分类信息 * @return boolean 更新状态 * @author Rocks */ public function update() { $data = $this->create(); if (!$data) { return false; } if (empty($data['id'])) { $res = $this->add(); } else { $res = $this->save(); } $this->cleanCache(array($data['id'])); action_log('update_series', 'series', $data['id'] ? $data['id'] : $res, UID); return $res; }
public function del() { $id = array_unique((array) I('id', 0)); if (empty($id)) { $this->error('请选择要操作的数据!'); } $map = array('id' => array('in', $id)); if (D('Menu')->where($map)->delete()) { action_log(); $this->updateCache(); $this->success('删除成功'); } else { $this->error('删除失败!'); } }
public function addReply($data) { $data = $this->create($data); //对帖子内容进行安全过滤 if (!$data) { return false; } $result = $this->add($data); if (!$result) { return false; } action_log('add_group_reply', 'GroupPostReply', $result, is_login()); //返回帖子编号 return $result; }
/** * 更新分类信息 * @return boolean 更新状态 */ public function addGuessWin($data) { $data['end_time'] = $this->getEndTime($data['end_time']); $data = $this->create($data); if (!$data) { return false; } if (empty($data['id'])) { $res = $this->add(); } else { $res = $this->save(); } $this->cleanCache(array($data['id'])); action_log('update_guess_win', 'guesswin', $data['id'] ? $data['id'] : $res, UID); return $res; }
/** * 更新分类信息 * @return boolean 更新状态 * @author Rocks */ public function update() { $data = $this->create(); if (!$data) { //数据对象创建错误 return false; } /* 添加或更新数据 */ if (empty($data['id'])) { $res = $this->add(); } else { $res = $this->save(); } action_log('update_video', 'video', $data['id'] ? $data['id'] : $res, UID); return $res; }
/** * 删除配置 * @author 麦当苗儿 <*****@*****.**> */ public function del() { $id = array_unique((array) I('id', 0)); if (empty($id)) { $this->error('请选择要操作的数据!'); } $map = array('id' => array('in', $id)); if (M('Message')->where($map)->delete()) { S('DB_CONFIG_DATA', null); //记录行为 action_log('update_config', 'BannerList', $id, UID); $this->success('删除成功'); } else { $this->error('删除失败!'); } }