function domain_taxonomy_load_term in Domain Taxonomy 6
Same name and namespace in other branches
- 7.3 domain_taxonomy.module \domain_taxonomy_load_term()
- 7 domain_taxonomy.module \domain_taxonomy_load_term()
4 calls to domain_taxonomy_load_term()
File
- ./
domain_taxonomy.module, line 23
Code
function domain_taxonomy_load_term(&$term) {
if (!isset($term->tid)) {
return;
}
// Append the domain grants to the term for editing.
$term->domains = array();
$term->domain_site = FALSE;
$result = db_query("SELECT gid, realm FROM {domain_taxonomy_access} WHERE tid = %d AND (realm = '%s' OR realm = '%s')", $term->tid, 'domain_id', 'domain_site');
while ($data = db_fetch_object($result)) {
// Transform the 0 to -1, since {domain_access} is unsigned.
$data->gid == 0 ? $gid = -1 : ($gid = $data->gid);
if ($data->realm == 'domain_id') {
$term->domains[$gid] = $gid;
if ($gid > 0) {
$domain = domain_lookup($gid);
$term->subdomains[] = $domain['sitename'];
}
else {
$term->subdomains[] = variable_get('domain_sitename', variable_get('site_name', 'Drupal'));
}
}
else {
if ($data->realm == 'domain_site') {
$term->domain_site = TRUE;
$term->subdomains[] = t('All affiliates');
}
}
}
if ($term->tid) {
$source = array();
$source = db_fetch_array(db_query("SELECT domain_id FROM {domain_taxonomy_source} WHERE tid = %d", $term->tid));
}
if (empty($source)) {
$term->domain_source = variable_get('domain_default_source', 0);
}
else {
$term->domain_source = $source['domain_id'];
}
}