/**
  * 重置密码验证
  * 包括邮件重置密码和短信重置密码都在这里统一验证
  * @param HttpRequest $request
  */
 public function password(HttpRequest $request)
 {
     $email = $request->getParameter('email', 'trim');
     $authcode = $request->getParameter('authcode', 'trim');
     $mobile = $request->getParameter('mobile', 'trim');
     $password = $request->getParameter('password', 'trim');
     $repass = $request->getParameter('repass', 'trim');
     $userid = $request->getParameter('userid', 'intval');
     if ($email != '') {
         $__authcode = getEmailCode($email, 7200);
     } else {
         if ($mobile != '') {
             $__authcode = getMobileCode($mobile, 600);
         }
     }
     if ($__authcode != $authcode) {
         AjaxResult::ajaxResult('error', '授权码错误');
     }
     if ($password != $repass) {
         AjaxResult::ajaxResult('error', '两次输入密码不一致');
     }
     $userService = Beans::get('user.user.service');
     if ($userService->set('password', md5(md5($password)), $userid)) {
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 添加媒体管理员角色操作
  * @param HttpRequest $request
  */
 public function insert(HttpRequest $request)
 {
     $data = $request->getParameter("data");
     $data["auth_time"] = time();
     $data["media_id"] = $this->loginMedia["id"];
     $data["status"] = 0;
     //如果邮箱已经注册过,则自动获取用户ID
     $userService = Beans::get('user.user.service');
     $user = $userService->getItem(array('email' => $data['email']), 'id');
     if ($user) {
         $data['userid'] = $user['id'];
     }
     $service = Beans::get($this->getServiceBean());
     $success = $service->add($data);
     if ($success) {
         //获取角色
         $roleService = Beans::get("media.managerRole.service");
         $role = $roleService->getItem($data['role_id']);
         $param = array('{role}' => $role['name'], '{id}' => $success);
         //发送邀请邀请邮件
         $emailService = Beans::get('common.email.service');
         $emailService->sendTemplateEmail($data['email'], 'manager_invitation_email', $param);
         AjaxResult::ajaxResult('ok', '已发送邮件到被邀请者邮箱中,请通知被邀请者2个小时内完成验证!');
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 登陆验证
  * @param HttpRequest $request
  */
 public function signin(HttpRequest $request)
 {
     $username = $request->getParameter('username');
     $password = $request->getParameter('password');
     $adminService = Beans::get('admin.admin.service');
     $CACHER = CacheFactory::create('file');
     $cacheKey = 'admin_loginTime_' . $username;
     $maxLoginTime = intval($CACHER->get($cacheKey, 0));
     //        if ( $maxLoginTime >= self::$LOGIN_FAIL_TIME ) {
     //            AjaxResult::ajaxResult(1, '您登录已经连续'.self::$LOGIN_FAIL_TIME.'次登录失败,帐号已被锁定,请联系管理员!');
     //        }
     $login = $adminService->login($username, $password);
     if ($login) {
         //登录成功,清空登录失败的记录
         $CACHER->set($cacheKey, 0);
         if ($login['status'] == 0) {
             AjaxResult::ajaxResult(1, '您的帐号已经被锁定,请联系管理员!');
         }
         AjaxResult::ajaxResult(0, '登录成功!');
     } else {
         //登录失败,记录用户登录失败次数
         $CACHER->set($cacheKey, $maxLoginTime + 1);
         if ($maxLoginTime + 1 >= 10) {
             //登录错误10次锁定帐号
             $adminService->sets('status', 0, array('username' => $username));
         }
         AjaxResult::ajaxResult(1, '登录失败,您还有' . (self::$LOGIN_FAIL_TIME - $maxLoginTime - 1) . '次登录机会!');
     }
 }
 /**
  * 获取爆料详情
  * @param HttpRequest $request
  */
 public function detail(HttpRequest $request)
 {
     $id = $request->getParameter('id', 'intval');
     $service = Beans::get($this->getServiceBean());
     $item = $service->getItem($id);
     if ($item) {
         AjaxResult::ajaxResult('ok', $item['content']);
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 发送邮件验证码
  * @param HttpRequest $request
  */
 public function sendEmailCode(HttpRequest $request)
 {
     //接收邮箱地址
     $email = $request->getParameter('email', 'urldecode|trim');
     //接收模板参数
     $template = $request->getParameter('template', 'trim');
     //获取模板参数
     $params = array();
     foreach ($request->getParameters() as $key => $value) {
         if (strpos($key, '_') !== 0) {
             continue;
         }
         //组合模板标签
         $key = '{' . ltrim($key, '_') . '}';
         $params[$key] = urldecode($value);
     }
     $service = Beans::get('common.email.service');
     $result = $service->sendTemplateEmail($email, $template, $params);
     if ($result) {
         AjaxResult::ajaxResult('ok', '邮件发送成功,请尽快登录邮箱验证!');
     } else {
         AjaxResult::ajaxResult('error', '邮件发送失败!');
     }
 }
Exemple #6
0
 /**
  * 获取过滤后的数据
  * @param $data
  * @return mixed
  */
 protected function loadFilterData(&$data)
 {
     $filterMap = $this->getFilterMap();
     if (empty($filterMap)) {
         return $data;
     }
     $error = null;
     $_data = Filter::loadFromModel($data, $filterMap, $error);
     if ($_data == false) {
         //如果开启了事物操作,则先回滚
         if ($this->inTransaction()) {
             $this->rollback();
         }
         AjaxResult::ajaxResult('error', $error);
     }
     return $_data;
 }
 /**
  * 快速保存
  * @param HttpRequest $request
  */
 public function update(HttpRequest $request)
 {
     $data = $request->getParameter("data");
     $ids = $request->getParameter("ids");
     $edit_id = $request->getParameter("edit_id", "intval");
     $service = Beans::get($this->getServiceBean());
     $counter = 0;
     if (empty($edit_id)) {
         foreach ($ids as $key => $val) {
             if ($service->update($data[$val], $val)) {
                 $counter++;
             }
         }
     } else {
         $service->update($data, $edit_id);
         $counter++;
     }
     //只要一条数据保存成功,则该操作成功
     if ($counter > 0) {
         AjaxResult::ajaxResult('ok', '保存成功!');
     } else {
         AjaxResult::ajaxResult('error', '保存失败!');
     }
 }
 /**
  * 邀请管理员登录
  * @param HttpRequest $request
  */
 public function inviteCheck(HttpRequest $request)
 {
     $username = $request->getParameter('username', 'trim');
     $password = $request->getParameter('password', 'trim');
     $authcode = $request->getParameter('authcode', 'trim');
     $email = $request->getParameter('email', 'trim');
     $mid = $request->getParameter('mid', 'intval');
     //管理员ID
     $__authcode = getEmailCode($email);
     if ($authcode != $__authcode) {
         AjaxResult::ajaxResult('error', "验证失败,邀请码错误或者失效!");
     }
     $userService = Beans::get('user.user.service');
     $errorMsg = null;
     $login = $userService->login($username, $password, $errorMsg);
     if ($login) {
         if ($login['ischeck'] == 2) {
             AjaxResult::ajaxResult('error', '您的帐号被封号,请联系管理员!');
         }
         $userService->setLoginUser($login);
         //更新管理员的授权状态
         $managerService = Beans::get('media.manager.service');
         $managerService->set('status', 1, $mid);
         AjaxResult::ajaxResult('ok', url('/user_ucenter_index'));
     } else {
         AjaxResult::ajaxResult('error', "验证失败,{$errorMsg}");
     }
 }
 /**
  * 关闭推荐位
  * @param HttpRequest $request
  */
 public function close(HttpRequest $request)
 {
     $id = $request->getParameter('id', 'intval');
     if ($id <= 0) {
         AjaxResult::ajaxFailtureResult();
     }
     $condi = array('position' => $id, 'media_id' => $this->loginMedia['id']);
     $service = Beans::get($this->getServiceBean());
     $item = $service->getItem($condi);
     if (!$item) {
         AjaxResult::ajaxFailtureResult();
     }
     if ($service->set('status', 0, $item['id'])) {
         AjaxResult::ajaxResult('ok', '关闭推荐位成功!');
     } else {
         AjaxResult::ajaxResult('error', '关闭推荐位失败!');
     }
 }
 /**
  * 更新文章操作
  * @param HttpRequest $request
  */
 public function update(HttpRequest $request)
 {
     $data = $request->getParameter('data');
     $data['update_time'] = time();
     //如果有标签则先插入标签
     $tag_bak = $request->getParameter('tag_bak', 'trim');
     if (trim($data['tags']) != $tag_bak) {
         $tagService = Beans::get('article.tags.service');
         $tags = explode(',', $data['tags']);
         $tagIds = array();
         foreach ($tags as $value) {
             //1.首先查看标签是否存在,如果存在则直接取其ID
             $item = $tagService->getItem("name='{$value}'", 'id');
             if ($item) {
                 $tagIds[] = $item['id'];
                 //不存在则加入新标签
             } else {
                 $id = $tagService->add(array('name' => $value));
                 if ($id > 0) {
                     $tagIds[] = $id;
                 }
             }
         }
         $data['tags'] = implode(',', $tagIds);
         //不更改标签
     } else {
         unset($data['tags']);
     }
     if (!$data) {
         AjaxResult::ajaxFailtureResult();
     }
     $id = $request->getParameter('id', 'intval');
     if ($id <= 0) {
         AjaxResult::ajaxResult('error', INVALID_ARGS);
     }
     if ($this->articleService->update($data, $id)) {
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 更新模板操作
  * @param HttpRequest $request
  */
 public function update(HttpRequest $request)
 {
     $data = $request->getParameter('data');
     $data['update_time'] = time();
     $id = $request->getParameter('id', 'intval');
     if ($id <= 0) {
         AjaxResult::ajaxResult('error', INVALID_ARGS);
     }
     //检验模板key唯一性
     $tkey_bak = $request->getParameter('tkey_bak', 'trim');
     if ($tkey_bak != trim($data['tkey'])) {
         $this->checkField('tkey', $data['tkey']);
     }
     $service = Beans::get($this->getServiceBean());
     if ($service->update($data, $id)) {
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 检验某个字段的值是否在数据库中存在,用于保持某个字段的唯一性
  * @param string $field 字段值
  * @param string $value 字段名
  */
 protected function checkField($field, $value)
 {
     $value = trim($value);
     $service = Beans::get($this->getServiceBean());
     $exists = $service->getItem(array($field => $value));
     if ($exists) {
         AjaxResult::ajaxResult('error', "{$value} 在数据库中已存在,请更换!");
     }
 }
 /**
  * 批量删除文章
  * @param HttpRequest $request
  */
 public function deletes(HttpRequest $request)
 {
     $ids = $request->getParameter("ids");
     if (empty($ids)) {
         AjaxResult::ajaxResult("error", "请选择要删除的文章");
     }
     $service = Beans::get($this->getServiceBean());
     $res = $service->deletes($ids);
     if ($res) {
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 重新绑定邮箱
  * @param HttpRequest $request
  */
 public function bindEmail(HttpRequest $request)
 {
     $email = $request->getParameter('email', 'trim');
     $password = $request->getParameter('password', 'trim');
     $authcode = $request->getParameter('authcode', 'trim');
     //验证登录密码
     $userService = Beans::get('user.user.service');
     $conditions = array('username' => $this->loginUser['username'], 'password' => md5(md5($password)));
     if ($userService->count($conditions) == 0) {
         AjaxResult::ajaxResult('error', '登录密码错误!');
     }
     //验证授权码
     $__authcode = getEmailCode($email, 1800);
     if ($__authcode != $authcode) {
         AjaxResult::ajaxResult('error', '授权码错误!');
     }
     $mediaService = Beans::get('media.media.service');
     $data = array('email' => $email);
     if ($mediaService->update($data, $this->loginUser['id'])) {
         $this->updateLoginMedia($data);
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 媒体新闻列表页
  * @param HttpRequest $request
  */
 public function medialist(HttpRequest $request)
 {
     $mediaTypeId = $request->getParameter('id', 'intval');
     $mediaTypeService = Beans::get('media.type.service');
     $mediaService = Beans::get('media.media.service');
     if ($this->getPage() == 1) {
         $mediaType = $mediaTypeService->getItems(null, 'id,name,tkey', 'sort_num ASC');
         foreach ($mediaType as $key => $value) {
             if (($mediaTypeId < 0 || empty($mediaTypeId)) && $value['tkey'] == 'qunmei') {
                 $mediaTypeId = $value['id'];
             }
             if ($value['id'] == $mediaTypeId) {
                 $mediaType[$key]['current'] = 'on';
                 if ($value['tkey'] == 'qunmei') {
                     $this->assign('css', 1);
                 }
             }
             $mediaType[$key]['url'] = url("/mobile_index_medialist/?id={$value['id']}");
         }
         $this->assign('mediaType', $mediaType);
         $conditions = array('media_type' => $mediaTypeId);
         $items = $mediaService->getItems($conditions, 'id,name,logo,intro', 'add_time DESC', $this->getPage(), $this->getPagesize());
         foreach ($items as $key => $value) {
             $items[$key][url] = url("/mobile_index_media/?id={$value['id']}");
             if ($value['logo'] == '') {
                 $items[$key]['logo'] = '/res/global/images/reception/mobile_default_180.jpg';
             }
         }
         $this->assign('items', $items);
         $this->assign('id', $mediaTypeId);
         $this->setView('index/medialist');
     } else {
         $conditions = array('media_type' => $mediaTypeId);
         $items = $mediaService->getItems($conditions, 'id,name,logo,intro', 'add_time DESC', $this->getPage(), $this->getPagesize());
         foreach ($items as $key => $value) {
             $items[$key][url] = url("/mobile_index_media/?id={$value['id']}");
             if ($value['logo'] == '') {
                 $items[$key]['logo'] = '/res/global/images/reception/mobile_default_180.jpg';
             }
         }
         if ($items) {
             AjaxResult::ajaxResult(1, 'success', $items);
         } else {
             AjaxResult::ajaxResult(0, 'error');
         }
     }
 }
 /**
  * 快速保存单文章
  * @param HttpRequest $request
  */
 public function quicksave(HttpRequest $request)
 {
     $ids = $request->getParameter("ids");
     $data = $request->getParameter("data");
     $service = Beans::get($this->getServiceBean());
     $c = 0;
     $data["update_time"] = time();
     foreach ($ids as $key => $val) {
         $service->update($data[$val], $val);
         $c++;
     }
     //只要一条数据保存成功,则该操作成功
     if ($c > 0) {
         AjaxResult::ajaxResult('ok', '保存成功!');
     } else {
         AjaxResult::ajaxResult('error', '保存失败!');
     }
 }
 /**
  * 第三方帐号微博登录返回的信息补全页面
  * @param HttpRequest $request
  */
 public function wbLogin(HttpRequest $request)
 {
     $code = $request->getParameter("code");
     if (!empty($code)) {
         //$url = "https://api.weibo.com/oauth2/access_token";
         $url = "https://api.weibo.com/oauth2/access_token?client_id=1725858045&client_secret=9ebb3937eefbb4cdeaf446a31e21b979&grant_type=authorization_code&redirect_uri=http://www.tuonews.com/wbLogin.php&code=" . $code;
         $httpWb = new HttpClient();
         $tokens = $httpWb->post($url);
         $tokenTmp = json_decode($tokens, true);
         $token = $tokenTmp["access_token"];
         //获取用户uid
         $url_uid = "https://api.weibo.com/oauth2/get_token_info";
         $uidds = $httpWb->post($url_uid, array("access_token" => $token));
         $uidtmp = json_decode($uidds, true);
         $uid = $uidtmp["uid"];
         //获取用户信息
         $url_user = "******" . $token . "&uid=" . $uid;
         $usertmp = file_get_contents($url_user);
         $userInfo = json_decode($usertmp, true);
         //如果openid在数据库中存在,则说明已经用这个账号注册过,直接跳转到登陆页面即可
         $userService = Beans::get('user.user.service');
         $openInfo = $userService->getItem("wb_openid = '{$userInfo["id"]}'", "*");
         if (!empty($openInfo)) {
             //登录成功,清空登录失败的记录
             if ($openInfo['ischeck'] == 2) {
                 AjaxResult::ajaxResult('error', '您的帐号被封号,请联系管理员!');
             }
             $userService->setLoginUser($openInfo);
             $this->location(url('/user_ucenter_profile'));
         }
         $this->assign("wbsign", true);
         $this->assign("userwbInfo", $userInfo);
         $this->setView("login_other");
     } else {
         echo "授权出错,请重新授权";
     }
 }
 /**
  * 批量封号
  * @param HttpRequest $request
  */
 public function abort(HttpRequest $request)
 {
     $ids = $request->getParameter('ids');
     $service = Beans::get($this->getServiceBean());
     if ($service->sets('ischeck', 2, $ids)) {
         AjaxResult::ajaxResult('ok', '保存成功!');
     } else {
         AjaxResult::ajaxResult('error', '保存失败!');
     }
 }
 /**
  * 修改密码
  * @param HttpRequest $request
  */
 public function password(HttpRequest $request)
 {
     $oldpass = $request->getParameter('oldpass', 'trim');
     $password = $request->getParameter('password', 'trim');
     $repass = $request->getParameter('repass', 'trim');
     $adminService = Beans::get($this->getServiceBean());
     if ($password != $repass) {
         AjaxResult::ajaxResult('error', '两次输入的密码不一致!');
     }
     //确认原密码是否正确
     $item = $adminService->getItem("password='******'");
     if (!$item) {
         AjaxResult::ajaxResult('error', '原密码错误!');
     }
     //更新密码
     $data = array('password' => md5(md5($password)));
     if ($adminService->update($data, $this->loginUser['id'])) {
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 媒体添加操作
  * @param HttpRequest $request
  */
 public function mediaAdd(HttpRequest $request)
 {
     $data = $request->getParameter('data');
     $data['userid'] = $this->loginUser['id'];
     $data['add_time'] = time();
     $data['name'] = $data['nickname'];
     $service = Beans::get('media.media.service');
     $conditions['userid'] = $this->loginUser['id'];
     $conditions = array('userid' => $this->loginUser['id'], 'ischeck' => '#IN 0,1');
     $num = $service->count($conditions);
     if ($num > 0) {
         AjaxResult::ajaxResult('bug', '会员登记不够或您尚未开通该服务,等级功能稍后开放(或联系客服开通服务)');
     }
     if ($service->add($data)) {
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 删除数据
  * @param HttpRequest $request
  */
 public function delete(HttpRequest $request)
 {
     $id = $request->getParameter('id', 'intval');
     if ($id <= 0) {
         AjaxResult::ajaxResult('error', INVALID_ARGS);
     }
     $service = Beans::get($this->getServiceBean());
     if ($service->delete($id)) {
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
Exemple #22
0
 /**
  * 检验邮箱
  * @param HttpRequest $request
  */
 public function email(HttpRequest $request)
 {
     $email = $request->getParameter('data');
     AjaxResult::ajaxResult('ok', "邮箱{$email}已经存在!");
 }
 /**
  * 获取指定分组的一级菜单
  * @param HttpRequest $request
  */
 public function getTopMemnu(HttpRequest $request)
 {
     $groupkey = $request->getParameter('groupkey', 'trim');
     $menuService = Beans::get('admin.menu.service');
     $items = $menuService->getItems("pid=0 AND groupkey='{$groupkey}'", null, "sort_num ASC");
     if (!empty($items)) {
         AjaxResult::ajaxResult('ok', $items);
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 金融服务报名
  * @param HttpRequest $request
  */
 public function financeApply(HttpRequest $request)
 {
     $name = $request->getParameter("name", "trim");
     $mobile = $request->getParameter("mobile", "trim");
     if (!$name || !$mobile) {
         AjaxResult::ajaxResult("0", "error", array("msg" => "姓名和电话不能为空", "msgcode" => "3"));
     }
     $data['name'] = $name;
     $data['mobile'] = $mobile;
     $data['addtime'] = time();
     $financeService = Beans::get('common.finance.service');
     $res = $financeService->get(array("mobile" => $mobile));
     if ($res) {
         AjaxResult::ajaxResult("0", "error", array("msg" => "此号码已经报名了", "msgcode" => '3'));
     }
     if ($financeService->add($data)) {
         AjaxResult::ajaxResult('1', 'success', array('msg' => '您已提交成功!客服将在1-3个工作日内给予回复', 'msgcode' => '1'));
     } else {
         AjaxResult::ajaxResult('0', 'error', array('msg' => '操作失败', 'msgcode' => '2'));
     }
 }
 /**
  * 物理删除文章
  * @param HttpRequest $request
  */
 public function deletes(HttpRequest $request)
 {
     $ids = $request->getParameter('ids');
     if (count($ids) == 0) {
         AjaxResult::ajaxResult('error', '您没有删除任何记录!');
     }
     $service = Beans::get($this->getServiceBean());
     if ($service->deletes($ids)) {
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 取消订阅标签
  * @param HttpRequest $request
  */
 public function unorder(HttpRequest $request)
 {
     $id = $request->getParameter('id', 'intval');
     $orderService = Beans::get('article.tags.order');
     $userService = Beans::get('user.user.service');
     $loginUser = $userService->getLoginUser();
     if ($loginUser) {
         $condi = array('userid' => $loginUser['id'], 'tagid' => $id);
         if ($orderService->deletes($condi)) {
             AjaxResult::ajaxResult(1, 'off');
         } else {
             AjaxResult::ajaxResult(0, 'error');
         }
     } else {
         AjaxResult::ajaxResult(0, 'login');
     }
 }
 /**
  * 裁剪图片
  * @param HttpRequest $request
  */
 public function crop(HttpRequest $request)
 {
     $x = $request->getParameter('x', 'intval');
     $y = $request->getParameter('y', 'intval');
     $w = $request->getParameter('w', 'intval');
     $h = $request->getParameter('h', 'intval');
     $_w = $request->getParameter('_w', 'intval');
     $_h = $request->getParameter('_h', 'intval');
     $src = $request->getParameter('src', 'trim');
     //$overwrite = $request->getParameter('overwrite', 'intval');
     $overwrite = 1;
     //裁剪图片
     $imgSrc = rtrim(APP_ROOT, '/') . $src;
     $position = array($x, $y);
     $size = array($w, $h);
     $thumb = ImageThumb::getInstance();
     $thumb->setFlag(0);
     $result = $thumb->crop($position, $size, $imgSrc, null, $overwrite);
     if ($result != false) {
         //如果传入了固定大小,则强制将图片缩放成指定大小
         if ($_w > 0 && $_h > 0) {
             $sizeNew = array($_w, $_h);
             $outfile = str_replace(implode('x', $size), implode('x', $sizeNew), $result);
             $thumb->makeThumb($sizeNew, $result, $outfile);
             //@unlink($result);
         }
         AjaxResult::ajaxResult(1, '裁剪成功!');
     } else {
         AjaxResult::ajaxResult(0, '裁剪失败!');
     }
 }
 public function chanelJson(HttpRequest $request)
 {
     $id = $request->getParameter('id', 'intval');
     if ($id < 0) {
         AjaxResult::ajaxFailtureResult();
     }
     $conditions = array('media_chanel' => $id, 'media_id' => $this->mediaId);
     $items = $this->getArticles($conditions, 'id,thumb,title,media_id,add_time,chanel_id,bcontent');
     foreach ($items as $key => $value) {
         $items[$key]['thumb'] = getImageThumb($value['thumb'], '90x63');
     }
     if ($items) {
         AjaxResult::ajaxResult(1, 'success', $items);
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 更新权限
  * @param HttpRequest $request
  */
 public function updatePermission(HttpRequest $request)
 {
     $id = $request->getParameter('id', 'intval');
     $data = $request->getParameter('data');
     if ($id <= 0) {
         AjaxResult::ajaxResult('error', INVALID_ARGS);
     }
     $service = Beans::get($this->getServiceBean());
     $data = cn_json_encode($data);
     if ($service->set('permissions', $data, $id)) {
         $adminService = Beans::get('admin.admin.service');
         $adminService->updateUserPermission($this->loginUser);
         AjaxResult::ajaxSuccessResult();
     } else {
         AjaxResult::ajaxFailtureResult();
     }
 }
 /**
  * 获取更多详情页评论
  * @param HttpRequest $request
  */
 public function ajaxCommentMore(HttpRequest $request)
 {
     $page = $request->getParameter('curpage', 'intval');
     $aid = $request->getParameter('aid', 'intval');
     $page++;
     $commentService = Beans::get('article.service.comment');
     //第一级评论
     $firstLevelcommentList = $commentService->getComment($aid, $page);
     if (!$firstLevelcommentList) {
         AjaxResult::ajaxResult('0', 'error', array('msg' => '没有了', 'msgcode' => '1'));
     }
     $pidList = array();
     foreach ($firstLevelcommentList as $val) {
         array_push($pidList, $val['pid']);
     }
     //上一级评论
     $secondLevelCommentList = $commentService->getCommentsById($pidList);
     $users = array();
     $firstLevel = array();
     //以评论id为键
     $secondLevel = array();
     foreach ($firstLevelcommentList as $val) {
         array_push($users, $val['uid']);
         $firstLevel[$val['id']] = $val;
     }
     foreach ($secondLevelCommentList as $val) {
         array_push($users, $val['uid']);
         $secondLevel[$val['id']] = $val;
     }
     $users = array_unique($users);
     $userService = Beans::get('user.user.service');
     $usersTmp = $userService->getUsers($users);
     foreach ($usersTmp as $val) {
         $users[$val['id']] = $val;
     }
     $requestData = array("firstLevel" => $firstLevel, "secondLevel" => $secondLevel, "users" => $users);
     AjaxResult::ajaxResult('1', 'success', $requestData);
 }