function ad_groups_list in Advertisement 5
Same name and namespace in other branches
- 5.2 ad.module \ad_groups_list()
- 6.3 ad.module \ad_groups_list()
- 6 ad.module \ad_groups_list()
- 6.2 ad.module \ad_groups_list()
- 7 ad.module \ad_groups_list()
Return an array of all groups, or a specific group.
@object If FALSE, will return only name of group(s). If TRUE, will return full group object including ->name, ->description, and ->tid.
Parameters
$tid: If set to an integer >0, will only return group info about that specific group.
3 calls to ad_groups_list()
- ad_admin_statistics in ./
ad.module - ad_block in ./
ad.module - Drupal _block hook.
- ad_embed_admin_configure_settings in embed/
ad_embed.module - Module settings page.
File
- ./
ad.module, line 2387 - An advertising system for Drupal powered websites.
Code
function ad_groups_list($object = FALSE, $tid = NULL) {
static $groups = array();
static $names = array();
// Return the full group object(s).
if ($object) {
if (empty($groups)) {
$tids = taxonomy_get_tree(_ad_get_vid());
if (is_array($tids)) {
foreach ($tids as $group) {
$groups[$group->tid]->name = check_plain($group->name);
$groups[$group->tid]->description = check_plain($group->description);
$groups[$group->tid]->tid = $group->tid;
}
}
// Hard coded "default" group with tid of 0.
$groups[0]->name = t('default');
$groups[0]->description = t('The default ad group is comprised of all ads not assigned to any other ad group.');
$groups[0]->tid = 0;
}
// Return a specific group object.
if ((int) $tid) {
return $groups[$tid];
}
else {
return $groups;
}
}
else {
if (empty($names)) {
$tids = taxonomy_get_tree(_ad_get_vid());
if (is_array($tids)) {
foreach ($tids as $group) {
$names[$group->tid] = "{$group->name}";
}
}
// Hard coded "default" group with tid of 0.
$names[0] = t('default');
}
// Return a specific group name.
if ((int) $tid) {
return $names[$tid];
}
else {
return $names;
}
}
}