public function add() { $model = $this->model; $Model = D(parse_name(get_table_name($model['id']), 1)); if (IS_POST) { // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && ($id = $Model->add())) { $this->_saveKeyword($model, $id, 'custom_reply_news'); $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $extra = $this->getCateData(); if (!empty($extra)) { foreach ($fields[1] as &$vo) { if ($vo['name'] == 'cate_id') { $vo['extra'] .= "\r\n" . $extra; } } } $this->assign('fields', $fields); $this->meta_title = '新增' . $model['title']; $this->display(); } }
public function edit($id = 0) { $model = $this->getModel($this->model); $id || ($id = I('id')); if (IS_POST) { $_POST['module'] = _ADDONS; $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && $Model->save()) { $this->_saveKeyword($model, $id); $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); // 获取数据 $data = M(get_table_name($model['id']))->find($id); $data || $this->error('数据不存在!'); $this->assign('fields', $fields); $this->assign('data', $data); $this->meta_title = '编辑' . $model['title']; $this->display(); } }
function edit() { $id = $this->shop_id; $model = $this->getModel(); if (IS_POST) { // $_POST ['update_time'] = NOW_TIME; $Model = D(parse_name(get_table_name($model['id']), 1)); if ($Model->create() && $Model->save()) { $this->_saveKeyword($model, $id); } // 清空缓存 method_exists($Model, 'clear') && $Model->clear($id, 'edit'); $this->success('保存' . $model['title'] . '成功!'); } else { $fields = get_model_attribute($model['id']); // 获取数据 $data = D('Shop')->getInfo($id, true); $data || $this->error('数据不存在!'); $token = get_token(); if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) { $this->error('非法访问!'); } $this->assign('fields', $fields); $this->assign('data', $data); $this->display(); } }
public function edit($id = 0) { $model = $this->getModel('credit_config'); $id || ($id = I('id')); // 获取数据 $data = M(get_table_name($model['id']))->find($id); $data || $this->error('数据不存在!'); if (IS_POST) { $act = 'save'; if ($data['token'] == 0) { $_POST['token'] = get_token(); unset($_POST['id']); $act = 'add'; } $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && $Model->{$act}()) { // dump($Model->getLastSql()); $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { // dump($Model->getLastSql()); $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); $this->assign('data', $data); $this->meta_title = '编辑' . $model['title']; $this->display('Addons/edit'); } }
function edit() { $model = $this->getModel('business_card'); $map['uid'] = $uid = $this->mid; $act = 'edit'; // $map['uid']=11857; $data = M('business_card')->where($map)->find(); // $id = I ( 'id' ); // 获取数据 // $data = M ( get_table_name ( $model ['id'] ) )->find ( $id ); $data || ($act = 'add'); // $token = get_token (); // if (isset ( $data ['token'] ) && $token != $data ['token'] && defined ( 'ADDON_PUBLIC_PATH' )) { // $this->error ( '非法访问!' ); // } if (IS_POST) { $_POST['uid'] = $this->mid; $_POST['token'] = get_token(); $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($act == 'edit') { if ($Model->create() && $Model->save()) { // 清空缓存 method_exists($Model, 'clear'); // $url= '<script language=javascript>history.go(-1);</script>'; $this->success('保存' . $model['title'] . '成功!'); } else { $this->error($Model->getError()); } } else { if ($Model->create() && ($id = $Model->add())) { // 清空缓存 method_exists($Model, 'clear') && $Model->clear($id, 'add'); $this->success('添加' . $model['title'] . '成功!'); } else { $this->error($Model->getError()); } } } else { $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); $this->assign('data', $data); $this->display(); } }
function form() { if (!is_login()) { Cookie('__forward__', $_SERVER['REQUEST_URI']); $this->error('您还没有登录,请先登录!', U('User/login')); } $model = M('Model')->find(I('get.model')); $this->assign('model', $model); $id = I('id', 0); $this->right_data($model); if (IS_POST) { $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); $res = $Model->create(); if ($id) { $res = $Model->save(); } else { $res = $Model->add(); } if ($res) { $url = U('index'); if ($model['name'] == 'store') { $url = U('store'); } $this->success('保存成功!', $url); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); // 获取数据 if ($id) { $data = M(get_table_name($model['id']))->find($id); $data || $this->error('数据不存在!'); $this->assign('data', $data); } $this->meta_title = '编辑' . $model['title']; $this->display(); } }
function add() { $model = $this->getModel(); if (IS_POST) { $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && ($id = $Model->add())) { $this->_saveKeyword($model, $id); $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); $this->meta_title = '新增' . $model['title']; $this->_deal_data(); $this->display(); } }
public function add() { if (IS_POST) { $Model = D(parse_name(get_table_name($this->model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $this->model['id']); if ($Model->create() && ($id = $Model->add())) { $param['test_id'] = $this->test_id; $param['model'] = $this->model['id']; $url = U('lists', $param); $this->success('添加' . $this->model['title'] . '成功!', $url); } else { $this->error($Model->getError()); } exit; } $this->_tip(); $fields = get_model_attribute($this->model['id']); $this->assign('fields', $fields); $this->meta_title = '新增' . $this->model['title']; $this->display(); }
public function add() { $model = $this->getModel('Message'); if (IS_POST) { if (!C('SEND_GROUP_MSG')) { $this->error('抱歉,您的公众号没有群发消息的权限'); } $send_type = I('send_type', 0, 'intval'); $group_id = I('group_id', 0, 'intval'); $send_openids = I('send_openids'); if ($send_type == 0) { $_POST['msg_id'] = $this->_send_by_group($group_id); } else { $_POST['msg_id'] = $this->_send_by_openid($send_openids); } $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && ($id = $Model->add())) { $this->_saveKeyword($model, $id); // 清空缓存 method_exists($Model, 'clear') && $Model->clear($id, 'edit'); $this->success('添加' . $model['title'] . '成功!', U('add')); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id'], $model['field_sort']); $this->assign('fields', $fields); $this->meta_title = '新增' . $model['title']; !C('SEND_GROUP_MSG') && $this->assign('normal_tips', '温馨提示:目前微信仅开放认证公众号的群发消息权限,未认证公众号无法使用此功能'); $map['token'] = get_token(); $map['manager_id'] = $this->mid; $map['is_del'] = 0; $group_list = M('auth_group')->where($map)->select(); $this->assign('group_list', $group_list); $this->display(); } }
public function add() { is_array($model) || ($model = $this->getModel($model)); if (IS_POST) { // $_POST ['token'] = get_token (); $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && ($id = $Model->add())) { $this->_saveKeyword($model, $id); $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); $this->meta_title = '新增' . $model['title']; $templateFile || ($templateFile = $model['template_add'] ? $model['template_add'] : ''); $this->display($templateFile); } }
public function edit() { $model = $this->model; $id = I('id'); if (IS_POST) { $_POST['token'] = get_token(); $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && $Model->save()) { D('Common/Keyword')->set($_POST['keyword'], _ADDONS, $id, $_POST['keyword_type'], 'custom_reply_news'); $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $extra = $this->getCateData(); if (!empty($extra)) { foreach ($fields[1] as &$vo) { if ($vo['name'] == 'cate_id') { $vo['extra'] .= "\r\n" . $extra; } } } // 获取数据 $data = M(get_table_name($model['id']))->find($id); $data || $this->error('数据不存在!'); $token = get_token(); if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) { $this->error('非法访问!'); } $this->assign('fields', $fields); $this->assign('data', $data); $this->meta_title = '编辑' . $model['title']; $this->display(); } }
public function edit() { $id = I('get.id', ''); if (empty($id)) { $this->error('参数不能为空!'); } $model_id = 6; // 获取详细数据 $Model = D('Record'); $data = $Model->detail($id); // 获取当前的模型信息 $model = get_top_model($data['model_id']); $model = $model[$model_id]; $this->assign('data', $data); $this->assign('model_id', $data['model_id']); $this->assign('model', $model); //获取表单字段排序 $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); //获取当前分类的文档类型 $this->assign('type_list', get_type_bycate($data['category_id'])); $this->meta_title = '编辑文档'; $this->display(); }
protected function checkAttr($Model, $model_id) { $fields = get_model_attribute($model_id, false); $validate = $auto = array(); foreach ($fields as $key => $attr) { if ($attr['is_must']) { // 必填字段 $validate[] = array($attr['name'], 'require', $attr['title'] . '必须!'); } // 自动验证规则 if (!empty($attr['validate_rule']) || $attr['validate_type'] == 'unique') { $validate[] = array($attr['name'], $attr['validate_rule'], $attr['error_info'] ? $attr['error_info'] : $attr['title'] . '验证错误', 0, $attr['validate_type'], $attr['validate_time']); } // 自动完成规则 if (!empty($attr['auto_rule'])) { $auto[] = array($attr['name'], $attr['auto_rule'], $attr['auto_time'], $attr['auto_type']); } elseif ('checkbox' == $attr['type']) { // 多选型 $auto[] = array($attr['name'], 'arr2str', 3, 'function'); } elseif ('datetime' == $attr['type']) { // 日期型 $auto[] = array($attr['name'], 'strtotime', 3, 'function'); } elseif ('date' == $attr['type']) { // 日期型 $auto[] = array($attr['name'], 'strtotime', 3, 'function'); } } return $Model->validate($validate)->auto($auto); }
function add() { $model = $this->getModel(); if (IS_POST) { $this->checkPostData(); $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && ($id = $Model->add())) { $this->_saveKeyword($model, $id); // 清空缓存 method_exists($Model, 'clear') && $Model->clear($id, 'edit'); D('Scratch')->getScratchInfo($id, true); $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); $this->meta_title = '新增' . $model['title']; $this->_deal_data(); $this->display(); } }
public function add() { $Model = D(parse_name(get_table_name($this->model['id']), 1)); if (IS_POST) { // 获取模型的字段信息 $Model = $this->checkAttr($Model, $this->model['id']); if ($Model->create() && ($id = $Model->add())) { $this->success('添加' . $this->model['title'] . '成功!', U('lists?model=' . $this->model['name'])); } else { $this->error($Model->getError()); } } else { // 获取一级菜单 $map['pid'] = 0; $map['token'] = get_token(); $list = $Model->where($map)->select(); foreach ($list as $v) { $extra .= $v['id'] . ':' . $v['title'] . "\r\n"; } $fields = get_model_attribute($this->model['id']); if (!empty($extra)) { foreach ($fields[1] as &$vo) { if ($vo['name'] == 'pid') { $vo['extra'] .= "\r\n" . $extra; } } } $this->assign('fields', $fields); $this->meta_title = '新增' . $this->model['title']; $this->display(); } }
function text_edit() { $model = $this->getModel('material_text'); $id = I('id'); // 获取数据 $data = M(get_table_name($model['id']))->find($id); $data || $this->error('数据不存在!'); $token = get_token(); if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) { $this->error('非法访问!'); } if (IS_POST) { $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && $Model->save()) { $this->success('保存' . $model['title'] . '成功!', U('text_lists?model=' . $model['name'], $this->get_param)); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); $this->assign('data', $data); $this->assign('post_url', U('text_edit')); $this->display('Addons:edit'); } }
function option_edit() { $model = $this->getModel('shop_vote_option'); $param['mdm'] = $_GET['mdm']; $res['title'] = '投票活动'; $res['url'] = addons_url('Vote://ShopVote/lists', $param); $res['class'] = _ACTION == 'lists' ? 'current' : ''; $nav[] = $res; $param['vote_id'] = I('vote_id'); $res['title'] = '投票选项'; $res['url'] = addons_url('Vote://ShopVote/option_lists', $param); $res['class'] = _ACTION == 'option_lists' ? 'current' : ''; $nav[] = $res; $res['title'] = '编辑选项'; $res['url'] = addons_url('Vote://ShopVote/option_edit', $param); $res['class'] = _ACTION == 'option_edit' ? 'current' : ''; $nav[] = $res; $this->assign('nav', $nav); // 获取模型信息 $id = I('id', 0, 'intval'); $postUrl = addons_url('Vote://ShopVote/option_edit', $param); $this->assign('post_url', $postUrl); if (IS_POST) { $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && $Model->save()) { D('Addons://Vote/ShopVoteOption')->getInfo($id, true); D('Addons://Vote/ShopVoteOption')->getOptions($_POST['vote_id'], true); $this->success('保存' . $model['title'] . '成功!', U('option_lists?model=' . $model['name'] . '&vote_id=' . $_POST['vote_id'] . '&mdm=' . $_GET['mdm'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); // 获取数据 $data = M(get_table_name($model['id']))->find($id); $data || $this->error('数据不存在!'); $token = get_token(); if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) { $this->error('非法访问!'); } $this->assign('fields', $fields); $this->assign('data', $data); $this->display('edit'); } }
public function edit() { // 获取模型信息 $id = I('id', 0, 'intval'); if (IS_POST) { $Model = D(parse_name(get_table_name($this->model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $this->model['id']); if ($Model->create() && $Model->save()) { $this->success('保存' . $this->model['title'] . '成功!', U('lists')); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($this->model['id']); // 获取数据 $data = M(get_table_name($this->model['id']))->find($id); $data || $this->error('数据不存在!'); $token = get_token(); if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) { $this->error('非法访问!'); } $this->assign('fields', $fields); $this->assign('data', $data); $this->meta_title = '编辑' . $this->model['title']; $this->display('edit'); } }
function add() { $model = $this->getModel(); if (IS_POST) { $this->checkPostData(); $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && ($id = $Model->add())) { $this->_saveKeyword($model, $id); $this->save_shop($id, $_POST['shop_id']); // 清空缓存 method_exists($Model, 'clear') && $Model->clear($id, 'add'); $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $levelData = $this->get_card_level(); $this->assign('level', $levelData); $this->assign('fields', $fields); $this->_deal_data(); $this->display(); } // $this->display (); }
function editPublicAdmin() { $model = $this->getModel('member_public'); $id = I('id', 0, 'intval'); if (IS_POST) { $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && $Model->save()) { $this->success('保存' . $model['title'] . '成功!', U('PublicAdmin')); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); foreach ($fields[1] as &$vo) { if ($vo['name'] == 'group_id') { $vo['is_show'] = 1; $group_list = M('member_public_group')->field('id, title')->select(); $extra = "0:无\n"; foreach ($group_list as $g) { $extra .= $g['id'] . ':' . $g['title'] . "\n"; } $vo['extra'] = $extra; } } // 获取数据 $data = M(get_table_name($model['id']))->find($id); $data || $this->error('数据不存在!'); $this->assign('fields', $fields); $this->assign('data', $data); $this->meta_title = '编辑' . $model['title']; $this->assign('post_url', U('admin/PublicGroup/editPublicAdmin', 'id=' . $id)); $this->display('Think:edit'); } }
public function lists($type = 0) { $wxplay_tip = "鉴别微信支付新老版本的三种方法:<br/>1. 9月中旬后申请的微信支付应该为新版,<br/>2. 申请微信支付时发来两个通知邮件是老版,<br/>3. 申请微信支付时微信发来的邮件中带有“paysignKey”字样是老版!<br/><br/>因为微信端的新版微信支付错误提示不完整且不易读,<br/>测试新版微信支付时,如果出现任何问题请先认真检查配置项是不是完全填写正确。<br/><br/>"; $normal_tips = '支持微信支付、财付通(WAP接口或者即时到帐接口)和支付宝支付(即时到帐接口)。请填写真实信息,否则支付中可能会出现错误<br/> <a href="' . U('testpay') . '">测试支付功能</a>'; if ($type == 0 || $type == 5) { $normal_tips = $wxplay_tip . $normal_tips; } $this->assign('normal_tips', $normal_tips); $token = get_token(); // 获取模型信息 $payid = M("payment_set")->where(array("token" => $token))->field('id')->find(); $id = 0; if (!empty($payid)) { $id = $payid["id"]; } if (IS_POST) { $isadd = I('get.isadd', 0, 'intval'); $savetype = I('get.savetype', 0, 'intval'); if (strpos($_POST["id"], "*") != false) { unset($_POST["id"]); } if (strpos($_POST["token"], "*") != false) { unset($_POST["token"]); } if (strpos($_POST["ctime"], "*") != false) { unset($_POST["ctime"]); } if (strpos($_POST["wxappid"], "*") != false) { unset($_POST["wxappid"]); } if (strpos($_POST["wxpaysignkey"], "*") != false) { unset($_POST["wxpaysignkey"]); } if (strpos($_POST["wxappsecret"], "*") != false) { unset($_POST["wxappsecret"]); } if (strpos($_POST["zfbname"], "*") != false) { unset($_POST["zfbname"]); } if (strpos($_POST["pid"], "*") != false) { unset($_POST["pid"]); } if (strpos($_POST["key"], "*") != false) { unset($_POST["key"]); } if (strpos($_POST["partnerid"], "*") != false) { unset($_POST["partnerid"]); } if (strpos($_POST["partnerkey"], "*") != false) { unset($_POST["partnerkey"]); } if (strpos($_POST["wappartnerid"], "*") != false) { unset($_POST["wappartnerid"]); } if (strpos($_POST["wappartnerkey"], "*") != false) { unset($_POST["wappartnerkey"]); } if (strpos($_POST["wxpartnerkey"], "*") != false) { unset($_POST["wxpartnerkey"]); } if (strpos($_POST["wxpartnerid"], "*") != false) { unset($_POST["wxpartnerid"]); } if (strpos($_POST["quick_security_key"], "*") != false) { unset($_POST["quick_security_key"]); } if (strpos($_POST["quick_merid"], "*") != false) { unset($_POST["quick_merid"]); } if (strpos($_POST["quick_merabbr"], "*") != false) { unset($_POST["quick_merabbr"]); } if (strpos($_POST["wxmchid"], "*") != false) { unset($_POST["wxmchid"]); } if (strpos($_POST["wxv3key"], "*") != false) { unset($_POST["wxv3key"]); } if (strpos($_POST["wxv3appsecret"], "*") != false) { unset($_POST["wxv3appsecret"]); } if ($isadd == 1) { // 自动补充token $_POST['token'] = $token; $Model = D(parse_name(get_table_name($this->model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $this->model['id']); if ($Model->create() && ($micsetid = $Model->add())) { switch ($savetype) { case 0: //微信支付 $this->success('保存' . $this->model['title'] . '成功!', U('lists')); break; case 5: //微信支付V3 $this->success('保存' . $this->model['title'] . '成功!', U('listsv3')); break; case 1: //支付宝 $this->success('保存' . $this->model['title'] . '成功!', U('zfbpay')); break; case 2: //财付通wap $this->success('保存' . $this->model['title'] . '成功!', U('cftwappay')); break; case 3: //财付通 $this->success('保存' . $this->model['title'] . '成功!', U('ctfpay')); break; case 4: //银联在线 $this->success('保存' . $this->model['title'] . '成功!', U('quickpay')); break; } } else { $this->error($Model->getError()); } } else { $Model = D(parse_name(get_table_name($this->model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $this->model['id']); if ($Model->create() && $Model->save()) { switch ($savetype) { case 0: //微信支付 $this->success('保存' . $this->model['title'] . '成功!', U('lists')); break; case 5: //微信支付V3 $this->success('保存' . $this->model['title'] . '成功!', U('listsv3')); break; case 1: //支付宝 $this->success('保存' . $this->model['title'] . '成功!', U('zfbpay')); break; case 2: //财付通wap $this->success('保存' . $this->model['title'] . '成功!', U('cftwappay')); break; case 3: //财付通 $this->success('保存' . $this->model['title'] . '成功!', U('ctfpay')); break; case 4: //银联在线 $this->success('保存' . $this->model['title'] . '成功!', U('quickpay')); break; } } else { $this->error($Model->getError()); } } } else { $fields = get_model_attribute($this->model['id']); // 获取数据 $data = M(get_table_name($this->model['id']))->find($id); //是否新增 $isadd = 0; if (empty($data)) { $isadd = 1; } $this->assign('isadd', $isadd); $this->assign('savetype', $savetype); //排除字段 switch ($type) { case 0: //微信支付 unset($fields[1]["pid"]); unset($fields[1]["key"]); unset($fields[1]["zfbname"]); unset($fields[1]["partnerid"]); unset($fields[1]["partnerkey"]); unset($fields[1]["wappartnerid"]); unset($fields[1]["wappartnerkey"]); unset($fields[1]["quick_security_key"]); unset($fields[1]["quick_merid"]); unset($fields[1]["quick_merabbr"]); unset($fields[1]["wxmchid"]); unset($fields[1]["wxv3key"]); unset($fields[1]["wxv3appsecret"]); break; case 5: //微信支付V3 unset($fields[1]["pid"]); unset($fields[1]["key"]); unset($fields[1]["zfbname"]); unset($fields[1]["partnerid"]); unset($fields[1]["partnerkey"]); unset($fields[1]["wappartnerid"]); unset($fields[1]["wappartnerkey"]); unset($fields[1]["quick_security_key"]); unset($fields[1]["quick_merid"]); unset($fields[1]["quick_merabbr"]); unset($fields[1]["wxpartnerkey"]); unset($fields[1]["wxpartnerid"]); unset($fields[1]["wxpaysignkey"]); unset($fields[1]["wxappsecret"]); break; case 1: //支付宝 unset($fields[1]["wxappsecret"]); unset($fields[1]["wxpaysignkey"]); unset($fields[1]["wxappid"]); unset($fields[1]["partnerid"]); unset($fields[1]["partnerkey"]); unset($fields[1]["wappartnerid"]); unset($fields[1]["wappartnerkey"]); unset($fields[1]["wxpartnerid"]); unset($fields[1]["wxpartnerkey"]); unset($fields[1]["quick_security_key"]); unset($fields[1]["quick_merid"]); unset($fields[1]["quick_merabbr"]); unset($fields[1]["wxmchid"]); unset($fields[1]["wxv3key"]); unset($fields[1]["wxv3appsecret"]); break; case 2: //财付通wap unset($fields[1]["pid"]); unset($fields[1]["key"]); unset($fields[1]["wxappsecret"]); unset($fields[1]["wxpaysignkey"]); unset($fields[1]["wxappid"]); unset($fields[1]["zfbname"]); unset($fields[1]["wappartnerid"]); unset($fields[1]["wappartnerkey"]); unset($fields[1]["wxpartnerkey"]); unset($fields[1]["wxpartnerid"]); unset($fields[1]["quick_security_key"]); unset($fields[1]["quick_merid"]); unset($fields[1]["quick_merabbr"]); unset($fields[1]["wxmchid"]); unset($fields[1]["wxv3key"]); unset($fields[1]["wxv3appsecret"]); break; case 3: //财付通 unset($fields[1]["pid"]); unset($fields[1]["key"]); unset($fields[1]["wxappsecret"]); unset($fields[1]["wxpaysignkey"]); unset($fields[1]["wxappid"]); unset($fields[1]["zfbname"]); unset($fields[1]["partnerid"]); unset($fields[1]["partnerkey"]); unset($fields[1]["wxpartnerkey"]); unset($fields[1]["wxpartnerid"]); unset($fields[1]["quick_security_key"]); unset($fields[1]["quick_merid"]); unset($fields[1]["quick_merabbr"]); unset($fields[1]["wxmchid"]); unset($fields[1]["wxv3key"]); unset($fields[1]["wxv3appsecret"]); break; case 4: unset($fields[1]["pid"]); unset($fields[1]["key"]); unset($fields[1]["wxappsecret"]); unset($fields[1]["wxpaysignkey"]); unset($fields[1]["wxappid"]); unset($fields[1]["zfbname"]); unset($fields[1]["wappartnerid"]); unset($fields[1]["wappartnerkey"]); unset($fields[1]["partnerid"]); unset($fields[1]["partnerkey"]); unset($fields[1]["wxpartnerkey"]); unset($fields[1]["wxpartnerid"]); unset($fields[1]["wxmchid"]); unset($fields[1]["wxv3key"]); unset($fields[1]["wxv3appsecret"]); break; } $this->assign('fields', $fields); $newdata = array(); foreach ($data as $key => $v) { //加密处理 if ($key == "id") { $newdata[$key] = $v; } else { $newdata[$key] = $this->hideStr($v, strlen($v) / 3, strlen($v) / 3); } } $this->assign('data', $newdata); $this->meta_title = '编辑' . $this->model['title']; } $this->display("wxpay"); }
/** * 文档编辑页面初始化 * @author huajie <*****@*****.**> */ public function edit() { //获取左边菜单 $this->getMenu(); $id = I('get.id', ''); if (empty($id)) { $this->error('参数不能为空!'); } // 获取详细数据 $Document = M('Doc0s1'); //$Document = M('Doc0s1A1'); $data = $Document->detail($id); if (!$data) { $this->error($Document->getError()); } if ($data['pid']) { // 获取上级文档 $article = $Document->field('id,title,type')->find($data['pid']); $this->assign('article', $article); } // 获取当前的模型信息 $model = get_document_model($data['model_id']); $this->assign('data', $data); $this->assign('model_id', $data['model_id']); $this->assign('model', $model); //获取表单字段排序 $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); //获取当前分类的文档类型 $this->assign('type_list', get_type_bycate($data['category_id'])); $this->meta_title = '编辑文档'; $this->display(); }
public function edit() { $is_admin_edit = false; if (!empty($_REQUEST['id'])) { $map['id'] = intval($_REQUEST['id']); $is_admin_edit = true; $msg = '编辑'; $html = 'edit'; } else { $msg = '绑定'; $openid = $map['openid'] = get_openid(); $html = 'moblieForm'; } $token = $map['token'] = get_token(); $model = $this->getModel('follow'); if (IS_POST) { $is_admin_edit && ($_POST['status'] = 2); $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && $Model->where($map)->save()) { //lastsql();exit; $url = ''; $bind_backurl = cookie('__forward__'); $config = getAddonConfig('UserCenter'); $jumpurl = $config['jumpurl']; if (!empty($bind_backurl)) { $url = $bind_backurl; cookie('__forward__', NULL); } elseif (!empty($jumpurl)) { $url = $jumpurl; } elseif (!$is_admin_edit) { $url = addons_url('WeiSite://WeiSite/index', $map); } $this->success($msg . '成功!', $url); } else { //lastsql(); //dump($map);exit; $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); if (!$is_admin_edit) { $fieldArr = array('nickname', 'sex', 'mobile'); //headimgurl foreach ($fields[1] as $k => $vo) { if (!in_array($vo['name'], $fieldArr)) { unset($fields[1][$k]); } } } // 获取数据 $data = M(get_table_name($model['id']))->where($map)->find(); $token = get_token(); if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) { $this->error('非法访问!'); } // 自动从微信接口获取用户信息 empty($openid) || ($info = getWeixinUserInfo($openid, $token)); if (is_array($info)) { if (empty($data['headimgurl']) && !empty($info['headimgurl'])) { // 把微信头像转到WeiPHP的通用图片ID保存 TODO $data['headimgurl'] = $info['headimgurl']; } $data = array_merge($info, $data); } $this->assign('fields', $fields); $this->assign('data', $data); $this->meta_title = $msg . '用户消息'; $this->assign('post_url', U('edit')); $this->display($html); } }
public function edit($id = 0) { $model = $this->model; $id || ($id = I('id')); // 获取数据 $data = M(get_table_name($model['id']))->find($id); $data || $this->error('数据不存在!'); if (IS_POST) { $act = 'save'; $has = $this->checkTitle($_POST['title'], $id); if ($has > 0) { $this->error('该分组名已经存在!'); } $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && $Model->{$act}()) { $title = I('title'); if ($this->syc_wechat && $title != $data['title'] && !empty($data['wechat_group_id'])) { // 修改的用户组名同步到微信端 $url = 'https://api.weixin.qq.com/cgi-bin/groups/update?access_token=' . $access_token; $param['group']['id'] = $data['wechat_group_id']; $param['group']['name'] = $title; $param = JSON($param); $res = post_data($url, $param); } $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $this->assign('fields', $fields); $this->assign('data', $data); $this->meta_title = '编辑' . $model['title']; $this->display('Addons/edit'); } }
public function add($model = null) { is_array($model) || ($model = $this->getModel($this->model_name)); $Model = D(parse_name(get_table_name($model['id']), 1)); if (IS_POST) { // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && ($id = $Model->add())) { $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { $this->error($Model->getError()); } } else { // 要先填写appid $map['token'] = get_token(); $info = M('member_public')->where($map)->find(); if (empty($info['appid']) || empty($info['secret'])) { $this->error('请先配置appid和secret', U('home/MemberPublic/edit', 'id=' . $info['id'])); } // 获取一级菜单 $map['pid'] = 0; $list = $Model->where($map)->select(); foreach ($list as $v) { $extra .= $v['id'] . ':' . $v['title'] . "\r\n"; } $fields = get_model_attribute($model['id']); if (!empty($extra)) { foreach ($fields[1] as &$vo) { if ($vo['name'] == 'pid') { $vo['extra'] .= "\r\n" . $extra; } } } $this->assign('fields', $fields); $this->meta_title = '新增' . $model['title']; $this->display(); } }
/** * 处理文档列表显示 * @param array $list 列表数据 * @param integer $model_id 模型id */ protected function parseDocumentList($list, $model_id = null) { $model_id = $model_id ? $model_id : 1; $attrList = get_model_attribute($model_id, false, 'id,name,type,extra'); // 对列表数据进行显示处理 if (is_array($list)) { foreach ($list as $k => $data) { foreach ($data as $key => $val) { if (isset($attrList[$key])) { $extra = $attrList[$key]['extra']; $type = $attrList[$key]['type']; if ('select' == $type || 'checkbox' == $type || 'radio' == $type || 'bool' == $type) { // 枚举/多选/单选/布尔型 $options = parse_field_attr($extra); if ($options && array_key_exists($val, $options)) { $data[$key] = $options[$val]; } } elseif ('date' == $type) { // 日期型 $data[$key] = date('Y-m-d', $val); } elseif ('datetime' == $type) { // 时间型 $data[$key] = date('Y-m-d H:i', $val); } } } $data['model_id'] = $model_id; $list[$k] = $data; } } return $list; }
function address_edit() { $id = I('id'); $model = $this->getModel('prize_address'); if (IS_POST) { $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && $Model->save()) { $this->_saveKeyword($model, $id); // 清空缓存 method_exists($Model, 'clear') && $Model->clear($id, 'edit'); $this->success('保存' . $model['title'] . '成功!', U('address_lists?model=' . $model['name'] . '&target_id=' . $_POST['prizeid'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); // 获取数据 $data = M(get_table_name($model['id']))->find($id); $data || $this->error('数据不存在!'); $token = get_token(); if (isset($data['token']) && $token != $data['token'] && defined('ADDON_PUBLIC_PATH')) { $this->error('非法访问!'); } $param['mdm'] = $_GET['mdm']; $postUrl = U('address_edit', $param); $this->assign('post_url', $postUrl); $this->assign('fields', $fields); $this->assign('data', $data); $this->meta_title = '编辑' . $model['title']; $this->display(SITE_PATH . '/Application/Home/View/default/Addons/edit.html'); } }
public function add() { $model = $this->model; $Model = D(parse_name(get_table_name($model['id']), 1)); $shop_id = $_POST['shop_id'] = $this->shop_id; if (IS_POST) { if ($_POST['imgs'] && count($_POST['imgs']) > 0) { $_POST['imgs'] = implode(',', $_POST['imgs']); } // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && ($id = $Model->add())) { D('Common/Keyword')->set($_POST['keyword'], _ADDONS, $id, $_POST['keyword_type'], 'custom_reply_news'); $this->success('添加' . $model['title'] . '成功!', U('lists?model=' . $model['name'] . '&shop_id=' . $shop_id)); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); $extra = $this->getCateData(); if (!empty($extra)) { foreach ($fields as &$vo) { if ($vo['name'] == 'category_id') { $vo['extra'] .= "\r\n" . $extra; } } } $this->assign('fields', $fields); $this->meta_title = '新增' . $model['title']; $this->display(); } }
/** * 检测属性的自动验证和自动完成属性 * @return boolean */ public function checkModelAttr($model_id) { $fields = get_model_attribute($model_id, false); $validate = $auto = array(); foreach ($fields as $key => $attr) { if ($attr['is_must']) { // 必填字段 $validate[] = array($attr['name'], 'require', $attr['title'] . '必须!', self::MUST_VALIDATE, 'regex', self::MODEL_BOTH); } // 自动验证规则 if (!empty($attr['validate_rule'])) { $validate[] = array($attr['name'], $attr['validate_rule'], $attr['error_info'] ? $attr['error_info'] : $attr['title'] . '验证错误', 0, $attr['validate_type'], $attr['validate_time']); } // 自动完成规则 if (!empty($attr['auto_rule'])) { $auto[] = array($attr['name'], $attr['auto_rule'], $attr['auto_time'], $attr['auto_type']); } elseif ('checkbox' == $attr['type']) { // 多选型 $auto[] = array($attr['name'], 'arr2str', 3, 'function'); } elseif ('datetime' == $attr['type']) { // 日期型 $auto[] = array($attr['name'], 'strtotime', 3, 'function'); } } $validate = array_merge($validate, $this->_validate); $auto = array_merge($auto, $this->_auto); return $this->validate($validate)->auto($auto); }
function mobileForm() { defined('_ACTION') or define('_ACTION', 'mobileForm'); $model = $this->getModel($model); if (IS_POST) { $Model = D(parse_name(get_table_name($model['id']), 1)); // 获取模型的字段信息 $Model = $this->checkAttr($Model, $model['id']); if ($Model->create() && $Model->save()) { $this->success('保存' . $model['title'] . '成功!', U('lists?model=' . $model['name'])); } else { $this->error($Model->getError()); } } else { $fields = get_model_attribute($model['id']); // 获取数据 $id = I('id'); $data = M(get_table_name($model['id']))->find($id); $this->assign('fields', $fields); $this->assign('data', $data); $this->meta_title = '编辑' . $model['title']; $this->display('./Application/Home/View/default/Addons/mobileForm.html'); } }