function similarterms_node_validate in Similar By Terms 6
Same name and namespace in other branches
- 7 similarterms.module \similarterms_node_validate()
Function to validate entries into the overrides table
1 call to similarterms_node_validate()
- similarterms_nodeapi in ./
similarterms.module - Implementation of hook_nodeapi().
File
- ./
similarterms.module, line 506 - Similar By Terms module displays a block with similar content based on taxonomy terms.
Code
function similarterms_node_validate($node) {
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,
)));
}
}
}
}