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) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Search API Params for searching emails for all location types - Civi 3.0.3
Pages: [1]

Author Topic: Search API Params for searching emails for all location types - Civi 3.0.3  (Read 779 times)

yasheshb

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 5
Search API Params for searching emails for all location types - Civi 3.0.3
July 05, 2010, 08:38:41 am
Hello:

   is there a way to specify a key in $params for searching all emails matching all location types.
currently when i use the code below, it searches only emails matching the primary (default) location type

Code: [Select]
  // initialize civicrm
  civicrm_initialize();
  require_once 'api/v2/Contact.php';

  // search for matching emails.
  $params = array('email' => $form_state['values']['email']);

  $result = civicrm_contact_search($params);

Another better idea would be to provide

Thanks.

Yashesh Bhatia.

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Search API Params for searching emails for all location types - Civi 3.0.3
July 05, 2010, 08:47:53 am
Don't think we have a civicrm_email_get yet.

Do you think you could develop and contribute it ? That's essentially a 3 lines wrapper function around

CRM_Core_BAO_Email::allEmails

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

yasheshb

  • I post occasionally
  • **
  • Posts: 72
  • Karma: 5
Re: Search API Params for searching emails for all location types - Civi 3.0.3
July 05, 2010, 10:42:00 pm
xavier:

  i looked at the function CRM_Core_BAO_Email::allEmails

Code: [Select]
    /**
     * Get all the emails for a specified contact_id, with the primary email being first
     *
     * @param int $id the contact id
     *
     * @return array  the array of email id's
     * @access public
     * @static
     */
    static function allEmails( $id )

  and it gets all emails for a specific contact id. what i needed was to obtain all contact id's for a particular email
address irrespective of whether it's primary/main/work/other etc.

not sure how wrapping this function with a wrapper and invoking the civicrm_contact_search could achieve it.
sorry i'm not totally familiar with internally how the api's are coded.  i'd be glad to work on it but i'll need some guidance on it.

thx.

yashesh bhatia

xavier

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4453
  • Karma: 161
    • Tech To The People
  • CiviCRM version: yes probably
  • CMS version: drupal
Re: Search API Params for searching emails for all location types - Civi 3.0.3
July 05, 2010, 11:08:11 pm
Hi,

Sorry misread your need. Indeed, that's a different method to call. I'm not on the dev computer now, but will check later (a method used in the civicampaign but blank on the name right now)

Would you like to know if it's the primary email or not ? In that case, pretty sure it doesn't exist and the api should use sql (or add a method on the BAO)

X+
-Hackathon and data journalism about the European parliament 24-26 jan. Watch out the result

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Search API Params for searching emails for all location types - Civi 3.0.3

This forum was archived on 2017-11-26.