updated rules
This commit is contained in:
@@ -0,0 +1,104 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Views integration for the rules scheduler module.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Default scheduled task handler.
|
||||
*/
|
||||
class RulesSchedulerDefaultTaskHandler implements RulesSchedulerTaskHandlerInterface {
|
||||
|
||||
/**
|
||||
* The task array.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected $task;
|
||||
|
||||
/**
|
||||
* Constructs a repetitive task handler object.
|
||||
*/
|
||||
public function __construct(array $task) {
|
||||
$this->task = $task;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesSchedulerTaskHandlerInterface::runTask().
|
||||
*/
|
||||
public function runTask() {
|
||||
if ($component = rules_get_cache('comp_' . $this->task['config'])) {
|
||||
$replacements = array('%label' => $component->label(), '%plugin' => $component->plugin());
|
||||
$replacements['%identifier'] = $this->task['identifier'] ? $this->task['identifier'] : t('without identifier');
|
||||
rules_log('Scheduled evaluation of %plugin %label, task %identifier.', $replacements, RulesLog::INFO, $component, TRUE);
|
||||
$state = unserialize($this->task['data']);
|
||||
$state->restoreBlocks();
|
||||
// Block the config to prevent any future recursion.
|
||||
$state->block($component);
|
||||
// Finally evaluate the component with the given state.
|
||||
$component->evaluate($state);
|
||||
$state->unblock($component);
|
||||
rules_log('Finished evaluation of %plugin %label, task %identifier.', $replacements, RulesLog::INFO, $component, FALSE);
|
||||
$state->cleanUp();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesSchedulerTaskHandlerInterface::afterTaskQueued().
|
||||
*/
|
||||
public function afterTaskQueued() {
|
||||
// Delete the task from the task list.
|
||||
db_delete('rules_scheduler')
|
||||
->condition('tid', $this->task['tid'])
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements RulesSchedulerTaskHandlerInterface::getTask().
|
||||
*/
|
||||
public function getTask() {
|
||||
return $this->task;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface for scheduled task handlers.
|
||||
*
|
||||
* Task handlers control the behavior of a task when it's queued or executed.
|
||||
* Unless specified otherwise, the RulesSchedulerDefaultTaskHandler task handler
|
||||
* is used.
|
||||
*
|
||||
* @see rules_scheduler_run_task()
|
||||
* @see rules_scheduler_cron()
|
||||
* @see RulesSchedulerDefaultTaskHandler
|
||||
*/
|
||||
interface RulesSchedulerTaskHandlerInterface {
|
||||
|
||||
/**
|
||||
* Processes a queue item.
|
||||
*
|
||||
* @throws RulesEvaluationException
|
||||
* If there are any problems executing the task.
|
||||
*
|
||||
* @see rules_scheduler_run_task()
|
||||
*/
|
||||
public function runTask();
|
||||
|
||||
/**
|
||||
* Processes a task after it has been queued.
|
||||
*
|
||||
* @see rules_scheduler_cron()
|
||||
*/
|
||||
public function afterTaskQueued();
|
||||
|
||||
/**
|
||||
* Returns the task associated with the task handler.
|
||||
*
|
||||
* @return array
|
||||
* The task (queue item) array.
|
||||
*/
|
||||
public function getTask();
|
||||
|
||||
}
|
@@ -6,8 +6,9 @@
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_views_data(). Specifies the list of future scheduled
|
||||
* tasks displayed on the schedule page.
|
||||
* Implements hook_views_data().
|
||||
*
|
||||
* Specifies the list of future scheduled tasks displayed on the schedule page.
|
||||
*/
|
||||
function rules_scheduler_views_data() {
|
||||
$table = array(
|
||||
@@ -71,7 +72,7 @@ function rules_scheduler_views_data() {
|
||||
'click sortable' => TRUE,
|
||||
),
|
||||
'filter' => array(
|
||||
'handler' => 'views_handler_filter',
|
||||
'handler' => 'views_handler_filter_string',
|
||||
),
|
||||
'sort' => array(
|
||||
'handler' => 'views_handler_sort',
|
||||
|
@@ -9,7 +9,7 @@
|
||||
* Implements hook_views_default_views().
|
||||
*/
|
||||
function rules_scheduler_views_default_views() {
|
||||
$view = new view;
|
||||
$view = new view();
|
||||
$view->name = 'rules_scheduler';
|
||||
$view->description = 'Scheduled Rules components';
|
||||
$view->tag = '';
|
||||
@@ -86,7 +86,7 @@ function rules_scheduler_views_default_views() {
|
||||
$handler->display->display_options['fields']['config']['field'] = 'config';
|
||||
$handler->display->display_options['fields']['config']['alter']['alter_text'] = 0;
|
||||
$handler->display->display_options['fields']['config']['alter']['make_link'] = 1;
|
||||
$handler->display->display_options['fields']['config']['alter']['path'] = 'admin/config/workflow/rules/config/[config]';
|
||||
$handler->display->display_options['fields']['config']['alter']['path'] = 'admin/config/workflow/rules/components/manage/[config]';
|
||||
$handler->display->display_options['fields']['config']['alter']['absolute'] = 0;
|
||||
$handler->display->display_options['fields']['config']['alter']['trim'] = 0;
|
||||
$handler->display->display_options['fields']['config']['alter']['word_boundary'] = 1;
|
||||
@@ -163,7 +163,7 @@ function rules_scheduler_views_default_views() {
|
||||
t('No tasks have been scheduled.'),
|
||||
t('Tid'),
|
||||
t('Component name'),
|
||||
t('admin/config/workflow/rules/config/[config]'),
|
||||
t('admin/config/workflow/rules/components/manage/[config]'),
|
||||
t('Scheduled date'),
|
||||
t('User provided identifier'),
|
||||
t('Operations'),
|
||||
|
@@ -4,8 +4,10 @@
|
||||
* @file
|
||||
* An extended subclass for component filtering.
|
||||
*/
|
||||
|
||||
class rules_scheduler_views_filter extends views_handler_filter_in_operator {
|
||||
function get_value_options() {
|
||||
|
||||
public function get_value_options() {
|
||||
if (!isset($this->value_options)) {
|
||||
$this->value_title = t('Component');
|
||||
$result = db_select('rules_scheduler', 'r')
|
||||
@@ -19,4 +21,5 @@ class rules_scheduler_views_filter extends views_handler_filter_in_operator {
|
||||
$this->value_options = $config_names;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user