public function edit() { if (IS_POST) { $post_data = I('post.'); $post_data["rules"] = I("post.rules"); $post_data["rules"] = implode(",", $post_data["rules"]); $data = $this->Model->create($post_data); if ($data) { $result = $this->Model->where(array('id' => $post_data['id']))->save($data); if ($result) { action_log('Edit_AuthGroup', 'AuthGroup', $post_data['id']); $this->success("操作成功!", U('index')); } else { $error = $this->Model->getError(); $this->error($error ? $error : "操作失败!"); } } else { $error = $this->Model->getError(); $this->error($error ? $error : "操作失败!"); } } else { $_info = I('get.'); $_info = $this->Model->where(array('id' => $_info['id']))->find(); $this->assign('_info', $_info); $this->display(); } }
protected function __autoload() { parent::__autoload(); if (MODULE_NAME == "Home" || MODULE_NAME == "User") { session('loginout_url', U('/')); } else { session('loginout_url', U(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME, param())); } if (MODULE_NAME == "Home" || MODULE_NAME == "User" && (CONTROLLER_NAME == "Register" || CONTROLLER_NAME == "Login")) { session('login_url', U('/')); } else { session('login_url', U(MODULE_NAME . '/' . CONTROLLER_NAME . '/' . ACTION_NAME, param())); } if (C("SITE_STATUS") != 1 && !$_SESSION["admin_member_id"]) { $this->error("站点已关闭"); } $this->__init(); $img_type = array('jpg', 'gif', 'png', 'jpeg', 'bmp'); /*设定图片格式,退款凭证显示图标用*/ $language = get_language_recommend_cache(); /*查询推荐的源语言*/ $all_themes = array_id_key(get_themes_cache()); /*查询平台拥有的所有皮肤,并将ID转换成KEY*/ $data['all_theme'] = $all_themes; $data['recommend_language'] = $language; $data['img_type'] = $img_type; $this->assign($data); /*@刘巧刷新消息*/ session('news_num', get_news_recode(session('home_member_id'))); }
public function step3() { if (IS_POST) { if ($_POST['if2011'] != '是') { $this->error("您已放弃报名", addons_url('Join2011://Join2011/index')); } //print_array($_POST); $Stu = D('Stu'); $Bmb = D('Bmb'); $data['ksh'] = $_SESSION['ksh']; $data['score'] = $_POST['score']; $data['jsscore'] = $_POST['jsscore']; $data['phone'] = $_POST['phone']; if ($Stu->where(array('ksh' => $_SESSION['ksh']))->find()) { } else { $this->error("您不在初选名单", addons_url('Join2011://Join2011/index')); } if ($Bmb->where(array('ksh' => $_SESSION['ksh']))->find()) { $this->error("您已经报名", addons_url('Join2011://Join2011/index')); } if ($Bmb->data($data)->add()) { session('ksh', ''); $this->success('报名成功', U('Home/Index/index')); } else { $this->error("报名失败,请重新报名", addons_url('Join2011://Join2011/index')); } } else { $this->error("您不可以直接访问这个页面", addons_url('Join2011://Join2011/index')); } }
function add_post() { if (IS_POST) { if (!empty($_POST['role_id']) && is_array($_POST['role_id'])) { $role_ids = $_POST['role_id']; unset($_POST['role_id']); if ($this->users_obj->create()) { $result = $this->users_obj->add(); if ($result !== false) { $role_user_model = M("RoleUser"); foreach ($role_ids as $role_id) { $role_user_model->add(array("role_id" => $role_id, "user_id" => $result)); } $this->success("添加成功!", U("user/index")); } else { $this->error("添加失败!"); } } else { $this->error($this->users_obj->getError()); } } else { $this->error("请为此用户指定角色!"); } } }
function content_5638503aa35533_60603029($_smarty_tpl) { $_smarty_tpl->properties['nocache_hash'] = '17972065005638503a9da791_81598189'; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head> <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> <link rel="stylesheet" href="./Public/Admin/Css/add_category.css" /> <title></title> </head> <body> <form action="<?php echo U('Category/addTopCate'); ?> " method="post"> <table class="table"> <tr > <td class="th" colspan="2">添加顶级分类</td> </tr> <tr> <td>分类名称</td> <td><input type="text" name="title"/></td> </tr> <tr> <td colspan="2"> <input type="submit" value="添加" class="input_button"/> <input type="reset" class="input_button"/> </td> </tr> </table> </form> </body> </html><?php }
public function update($admin_id) { $admin_id = $admin_id + 0; $model = new \Model\AdminModel(); if (IS_POST) { if ($data = $model->create()) { $password = I('post.password'); //判断有没有输入新密码 if (empty($password)) { unset($data['password']); } else { //重新生成密码和salt $str = uniqid(); $salt = substr($str, -6); $password = I('post.password'); //生成密码 $data['password'] = md5(md5($password) . $salt); $data['salt'] = $salt; } if ($model->save($data) !== false) { $this->success('修改管理员成功', U('showlist'), 1); exit; } $this->error('修改管理员失败'); } $this->error($model->getError()); } //获取要修改管理员的属性并显示 $info = $model->field('admin_id,admin_name,role_id')->join("left join it_admin_role using(admin_id)")->find($admin_id); $this->assign('info', $info); //获取角色并遍历显示 $role_list = M('Role')->select(); $this->assign('role_list', $role_list); $this->display(); }
public function checkUser() { if (isset($_REQUEST['code'])) { $keys = array(); $keys['code'] = $_REQUEST['code']; $keys['redirect_uri'] = U('public/Widget/displayAddons', array('type' => $_REQUEST['type'], 'addon' => 'Login', 'hook' => 'no_register_display')); try { $token = $this->_oauth->getAccessToken('code', $keys); } catch (OAuthException $e) { $token = null; } } else { $keys = array(); $keys['refresh_token'] = $_REQUEST['code']; try { $token = $this->_oauth->getAccessToken('token', $keys); } catch (OAuthException $e) { $token = null; } } if ($token) { setcookie('weibojs_' . $this->_oauth->client_id, http_build_query($token)); $_SESSION['sina']['access_token']['oauth_token'] = $token['access_token']; $_SESSION['sina']['access_token']['oauth_token_secret'] = $token['refresh_token']; $_SESSION['sina']['expire'] = time() + $token['expires_in']; $_SESSION['sina']['uid'] = $token['uid']; $_SESSION['open_platform_type'] = 'sina'; return $token; } else { return false; } }
/** * 获取导航列表,支持多级导航 * * @param boolean $field * 要列出的字段 * @return array 导航树 * @author 麦当苗儿 <*****@*****.**> */ public function getMediaIdByGroupId($group_id) { $map['group_id'] = $group_id; $list = $this->where($map)->order('id asc')->select(); if (!empty($list[0]['media_id'])) { return $list[0]['media_id']; } // 自动同步到微信端 foreach ($list as $vo) { $data['title'] = $vo['title']; $data['thumb_media_id'] = empty($vo['thumb_media_id']) ? $this->_thumb_media_id($vo['cover_id']) : $vo['thumb_media_id']; $data['author'] = $vo['author']; $data['digest'] = $vo['intro']; $data['show_cover_pic'] = 1; $data['content'] = $vo['content']; $data['content_source_url'] = U('news_detail', array('id' => $vo['id'])); $articles[] = $data; } $url = 'https://api.weixin.qq.com/cgi-bin/material/add_news?access_token=' . get_access_token(); $param['articles'] = $articles; $res = post_data($url, $param); if ($res['errcode'] != 0) { return false; } else { $this->where($map)->setField('media_id', $res['media_id']); return $res['media_id']; } }
public function add() { $id = I('id'); $p_id = I('p_id'); if (IS_POST) { $p['category_name'] = I('category_name'); $p['status'] = I('state'); $p['sort'] = I('order'); $p['is_home'] = I('is_home'); $p['home_num'] = I('home_num'); $p['ad_url'] = I('ad_url'); $p['catepic_url'] = I('catepic_url'); $p['sku'] = I('sku'); $p['is_home_banner'] = I('is_home_banner'); $p['is_home_banner_type'] = I('is_home_banner_type'); $p['color'] = I('color'); if ($id) { M('CategoryGoods')->where("id='{$id}'")->save($p); $this->success('修改成功'); } $p['p_id'] = I('p_id'); if ($p['p_id']) { $category = M('CategoryGoods')->where("id='{$p['p_id']}'")->find(); !$category && $this->error('没有上级栏目'); } M('CategoryGoods')->add($p); $this->success('添加成功', U('add')); } $this->assign('id', $id); $this->assign('p_id', $p_id); $id && $this->assign('category', M('CategoryGoods')->find($id)); $this->display(); }
public function menu() { //$this->checkUser(); //显示菜单项 $id = intval($_REQUEST['tag']) == 0 ? 6 : intval($_REQUEST['tag']); $menu = array(); $role_id = D('admin')->where('id=' . $_SESSION['admin_info']['id'])->getField('role_id'); $node_ids_res = D("access")->where("role_id=" . $role_id)->field("node_id")->select(); $node_ids = array(); foreach ($node_ids_res as $row) { array_push($node_ids, $row['node_id']); } //读取数据库模块列表生成菜单项 $node = M("node"); $where = "auth_type<>2 AND status=1 AND is_show=0 AND group_id=" . $id; $list = $node->where($where)->field('id,action,action_name,module,module_name,data')->order('sort DESC')->select(); foreach ($list as $key => $action) { $data_arg = array(); if ($action['data']) { $data_arr = explode('&', $action['data']); foreach ($data_arr as $data_one) { $data_one_arr = explode('=', $data_one); $data_arg[$data_one_arr[0]] = $data_one_arr[1]; } } $action['url'] = U($action['module'] . '/' . $action['action'], $data_arg); if ($action['action']) { $menu[$action['module']]['navs'][] = $action; } $menu[$action['module']]['name'] = $action['module_name']; $menu[$action['module']]['id'] = $action['id']; } $this->assign('menu', $menu); $this->display('left'); }
public function delete() { $id = I('get.id'); $res = D('Develop')->delete($id); $mess = new MessController(); $mess->message($res, '删除成功', '删除失败', U('Develop/index', array('mess' => '删除成功'))); }
function edit() { if (isset($_POST['dosubmit'])) { $node_mod = D('wf_node'); $data = $node_mod->create(); if ($data['node_id'] == 0) { $this->error('请选择分类'); } $result = $node_mod->save($data); if (false !== $result) { $this->success(L('operation_success'), U('WFNode/index')); } else { $this->error(L('operation_failure')); } } else { $node_mod = D('wf_node'); if (isset($_GET['node_id'])) { $node_id = isset($_GET['node_id']) && intval($_GET['node_id']) ? intval($_GET['node_id']) : $this->error(L('please_select')); } $defination_mod = D('wf_defination'); $result = $defination_mod->order('defination_id ASC')->select(); $defination_list = array(); foreach ($result as $val) { if ($val['pid'] == 0) { $defination_list['parent'][$val['defination_id']] = $val; } } $note_info = $node_mod->where('node_id=' . $node_id)->find(); $this->assign('show_header', false); $this->assign('defination_list', $defination_list); $this->assign('node', $note_info); $this->display(); } }
public function add() { $brand = D('brand'); $list = $this->menulist(); if (IS_POST) { //提交表单 $brandid = $_POST["ypid"]; $good = $_POST["goodid"]; if ($brand->where("ypid='{$brandid}'")->select()) { $brand->where("ypid='{$brandid}'")->delete(); } if (false !== $brand->update()) { $this->success('新增成功!', U('index')); } else { $error = $brand->getError(); $this->error(empty($error) ? '未知错误!' : $error); } } else { $cate = array(); if ($pid) { /* 获取上级信息 */ $cate = $brand->info($pid, 'id,title,status'); if (!($cate && 1 == $cate['status'])) { $this->error('指定的上级分类不存在或被禁用!'); } } /*品牌信息 */ $this->assign('list', $list); $this->assign('info', null); $this->assign('category', $cate); $this->meta_title = '新增优惠券'; $this->display(); } }
public function cache() { if (isset($_GET['type'])) { $Dir = new \Dir(); $cache = D('Common/Cache'); $type = I('get.type'); switch ($type) { case "template": //删除缓存目录下的文件 $Dir->del(RUNTIME_PATH); $Dir->delDir(RUNTIME_PATH . "Cache/"); $Dir->delDir(RUNTIME_PATH . "Temp/"); //更新开启其他方式的缓存 \Think\Cache::getInstance()->clear(); $this->success("模板缓存清理成功!", U('Index/cache')); break; case "logs": $Dir->delDir(RUNTIME_PATH . "Logs/"); $this->success("站点日志清理成功!", U('Index/cache')); break; default: $this->error("请选择清楚缓存类型!"); break; } } else { $this->display(); } }
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_text'); $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 add($pid = 0) { $Category = D('fcoupon'); if (IS_POST) { //提交表单 if (false !== $Category->update()) { $this->success('新增成功!', U('index')); } else { $error = $Category->getError(); $this->error(empty($error) ? '未知错误!' : $error); } } else { $cate = array(); if ($pid) { /* 获取上级优惠券信息 */ $cate = $Category->info($pid, 'id,name,title,status'); if (!($cate && 1 == $cate['status'])) { $this->error('指定的上级分类不存在或被禁用!'); } } /* 获取优惠券信息 */ $this->assign('info', null); $this->assign('category', $cate); $this->meta_title = '新增优惠券'; $this->display('edit'); } }
public function login($username = null, $password = null, $verify = null) { if (IS_POST) { $db = M('user'); $map['name'] = $username; $map['password'] = md5($password); $userInfo = $db->where($map)->find(); if (!$userInfo) { $this->error('帐号不存在或被禁用'); } $_SESSION['userid'] = $userInfo['id']; $_SESSION['username'] = $userInfo['name']; $_SESSION['truename'] = $userInfo['name']; $_SESSION['usertype'] = $userInfo['usertype']; $_SESSION['studentid'] = $userInfo['studentid']; $this->success('登录成功!', U('Index/index')); return; } else { if (is_login()) { $this->display('Project/projectList'); return; } else { $this->display('User/login'); } } }
public function edit() { $js_id = $_POST['id'] ? $_POST['id'] : $_GET['id']; if (empty($js_id)) { $this->error("站点编号丢失"); } if (IS_POST) { if ($this->model_js->create()) { if ($this->model_js->save($_POST) !== false) { $this->success("修改成功!", U("Js/edit", "id={$js_id}")); } else { $this->error("修改失败!"); } } else { $this->error($this->model_js->getError()); } } else { $info = $this->model_js->where("id={$js_id}")->find(); if ($info) { $this->assign("info", $info); $this->display(); } else { $this->error("应用不存在或数据获取失败"); } } }
public function index() { //$Line_type = M('Line_type'); $catid = I('get.catid', 1); $sql = "select count(*) as num from __LINE_TYPE__ as a,__LINE__ as b\n where a.type_id = {$catid} and a.line_id = b.line_id and b.status=1"; $pageNum = 10; $_page = pages($sql, $pageNum); $nowPage = I('get.p', 1); $firstRow = ($nowPage - 1) * $pageNum; $Model = new \Think\Model(); $line_lists = $Model->query("select a.*, b.* from __LINE_TYPE__ as a,\n __LINE__ as b where a.type_id = {$catid} and a.line_id = b.line_id and b.status=1\n order by b.update_time desc, b.line_id desc limit {$firstRow},{$pageNum}"); $line_lists = array_filter($line_lists); foreach ($line_lists as $key => $val) { $map_two = array(); $map_two['line_id&is_default'] = array($val['line_id'], 1, '_multi' => true); $res = get_tc_val($map_two); $line_lists[$key]['price'] = $res['price']; $line_lists[$key]['best_price'] = $res['best_price']; $line_lists[$key]['start_date'] = get_start_date($res['date_price_data']); $line_lists[$key]['img'] = get_cover(array_shift(explode(',', $val['images'])), 'path'); $line_lists[$key]['url'] = U('Line/show', array('id' => $val['line_id'])); } $this->assign('line_lists', $line_lists); $this->assign('_page', $_page); $this->display(); }
public function checkAccess() { //未登录 if (!IS_LOGIN) { go(U("Member/Login/login")); } //状态 if (!USER_STATE) { $this->error('帐号审核中...'); } //锁定 if (IS_LOCK) { $this->error('帐号已锁定...'); } //管理员 if (WEB_MASTER || IN_ADMIN) { return true; } //会员中心关闭 if (C("MEMBER_OPEN") == 0) { $this->display("template/system/member_close.html"); exit; } //邮箱验证 if (C('MEMBER_EMAIL_VALIDATE') && $_SESSION['user_state'] == 0) { go(U('Member/Email/VaifyMail')); } return true; }
public function xiugai() { $mana = M('manager'); $name = session('username'); $ps = $mana->where("username='******'")->getField('password'); $error = ''; if (IS_POST) { if (intval(I('post.state')) === 1) { if (md5(I('post.opassword')) === $ps) { $initial = md5('123456'); $mana->where("username='******'")->setField('password', $initial); $this->success('初始化成功', U('index/index'), 2); } else { $error = '初始化失败,原密码输入错误'; $this->assign('error', $error); $this->display('Admin/index'); } } else { if (md5(I('post.opassword')) === $ps) { $nps = md5(I('post.npassword')); $mana->where("username='******'")->setField('password', $nps); $this->success('修改密码成功', U('index/index'), 2); } else { $error = '原密码输入错误,修改密码失败'; $this->assign('error', $error); $this->display('Admin/index'); } } } }
public function show() { $request['wd'] = urldecode(trim($_REQUEST['wd'])); $request['status'] = intval($_GET['status']); if (!empty($request['wd'])) { $where[C('db_prefix') . 'comment.ip'] = array('like', '%' . $request["wd"] . '%'); $where[C('db_prefix') . 'comment.content'] = array('like', '%' . $request["wd"] . '%'); $where[C('db_prefix') . 'user.username'] = array('like', '%' . $request["wd"] . '%'); $where[C('db_prefix') . 'video.title'] = array('like', '%' . $request["wd"] . '%'); $where['_logic'] = 'or'; } if ($request['status']) { $where[C('db_prefix') . 'comment.status'] = 0; } $join = C('db_prefix') . 'user on ' . C('db_prefix') . 'comment.uid = ' . C('db_prefix') . 'user.id'; //查询影片名称 $join_video = C('db_prefix') . 'video on ' . C('db_prefix') . 'comment.did = ' . C('db_prefix') . 'video.id'; $field = C('db_prefix') . 'comment.*,' . C('db_prefix') . 'user.id as userid,' . C('db_prefix') . 'user.username,' . C('db_prefix') . 'video.title'; $order = C('db_prefix') . 'comment.id desc'; $cm_count = $this->CommDB->field($field)->where($where)->join($join)->join($join_video)->count(); $cm_page = !empty($_GET['p']) ? intval($_GET['p']) : 1; $cm_page = get_cms_page_max($cm_count, C('web_admin_pagenum'), $cm_page); $cm_url = U('Admin-Comment/Show', array('status' => $request['status'], 'wd' => urlencode($request['wd']), 'p' => ''), false, false); $listpages = get_cms_page($cm_count, C('web_admin_pagenum'), $cm_page, $cm_url, '条评论'); $list_comment = $this->CommDB->field($field)->where($where)->join($join)->join($join_video)->order($order)->limit(C('web_admin_pagenum'))->page($cm_page)->select(); // $_SESSION['comment_reurl'] = $cm_url . $cm_page; $this->assign($listpages); $this->assign('wd', $request['wd']); $this->assign('list_comment', $list_comment); $this->display('./views/admin/comment_show.html'); }
public function insert() { C('TOKEN_ON', false); $db = D('Call'); $where['uid'] = $_SESSION['uid']; $where['token'] = $_SESSION['token']; $res = $db->where($where)->find(); if ($res == false) { $where['phone_account'] = $this->_post('phone_account', 'trim'); if (isset($_POST['phone_password'])) { $where['phone_password'] = $this->_post('phone_password', 'trim'); } if ($where['phone_account'] == false) { $this->error('标题必须填写'); } $id = $db->data($where)->add(); if ($id) { $this->success('添加成功', U('Call/index')); } else { $this->error('添加失败', U('Call/index')); } } else { $where['id'] = $res['id']; $where['phone_account'] = $this->_post('phone_account', 'trim'); if (isset($_POST['phone_password'])) { $where['phone_password'] = $this->_post('phone_password', 'trim'); } if ($db->save($where)) { $this->success('更新成功', U('Call/index')); } else { $this->error('更新失败', U('Call/index')); } } }
public function IndexAction() { $intro = M('config'); $map1[name] = "SYSTEM_FIRST_HEAVY"; $map2[name] = "SYSTEM_FIRST_COST"; $map3[name] = "SYSTEM_CONTINUE_HEAVY"; $map4[name] = "SYSYEM_CONTINUE_COST"; $map5[name] = "SYSTEM_PACKAGE_HEAVY"; $map6[name] = "SYSTEM_FREIGHT_EXPLAIN"; $firstHeavy = $intro->where($map1)->find(); $firstCost = $intro->where($map2)->find(); $continueHeavy = $intro->where($map3)->find(); $continueCost = $intro->where($map4)->find(); $packageHeavy = $intro->where($map5)->find(); $freightExplain = $intro->where($map6)->find(); $this->assign('firstHeavy', $firstHeavy); $this->assign('firstCost', $firstCost); $this->assign('continueHeavy', $continueHeavy); $this->assign('continueCost', $continueCost); $this->assign('packageHeavy', $packageHeavy); $this->assign('freightExplain', $freightExplain); $this->assign('urlUpdate', U('Update')); $TPL = T('Introduction@Weight/index'); $this->assign('YZRight', $this->fetch($TPl)); $this->display(YZ_TEMPLATE); }
public function chuanciquery() { if (IS_POST) { //注册用户 /* 检测验证码 */ if (!check_verify($verify)) { $this->error('验证码输入错误!'); } /* 检测密码 */ if ($password != $repassword) { $this->error('密码和重复密码不一致!'); } /* 调用注册接口注册用户 */ $User = new UserApi(); $uid = $User->register($username, $password, $email); if (0 < $uid) { //注册成功 //TODO: 发送验证邮件 $this->success('注册成功!', U('login')); } else { //注册失败,显示错误信息 $this->error($this->showRegError($uid)); } } else { //显示注册表单 $this->display(); } }
/** * 后台登陆控制器 */ public function login() { $arr = array('user_login' => I('user_login'), 'user_pass' => encrypt(I('user_pass'), C('ENCRYPTION_KEY')), 'remember-me' => I('remember-me')); //处理下次自动登录 if ($arr['remember-me'] == 1) { $account = $arr['user_login']; $ip = get_client_ip(0, true); $value = $account . '|' . $ip; $value = encrypt($value, C('ENCRYPTION_KEY')); @setcookie('remember-me', $value, time() + 7 * 24 * 3600, "/"); } $user = M('user')->where(array('user_login' => $arr['user_login']))->find(); $userinfo = D('user')->getInfo($user['id']); if ($user['user_status'] == 0) { $this->error('账号被禁用,请联系管理员...'); } if ($user['user_type'] != '管理员') { $this->error('无权限登录...'); } if (!$user || $user['user_pass'] != $arr['user_pass']) { $this->error('账号密码错误,请重试...'); } $data = array('id' => $user['id'], 'last_login_ip' => get_client_ip(0, true), 'last_login_time' => date("Y-m-d H:i:s")); $result = M('user')->save($data); if (!$result) { $this->error('登录失败,请重试...'); } session('uid', $user['id']); session('username', $userinfo['username']); session('last_login_time', $data['last_login_time']); session('last_login_ip', $data['last_login_ip']); $this->success('登陆成功', U('Index/index')); }
public function getLocation() { $action = U(MODULE_NAME . "/" . CONTROLLER_NAME . "/" . ACTION_NAME); $menu = config('menu'); $result = array(); foreach ($menu as $value) { if (in_array(CONTROLLER_NAME, $value['controller'])) { $result[] = array('name' => $value['name'], 'url' => U($value['module'] . '/' . $value['controller'][0] . '/index')); foreach ($value['items'] as $v) { if ($v['uri'] == CONTROLLER_NAME . '/' . ACTION_NAME) { $result[] = array('name' => $v['name'], 'url' => U($value['module'] . '/' . $v["uri"])); } } } } // dump_json_format($result); $res = array(); $count = count($result) - 1; foreach ($result as $key => $value) { if ($key < $count) { $a = sprintf('<a href="%s">%s</a><i class="fa fa-angle-right"></i>', $value['url'], $value['name']); } else { $a = $value['name']; $cls = ' class="active"'; } $res[] = sprintf('<li%s>%s</li>', $cls, $a); } return join('', $res); }
/** * 编辑 * @param $id 编辑id */ public function edit($id) { if (IS_POST) { //收集验证数据 if ($this->model->create() !== false) { //修改数据并保存到数据库 if ($this->model->save($this->usePostParams ? I('post.') : '') !== false) { $this->success('修改成功', U('index')); return; } } $this->error('操作失败' . show_model_error($this->model)); } else { //>>回显 //通过find查询出要编辑的一行 $rows = $this->model->find($id); //将数据分配到页面上 $this->assign($rows); $this->assign('meta_title', $this->meta_title); //查询数据 $this->_editGetTreeList(true, 'id,name,parent_id'); //展示视图页面 $this->display('edit'); } }
/** * 修改权限 */ public function rule_edit($id) { $model = D('Rule'); if (IS_POST) { if ($data = $model->create()) { //判断提交的父id是否是自己和自己的子分类 $id = I('post.id'); $data['ru_id'] = $id; if ($model->save($data) !== false) { $this->success('修改成功', U('rule_list')); exit; } else { $this->error($model->getError()); } } else { $this->error($model->getError()); } } $id = (int) $id; //取出要修改的分类的数据 $info = $model->find($id); $this->assign('id', $id); $this->assign('info', $info); $data = $model->order('ru_order')->where(array('ru_pid' => '0', 'ru_status' => '1'))->select(); $this->assign('data', $data); $this->display(); }
function add($pid = '') { if (IS_POST) { F('sys_menu_tree', null); $model = D('Menu'); $data = $model->create(); if ($data) { if ($model->add()) { $this->success(L('_ADD_SUCCESS_'), U('index')); } else { $this->error(L('_ADD_FAIL_')); } } else { $this->error($model->getError()); } } else { //$field=Api('Model/menuModel'); $field = get_model_attr('menu'); $this->assign('fieldarr', $field); $data = array(); if (!empty($pid)) { $data['pid'] = $pid; } $this->assign('data', $data); $this->assign('meta_title', '添加菜单'); $this->display('edit'); } F("sys_menu_tree", null); }