Example #1
0
 public function getGroupMembers(array $params = array(), $limit = '')
 {
     $gid = $this->id;
     $model = new GroupMember();
     $criteria = new CDbCriteria();
     $criteria->condition .= " gid = :gid";
     $criteria->params[':gid'] = $gid;
     $criteria->order = !empty($params['order']) ? $params['order'] : 't.ctime';
     if (!empty($limit)) {
         $criteria->limit = $limit;
     }
     if (!empty($params)) {
         $array = array('status', 'level');
         foreach ($params as $key => $value) {
             if (in_array($key, $array)) {
                 $criteria->condition .= " and t.{$key}=:{$key}";
                 $criteria->params[':' . $key] = $value;
             }
         }
     }
     $pages = '';
     if (!empty($params['pageSize'])) {
         $pageSize = $params['pageSize'];
         $page = $params['page'];
         $_GET['page'] = $page;
         $total = $model->count($criteria);
         $pages = new CPagination($total);
         $pages->pageSize = $pageSize ? $pageSize : self::PAGE_SIZE;
         $pages->applyLimit($criteria);
     }
     $models = $model->with('user')->findAll($criteria);
     $data = array('members' => $models, 'pages' => $pages);
     return $data;
 }