protected function getData($field, $order, $limit, $offset)
 {
     Wind::import('SRV:user.vo.PwUserSo');
     $so = new PwUserSo();
     $field['uids'] && $so->setUid($field['uids']);
     $field['gid'] != '-1' && $so->setGid($field['gid']);
     if ($field['gender']) {
         if (in_array(0, $field['gender']) && !in_array(1, $field['gender'])) {
             $so->setGender(0);
         } elseif (!in_array(0, $field['gender']) && in_array(1, $field['gender'])) {
             $so->setGender(1);
         }
     }
     $field['hometown']['id'] && $so->setHometown($field['hometown']['id']);
     $field['location']['id'] && $so->setLocation($field['location']['id']);
     $orderby = $field['orderby'];
     switch ($orderby) {
         case '2':
             //按主题数倒序,
             $so->orderbyPostnum(false);
             break;
         case '3':
             //按发帖时间倒序,
             $so->orderbyLastpost(false);
             break;
         case '4':
             //按被喜欢数倒序,
             break;
         case '5':
             //按注册时间倒序,
             $so->orderbyRegdate(false);
             break;
         case '6':
             // 按访问时间倒序,
             $so->orderbyLastvisit(false);
             break;
         case '1':
             //系统推荐排序
         //系统推荐排序
         default:
             break;
     }
     $list = Wekit::load('user.PwUserSearch')->searchUserAllData($so, $limit, $offset);
     return $this->_buildSignKey($list);
 }
Exemplo n.º 2
0
 public function run()
 {
     /* @var $groupDs PwUserGroups */
     $groupDs = Wekit::load('usergroup.PwUserGroups');
     $groups = $groupDs->getNonUpgradeGroups();
     $groups[0] = $this->upgradeGroups;
     ksort($groups);
     list($sName, $sUid, $sEmail, $sGroup, $page) = $this->getInput(array('username', 'uid', 'email', 'gid', 'page'));
     $vo = new PwUserSo();
     $sName && $vo->setUsername($sName);
     $sUid && $vo->setUid($sUid);
     $sEmail && $vo->setEmail($sEmail);
     !$sGroup || in_array(-1, $sGroup) || $vo->setGid($sGroup);
     $page = intval($page) == 0 ? 1 : abs(intval($page));
     /* @var $searchDs PwUserSearch */
     $searchDs = Wekit::load('SRV:user.PwUserSearch');
     $count = $searchDs->countSearchUser($vo);
     $result = array();
     if (0 < $count) {
         $totalPage = ceil($count / $this->pageNumber);
         $page > $totalPage && ($page = $totalPage);
         /* @var $searchDs PwUserSearch */
         $searchDs = Wekit::load('user.PwUserSearch');
         list($start, $limit) = Pw::page2limit($page, $this->pageNumber);
         $result = $searchDs->searchUser($vo, $limit, $start);
         if ($result) {
             /* @var $userDs PwUser */
             $userDs = Wekit::load('user.PwUser');
             $list = $userDs->fetchUserByUid(array_keys($result), PwUser::FETCH_DATA);
             $result = WindUtility::mergeArray($result, $list);
         }
     }
     $data = $vo->getData();
     (!$sGroup || in_array(-1, $sGroup)) && ($data['gid'] = array(-1));
     $this->setOutput($data, 'args');
     $this->setOutput($page, 'page');
     $this->setOutput($this->pageNumber, 'perPage');
     $this->setOutput($count, 'count');
     $this->setOutput($result, 'list');
     $this->setOutput($groups, 'groups');
 }
Exemplo n.º 3
0
 /**
  * do群发消息
  *
  * @return void
  */
 public function doSendAction()
 {
     list($type, $content, $title, $step, $countStep) = $this->getInput(array('type', 'content', 'title', 'step', 'countStep'));
     !$content && $this->showError('Message:content.empty');
     if ($step > $countStep) {
         $this->showMessage("ADMIN:success");
     }
     $step = $step ? $step : 1;
     switch ($type) {
         case 1:
             // 根据用户组
             list($user_groups, $grouptype) = $this->getInput(array('user_groups', 'grouptype'));
             Wind::import('SRV:user.vo.PwUserSo');
             $vo = new PwUserSo();
             $searchDs = Wekit::load('SRV:user.PwUserSearch');
             if (!$user_groups) {
                 $this->showError('Message:user.groups.empty');
             }
             if ($grouptype == 'memberid') {
                 $vo->setMemberid($user_groups);
             } else {
                 $vo->setGid($user_groups);
             }
             $count = $searchDs->countSearchUser($vo);
             $countStep = ceil($count / $this->perstep);
             if ($step <= $countStep) {
                 list($start, $limit) = Pw::page2limit($step, $this->perstep);
                 $userInfos = $searchDs->searchUser($vo, $limit, $start);
             }
             break;
         case 2:
             // 根据用户名
             $touser = $this->getInput('touser');
             !$touser && $this->showError('Message:receive.user.empty');
             $touser = explode(' ', $touser);
             $count = count($touser);
             $countStep = ceil($count / $this->perstep);
             if ($step <= $countStep) {
                 $userDs = Wekit::load('user.PwUser');
                 list($start, $limit) = Pw::page2limit($step, $this->perstep);
                 $userInfos = $userDs->fetchUserByName(array_slice($touser, $start, $limit));
             }
             break;
         case 3:
             // 根据在线用户(精确在线)
             $onlineService = Wekit::load('online.srv.PwOnlineCountService');
             list($count, $userInfos) = $onlineService->getVisitorList('', $step, $this->perstep, true);
             $countStep = ceil($count / $this->perstep);
             break;
     }
     $result = $this->sendNoticeByUsers((array) $userInfos, $content, strip_tags($title));
     if ($result instanceof PwError) {
         $this->showError($result->getError());
     }
     $haveBuild = $step * $this->perstep;
     $haveBuild = $haveBuild > $count ? $count : $haveBuild;
     $step++;
     usleep(500);
     $data = array('step' => $step, 'countStep' => $countStep, 'count' => $count, 'haveBuild' => $haveBuild);
     echo Pw::jsonEncode(array('data' => $data));
     exit;
 }