? 1012132.patch
? 1016350.patch
? 1017036_0.txt
? 1020388_test.patch
? 1030220.txt
? 1042014.patch
? 1051088.patch
? 1051158.patch
? services_better_debug_watchdog.txt
? services_update_spyc.txt
Index: resources/file_resource.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/services/resources/file_resource.inc,v
retrieving revision 1.4
diff -u -p -r1.4 file_resource.inc
--- resources/file_resource.inc	30 Jan 2011 18:32:12 -0000	1.4
+++ resources/file_resource.inc	7 Feb 2011 21:35:09 -0000
@@ -69,33 +69,6 @@ function _file_resource_definition() {
           ),
         ),
       ),
-      'actions' => array(
-        'nodeFiles' => array(
-          'help'   => t('This method returns the files on a given node.'),
-           'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/file_resource'),
-          'access callback' => '_file_resource_node_access',
-          'access arguments' => array('view'),
-          'access arguments append' => TRUE,
-          'callback' => '_file_resource_load_node_files',
-          'args'     => array(
-            array(
-              'name'         => 'nid',
-              'type'         => 'int',
-              'description'  => t('The node id to load files for.'),
-              'source'       => 'data',
-              'optional'     => FALSE,
-            ),
-            array(
-              'name'         => 'file_contents',
-              'type'         => 'int',
-              'description'  => t('To return file contents or not.'),
-              'source'       => 'data',
-              'optional'     => FALSE,
-              'default value' => TRUE,
-            ),
-          ),
-        ),
-      ),
     ),
   );
 }
@@ -193,43 +166,6 @@ function _file_resource_retrieve($fid, $
 }
 
 /**
- * Generates an array of base64 encoded files attached to a node
- *
- * @param $nid
- *   Number. Node ID
- * @param $include_file_contents
- *   Bool Whether or not to include the base64_encoded version of the file.
- * @return
- *   Array. A list of all files from the given node
- */
-function _file_resource_load_node_files($nid, $include_file_contents = TRUE) {
-  $node = node_load($nid);
-  //Hopefully theres another way to get a nodes fields that are a file, but this was the only way I could do it.
-  $fields = field_info_fields();
-  $files = array();
-  //Loop through all of the fields on the site
-  foreach($fields as $key=>$field) {
-    //if we are a field type of file 
-    if($field['type'] == 'image' || $field['type'] == 'file') {
-      //if this field exists on our current node
-      if(isset($node->{$field['field_name']})) {
-      //grab the items given and attach them to the array.
-       $node_file_field_items = $node->{$field['field_name']}[LANGUAGE_NONE];
-        foreach ($node_file_field_items as $file) { 
-            $files[] = _file_resource_retrieve($file['fid'], $include_file_contents);
-        }
-      }
-    }
-  }
-  if (count($files) >= 1) {
-    return $files;
-  }
-  else {
-    return services_error(t('There are no files on given node.'), 406);
-  }
-}
-
-/**
  * Delete a file.
  *
  * @param $fid
Index: resources/node_resource.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/services/resources/node_resource.inc,v
retrieving revision 1.9
diff -u -p -r1.9 node_resource.inc
--- resources/node_resource.inc	30 Jan 2011 21:12:32 -0000	1.9
+++ resources/node_resource.inc	7 Feb 2011 21:35:09 -0000
@@ -105,6 +105,33 @@ function _node_resource_definition() {
         ),
         'access arguments' => array('access content'),
       ),
+      'relationships' => array(
+        'files' => array(
+          'file' => array('type' => 'inc', 'module' => 'services', 'name' => 'resources/node_resource'),
+          'help'   => t('This method returns files associated with a node.'),
+          'access callback' => '_node_resource_access',
+          'access arguments' => array('view'),
+          'access arguments append' => TRUE,
+          'callback' => '_node_resource_load_node_files',
+          'args'     => array(
+            array(
+              'name' => 'nid',
+              'optional' => FALSE,
+              'source' => array('path' => 0),
+              'type' => 'int',
+              'description' => 'The nid of the node whose files we are getting',
+            ),
+            array(
+              'name' => 'file_contents',
+              'type' => 'int',
+              'description'  => t('To return file contents or not.'),
+              'source' => array('path' => 2),
+              'optional' => TRUE,
+              'default value' => TRUE,
+            ),
+          ),
+        ),
+      ),
     ),
   );
 }
@@ -339,3 +366,42 @@ function _node_resource_access($op = 'vi
   }
 }
 
+/**
+ * Generates an array of base64 encoded files attached to a node
+ *
+ * @param $nid
+ *   Number. Node ID
+ * @param $include_file_contents
+ *   Bool Whether or not to include the base64_encoded version of the file.
+ * @return
+ *   Array. A list of all files from the given node
+ */
+function _node_resource_load_node_files($nid, $include_file_contents = TRUE) {
+  $node = node_load($nid);
+
+  // Hopefully theres another way to get a nodes fields that are a file, but this was the only way I could do it.
+  $fields = field_info_fields();
+  $files = array();
+
+  // Loop through all of the fields on the site
+  foreach ($fields as $key => $field) {
+    //if we are a field type of file 
+    if ($field['type'] == 'image' || $field['type'] == 'file') {
+      // If this field exists on our current node..
+      if (isset($node->{$field['field_name']})) {
+        // If there are items in the field...
+        if (isset($node->{$field['field_name']}[LANGUAGE_NONE])) {
+          // Grab the items given and attach them to the array.
+          $node_file_field_items = $node->{$field['field_name']}[LANGUAGE_NONE];
+          module_load_include('inc', 'services', 'resources/file_resource');
+          foreach ($node_file_field_items as $file) { 
+            $files[] = _file_resource_retrieve($file['fid'], $include_file_contents);
+          }
+        }
+      }
+    }
+  }
+
+  return $files;
+}
+
