/** * 用户信息信息保存 * @param $uid int user_id */ public function profileHandle($uid) { $this->_checkCurrentUser($uid); $UserLogic = new UserLogic(); $post_data = I('post.'); $res = $UserLogic->update($uid, $post_data); $this->array2Response($res); }
/** * +---------------------------------------------------------- * 游客列表 * +---------------------------------------------------------- */ public function guestList($limit = 0) { $where = array("user_level" => '5'); $UserLogic = new UserLogic(); $res = $UserLogic->selectWithPostsCount($limit, true, $where); foreach ($res as $k => $v) { $res[$k]['user_status'] = $v['user_status'] == 1 ? "启用" : "禁用"; } return $res; }
/** * */ public function guest() { $page = I('get.page', C('PAGER')); $UserLogic = new UserLogic(); $where = array("user_level" => array('eq', 5)); $count = $UserLogic->where($where)->count(); if ($count != 0) { $Page = new GreenPage($count, $page); // 实例化分页类 传入总记录数 $pager_bar = $Page->show(); $limit = $Page->firstRow . ',' . $Page->listRows; $list = D('Access', 'Logic')->guestList($limit); } $this->assign('pager', $pager_bar); $this->assign('listname', '游客用户'); $this->assign('list', $list); $this->display('userlist'); }
/** * */ public function addUserHandle() { $UserLogic = new UserLogic(); $user_login = htmlspecialchars(trim($_POST['user_login'])); $userDetail = $UserLogic->detailByUserlogin($user_login); if ($userDetail != '') { $this->error('用户名已存在!'); } else { // 组合用户信息并添加 $user = array('user_login' => I('post.user_login'), 'user_nicename' => I('post.user_nicename'), 'user_pass' => encrypt(I('post.password')), 'user_email' => I('post.user_email'), 'user_url' => I('post.user_url'), 'user_intro' => I('post.user_intro'), 'user_status' => I('post.user_status'), 'user_level' => I('post.role_id')); // 添加用户与角色关系 $res = $UserLogic->addUser($user); $this->array2Response($res); } }
/** * 注册用户 * @param $username * @param $nickname * @param $password * @param $email * @return string */ public function register($username, $nickname, $password, $email) { $new_user_role = get_opinion('new_user_role', true, 5); $new_user_statue = get_opinion('new_user_statue', true, 1); $User = new UserLogic(); $userDetail = $User->where(array('user_login' => $username))->select(); if ($userDetail != '') { return $this->jsonResult(0, "用户名已存在"); } else { // 组合用户信息并添加 $newUserDetail = array('user_login' => $username, 'user_nicename' => $nickname, 'user_pass' => encrypt($password), 'user_email' => $email, 'user_status' => $new_user_statue); // 添加用户与角色关系 $newUserDetail['user_level'] = $new_user_role; $Role_users = D('Role_users'); if ($new_id = $User->add($newUserDetail)) { $role = array('role_id' => $new_user_role, 'user_id' => $new_id); if ($Role_users->add($role)) { return $this->jsonResult(1, "注册成功!", U('Admin/Access/index')); } else { return $this->jsonResult(0, "注册成功,添加用户权限失败!"); } } else { return $this->jsonResult(0, "注册用户失败"); } } }
public function count() { $year = I('request.year', date('Y')); $month_start = I('request.month_start', date('m')); $month_end = I('request.month_end', date('m')); if ($month_start == $month_end) { $condition['post_date'] = array('like', I('request.year', '%') . '-' . I('request.month', '%') . '-' . I('request.day', '%') . '%'); } else { if ($month_start == '%%') { $condition['post_date'] = array('between', "{$year}-0-0,{$year}-{$month_end}-31"); } else { if ($month_end == '%%') { $condition['post_date'] = array('between', "{$year}-{$month_start}-0,{$year}-12-31"); } else { $condition['post_date'] = array('between', "{$year}-{$month_start}-0,{$year}-{$month_end}-31"); } } } $UserLogic = new UserLogic(); $PostsLogic = new PostsLogic(); $user_list = $UserLogic->getList(false); foreach ($user_list as $key => $user) { $condition['user_id'] = $user['user_id']; $user_list[$key]['post_count'] = $PostsLogic->countAll('single', $condition); $user_list[$key]['date'] = substr($condition['post_date'][1], 0, 7); } $this->assign("user_list", $user_list); $this->assign("year", $year); $this->assign("month_start", $month_start); $this->assign("month_end", $month_end); $this->display('count'); }
/** * 列表显示,包括page和single * @param string $post_type 文章类型 * @param string $post_status 文章状态 * @param string $order 顺序 * @param string $keyword 搜索关键词 * @param string $tpl 模板名称 * @param string $name */ public function index($post_type = 'single', $post_status = 'publish', $order = 'post_date desc', $keyword = '', $tpl = 'index_no_js', $name = '', $uid = 0) { $CatsLogic = new CatsLogic(); $TagsLogic = new TagsLogic(); $key = ''; //获取get参数 $cat = I('get.cat'); $tag = I('get.tag'); $page = I('get.page', get_opinion('PAGER')); $where = array('post_status' => $post_status); $where['post_content|post_title'] = array('like', "%{$keyword}%"); $post_ids = array(); if ($uid != 0 && $this->noVerify()) { $where['user_id'] = $uid; $UserLogic = new UserLogic(); $user_info = $UserLogic->detail($uid); $key .= $user_info["user_nicename"] . ' 的'; } //投稿员只能看到自己的 if (!$this->noVerify()) { $where['user_id'] = get_current_user_id(); } //处理详细信息 搜索,指定TAG CAT文章 if ($cat != '') { $post_ids = $CatsLogic->getPostsIdWithChildren($cat); $post_ids = empty($post_ids) ? array('post_id' => 0) : $post_ids; $cat_detail = $CatsLogic->detail($cat); $cat = '关于分类 ' . $cat_detail['cat_name'] . ' 的'; } else { if ($tag != '') { $post_ids = $TagsLogic->getPostsId($tag); $post_ids = empty($post_ids) ? array('post_id' => 0) : $post_ids; $tag_detail = $TagsLogic->detail($tag); $tag = '关于标签' . $tag_detail['tag_name'] . ' 的'; } else { if ($keyword != '') { $key .= '关于' . $keyword . ' 的'; } } } $PostsLogic = new PostsLogic(); $count = $PostsLogic->countAll($post_type, $where, $post_ids); // 查询满足要求的总记录数 if ($count != 0) { $Page = new GreenPage($count, $page); // 实例化分页类 传入总记录数 $pager_bar = $Page->show(); $limit = $Page->firstRow . ',' . $Page->listRows; $posts_list = $PostsLogic->getList($limit, $post_type, $order, true, $where, $post_ids); } $cats = $CatsLogic->category(); $tags = $TagsLogic->select(); $this->assign("cats", $cats); $this->assign("tags", $tags); $this->assign('post_type', $post_type); $this->assign('action', $name . $key . $cat . $tag . get_real_string($post_type) . '列表'); $this->assign('posts', $posts_list); $this->assign('pager', $pager_bar); $this->display($tpl); }