function views_handler_filter_user_relationships_type::validate_type_strings in User Relationships 6
Same name and namespace in other branches
- 7 user_relationship_views/views_handler_filter_user_relationships_type.inc \views_handler_filter_user_relationships_type::validate_type_strings()
Validate the relationship type string. Since this can come from either the form or the exposed filter, this is abstracted out a bit so it can handle the multiple input sources.
2 calls to views_handler_filter_user_relationships_type::validate_type_strings()
- views_handler_filter_user_relationships_type::exposed_validate in user_relationship_views/
views_handler_filter_user_relationships_type.inc - views_handler_filter_user_relationships_type::value_validate in user_relationship_views/
views_handler_filter_user_relationships_type.inc
File
- user_relationship_views/
views_handler_filter_user_relationships_type.inc, line 79 - User Relationships Views integration. Filter handler for relationship types, with autocomplete for type names. Modeled after views_handler_filter_user_name. @author Alex Karshakevich http://drupal.org/user/183217
Class
- views_handler_filter_user_relationships_type
- @file User Relationships Views integration. Filter handler for relationship types, with autocomplete for type names. Modeled after views_handler_filter_user_name. @author Alex Karshakevich http://drupal.org/user/183217
Code
function validate_type_strings(&$form, $values) {
$rtids = array();
$placeholders = array();
$args = array();
$results = array();
foreach ($values as $value) {
$missing[strtolower($value)] = TRUE;
$args[] = $value;
$placeholders[] = "'%s'";
}
if (!$args) {
return $rtids;
}
$result = db_query("SELECT * FROM {user_relationship_types} WHERE name IN (" . implode(', ', $placeholders) . ")", $args);
while ($rtype = db_fetch_object($result)) {
unset($missing[strtolower($rtype->name)]);
$rtids[] = $rtype->rtid;
}
if ($missing) {
form_error($form, format_plural(count($missing), 'Unable to find relationship type: @types', 'Unable to find relationship types: @types', array(
'@types' => implode(', ', array_keys($missing)),
)));
}
return $rtids;
}