CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • crm_contact_search and civinode and civicrn 1.8
Pages: [1]

Author Topic: crm_contact_search and civinode and civicrn 1.8  (Read 1219 times)

alfred_nutile

  • Ask me questions
  • ****
  • Posts: 464
  • Karma: 14
    • River Valley Tech Collective
crm_contact_search and civinode and civicrn 1.8
July 19, 2008, 05:05:36 am
Just wondering if there is a way to make it so this function does not die out when there is an apostrophe in the name.
For example John's Farm will not work but if the name is Johns Farm it work.
By working I mean this.
Locations nodes have a cck field and that is a civicrm node autocomplete.
Below, I think is the code from civinode_utils.inc. Line 859
My main question is the limitation in this code or in civi? If in this code I will work on it.
Thanks
Code: [Select]
function civinode_contact_autocompleter($key, $val, $string){
  if (!civinode_check_init()){
    watchdog('CRM', t('CiviCRM must be installed for CiviNode'),
             WATCHDOG_ERROR);
    exit();
  }
  //first, require that we have at least 3 characters
  if (strlen($string) < 3)
    exit();

  //OR is really needed here. Lobo??
  $return_fields = array('display_name' => 1,
                         'id' => 1,
                         'contact_type' => 1,
                         );
 
  $params['sort_name'] = "%$string%";
  //Check the key/val argument for special handling
  if ($key == 'gid' and is_numeric($val)) {
    $params['group'] = array($val => 1);

  }
  $rslt = crm_contact_search($params, $return_fields);
  $matches = array();
  foreach($rslt[0] as $id => $data){
    $id_str = " (" . $id . ")";
    $matches[$data['display_name'] . $id_str] = check_plain($data['display_name'] . $id_str);
  }
  //This assumes you are using
  //4.7 RC2 or later...
  print drupal_to_js($matches);
  exit();

}


Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Support »
  • Using CiviCRM »
  • Using Core CiviCRM Functions (Moderator: Yashodha Chaku) »
  • crm_contact_search and civinode and civicrn 1.8

This forum was archived on 2017-11-26.