public function getGroupPermissions($perm = null) { if (!isset($this->data['groups']) || !is_array($this->data['groups'])) { return array(); } elseif (!$perm) { return $this->data['groups']; } $groups = array(); foreach ($this->data['groups'] as $group => $gperm) { if ($gperm & $perm) { $groups[$group] = $gperm; } } return $groups; }