Index: plupload.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/plupload/plupload.module,v retrieving revision 1.1.2.5 diff -u -r1.1.2.5 plupload.module --- plupload.module 25 Oct 2010 01:19:49 -0000 1.1.2.5 +++ plupload.module 25 Oct 2010 02:45:56 -0000 @@ -2,6 +2,13 @@ // $Id: plupload.module,v 1.1.2.5 2010/10/25 01:19:49 justintime Exp $ /** + * This defines what each url param need to be prefixed with so that we + * include it on the node object when created so that other contrib + * modules can deal with it later via nodeapi + */ +define('PLUPLOAD_URL_PARAM_PREFIX', 'drupal_'); + +/** * Implementation of hook_perm(). */ function plupload_perm() { @@ -75,13 +82,17 @@ /** * Page callback for the bulk uploader. */ -function plupload_upload_page() { +function plupload_upload_page($options = array()) { $path = drupal_get_path('module', 'plupload'); drupal_add_js($path . '/plupload/src/javascript/plupload.js'); drupal_add_js($path . '/plupload/src/javascript/plupload.html5.js'); drupal_add_js($path . '/plupload/src/javascript/jquery.plupload.queue.js'); drupal_add_js($path . '/plupload/src/javascript/plupload.flash.js'); drupal_add_css($path .'/plupload/examples/css/plupload.queue.css'); + $query_string = $_GET; + unset($query_string['q']); + // In case we're not being called via hook_menu, we allow other contrib modules to add query string options + $query_string += $options; // Get the field and its validators so we can build our extension list. list($type, $field_name) = split(':::', variable_get('plupload_import_field_type', 'photo:::field_photo')); @@ -89,7 +100,7 @@ $validators = imagefield_widget_upload_validators($field); $extensions = str_replace(' ', ',', $validators['filefield_validate_extensions'][0]); - $url = url('plupload-pernode'); + $url = url('plupload-pernode', array('query' => $query_string)); $swfurl = url($path.'/plupload/js/plupload.flash.swf'); $script = <<<__RSD__ // Convert divs to queue widgets when the DOM is ready @@ -189,8 +200,17 @@ // Move it to it's final home. $path = file_directory_path(); + + // Pull off all the options from the query string for later attachment to the node. + $options = array(); + foreach (array_keys($_GET) as $k) { + $pos = strpos($k, PLUPLOAD_URL_PARAM_PREFIX); + if ($pos === 0) { + $options[substr($k, strlen(PLUPLOAD_URL_PARAM_PREFIX))] = $_GET[$k]; + } + } - $image_node = plupload_imagefield_create_node_from($temp_directory . DIRECTORY_SEPARATOR . $file_name, $file_name); + $image_node = plupload_imagefield_create_node_from($temp_directory . DIRECTORY_SEPARATOR . $file_name, $file_name, $options); // @todo check the $image_node and do some error handling. @@ -209,7 +229,7 @@ * @return $node * a node object. */ -function plupload_imagefield_create_node_from($temp_filepath, $file_name) { +function plupload_imagefield_create_node_from($temp_filepath, $file_name, $options) { // Only get files from Drupal's tmp directory. $directory = file_directory_temp(); if (file_check_location($temp_filepath, $directory)) { @@ -254,7 +274,7 @@ // Save the file and create a node. if ($file = field_file_save_file($temp_filepath, $validators, $directory)) { $file['original_path'] = $temp_filepath; - $node = _plupload_imagefield_import_create_node($field, $form_state_values, $file); + $node = _plupload_imagefield_import_create_node($field, $form_state_values, $file, $options); file_delete($temp_filepath); } } @@ -268,7 +288,7 @@ * Create a new node with an attached image file. * Largely copied from imagefield_import. */ -function _plupload_imagefield_import_create_node($field, $form_state_values, $file = NULL) { +function _plupload_imagefield_import_create_node($field, $form_state_values, $file = NULL, $options) { global $user; module_load_include('inc', 'node', 'node.pages'); @@ -289,9 +309,9 @@ // Make it easy for other modules to add data to imported nodes using // hook_form_alter (@see http://drupal.org/node/714550). - foreach (array_keys($form_state_values) as $key) { + foreach (array_keys($options) as $key) { if (!isset($node->$key)) { - $node->$key = $form_state_values[$key]; + $node->$key = $options[$key]; } }