? issue-157103-0.patch
Index: civinode_utils.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/civinode/civinode_utils.inc,v
retrieving revision 1.31.2.7
diff -u -r1.31.2.7 civinode_utils.inc
--- civinode_utils.inc	21 Jun 2007 05:00:34 -0000	1.31.2.7
+++ civinode_utils.inc	5 Jul 2007 21:06:26 -0000
@@ -1,5 +1,5 @@
 <?php
-  // $Id: civinode_utils.inc,v 1.31.2.7 2007/06/21 05:00:34 torenware Exp $
+  // $Id: civinode_utils.inc,v 1.32 2007/02/17 01:15:49 torenware Exp $
   /**
    *
    * CiviNode Utility Functions
@@ -108,8 +108,8 @@
   //Docs are wrong... :-(
   //if(crm_is_error($obj)){
   if($obj and is_a($obj, 'CRM_Core_Error')){
-    $msg = $obj->_errors[0]['message'];
-    _civinode_set_error($msg);
+    //$msg = $obj->_errors[0]['message'];
+    _civinode_set_error($obj);
     if (!$log_error)
       return TRUE;
     //may want to record the calling URL as well...
@@ -130,7 +130,24 @@
  * @return string Error string.
  */
 function civinode_get_last_error(){
-  return _civinode_set_error();
+  $err_obj = _civinode_set_error();
+  if ($err_obj) {
+    $msg = $err_obj->_errors[0]['message'];
+    return $msg;
+  }
+  return '';
+}
+
+/**
+ * Get the last error object checked via civinode_check_error
+ * 
+ * @ingroup Error_Handlers
+ * @return object PEAR error object.
+ */
+
+function civinode_get_last_error_object() {
+  $err_obj = _civinode_set_error();
+  return $err_obj;
 }
 
 /**
@@ -180,7 +197,7 @@
   //return just the tip of the stack.
   if ($error_stack->hasErrors()) {
     $errors = $error_stack->getErrors();
-    $lastError = array_pop($errors);
+    $last_error = array_pop($errors);
   }
   
   return $last_error;
@@ -722,25 +739,16 @@
     watchdog('CRM', t('CiviCRM must be installed for CiviNode'), WATCHDOG_ERROR);
     return NULL;
   }
-  $group = crm_get_groups(array('id' => $gid));
-  $list = array();
-  //establish a limit, due to memory bugs
-  //in 1.4.
+  $groups = array( $gid => 1);
+  $params = array( 'group' => $groups );
+  $returnProperties = array('contact_id' => 1);
   $limit = $num_recs ? $num_recs : 1000; 
-  if(civinode_check_error($group))
-    return NULL;
-  if (!count($group))
-    return array();
-  $contacts = crm_get_group_contacts($group[0],
-                                     //array('id' => 1), //bare min please
-                                     NULL, //default instead
-                                     'Added', NULL, //status and sort
-                                     $start, $limit); //up to first 10K records
-  foreach($contacts as $contact){
-    $list[] = $contact->contact_id;
+  $contacts = crm_contact_search($params, $returnProperties, NULL, $start, $limit);
+  $list = array();
+  foreach($contacts[0] as $contact){
+    $list[] = $contact['contact_id'];
   }
   return $list;
-
 }
 
 
@@ -1289,31 +1297,7 @@
     drupal_add_js($init_js, 'inline', 'footer', TRUE);
   }
 }
-/**
- * Put path info in one place (since this may change)
- *
- * @param string $item
- */
-function _civinode_get_path($item = 'base') {
-  global $civicrm_root;
-  
-  //$install_root = realpath($_SERVER['DOCUMENT_ROOT'] . base_path());
-  //$len = strlen($install_root);
-  //$base = substr($civicrm_root, $len + 1);
-  civinode_check_init();
-  $config =& CRM_Core_Config::singleton();
-  $resbase = $config->resourceBase;
-  $url_base = url(NULL, NULL, NULL, TRUE);
-  $base = substr($resbase, strlen($url_base));
-  switch ($item) {
-    case 'ajax':
-      return $base . "extern/ajax.php";
-    case 'dojo_lib':
-      return $base . "packages/dojo/dojo.js";
-    default:
-      return $base;
-  }
-}
+
 
 function _civinode_dojo_dataurl($group_id = 0) {
   //$path = _civinode_get_path('ajax');
@@ -1454,6 +1438,33 @@
 
 }
 
+
+/**
+ * Put path info in one place (since this may change)
+ *
+ * @param string $item
+ */
+function _civinode_get_path($item = 'base') {
+  global $civicrm_root;
+  
+  //$install_root = realpath($_SERVER['DOCUMENT_ROOT'] . base_path());
+  //$len = strlen($install_root);
+  //$base = substr($civicrm_root, $len + 1);
+  civinode_check_init();
+  $config =& CRM_Core_Config::singleton();
+  $resbase = $config->resourceBase;
+  $url_base = url(NULL, NULL, NULL, TRUE);
+  $base = substr($resbase, strlen($url_base));
+  switch ($item) {
+    case 'ajax':
+      return $base . "extern/ajax.php";
+    case 'dojo_lib':
+      return $base . "packages/dojo/dojo.js";
+    default:
+      return $base;
+  }
+}
+
 /**
  * Helper function for extracting CiviCRM config strings
  *
