git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@797 97e9348a-65ac-dc4b-aefc-98561f571b83
38 lines
871 B
PHP
38 lines
871 B
PHP
<?php
|
|
class Membership extends AppModel {
|
|
|
|
var $belongsTo =
|
|
array('User',
|
|
'Site',
|
|
'Group'
|
|
);
|
|
|
|
function memberGroups($user_id, $site_id) {
|
|
$this->prEnter(compact('user_id', 'site_id'));
|
|
|
|
$this->cacheQueries = true;
|
|
$groups = $this->find('all', array
|
|
('recursive' => -1,
|
|
'fields' => array('group_id'),
|
|
'conditions' => array(array('user_id' => $user_id),
|
|
array('site_id' => $site_id)),
|
|
));
|
|
$this->cacheQueries = false;
|
|
|
|
if (empty($groups))
|
|
return $this->prReturn(null);
|
|
|
|
$group_ids = array();
|
|
foreach ($groups AS $group)
|
|
$group_ids[] = $group['Membership']['group_id'];
|
|
|
|
return $this->prReturn($group_ids);
|
|
}
|
|
|
|
function memberOf($user_id, $site_id) {
|
|
$groups = $this->memberGroups($user_id, $site_id);
|
|
return (!empty($groups));
|
|
}
|
|
|
|
}
|