Ejemplo n.º 1
0
 public function studentAdd($data = array())
 {
     if (!empty($data)) {
         $account_data['login_email'] = $data['login_email'];
         $account_data['login_pass'] = MD5(Crypt::encrypt(123456));
         //默认密码
         $account_data['account_type'] = 2;
         //默认账户类型
         $account_data['create_time'] = $data['create_time'];
         $account_data['modify_time'] = $data['modify_time'];
         $account_id = D('Account')->accountAdd($account_data);
         if ($account_id) {
             $data['account_id'] = $account_id;
             $bool = $this->data($data)->add();
             if ($bool) {
                 return array('status' => 'true', 'msg' => '新增学员成功', 'data' => $bool);
             } else {
                 // $bool = D('Account')->accountDelete(); to do ...
                 return array('status' => 'true', 'msg' => '新增学员失败', 'data' => $account_id);
             }
         } else {
             return array('status' => 'false', 'msg' => '学员Account添加失败');
         }
     }
 }
Ejemplo n.º 2
0
 public function resetAccount()
 {
     $data = I('post.');
     $acParam = array('pkid' => $data['acId'], 'login_email' => $data['email'], 'login_pass' => MD5(C('DATA_AUTH_KEY') . Crypt::encrypt(strtolower($data['password']))));
     /* $bool = D('Account')->checkMailUnique($acParam['login_email'],$acParam['pkid']);
        if(!$bool){
            exit(json_encode(array('status' => 'fail','msg' => '修改失败','email' => 'notunique')));
        } */
     $pwdRule = checkpass($data['password']);
     if (!$pwdRule) {
         exit(json_encode(array('status' => 'fail', 'msg' => '修改失败', 'pass_word' => 'notunique')));
     }
     $stParam = array('pkid' => $data['enId'], 'login_email' => $data['email']);
     //$result = D('Account')->data($acParam)->save();
     $this->StudentModel->data($stParam)->save();
     /*  if($result !== false){
             exit(json_encode(array('status' => 'success','msg' => '修改成功')));
         }else{
             exit(json_encode(array('status' => 'fail','msg' => '修改失败')));
         } */
 }
Ejemplo n.º 3
0
 /**
  * 获取文章详情
  * @author jry <*****@*****.**>
  */
 public function detail($id, $map = null)
 {
     //获取基础表信息
     $con = array();
     $con['id'] = $id;
     $con['status'] = array('egt', 1);
     // 正常、隐藏两种状态是可以访问的
     if ($map) {
         $con = array_merge($con, $map);
     }
     $info = $this->where($con)->find();
     if (!is_array($info)) {
         $this->error = '文章被禁用或已删除!';
         return false;
     }
     // 阅读量加1
     $result = $this->where(array('id' => $id))->SetInc('view');
     // 获取作者信息
     $info['user'] = get_user_info($info['uid']);
     // 获取发帖数量
     $info['user']['post_count'] = $this->where(array('uid' => $info['uid']))->count();
     // 获取文档模型相关信息
     $doc_type_info = D($this->moduleName . '/Type')->find($info['category_info']['doc_type']);
     if ($doc_type_info['system']) {
         $this->error = '文档类型错误!';
         return false;
     }
     $info['doc_type_info'] = $doc_type_info;
     // 根据文章模型获取扩展表的息
     $extend_table_object = D($this->moduleName . '/' . $this->moduleName . ucfirst($doc_type_info['name']));
     $extend_data = $extend_table_object->find($id);
     // 基础信息与扩展信息合并
     if (is_array($extend_data)) {
         $info = array_merge($info, $extend_data);
     }
     // 获取筛选字段
     $con = array();
     $con['id'] = array('in', $doc_type_info['filter_field']);
     $attribute_object = D($this->moduleName . '/Attribute');
     $filter_field_list = $attribute_object->where($con)->select();
     $new_filter_field_list = array();
     foreach ($filter_field_list as $key => $val) {
         $val['options'] = parse_attr($val['options']);
         $new_filter_field_list[$val['name']] = $val;
     }
     $info['filter_field_list'] = $new_filter_field_list;
     // 给文档主要字段赋值,如:文章标题、商品名称
     $type_main_field = $attribute_object->getFieldById($doc_type_info['main_field'], 'name');
     $info['main_field'] = $info[$type_main_field];
     // 下载文件地址加密
     if ($info['file']) {
         $file_list = explode(',', $info['file']);
         foreach ($file_list as &$file) {
             $file = D('Home/Upload')->find($file);
             $uid = is_login();
             if ($uid) {
                 $file['token'] = \Think\Crypt::encrypt($file['md5'], user_md5($uid), 3600);
             } else {
                 $file['token'] = 'please login';
             }
         }
         $info['file_list'] = $file_list;
     }
     // 获取上一篇和下一篇文章信息
     $info['previous'] = $this->getPrevious($info);
     $info['next'] = $this->getNext($info);
     return $info;
 }
Ejemplo n.º 4
0
 /**
  * 文章信息
  * @author jry <*****@*****.**>
  */
 public function detail($id)
 {
     $map['status'] = array('egt', 1);
     // 正常、隐藏两种状态是可以访问的
     $info = D('Article')->where($map)->detail($id);
     if (!$info) {
         $this->error('您访问的文档已禁用或不存在');
     }
     $result = D('Article')->where(array('id' => $id))->SetInc('view');
     // 阅读量加1
     // 获取文档所属分类详细信息
     $category_info = D('Category')->find($info['cid']);
     // 获取该分类绑定文档模型的主要字段
     $type_object = D('Type');
     $attribute_object = D('Attribute');
     $doc_type_info = $type_object->find($category_info['doc_type']);
     $type_main_field = $type_object->getFieldById($category_info['doc_type'], 'main_field');
     $type_main_field = $attribute_object->getFieldById($doc_type_info['main_field'], 'name');
     // 获取筛选字段
     $con = array();
     $con['id'] = array('in', $doc_type_info['filter_field']);
     $filter_field_list = $attribute_object->where($con)->select();
     $new_filter_field_list = array();
     foreach ($filter_field_list as $key => $val) {
         $val['options'] = parse_attr($val['options']);
         $new_filter_field_list[$val['name']] = $val;
     }
     // 给文档主要字段赋值,如:文章标题、商品名称
     $info['main_field'] = $info[$type_main_field];
     if ($info['file']) {
         $file_list = explode(',', $info['file']);
         foreach ($file_list as &$file) {
             $file = D('Home/Upload')->find($file);
             $uid = is_login();
             if ($uid) {
                 $file['token'] = \Think\Crypt::encrypt($file['md5'], user_md5($uid), 3600);
             } else {
                 $file['token'] = 'please login';
             }
         }
         $info['file_list'] = $file_list;
     }
     // 设置文档显示模版
     if (C('CURRENT_THEME')) {
         if ($category_info['detail_template']) {
             $template = 'article/' . $info['detail_template'];
         } else {
             $template = 'article/detail_default';
         }
     } else {
         $template = $category_info['detail_template'] ? 'Home/article/' . $category_info['detail_template'] : 'Home/article/detail_default';
     }
     // 获取作者信息
     $info['user'] = get_user_info($info['uid']);
     $this->assign('info', $info);
     $this->assign('_current_category', $category_info);
     $this->assign('_filter_field_list', $new_filter_field_list);
     $this->assign('_search_url', U('index', array('cid' => $category_info['id'])));
     // 构造搜索地址
     $this->assign('meta_title', $info['main_field']);
     $this->assign('meta_keywords', $info['tags'] ?: C('WEB_SITE_KEYWORD'));
     $this->assign('meta_description', $info['abstract'] ?: C('WEB_SITE_DESCRIPTION'));
     $this->assign('meta_cover', $info['cover']);
     Cookie('__forward__', $_SERVER['REQUEST_URI']);
     $this->display($template);
 }
Ejemplo n.º 5
0
 /**
  * 管理员信息更新
  * @author Martin.Cheng <*****@*****.**>
  */
 public function update()
 {
     if (IS_POST) {
         $id = I("post.user_id");
         $data['login_email'] = I('post.mail');
         $data['truename'] = I('post.username');
         $data['avatar'] = I('post.headpic');
         $data['mobile'] = I('post.mobile');
         $data['valid_status'] = I('post.status');
         $data['modify_time'] = $this->nowtime;
         $password = I('post.password');
         if (!empty($password)) {
             $data['login_pass'] = MD5(Crypt::encrypt(I('post.password')));
         }
         $bool = $this->AdminUserModel->adminUpdata($data, I("post.user_id"));
         if ($bool) {
             $this->redirect("AdminUser/index", '', 3, '修改成功');
         } else {
             $this->redirect("AdminUser/edit", array('id' => $id), 3, '修改失败');
         }
     }
 }
 /**
  * 文章信息
  * @author jry <*****@*****.**>
  */
 public function detail($id)
 {
     $map['status'] = array('egt', 1);
     //正常、隐藏两种状态是可以访问的
     $info = D('Document')->where($map)->detail($id);
     if (!$info) {
         $this->error('您访问的文档已禁用或不存在');
     }
     $result = D('Document')->where(array('id' => $id))->SetInc('view');
     //阅读量加1
     //获取文档所属分类详细信息
     $category_info = D('Category')->find($info['cid']);
     //获取该分类绑定文档模型的主要字段
     $document_type_object = D('DocumentType');
     $document_type_main_field = $document_type_object->getFieldById($category_info['doc_type'], 'main_field');
     $document_type_main_field = D('DocumentAttribute')->getFieldById($document_type_main_field, 'name');
     //给文档主要字段赋值,如:文章标题、商品名称
     $info['main_field'] = $info[$document_type_main_field];
     if ($info['file']) {
         $file_list = explode(',', $info['file']);
         foreach ($file_list as &$file) {
             $file = D('PublicUpload')->find($file);
             $uid = is_login();
             if ($uid) {
                 $file['token'] = \Think\Crypt::encrypt($file['md5'], user_md5($uid), 60);
             } else {
                 $file['token'] = 'please login';
             }
         }
         $info['file_list'] = $file_list;
     }
     //设置文档显示模版
     $template = $category_info['detail_template'] ? 'Document/' . $category_info['detail_template'] : 'Document/detail_default';
     $this->assign('info', $info);
     $this->assign('__CURRENT_CATEGORY__', $category_info['id']);
     $this->assign('meta_title', $info['main_field']);
     Cookie('__forward__', $_SERVER['REQUEST_URI']);
     $this->display($template);
 }