Created
May 8, 2013 18:15
-
-
Save joshuaadickerson/5542380 to your computer and use it in GitHub Desktop.
Refactor to use loadMemberGroups()
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function membergroupsById($group_id, $limit = 1, $detailed = false, $assignable = false, $protected = false) | |
{ | |
global $context; | |
if (!isset($group_id)) | |
return false; | |
if (empty($context['membergroups'])) | |
loadMemberGroups(); | |
$group_ids = is_array($group_id) ? $group_id : array($group_id); | |
$groups = array(); | |
foreach ($group_ids as $group) | |
{ | |
$id = (int) $group; | |
if (isset($context['memmbergroups'][$id]) && (!$protected || ($protected && $context['memmbergroups'][$id]['group_type'] != 1))) | |
$groups[$id] = $context['memmbergroups'][$id]; | |
} | |
if (is_array($group_id)) | |
return $groups; | |
else | |
return $groups[$group_id]; | |
} |
Author
joshuaadickerson
commented
May 8, 2013
- it needs to be refactored all around to get rid of the now extraneous parameters: $limit, $detailed, $assignable
- it should always return an array
- it should have a verb in there - getMembergroupsById()
- obviously with the changes it needs a new doc block
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment