/** * Takes a bunch of params that are needed to match certain criteria and * retrieves the relevant objects. Typically the valid params are only * contact_id. We'll tweak this function to be more full featured over a period * of time. This is the inverse function of create. It also stores all the retrieved * values in the default array * * @param array $params (reference ) an assoc array of name/value pairs * @param array $defaults (reference ) an assoc array to hold the name / value pairs * in a hierarchical manner * @param array $ids (reference) the array that holds all the db ids * @param boolean $microformat for location in microformat * * @return object CRM_Contact_BAO_Contact object * @access public * @static */ static function &retrieve(&$params, &$defaults, $microformat = false) { if (array_key_exists('contact_id', $params)) { $params['id'] = $params['contact_id']; } else { if (array_key_exists('id', $params)) { $params['contact_id'] = $params['id']; } } $contact = self::_getValues($params, $defaults); unset($params['id']); //get the block information for this contact $entityBlock = array('contact_id' => $params['contact_id']); $blocks = CRM_Core_BAO_Location::getValues($entityBlock, $microformat); $defaults = array_merge($defaults, $blocks); foreach ($blocks as $block => $value) { $contact->{$block} = $value; } $contact->notes =& CRM_Core_BAO_Note::getValues($params, $defaults); $contact->relationship =& CRM_Contact_BAO_Relationship::getValues($params, $defaults); $contact->groupContact =& CRM_Contact_BAO_GroupContact::getValues($params, $defaults); return $contact; }
/** * Fetch object based on array of properties. * * @param array $params * (reference ) an assoc array of name/value pairs. * @param array $defaults * (reference ) an assoc array to hold the name / value pairs. * in a hierarchical manner * @param bool $microformat * For location in microformat. * * @return CRM_Contact_BAO_Contact */ public static function &retrieve(&$params, &$defaults, $microformat = FALSE) { if (array_key_exists('contact_id', $params)) { $params['id'] = $params['contact_id']; } elseif (array_key_exists('id', $params)) { $params['contact_id'] = $params['id']; } $contact = self::getValues($params, $defaults); unset($params['id']); //get the block information for this contact $entityBlock = array('contact_id' => $params['contact_id']); $blocks = CRM_Core_BAO_Location::getValues($entityBlock, $microformat); $defaults = array_merge($defaults, $blocks); foreach ($blocks as $block => $value) { $contact->{$block} = $value; } if (!isset($params['noNotes'])) { $contact->notes = CRM_Core_BAO_Note::getValues($params, $defaults); } if (!isset($params['noRelationships'])) { $contact->relationship = CRM_Contact_BAO_Relationship::getValues($params, $defaults); } if (!isset($params['noGroups'])) { $contact->groupContact = CRM_Contact_BAO_GroupContact::getValues($params, $defaults); } if (!isset($params['noWebsite'])) { $contact->website = CRM_Core_BAO_Website::getValues($params, $defaults); } return $contact; }
/** * Takes a bunch of params that are needed to match certain criteria and * retrieves the relevant objects. Typically the valid params are only * contact_id. We'll tweak this function to be more full featured over a period * of time. This is the inverse function of create. It also stores all the retrieved * values in the default array * * @param array $params (reference ) an assoc array of name/value pairs * @param array $defaults (reference ) an assoc array to hold the name / value pairs * in a hierarchical manner * @param array $ids (reference) the array that holds all the db ids * * @return object CRM_Contact_BAO_Contact object * @access public * @static */ function retrieve(&$params, &$defaults, &$ids) { $contact = CRM_Contact_BAO_Contact::getValues($params, $defaults, $ids); unset($params['id']); require_once str_replace('_', DIRECTORY_SEPARATOR, "CRM_Contact_BAO_" . $contact->contact_type) . ".php"; eval('$contact->contact_type_object =& CRM_Contact_BAO_' . $contact->contact_type . '::getValues( $params, $defaults, $ids );'); $locParams = $params + array('entity_id' => $params['contact_id'], 'entity_table' => CRM_Contact_BAO_Contact::getTableName()); $contact->location =& CRM_Core_BAO_Location::getValues($locParams, $defaults, $ids, 3); $contact->notes =& CRM_Core_BAO_Note::getValues($params, $defaults, $ids); $contact->relationship =& CRM_Contact_BAO_Relationship::getValues($params, $defaults, $ids); $contact->groupContact =& CRM_Contact_BAO_GroupContact::getValues($params, $defaults, $ids); $activityParam = array('entity_id' => $params['contact_id']); $contact->activity =& CRM_Core_BAO_History::getValues($activityParam, $defaults, 'Activity'); $activityParam = array('contact_id' => $params['contact_id']); $defaults['openActivity'] = array('data' => CRM_Contact_BAO_Contact::getOpenActivities($activityParam, 0, 3), 'totalCount' => CRM_Contact_BAO_Contact::getNumOpenActivity($params['contact_id'])); return $contact; }