2012-04-11 67 views
0

我有一個group_id分配給用戶,但在我的用戶索引頁面我想知道屬於日誌用戶所屬的特定組的用戶。 目前其設置爲顯示所有用戶如何獲得基於組ID的列表

public function index() { 

          $this->User->recursive = 0; 
          $this->set('users', $this->paginate()); 
} 

我將如何改變這種

登錄:

public function login() { 
    if ($this->request->is('post')){ 
     if ($this->Auth->login()) { 
      $this->redirect($this->Auth->redirect()); 
     }else { 
      $this->Session->setFlash('Your username or password was incorrect.'); 
     } 
    } 
} 

感謝

+0

用戶如何登錄?來自acl的 – Wylie 2012-04-11 01:31:06

+0

。我 – Autolycus 2012-04-11 01:39:05

+0

增加登錄功能的問題 – Autolycus 2012-04-11 01:39:35

回答

2

爲了獲得在當前登錄用戶的GROUP_ID,更新index()動作包括:

public function index() { 

    // get logged in user info 
    $user = $this->Auth->user(); 
    $group_id = $user['group_id']; 

    // add pagination conditions 
    $this->paginate = array(
     'conditions' => array('User.group_id' => $group_id) 
    ); 
    $this->User->recursive = 0; 
    $this->set('users', $this->paginate('User')); 

} 

希望有所幫助。