View source
<?php
function computing_rules_event_info() {
$events = array(
'computing_event_created' => array(
'label' => t('A new computing record is created'),
'group' => t('Computing'),
'variables' => array(
'computing_record' => array(
'type' => 'computing_record',
'label' => t('Computing record'),
),
),
),
'computing_event_updated' => array(
'label' => t('A computing record is updated'),
'help' => t('This event is not supposed to work for "claim" and "finish" operations. Use corresponded events instead.'),
'group' => t('Computing'),
'variables' => array(
'computing_record' => array(
'type' => 'computing_record',
'label' => t('Computing record'),
),
),
),
'computing_event_claimed' => array(
'label' => t('A computing record is claimed by agent'),
'group' => t('Computing'),
'variables' => array(
'computing_record' => array(
'type' => 'computing_record',
'label' => t('Computing record'),
),
),
),
'computing_event_finished' => array(
'label' => t('A computing record is finished by agent'),
'group' => t('Computing'),
'variables' => array(
'computing_record' => array(
'type' => 'computing_record',
'label' => t('Computing record'),
),
),
),
'computing_event_released' => array(
'label' => t('A computing record is released back to Drupal'),
'group' => t('Computing'),
'variables' => array(
'computing_record' => array(
'type' => 'computing_record',
'label' => t('Computing record'),
),
),
),
);
return $events;
}
function computing_rules_action_info() {
$actions = array(
'computing_action_handle_output' => array(
'label' => t('Process output data from agent.'),
'group' => t('Computing'),
'parameter' => array(
'computing_record' => array(
'type' => 'computing_record',
'label' => t('Computing record'),
),
),
),
);
return $actions;
}
function computing_action_handle_output($record) {
$command_data = computing_fetch_data($record->application, $record->command);
if ($command_data && isset($command_data['file']) && is_array($command_data['file'])) {
call_user_func_array('module_load_include', $command_data['file']);
}
if ($command_data && isset($command_data['result callback']) && function_exists($command_data['result callback'])) {
$output = isset($record->output) ? $record->output : NULL;
return call_user_func($command_data['result callback'], $output, $record);
}
return FALSE;
}