public static function getGroupsForDropDown($profileId, $includeId = null)
{
// init db
$db = BackendModel::getContainer()->get('database');
// get groups already linked but don't include the includeId
if ($includeId !== null) {
$groupIds = (array) $db->getColumn('SELECT group_id
FROM profiles_groups_rights
WHERE profile_id = ? AND id != ?', array($profileId, $includeId));
} else {
$groupIds = (array) $db->getColumn('SELECT group_id
FROM profiles_groups_rights
WHERE profile_id = ?', (int) $profileId);
}
// get groups not yet linked
return (array) $db->getPairs('SELECT id, name
FROM profiles_groups
WHERE id NOT IN(\'' . implode('\',\'', $groupIds) . '\')');
}