diff --git a/resources/node_resource.inc b/resources/node_resource.inc index 928e09d..179835e 100644 --- a/resources/node_resource.inc +++ b/resources/node_resource.inc @@ -114,6 +114,31 @@ function _node_resource_definition() { 'access arguments' => array('access content'), ), ), + 'targeted_actions' => array( + 'attach_file' => array( + 'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/node_resource'), + 'callback' => '_node_resource_attach_file', + 'args' => array( + array( + 'name' => 'nid', + 'optional' => FALSE, + 'source' => array('path' => 0), + 'type' => 'int', + 'description' => 'The nid of the node to attach a file to', + ), + array( + 'name' => 'field_name', + 'optional' => TRUE, + 'source' => array('param' => 'field_name'), + 'description' => 'The file parameters', + 'type' => 'array', + ), + ), + 'access callback' => '_node_resource_access', + 'access arguments' => array('update'), + 'access arguments append' => TRUE, + ), + ), 'relationships' => array( 'files' => array( 'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/node_resource'), @@ -534,3 +559,73 @@ function _node_resource_load_node_comments($nid, $count = 0, $start = 0) { return !empty($cids) ? comment_load_multiple($cids) : array(); } + +/** + * Attaches file(s) to an existing node based on nodeID, and the field's + * machine_name + * + * Example form element used to post files to attach_file: + *