function ad_groups_list in Advertisement 6
Same name and namespace in other branches
- 5.2 ad.module \ad_groups_list()
- 5 ad.module \ad_groups_list()
- 6.3 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.
Parameters
$object: If FALSE, will return only name of group(s). If TRUE, will return full group object including ->name, ->description, and ->tid.
$tid: If set to an integer >0, will only return group info about that specific group.
4 calls to ad_groups_list()
- ad_admin_statistics in ./
ad.admin.inc - ad_block in ./
ad.module - Implementation of hook_block().
- ad_embed_admin_configure_settings in embed/
ad_embed.module - Module settings page.
- ad_group_load in ./
ad.module - Drupal menu wildcard Ad group loader
File
- ./
ad.module, line 1197 - 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 = $group->name;
$groups[$group->tid]->description = $group->description;
$groups[$group->tid]->tid = $group->tid;
$groups[$group->tid]->weight = $group->weight;
}
}
// 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;
$groups[0]->weight = 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;
}
}
}