Index: media_mover_api.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/media_mover/media_mover_api.module,v
retrieving revision 1.1.2.73
diff -u -p -r1.1.2.73 media_mover_api.module
--- media_mover_api.module 18 Apr 2008 12:53:19 -0000 1.1.2.73
+++ media_mover_api.module 27 Apr 2008 11:14:39 -0000
@@ -1,7 +1,7 @@
';
$files = module_invoke($config->harvest->module, 'media_mover', 'harvest', $config->harvest->action, $config->harvest->configuration, null, $config, $nid);
-
+
// store the harvested files
if (count($files) > 0 ) {
- foreach ($files as $harvested_file) {
+ foreach ($files as $harvested_file) {
// save harvested file
media_mover_api_file_db_add($harvested_file, $config, 'harvest', MMA_FILE_STATUS_HARVESTED);
}
@@ -620,10 +620,14 @@ function media_mover_api_run_config($con
}
// Harvest is complete, now we can batch process files
- $output .= t('processing....') .'
';
+ $output .= t('processing....') .'
';
// PROCESS get all files ready for processing
$files = media_mover_api_get_files(MMA_FILE_STATUS_HARVESTED, $config->cid, variable_get('mma_process_num', 0));
foreach($files as $file) {
+ if (module_exists('mm_workflow_ng')) {
+ //fire the harvest method;
+ workflow_ng_invoke_event('mediamover_harvested_file',$file);
+ }
// make sure no one else is trying to operate on this file
if (media_mover_api_file_lock($file['mmfid'], MMA_FILE_STATUS_HARVESTED, MMA_FILE_STATUS_IN_PROCESS) ) {
$file = module_invoke($config->process->module, 'media_mover', 'process', $config->process->action, $config->process->configuration, $file, $config);
@@ -635,7 +639,11 @@ function media_mover_api_run_config($con
// STORAGE get all files ready for storage
$output .= t('storing....') .'
';
$files = media_mover_api_get_files(MMA_FILE_STATUS_PROCESS_COMPLETE, $config->cid, variable_get('mma_storage_num', 0));
- foreach($files as $file) {
+ foreach($files as $file) {
+ if (module_exists('mm_workflow_ng')) {
+ //fire the process event;
+ workflow_ng_invoke_event('mediamover_process_file',$file);
+ }
// make sure no one else is trying to operate on this file
if (media_mover_api_file_lock($file['mmfid'], MMA_FILE_STATUS_PROCESS_COMPLETE, MMA_FILE_STATUS_IN_STORAGE) ) {
$file = module_invoke($config->storage->module, 'media_mover', 'storage', $config->storage->action, $config->storage->configuration, $file, $config);
@@ -645,13 +653,25 @@ function media_mover_api_run_config($con
// COMPLETE get all files ready for completion
$output .= t('completing....') .'
';
- $files = media_mover_api_get_files(MMA_FILE_STATUS_STORAGE_COMPLETE, $config->cid, variable_get('mma_complete_num', 0));
- foreach($files as $file) {
+ $files = media_mover_api_get_files(MMA_FILE_STATUS_STORAGE_COMPLETE, $config->cid, variable_get('mma_complete_num', 0));
+
+ foreach($files as $file) {
+ if (module_exists('mm_workflow_ng')) {
+ //fire the store event;
+ workflow_ng_invoke_event('mediamover_store_file',$file);
+ }
+
// make sure no one else is trying to operate on this file
if (media_mover_api_file_lock($file['mmfid'], MMA_FILE_STATUS_STORAGE_COMPLETE, MMA_FILE_STATUS_IN_COMPLETE) ) {
$file = module_invoke($config->complete->module, 'media_mover', 'complete', $config->complete->action, $config->complete->configuration, $file, $config);
media_mover_api_update_file($file, MMA_FILE_STATUS_COMPLETE_COMPLETE);
}
+
+ if (module_exists('mm_workflow_ng')) {
+ //fire the complete event;
+
+ workflow_ng_invoke_event('mediamover_complete_file',$file);
+ }
}
// if in debug mode.....
Index: media_mover_token.inc
===================================================================
RCS file: media_mover_token.inc
diff -N media_mover_token.inc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ media_mover_token.inc 27 Apr 2008 11:14:39 -0000
@@ -0,0 +1,138 @@
+ $v) {
+ if ($k == 'status') {
+ //@TODO
+ //$values['status_name'] = media_mover_api_con($v);
+ }
+ if ($k == 'states') {
+ foreach ($v as $verb => $state) {
+ foreach ($state as $state_key => $state_var) {
+ if (is_string($state_var)) {
+ $values["{$verb}-{$state_key}"] = $state_var;
+ }
+ }
+ if (function_exists("{$state['module']}_token_values")) {
+ //Would be nice to have this stuff... but not sure how to integrate nicely without jumbling the interface.
+ $extra_config_tokens = call_user_func("{$state['module']}_token_values",$type,unserialize($state['configuration']));
+ foreach ($extra_config_tokens as $config_key => $config_val) {
+ $values["{$verb}-{$state_key}-{$config_key}"] = $config_val;
+ }
+ }
+ }
+ } else {
+ $values[$k] = $v;
+ }
+ }
+ break;
+ case 'mm_file':
+
+ $file = (object)$object;
+
+ foreach ($file as $key => $v) {
+
+ if ($k == 'status') {
+ $values['status_name'] = media_mover_api_item_status($v);
+ }
+ if (is_array($v)) {
+ //this handles the data element
+ foreach ($v as $file_key => $file_v) {
+ $values['data-' . $file_key] = $file_v;
+ }
+ } else {
+ $values[$key] = $v;
+ }
+ }
+ break;
+ }
+
+ return $values;
+}
+
+/**
+ * Implementation of hook_token_list().
+ */
+function media_mover_api_token_list($type = 'all') {
+
+ //@TODO: Flesh these out with real descriptions
+ if ($type == 'mm_file' || $type == 'all') {
+ $tokens['Media Mover File'] = array (
+
+ 'mmfid' => t('Media Mover File Id'),
+ 'nid' => t('Node Id of assocaited node (if any)'),
+ 'fid' => t('File Id of associated file type entry (if any)'),
+ 'cid' => t('Media Mover configuration from whence this file came'),
+ 'harvest_file' => t('Path to harvested file'),
+ 'process_file' => t('Path to processed file'),
+ 'storage_file' => t('Path to stored file'),
+ 'complete_file' => t('Path to completed file'),
+ 'url' => t('Url for file access (if any)'),
+ 'status' => t('Status code of file'),
+ 'status_name' => t('Status name of file'),
+ 'date' => t('Date of creation'),
+ );
+
+ $tokens['Media Mover File'] = array_merge($tokens['Media Mover File'],
+ array (
+ 'data-filesize' => t('Filesize of completed file'),
+ 'data-filename' => t('Filename of compelted file'),
+ 'data-filepath' => t('Filepath of completed file'),
+ 'data-harvest_module' => t('Module used for harvesting'),
+ 'data-harvest_action' => t('Action of harvesting Module'),
+ 'data-harvest_file' => t('Harvested file'),
+ 'data-node' => t('Node??'), )
+ );
+
+
+
+ }
+
+ if ($type == "mm_config") {
+ $tokens['Media Mover Configuration'] = array (
+ 'cid' => t('Media Mover Configuration '),
+ 'name' => t('Name of Configuration'),
+ 'description' => t('Configuration description'),
+ 'status' => t('Configuration status'),
+ //@TODO
+ //'status_name' => t('Configuration status name'),
+ 'start_time' => t('Configuration start time'),
+ 'last_start_time' => t('Configuration last start time'),
+ 'rss' => t('is configuration exposed via RSS?'),
+ 'cron' => t('is configuration set to run on cron'),
+ );
+
+
+ $tokens['Media Mover Configuration']['harvest-module'] = t("Module used for Harvesting");
+ $tokens['Media Mover Configuration']['storage-module'] = t("Module used for Storage");
+ $tokens['Media Mover Configuration']['process-module'] = t("Module used for Processing");
+ $tokens['Media Mover Configuration']['complete-module'] = t("Module used for Completion");
+
+ }
+
+ return $tokens;
+}
+
+?>
\ No newline at end of file
Index: media_mover_ftp/media_mover_ftp.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/media_mover/media_mover_ftp/Attic/media_mover_ftp.module,v
retrieving revision 1.1.2.4
diff -u -p -r1.1.2.4 media_mover_ftp.module
--- media_mover_ftp/media_mover_ftp.module 25 Apr 2008 13:23:54 -0000 1.1.2.4
+++ media_mover_ftp/media_mover_ftp.module 27 Apr 2008 11:14:39 -0000
@@ -287,4 +287,25 @@ function media_mover_ftp_token_form_subm
array('@token' => $token))
);
return;
+}
+
+/**
+ * Implementation of hook_token_values().
+ */
+function media_mover_ftp_token_values($type, $object = NULL) {
+ $values = array();
+ switch ($type) {
+
+ case 'mm_config':
+ if (!is_array($object)) {
+ return array();
+ }
+ $config = $object;
+ foreach ($config as $k => $v) {
+ $values[$k] = $v;
+ }
+ break;
+
+ }
+ return $values;
}
\ No newline at end of file
Index: mm_node/mm_node.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/media_mover/mm_node/mm_node.module,v
retrieving revision 1.1.2.37
diff -u -p -r1.1.2.37 mm_node.module
--- mm_node/mm_node.module 30 Mar 2008 03:18:37 -0000 1.1.2.37
+++ mm_node/mm_node.module 27 Apr 2008 11:14:40 -0000
@@ -274,6 +274,8 @@ function mm_node_complete( $configuratio
$options = implode(", ", $options);
db_query("UPDATE node SET $options WHERE nid = %d", $file['nid']);
}
+ $file['complete_file'] = $file['storage_file'];
+ return $file;
}
Index: mm_workflow_ng/mm_workflow_ng.info
===================================================================
RCS file: mm_workflow_ng/mm_workflow_ng.info
diff -N mm_workflow_ng/mm_workflow_ng.info
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ mm_workflow_ng/mm_workflow_ng.info 27 Apr 2008 11:14:40 -0000
@@ -0,0 +1,4 @@
+name = Media Mover Workflow-NG
+description = Allowes Workflow-ng to react to media mover events. Also provides some conditions for evaluating media mover actions in workflow-ng sans tokens
+dependencies = media_mover_api workflow_ng
+package = Media Mover
Index: mm_workflow_ng/mm_workflow_ng.module
===================================================================
RCS file: mm_workflow_ng/mm_workflow_ng.module
diff -N mm_workflow_ng/mm_workflow_ng.module
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ mm_workflow_ng/mm_workflow_ng.module 27 Apr 2008 11:14:40 -0000
@@ -0,0 +1,241 @@
+ array(
+ '#label' => t('Media has finished being added'),
+ '#module' => t('Media Mover'),
+ '#arguments' => workflow_ng_events_hook_media_mover_arguments('complete'),
+ '#redirect' => TRUE,
+ ),
+
+ 'mediamover_processed_file' => array(
+ '#label' => t('Media has been processed'),
+ '#module' => t('Media Mover'),
+ '#arguments' => workflow_ng_events_hook_media_mover_arguments('process'),
+ '#redirect' => TRUE,
+ ),
+
+ 'mediamover_harvested_file' => array(
+ '#label' => t('Media has been harvested'),
+ '#module' => t('Media Mover'),
+ '#arguments' => workflow_ng_events_hook_media_mover_arguments('harvest'),
+ '#redirect' => TRUE,
+ ),
+
+ 'mediamover_stored_file' => array(
+ '#label' => t('Media has been stored'),
+ '#module' => t('Media Mover'),
+ '#arguments' => workflow_ng_events_hook_media_mover_arguments('store'),
+ '#redirect' => TRUE,
+ ),
+ );
+}
+
+
+/*
+ * Returns some arguments suitable for hook comment
+ */
+function workflow_ng_events_hook_media_mover_arguments($type) {
+
+ $args = array (
+ 'mm_file' => array('#entity' => 'mm_file', '#label' => t('New Media Mover file')),
+ 'mm_config' => array('#entity' => 'mm_config', '#label' => t('Media Mover Configuration'), '#handler' => 'media_mover_workflow_ng_config_argument_handler'),
+ );
+
+
+ switch ($type) {
+ case 'complete':
+ $args['node'] = array ('#entity' => 'node', '#label' => t('New Media Mover Node'), '#handler' => 'media_mover_workflow_ng_node_argument_handler');
+ $args['user'] = array ('#entity' => 'user', '#label' => t('Uploading User (if avail)'), '#handler' => 'media_mover_workflow_ng_user_argument_handler');
+ break;
+ }
+
+ return $args;
+}
+
+
+function mm_workflow_ng_complete($configuration,$file) {
+ //workflow_ng_invoke_event('mediamover_completed_file',$file);
+ return $file;
+}
+
+function media_mover_workflow_ng_config_argument_handler($file) {
+ if ($config = media_mover_token_get_config($file['cid']) ) {
+ return $config;
+ }
+}
+
+function media_mover_workflow_ng_node_argument_handler($file) {
+ if ($node = node_load(array('nid' => $file['nid']))) {
+ return $node;
+ }
+ return new stdClass();
+}
+
+function media_mover_workflow_ng_user_argument_handler($file) {
+ if ($node = node_load(array('nid' => $file['nid']))) {
+ return user_load(array('uid' => $node->uid));
+ }
+}
+
+
+/*
+ * Implementation of hook_action_info()
+ */
+function mm_workflow_ng_action_info() {
+ return array(
+ 'workflow_ng_action_mm_run_config_with_node' => array(
+ '#label' => t('DEBUG_ONLY: Run a Media Mover config with completed node'),
+ '#arguments' => array(
+ 'node' => array('#entity' => 'node', '#label' => t('Node')),
+ ),
+ '#module' => t('Media Mover'),
+ )
+ );
+}
+
+function workflow_ng_action_mm_run_config_with_node($node, $settings, &$arguments, &$log) {
+ //first sanity check to make sure we aren't running a workflow_ng complete enabled config
+ //This is dicey... will write later.
+
+ if ( ($config = _mm_get_configuration($settings['configuration']) ) && $node->nid) {
+ $cmd = "media_mover_api_run_config(" . var_export($config,1) . ",false,$node->nid);";
+ dpr('I would have ran' . $cmd);
+ }
+}
+
+function workflow_ng_action_mm_run_config_with_node_form($settings = array(), $argument_info) {
+ $form = array();
+
+ $form['configuration'] = _mm_workflow_ng_configuration_select_elem();
+ $form['configuration']['#description'] = t('Select the Media Mover Configuration you would like to feed the new node into');
+ $form['configuration']['#default_value'] = $settings['configuration'];
+
+ return $form;
+}
+
+function workflow_ng_action_mm_run_config_with_node_submit($form_id, $form_values) {
+ return array ('configuration' => $form_values['configuration']);
+}
+/*
+ * Implementation of hook_condition_info()
+ */
+function mm_workflow_ng_condition_info() {
+ return array(
+ 'workflow_ng_condition_mm_configuration_is' => array(
+ '#label' => t('Media Mover Configuration is'),
+ '#arguments' => array(
+ 'mm_config' => array('#entity' => 'mm_config', '#label' => t('Media Mover configuration being run')),
+ ),
+ '#description' => t('Evaluates to TRUE, if the given configuration selected is the one being run.'),
+ '#module' => t('Media Mover'),
+ ),
+
+ 'workflow_ng_condition_mm_file_type_is' => array(
+ '#label' => t('Media Mover file type is'),
+ '#arguments' => array(
+ 'mm_file' => array('#entity' => 'mm_file', '#label' => t('Media Mover file being sent through')),
+ ),
+ '#description' => t('Evaluates to TRUE, if the file type selected is the same as the one being used.'),
+ '#module' => t('Media Mover'),
+ ),
+ );
+}
+
+/*
+ * Condition: Check for selected content types
+ */
+function workflow_ng_condition_mm_configuration_is($config, $settings) {
+ return in_array($config['cid'], $settings['configuration']);
+}
+
+/*
+ * Check for content types - Configuration form
+ */
+function workflow_ng_condition_mm_configuration_is_form($settings = array()) {
+
+ $form['configuration'] = _mm_workflow_ng_configuration_select_elem();
+ $form['configuration']['#description'] = t('Select the Media Mover Configuration');
+ $form['configuration']['#default_value'] = $settings['configuration'];
+ $form['configuration']['#multiple'] = true;
+ $form['configuration']['#size'] = 6;
+
+ return $form;
+}
+
+function workflow_ng_condition_mm_configuration_is_submit($form_id, $form_values) {
+ return array('configuration' => $form_values['configuration']);
+}
+
+/*
+ * Condition: Check for selected content types
+ */
+function workflow_ng_condition_mm_file_type_is($file, $settings) {
+ //dpr("testing " . $config['cid'] . " against " . var_export($settings['configuration'],1));
+ $states = array(
+ MMA_FILE_STATUS_HARVESTED => 'harvest',
+ MMA_FILE_STATUS_IN_PROCESS => 'process',
+ MMA_FILE_STATUS_PROCESS_COMPLETE => 'process',
+ MMA_FILE_STATUS_IN_STORAGE => 'storage',
+ MMA_FILE_STATUS_STORAGE_COMPLETE => 'storage',
+ MMA_FILE_STATUS_IN_COMPLETE => 'complete',
+ MMA_FILE_STATUS_COMPLETE_COMPLETE => 'complete',
+ );
+ $file_path = $file[$states[$file['status']] .'_file'];
+ $_pinfo = pathinfo($file_path);
+ //Get rid of spaces
+ $allowed_ext = explode(',',str_replace(array(' ','.'),'',$settings['extensions']));
+ return in_array($_pinfo['extension'], $allowed_ext);
+}
+
+function trim_value(&$value)
+{
+ $value = trim($value);
+}
+
+/*
+ * Check for content types - Configuration form
+ */
+function workflow_ng_condition_mm_file_type_is_form($settings = array()) {
+
+ $form['extensions'] = array (
+ '#type' => 'textfield',
+ '#title' => t('Extensions'),
+ '#required' => true,
+ '#description' => t('Input a comma separated list of extensions to evaluate against (e.g. avi,mpeg,m4v)'),
+ '#default_value' => $settings['extensions'],
+ );
+
+ return $form;
+}
+
+function workflow_ng_condition_mm_file_type_is_submit($form_id, $form_values) {
+ return array('extensions' => $form_values['extensions']);
+}
+
+/**
+ * Util
+ */
+
+function _mm_workflow_ng_configuration_select_elem() {
+ $configs = _mm_get_active_configurations();
+ foreach ($configs as $config) {
+ $config_options[$config->cid] = $config->name;
+ }
+
+ $configuration_elem = array (
+ "#type" => "select",
+ '#title' => t('Media Mover Configuration'),
+ '#description' => t('Select the Media Mover Configuration you would like to feed the new node into'),
+ "#multiple" => 0,
+ "#size" => 1,
+ '#options' => $config_options,
+ );
+
+ return $configuration_elem;
+}
+
+?>
\ No newline at end of file
Index: mm_workflow_ng/mm_workflow_ng_sample_cfg.inc
===================================================================
RCS file: mm_workflow_ng/mm_workflow_ng_sample_cfg.inc
diff -N mm_workflow_ng/mm_workflow_ng_sample_cfg.inc
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ mm_workflow_ng/mm_workflow_ng_sample_cfg.inc 27 Apr 2008 11:14:40 -0000
@@ -0,0 +1,173 @@
+
+ array (
+ '#type' => 'configuration',
+ '#altered' => false,
+ '#event' => 'mediamover_harvested_file',
+ '#label' => 'Media Mover Harvest Log Test',
+ '#active' => 0,
+ '#module' => 'workflow-ng',
+ 0 =>
+ array (
+ '#type' => 'condition',
+ '#name' => 'workflow_ng_condition_mm_file_type_is',
+ '#argument map' =>
+ array (
+ 'mm_file' => 'mm_file',
+ ),
+ '#label' => 'Media Mover file type is',
+ '#settings' =>
+ array (
+ 'extensions' => 'avi',
+ ),
+ ),
+ 1 =>
+ array (
+ '#type' => 'action',
+ '#name' => 'workflow_ng_action_watchdog',
+ '#settings' =>
+ array (
+ 'severity' => '0',
+ 'type' => 'workflow-ng',
+ 'message' => '[mm_file:data-filename] made it to this step',
+ 'message_args' =>
+ array (
+ 0 => 'mm_file',
+ ),
+ 'link' => '',
+ 'link_args' =>
+ array (
+ ),
+ ),
+ ),
+ '#name' => 'cfg_13',
+ ),
+ 'cfg_15' =>
+ array (
+ '#type' => 'configuration',
+ '#altered' => false,
+ '#event' => 'mediamover_complete_file',
+ '#label' => 'Notify Admin abount newly processed files over 500k',
+ '#active' => 0,
+ '#module' => 'workflow-ng',
+ 0 =>
+ array (
+ '#type' => 'condition',
+ '#name' => 'workflow_ng_condition_token_numeric',
+ '#settings' =>
+ array (
+ 'text1' => '[mm_file:data-filesize]',
+ 'text1_args' =>
+ array (
+ 0 => 'mm_file',
+ ),
+ 'text2' => '500000',
+ 'text2_args' =>
+ array (
+ ),
+ 'operation' => 'less',
+ ),
+ '#label' => 'File Size > 500k',
+ ),
+ 1 =>
+ array (
+ '#type' => 'action',
+ '#name' => 'workflow_ng_action_mail',
+ '#settings' =>
+ array (
+ 'to' => '[node:site-mail]',
+ 'to_args' =>
+ array (
+ 0 => 'node',
+ ),
+ 'from' => '[node:site-mail]',
+ 'from_args' =>
+ array (
+ 0 => 'node',
+ ),
+ 'subject' => '[user:user] Just uploaded [mm_file:data-filename] of [mm_file:data-filesize]',
+ 'subject_args' =>
+ array (
+ 0 => 'mm_file',
+ 1 => 'user',
+ ),
+ 'message' => 'This came in from:
+[mm_config:name]
+which started at: [mm_config:start_time]
+
+If you are lazy, [mm_config:name] uses:
+
+[mm_config:harvest-module] for harvesting
+[mm_config:process-module] for processing
+[mm_config:storage-module] for storage
+[mm_config:complete-module] for completion
+
+Adios!
+
+"The token programmer"',
+ 'message_args' =>
+ array (
+ 0 => 'mm_config',
+ ),
+ ),
+ '#label' => 'Send a mail to an arbitrary mail address',
+ ),
+ 2 =>
+ array (
+ '#type' => 'action',
+ '#name' => 'workflow_ng_action_watchdog',
+ '#settings' =>
+ array (
+ 'severity' => '0',
+ 'type' => 'workflow-ng',
+ 'message' => 'sent a mail to [user:mail] because of [mm_file:data-filesize] file',
+ 'message_args' =>
+ array (
+ 0 => 'mm_file',
+ 1 => 'user',
+ ),
+ 'link' => '',
+ 'link_args' =>
+ array (
+ ),
+ ),
+ '#label' => 'Log to watchdog',
+ ),
+ 3 =>
+ array (
+ '#type' => 'action',
+ '#name' => 'workflow_ng_action_drupal_message',
+ '#settings' =>
+ array (
+ 'message' => 'This came in from:
+[mm_config:name]
+which started at: [mm_config:start_time]
+
+If you are lazy, [mm_config:name] uses:
+
+[mm_config:harvest-module] for harvesting
+[mm_config:process-module] for processing
+[mm_config:storage-module] for storage
+[mm_config:complete-module] for completion
+
+Adios!
+
+"The token programmer"',
+ 'message_args' =>
+ array (
+ 0 => 'mm_config',
+ ),
+ 'error' => 0,
+ ),
+ ),
+ '#name' => 'cfg_15',
+ ),
+);
+
+return $configurations;
+
+}
+?>
\ No newline at end of file