public function getGlobalPermissions($RoleID, $LimitToSuffix = '')
{
$RoleIDs = (array) $RoleID;
// Get the global permissions.
$Data = $this->SQL->select('*')->from('Permission p')->whereIn('p.RoleID', array_merge($RoleIDs, array(0)))->where('p.JunctionTable is null')->orderBy('p.RoleID')->get()->resultArray();
$this->_MergeDisabledPermissions($Data);
$Data = Gdn_DataSet::Index($Data, 'RoleID');
$DefaultRow = $Data[0];
unset($Data[0], $DefaultRow['RoleID'], $DefaultRow['JunctionTable'], $DefaultRow['JunctionColumn'], $DefaultRow['JunctionID']);
$DefaultRow = $this->StripPermissions($DefaultRow, $DefaultRow, $LimitToSuffix);
if ($RoleID) {
// When editing a role make sure the default permissions are false so as not to be misleading.
$DefaultRow = array_fill_keys(array_keys($DefaultRow), 0);
}
foreach ($RoleIDs as $ID) {
if (isset($Data[$ID])) {
$Data[$ID] = array_intersect_key($Data[$ID], $DefaultRow);
} else {
$Data[$ID] = $DefaultRow;
$Data[$ID]['PermissionID'] = null;
}
}
if (count($RoleIDs) === 1) {
return array_pop($Data);
} else {
return $Data;
}
}