git-svn-id: file:///svn-source/pmgr/branches/pre_0.1_work_20090819@797 97e9348a-65ac-dc4b-aefc-98561f571b83
39 lines
983 B
PHP
39 lines
983 B
PHP
<?php
|
|
class Group extends AppModel {
|
|
|
|
var $hasMany =
|
|
array('GroupOption',
|
|
'Membership',
|
|
);
|
|
|
|
var $knows =
|
|
array('User',
|
|
'Site',
|
|
);
|
|
|
|
static $current_group_ids;
|
|
function currentGroupIds() {
|
|
if (empty(self::$current_group_ids))
|
|
self::$current_group_ids = $this->groupIds();
|
|
|
|
if (empty(self::$current_group_ids))
|
|
// We must force a stop here, since this is typically
|
|
// called very early on, and so will cause a recursive
|
|
// crash as we try to render the internal error and
|
|
// again stumble on this problem.
|
|
$this->INTERNAL_ERROR('INVALID MEMBERSHIP', 0, true);
|
|
|
|
return self::$current_group_ids;
|
|
}
|
|
|
|
function groupIds($user_id = null, $site_id = null) {
|
|
if (empty($user_id))
|
|
$user_id = $this->User->currentUserId();
|
|
if (empty($site_id))
|
|
$site_id = $this->Site->currentSiteId();
|
|
|
|
return $this->Membership->memberGroups($user_id, $site_id);
|
|
}
|
|
|
|
}
|