function rb_misc_action_views_result_count in Rules Bonus Pack 7
Same name and namespace in other branches
- 6 rb_misc.module \rb_misc_action_views_result_count()
The 'rb_misc_action_views_result_count' condition.
File
- ./
rb_misc.rules.inc, line 546 - Miscellaneous conditions and actions for Rules.
Code
function rb_misc_action_views_result_count($view, $args, $minimum) {
// Prepare some data about the view.
$views_settings = explode('|', $view);
$view_name = $views_settings[0];
$display_name = $views_settings[1];
$view_arguments = explode("\r", $args);
// Load the view and set the properties.
$view = views_get_view($view_name);
$view
->set_display($display_name);
$view
->set_arguments($view_arguments);
$view
->set_items_per_page(0);
// Get the results of the view and return TRUE or FALSE depending the number
// of hits.
$view
->execute();
$results = $view->result;
return count($results) >= $minimum;
}