function path_redirect_nodeapi in Path redirect 5
Same name and namespace in other branches
- 6 path_redirect.module \path_redirect_nodeapi()
File
- ./
path_redirect.module, line 545
Code
function path_redirect_nodeapi(&$node, $op, $arg) {
if (user_access('administer redirects')) {
switch ($op) {
case 'validate':
if (db_result(db_query("SELECT COUNT(rid) FROM {path_redirect} WHERE path = '%s' AND redirect != '%s' AND redirect != '%s'", $node->path_redirect_add, "node/{$node->nid}", $node->path))) {
form_set_error('path_redirect_add', t('The path is already redirected elsewhere.'));
}
break;
case 'load':
break;
case 'update':
case 'insert':
if ($node->path_redirect_add) {
path_redirect_save(array(
'path' => $node->path_redirect_add,
'redirect' => 'node/' . $node->nid,
'type' => 301,
));
}
break;
case 'delete':
break;
}
}
}