123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143 |
- <?php
- /**
- * 用户私信管理页面
- * @author zhouxuchen 2016-01-07
- */
- class RMessageController extends AdminController {
- public function actionIndex() {
- $status_option = Message::$status_option;
- $status = CommonFn::getComboboxData($status_option, 1, true, 100);
- $type_option = Message::$type_option;
- $type = CommonFn::getComboboxData($type_option, 'all', true, 'all');
- $data['status'] = $status;
- $data['type'] = $type;
- $this->render('index', $data);
- }
- public function actionList() {
- $params = CommonFn::getPageParams();
- $search = Yii::app()->request->getParam('search', '');
- $search_from = Yii::app()->request->getParam('search_from', '');
- $search_to = Yii::app()->request->getParam('search_to', '');
- $filter_start = Yii::app()->request->getParam('start', '');
- $filter_end = Yii::app()->request->getParam('end', '');
- $filter_status = intval(Yii::app()->request->getParam('status', 100));
- $filter_type = Yii::app()->request->getParam('type', 'all');
- $filter_is_kennel = intval(Yii::app()->request->getParam('is_kennel', 0));
- // 是否查看商家私信
- $kennel_manager_list = [];
- if ($filter_is_kennel) {
- $criteria = new EMongoCriteria();
- $criteria->status('==', 1);
- $managers = KennelManager::model()->findAll($criteria);
- foreach ($managers as $key => $item) {
- $kennel_manager_list[] = $item->user;
- }
- }
- $criteria = new EMongoCriteria($params);
- // 过滤系统通知
- $kefu_user = Yii::app()->params['kefu_user'];
- $sys_user = Yii::app()->params['sys_user'];
- $notin_user = [
- new MongoId($kefu_user),
- new MongoId($sys_user),
- ];
- $criteria->from_user('notin', $notin_user);
- $criteria->to_user('notin', $notin_user);
- if ($kennel_manager_list) {
- $criteria->from_user('in', $kennel_manager_list);
- $criteria->to_user('in', $kennel_manager_list);
- }
- if ($search != '') {
- $regex = new MongoRegex ('/'.$search.'/');
- $criteria->content('==', $regex);
- }
- if ($search_from != '') {
- if (CommonFn::isMongoId($search_from)) {
- $criteria->from_user('==', new MongoId($search_from));
- } else {
- $regex = new MongoRegex('/'.$search_from.'/');
- $criteria_from = new EMongoCriteria();
- $criteria_from->user_name('==', $regex);
- $cursor = RUser::model()->findAll($criteria_from);
- foreach ($cursor as $key => $eCursor) {
- $from_users[] = $eCursor->_id;
- }
- $criteria->from_user('in', $from_users);
- }
- }
- if ($search_to != '') {
- if (CommonFn::isMongoId($search_to)) {
- $criteria->to_user('==', new MongoId($search_to));
- } else {
- $regex = new MongoRegex('/'.$search_to.'/');
- $criteria_to = new EMongoCriteria();
- $criteria_to->user_name('==', $regex);
- $cursor = RUser::model()->findAll($criteria_to);
- foreach ($cursor as $key => $eCursor) {
- $to_users[] = $eCursor->_id;
- }
- $criteria->to_user('in', $to_users);
- }
- }
- if ($filter_status != 100) {
- $criteria->status('==', $filter_status);
- }
- if ($filter_start != '') {
- $start = strtotime($filter_start);
- $criteria->time('>=', $start);
- }
- if ($filter_end != '') {
- $end = strtotime($filter_end);
- $criteria->time('<=', $end);
- }
- if ($filter_type != 'all') {
- if ($filter_type == 'text') {
- $criteria->content('!=', '');
- } else if ($filter_type == 'image') {
- $criteria->pics('size', 1);
- } else if ($filter_type == 'voice') {
- $criteria->voice('exists', true);
- $criteria->voice('!=', array());
- } else if ($filter_type == 'video') {
- $criteria->video('exists', true);
- $criteria->video('!=', array());
- }
- }
- $cursor = Message::model()->findAll($criteria);
- // $total = $cursor->count();
- $total = 9999;
- $rows = CommonFn::getRowsFromCursor($cursor);
- $parsedRows = Message::model()->parse($rows);
-
- echo CommonFn::composeDatagridData($parsedRows, $total);
- }
- public function actionEdit() {
- $id = Yii::app()->request->getParam('id', '');
- $status = intval(Yii::app()->request->getParam('status', 1));
- $_id = new MongoId($id);
- $message = Message::get($_id);
- $message->status = $status;
- $success = $message->save();
- CommonFn::requestAjax($success, '', array());
- }
- }
|