? feedback-402438-7.patch
? load.patch
Index: feedback.api.php
===================================================================
RCS file: feedback.api.php
diff -N feedback.api.php
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ feedback.api.php	3 Jan 2011 22:19:51 -0000
@@ -0,0 +1,29 @@
+<?php
+// $Id$
+
+/**
+ * @file
+ * Hooks provided by the Feedback module.
+ */
+
+/**
+ * @addtogroup hooks
+ * @{
+ */
+
+/**
+ * Act on an array of feedback entry objects when loaded from the database.
+ *
+ * @param $entries
+ *   An array of feedback entry objects, indexed by fid.
+ */
+function hook_feedback_load($entries) {
+  $result = db_query('SELECT * FROM {my_table} WHERE fid IN (:fids)', array(':fids' => array_keys($entries)));
+  foreach ($result as $record) {
+    $entries[$record->fid]->foo = $result->foo;
+  }
+}
+
+/**
+ * @} End of "addtogroup hooks".
+ */
Index: feedback.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/feedback/feedback.module,v
retrieving revision 1.80
diff -u -p -r1.80 feedback.module
--- feedback.module	12 Nov 2010 01:26:01 -0000	1.80
+++ feedback.module	3 Jan 2011 22:19:51 -0000
@@ -126,10 +126,10 @@ function feedback_form($form, &$form_sta
   );
   if (user_access('view feedback messages')) {
     if (arg(0) != 'node') {
-      $feedbacks = feedback_load(array('f.status' => 0, 'f.location_masked' => feedback_mask_path($_GET['q'])));
+      $feedbacks = feedback_load(array(), array('f.status' => 0, 'f.location_masked' => feedback_mask_path($_GET['q'])));
     }
     else {
-      $feedbacks = feedback_load(array('f.status' => 0, 'f.location' => $_GET['q']));
+      $feedbacks = feedback_load(array(), array('f.status' => 0, 'f.location' => $_GET['q']));
     }
     if ($feedbacks) {
       $rows = '';
@@ -199,24 +199,54 @@ function feedback_format_message($entry)
 /**
  * Load feedback entries from the database.
  *
+ * This function should be used whenever you need to load more than one entry
+ * from the database.
+ *
+ * @param $fids
+ *   An array of feedback entry IDs.
  * @param $conditions
- *   A keyed array of optional query conditions.
+ *   An associative array of conditions on the {feedback}
+ *   table, where the keys are the database fields and the values are the
+ *   values those fields must have.
+ *
+ * @return
+ *   An array of feedback entry objects indexed by fid.
  */
-function feedback_load($conditions) {
+function feedback_load_multiple($fids = array(), $conditions = array()) {
   $query = db_select('feedback', 'f')->fields('f');
   $query->join('users', 'u', 'f.uid = u.uid');
   $query->fields('u', array('name'));
-
+  
+  if (!empty($fids)) {
+    $query->condition('fid', $fids, 'IN');
+  }
   if (!empty($conditions)) {
     foreach ($conditions as $key => $value) {
       $query->condition($key, $value);
     }
   }
   $entries = $query->execute()->fetchAllAssoc('fid');
+  module_invoke_all('feedback_load', $entries);
   return $entries;
 }
 
 /**
+ * Loads a feedback entry object.
+ *
+ * @param $fid
+ *   Integer specifying the feedback ID to load.
+ *
+ * @return
+ *   A loaded feedback entry object upon successful load, or FALSE if the entry
+ *   cannot be loaded.
+ *
+ * @see feedback_load_multiple()
+ */
+function feedback_load($fid) {
+  return feedback_load_multiple(array($fid));
+}
+
+/**
  * 'Mask' a path, i.e. replace all numeric arguments in a path with '%' placeholders.
  *
  * Please note that only numeric arguments with a preceding slash will be
