function similarterms_node_validate in Similar By Terms 7
Same name and namespace in other branches
- 6 similarterms.module \similarterms_node_validate()
Implements hook_node_validate().
File
- ./
similarterms.module, line 449 - Similar By Terms module displays a block with similar content based on taxonomy terms.
Code
function similarterms_node_validate($node, $form) {
if (!variable_get('similarterms_override_options', 0)) {
return;
}
foreach (similarterms_taxonomy_get_vocabularies() as $v) {
$vid = 'similarterms_vid_' . $v->vid;
$alias =& $node->{$vid};
// Make sure that the paths are valid
foreach ($alias['similarterms_paths'] as $id => $path) {
$pieces = explode('/', $path);
if (sizeof($pieces) == 2 && $pieces[0] == "node" && is_numeric($pieces[1])) {
// If there's a better way to check if a node exists, replace this code
$thisnode = node_load($pieces[1]);
if (!$thisnode->nid) {
form_set_error("{$vid}][similarterms_paths][{$id}", t('%path is not a valid path', array(
'%path' => $path,
)));
}
}
elseif ($path == '') {
continue;
}
elseif (!drupal_lookup_path('source', $path)) {
form_set_error("{$vid}][similarterms_paths][{$id}", t('%vocab %path is not a valid path', array(
'%path' => $path,
'%vocab' => $v->name,
)));
}
}
}
}