function hosting_alias_nodeapi in Hosting 5
Same name and namespace in other branches
- 6.2 alias/hosting_alias.module \hosting_alias_nodeapi()
Implementation of hook_nodeapi
File
- alias/
hosting_alias.module, line 118
Code
function hosting_alias_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
if ($node->type == 'site') {
switch ($op) {
case 'insert':
hosting_alias_insert($node);
break;
case 'update':
hosting_alias_update($node);
break;
case 'delete':
hosting_alias_delete($node);
break;
case 'delete revision':
hosting_alias_delete_revision($node);
break;
case 'validate':
$aliases = explode("\n", $node->aliases);
foreach ($aliases as $alias) {
if ($alias = trim($alias)) {
if (hosting_site_exists($alias, $node->nid)) {
form_set_error('aliases', t('The domain name @alias is already in use by another site', array(
'@alias' => $alias,
)));
}
}
}
break;
case 'load':
// Only retrieves custom aliases, as they are all that can be modified.
$additions['aliases'] = hosting_alias_get_aliases($node, HOSTING_ALIAS_CUSTOM);
return $additions;
break;
case 'view':
$aliases = hosting_alias_get_aliases($node);
if (sizeof($aliases)) {
foreach ($aliases as $link) {
$links[] = l($link, "http://{$link}");
}
$node->content['info']['aliases'] = array(
'#type' => 'item',
'#title' => t('Domain aliases'),
'#value' => implode(', ', $links),
'#weight' => 10,
);
}
break;
}
}
}