-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGroupsComponent.php
More file actions
36 lines (32 loc) · 1013 Bytes
/
GroupsComponent.php
File metadata and controls
36 lines (32 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* Groups Component
*
* @author Masaki Goto <go8ogle@gmail.com>
* @link http://www.netcommons.org NetCommons Project
* @license http://www.netcommons.org/license.txt NetCommons License
*/
App::uses('Component', 'Controller');
/**
* Group List Component
*
* @author Masaki Goto <go8ogle@gmail.com>
* @package NetCommons\Groups\Controller\Component
*/
class GroupsComponent extends Component {
/**
* グループ一覧・グループユーザを設定
*
* @param Controller $controller コントローラー
* @param array $query find条件
* @return void
*/
public function setGroupList(Controller $controller, $query = array()) {
$groups = $controller->Group->getGroupList($query);
$controller->set('groups', $groups);
$userIdArr = Hash::extract($groups, '{n}.GroupsUser.{n}.user_id');
$userIdArr = array_unique($userIdArr); // 重複した値をまとめる
$groupUsers = $controller->GroupsUser->getGroupUsers($userIdArr);
$controller->set('users', $groupUsers);
}
}