/** * Given the list of params in the params array, fetch the object * and store the values in the values array * * @param array $params input parameters to find object * @param array $values output values of the object * @param array $ids the array that holds all the db ids * @param int $locationCount number of locations to fetch * * @return array array of objects(CRM_Core_BAO_Location) * @access public * @static */ function &getValues(&$params, &$values, &$ids, $locationCount = 0) { $location =& new CRM_Core_BAO_Location(); $location->copyValues($params); if ($params['contact_id']) { $location->entity_table = 'civicrm_contact'; $location->entity_id = $params['contact_id']; } else { if ($params['domain_id']) { $location->entity_table = 'civicrm_domain'; $location->entity_id = $params['domain_id']; } } $flatten = false; if (empty($locationCount)) { $locationCount = 1; $flatten = true; } else { $values['location'] = array(); $ids['location'] = array(); } // we first get the primary location due to the order by clause $location->orderBy('is_primary desc, id'); $location->find(); $locations = array(); for ($i = 0; $i < $locationCount; $i++) { if ($location->fetch()) { $params['location_id'] = $location->id; if ($flatten) { $ids['location'] = $location->id; CRM_Core_DAO::storeValues($location, $values); CRM_Core_BAO_Location::getBlocks($params, $values, $ids, 0, $location); } else { $values['location'][$i + 1] = array(); $ids['location'][$i + 1] = array(); $ids['location'][$i + 1]['id'] = $location->id; CRM_Core_DAO::storeValues($location, $values['location'][$i + 1]); CRM_Core_BAO_Location::getBlocks($params, $values['location'][$i + 1], $ids['location'][$i + 1], CRM_CONTACT_FORM_LOCATION_BLOCKS, $location); } $locations[$i + 1] = clone $location; } } return $locations; }