function workbench_moderation_handler_filter_moderated_type::query in Workbench Moderation 7.3
Same name and namespace in other branches
- 7 includes/workbench_moderation_handler_filter_moderated_type.inc \workbench_moderation_handler_filter_moderated_type::query()
Add this filter to the query.
Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.
Overrides views_handler_filter_boolean_operator::query
File
- includes/
workbench_moderation_handler_filter_moderated_type.inc, line 12 - Provides moderation filters for Views.
Class
- workbench_moderation_handler_filter_moderated_type
- Filter by whether a node type has moderation enabled or not.
Code
function query() {
if (!isset($this->value) || $this->value === NULL) {
return;
}
$node_types = workbench_moderation_moderate_node_types();
// If there are no node types using moderation set this variable to an array with a blank value.
// This will force the query to return no values.
if (empty($node_types)) {
$node_types = array(
'',
);
// Tell users to configure content types for moderation
// It's conceivable that a hook_menu_alter has changed the permission needed to get to admin/structure/types
// and as such, perhaps a better check should be used here.
if (user_access('administer content types')) {
$message = t('<a href="@settings" title="Content type administration">No content types have been configured to use Workbench Moderation.</a>', array(
'@settings' => url('admin/structure/types'),
));
$type = 'error';
}
else {
$message = t('Moderation is not ready to for use at this time. Please contact your administrator.');
$type = 'warning';
}
drupal_set_message($message, $type, $repeat = FALSE);
}
$operator = $this->value ? "IN" : "NOT IN";
$this
->ensure_my_table();
$this->query
->add_where($this->options['group'], "{$this->table_alias}.{$this->real_field}", $node_types, $operator);
}