/** * 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 int $numNotes * The maximum number of notes to return (0 if all). * * @return object * $notes Object of CRM_Core_BAO_Note */ public static function &getValues(&$params, &$values, $numNotes = self::MAX_NOTES) { if (empty($params)) { return NULL; } $note = new CRM_Core_BAO_Note(); $note->entity_id = $params['contact_id']; $note->entity_table = 'civicrm_contact'; // get the total count of notes $values['noteTotalCount'] = $note->count(); // get only 3 recent notes $note->orderBy('modified_date desc'); $note->limit($numNotes); $note->find(); $notes = array(); $count = 0; while ($note->fetch()) { $values['note'][$note->id] = array(); CRM_Core_DAO::storeValues($note, $values['note'][$note->id]); $notes[] = $note; $count++; // if we have collected the number of notes, exit loop if ($numNotes > 0 && $count >= $numNotes) { break; } } return $notes; }