/** * @Author: 段涛 * @获取用户中心基本内容,如签到,最近访客,我的足迹 * @function name getSpaceInf * @param $userID */ public function getSpaceInf($userID) { //我的足迹 $footMark = M('footmark')->field('footName,footUrl')->where(array('uid' => $userID))->order('createTime DESC')->select(); change_lang($footMark, LANG_SET); $this->assign('myFoot', $footMark); //最近访客 $visitor = M("space_visitor")->field('vuid,vuserName,avatar,visitTime')->where(array('uid' => $userID))->order('id DESC')->limit(3)->select(); $this->assign('visitor', $visitor); //签到 $weekArray = array("周日", "周一", "周二", "周三", "周四", "周五", "周六"); $time['week'] = $weekArray[date("w")]; $time['m'] = date('m'); $time['d'] = date('d'); $this->assign('time', $time); //签到信息 $where['uid'] = $userID; $where['userName'] = session('userName'); $where['signTime'] = date('Ymd'); $model = M('Sign'); //判断是否签到 $sign = $model->field("id,totalNum,signTime,conNum")->where($where)->order('id DESC')->find(); if ($sign) { $status['status'] = '已签到'; $status['conNum'] = $sign['conNum']; $status['totalNum'] = $sign['totalNum'] . '天'; } else { $status['status'] = '签到'; } $this->assign('Registration', $status); //获取签到积分规则 $creditRule = M('creditrule')->where(array('action' => 'Registration'))->getField('credit'); $this->assign('creditRule', $creditRule); }
/** * 管理个人发布的推广和置顶信息 * @author wangyuan * @return void * @access public */ public function infoTop() { $userID = session('userID'); $avatar = session('avatar'); $content = array(); $model = M('ctg_data'); $where['a.userID'] = session('userID'); $where['_string'] = 'recommend=1 or isTop = 1'; $join = array('left join __CTG_CLASS__ as b on a.ctgClassID = b.ctgClassID', 'left join __CTG_CLASS__ as c on b.fctgClassID = c.ctgClassID', 'left join __CITY__ as d on a.cityID = d.fid'); $field = 'a.dataID, a.title,a.verify, a.recStartTime,a.recEndTime,a.topStartTime,a.topEndTime, a.isTop, a.recommend, concat(c.ctgClassName,"->", b.ctgClassName) as className, d.name as cityName'; $count = $model->alias('a')->where($where)->count(); $Page = new \Think\Page($count, 10); // 实例化分页类 传入总记录数和每页显示的记录数(25) $show = $Page->show(); // 分页显示; $content = $model->alias('a')->field($field)->join($join)->where($where)->order('a.editTime desc')->limit($Page->firstRow . ',' . $Page->listRows)->select(); change_lang($content, 'zh_cn'); $this->assign('avatar', $avatar); $this->assign('content', $content); $this->assign('page', $show); // 赋值分页输出 $this->display(); }
/** * 删除信息 * @author liuxiaolin <*****@*****.**> * @param int $dataID 信息的ID编号 * @return void */ public function del($id) { $dataID = (int) $id; if (empty($dataID)) { $errorTpl = '{{信息ID不正确|信息ID不正確}}'; change_lang($errorTpl, LANG_SET); $this->error($errorTpl); } //实例化ctg_data表,获得主表数据,同时得到模型ID $model = M('ctg_data'); $data = $model->where(array('dataID' => $dataID))->find(); //是否有删除权限 if ($_SESSION['userName'] !== $data['userName'] && $_SESSION['adminUserName'] !== 'admin') { $this->error('你没有权限删除', U('Ucenter/AdInfo/infoClass')); } $map = array('dataID' => $dataID); //获得副表模型 $fmodel = M('ctg_data' . $data['modID']); //获得收藏模型 $cmodel = M('user_collect'); //开启事务 $model->startTrans(); $res1 = $model->where($map)->delete(); $res2 = $fmodel->where($map)->delete(); if ($cmodel->where($map)->where(array('type' => 1))->count() != 0) { $res4 = $cmodel->where($map)->where(array('type' => 1))->delete(); if ($res1 !== FALSE && $res2 !== FALSE && $res4 !== FALSE) { M('Member')->where("uid={$_SESSION['userID']}")->setDec('ctgs'); $model->commit(); //信息数量减1 $this->success('删除成功', U('Ucenter/AdInfo/infoClass')); } else { $model->rollback(); $this->error('删除失败'); } } else { if ($res1 !== FALSE && $res2 !== FALSE) { M('Member')->where("uid={$_SESSION['userID']}")->setDec('ctgs'); $model->commit(); $this->success('删除成功', U('Ucenter/AdInfo/infoClass')); } else { $model->rollback(); $this->error('删除失败'); } } }
} break; default: $inc = $_SERVER['SRVROOT'] . "/cms/admin/plugin/index.php"; $current_plugin = $current; break; } $func = isset($_GET['func']) ? $_GET['func'] : ""; switch ($func) { case "logout": user_logout(); redirect(WEBROOT, 0, '您已登出'); break; case "set_lang": $lang = isset($_GET['lang']) ? $_GET['lang'] : DEFAULTLANG; change_lang($lang); break; default: break; } ob_start(); if ($cmsroot != "get_data") { include $header; ?> <script> $(function(){ $('#jsCheck').remove(); }); </script> <?php
public function classTotal() { //获取栏目名称 $class = M('ctg_class')->field('ctgClassName,ctgClassID,mark')->where(array('level' => 1, 'isDel' => 0))->select(); change_lang($class, 'zh_cn'); foreach ($class as &$v) { if ($v['mark'] == 1) { $v['ctgClassName'] = '英国->' . $v['ctgClassName']; } else { $v['ctgClassName'] = '美国->' . $v['ctgClassName']; } } //查询所有的社区资讯栏目 $sqClass = M('sq_class')->field('name,id')->order('id asc')->select(); $this->assign('sqClass', $sqClass); $this->assign('class', $class); //生成搜索条件 if (IS_POST) { //根据时间查询 $show['time'] = $time = I('post.time'); if ($time != "") { $time = explode('/', $time); $oneday_count = 3600 * 24; //一天有多少秒 if (count($time) == 1) { $where['postTime'] = array('between', array(strtotime($time[0]), time())); } else { $where['postTime'] = array('between', array(strtotime($time[0]), strtotime($time[1]) + $oneday_count)); } } //判断搜索栏目 $show['type'] = $type = I('post.type'); $show['totalPost'] = 0; $show['totalVisits'] = 0; $allSqList = array(); if ($type == '') { //搜索整个栏目 foreach ($class as $rs) { $where['ctgClassID'] = array('in', $this->getClassTree($rs['ctgClassID'])); $rs['visits'] = M('ctg_data')->where($where)->Sum('visits'); $rs['post'] = M('ctg_data')->where($where)->count(); $show['totalVisits'] += $rs['visits']; $show['totalPost'] += $rs['post']; $allList[] = $rs; } //获取社区资讯下面的所有信息 foreach ($sqClass as $a) { $map['sid'] = $a['id']; $map['postTime'] = $where['postTime']; $a['visits'] = M('sq_data')->where($map)->Sum('visits'); $a['post'] = M('sq_data')->where($map)->count(); $show['totalVisits'] += $a['visits']; $show['totalPost'] += $a['post']; $allSqList[] = $a; } //留学生招聘 $where3['creat_time'] = $where['postTime']; $show['totalVisits'] += $stu_job['visits'] = M('stu_job')->where($where3)->Sum('visits'); $show['totalPost'] += $stu_job['post'] = M('stu_job')->where($where3)->count(); $stu_job['ctgClassName'] = '社区资讯->留学生招聘'; $allList[] = $stu_job; } else { //搜索制定栏目 if ($type < 0) { $type = abs($type); //取type的绝对值 //搜索的是社区资讯的时候 $map['postTime'] = $where['postTime']; $map['sid'] = $type; $show['totalVisits'] = $allSqList[0]['visits'] = M('sq_data')->where($map)->Sum('visits'); $show['totalPost'] = $allSqList[0]['post'] = M('sq_data')->where($map)->count(); //查找社区资讯栏目名称 $info = M('sq_class')->field('name')->where("id={$type}")->find(); $allSqList[0]['name'] = $info['name']; } elseif ($type == 100) { //搜索的是留学生招聘的时候 $where2['creat_time'] = $where['postTime']; $show['totalVisits'] = $allList[0]['visits'] = M('stu_job')->where($where2)->Sum('visits'); $show['totalPost'] = $allList[0]['post'] = M('stu_job')->where($where2)->count(); $allList[0]['ctgClassName'] = '社区资讯->留学生招聘'; } else { //剩下的就是搜索分类栏目的时候 $where['ctgClassID'] = array('in', $this->getClassTree($type)); $show['totalVisits'] = $allList[0]['visits'] = M('ctg_data')->where($where)->Sum('visits'); $show['totalPost'] = $allList[0]['post'] = M('ctg_data')->where($where)->count(); $allList[0]['ctgClassName'] = M('ctg_class')->where(array('ctgClassID' => $type))->getField('ctgClassName'); $allList[0]['ctgClassID'] = $type; } } } $this->assign('show', $show); change_lang($allList, 'zh_cn'); $this->assign('list', $allList); $this->assign('allSqList', $allSqList); $this->display(); }