static function getContactList() { $siteGroups = CRM_Core_BAO_Domain::getChildGroupIds(); $siteContacts = array(); if (!empty($siteGroups)) { $query = "\nSELECT cc.id\nFROM civicrm_contact cc\nINNER JOIN civicrm_group_contact gc ON \n (gc.contact_id = cc.id AND gc.status = 'Added' AND gc.group_id IN (" . implode(',', $siteGroups) . "))"; $dao =& CRM_Core_DAO::executeQuery($query); while ($dao->fetch()) { $siteContacts[] = $dao->id; } } return $siteContacts; }
/** * Find the get contact details. * * This function does not respect ACLs for now, which might need to be rectified at some * stage based on how its used. * * @param string $mail * Primary email address of the contact. * @param string $ctype * Contact type. * * @return object * $dao contact details */ public static function &matchContactOnEmail($mail, $ctype = NULL) { $strtolower = function_exists('mb_strtolower') ? 'mb_strtolower' : 'strtolower'; $mail = $strtolower(trim($mail)); $query = "\nSELECT civicrm_contact.id as contact_id,\n civicrm_contact.hash as hash,\n civicrm_contact.contact_type as contact_type,\n civicrm_contact.contact_sub_type as contact_sub_type\nFROM civicrm_contact\nINNER JOIN civicrm_email ON ( civicrm_contact.id = civicrm_email.contact_id )"; if (CRM_Core_BAO_Setting::getItem(CRM_Core_BAO_Setting::MULTISITE_PREFERENCES_NAME, 'uniq_email_per_site')) { // try to find a match within a site (multisite). $groups = CRM_Core_BAO_Domain::getChildGroupIds(); if (!empty($groups)) { $query .= "\nINNER JOIN civicrm_group_contact gc ON\n(civicrm_contact.id = gc.contact_id AND gc.status = 'Added' AND gc.group_id IN (" . implode(',', $groups) . "))"; } } $query .= "\nWHERE civicrm_email.email = %1 AND civicrm_contact.is_deleted=0"; $p = array(1 => array($mail, 'String')); if ($ctype) { $query .= " AND civicrm_contact.contact_type = %3"; $p[3] = array($ctype, 'String'); } $query .= " ORDER BY civicrm_email.is_primary DESC"; $dao = CRM_Core_DAO::executeQuery($query, $p); if ($dao->fetch()) { return $dao; } return CRM_Core_DAO::$_nullObject; }
/** * Function to find the get contact details * * @param string $mail primary email address of the contact * @param string $ctype contact type * * @return object $dao contact details * @static */ static function &matchContactOnEmail($mail, $ctype = null) { $mail = strtolower(trim($mail)); $query = "\nSELECT civicrm_contact.id as contact_id,\n civicrm_contact.hash as hash,\n civicrm_contact.contact_type as contact_type,\n civicrm_contact.contact_sub_type as contact_sub_type\nFROM civicrm_contact\nINNER JOIN civicrm_email ON ( civicrm_contact.id = civicrm_email.contact_id )"; if (defined('CIVICRM_UNIQ_EMAIL_PER_SITE') && CIVICRM_UNIQ_EMAIL_PER_SITE) { // try to find a match within a site (multisite). require_once 'CRM/Core/BAO/Domain.php'; $groups = CRM_Core_BAO_Domain::getChildGroupIds(); if (!empty($groups)) { $query .= "\nINNER JOIN civicrm_group_contact gc ON \n(civicrm_contact.id = gc.contact_id AND gc.group_id IN (" . implode(',', $groups) . "))"; } } $query .= " \nWHERE civicrm_email.email = %1"; $p = array(1 => array($mail, 'String')); if ($ctype) { $query .= " AND civicrm_contact.contact_type = %3"; $p[3] = array($ctype, 'String'); } $query .= " ORDER BY civicrm_email.is_primary DESC"; $dao =& CRM_Core_DAO::executeQuery($query, $p); if ($dao->fetch()) { return $dao; } return CRM_Core_DAO::$_nullObject; }