X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCore%2FBAO%2FNote.php;h=08ad15333bac4d8b33d699cb576c3b987323350d;hb=553ffa22464ff37a28a070458bcd52097b54235f;hp=bc417d76e8c391236e1d8e5b37d8f88cd31f87cc;hpb=5667521530926d61b370a4bb0806b7e5ad63ccbc;p=civicrm-core.git diff --git a/CRM/Core/BAO/Note.php b/CRM/Core/BAO/Note.php index bc417d76e8..08ad15333b 100644 --- a/CRM/Core/BAO/Note.php +++ b/CRM/Core/BAO/Note.php @@ -23,7 +23,7 @@ | GNU Affero General Public License or the licensing of CiviCRM, | | see the CiviCRM license FAQ at http://civicrm.org/licensing | +--------------------------------------------------------------------+ -*/ + */ /** * @@ -47,11 +47,12 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { /** * Given a note id, retrieve the note text * - * @param int $id id of the note to retrieve + * @param int $id + * Id of the note to retrieve. * - * @return string the note text or null if note not found + * @return string + * the note text or NULL if note not found * - * @static */ public static function getNoteText($id) { return CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $id, 'note'); @@ -60,11 +61,12 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { /** * Given a note id, retrieve the note subject * - * @param int $id id of the note to retrieve + * @param int $id + * Id of the note to retrieve. * - * @return string the note subject or null if note not found + * @return string + * the note subject or NULL if note not found * - * @static */ public static function getNoteSubject($id) { return CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $id, 'subject'); @@ -73,11 +75,12 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { /** * Given a note id, decide if the note should be displayed based on privacy setting * - * @param object $note Either the id of the note to retrieve, or the CRM_Core_DAO_Note object itself + * @param object $note + * Either the id of the note to retrieve, or the CRM_Core_DAO_Note object itself. * - * @return boolean TRUE if the note should be displayed, otherwise FALSE + * @return bool + * TRUE if the note should be displayed, otherwise FALSE * - * @static */ public static function getNotePrivacyHidden($note) { if (CRM_Core_Permission::check('view all notes')) { @@ -128,11 +131,13 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { * note object. the params array could contain additional unused name/value * pairs * - * @param array $params (reference) an assoc array of name/value pairs - * @param array $ids (deprecated) associated array with note id - preferably set $params['id'] + * @param array $params + * (reference) an assoc array of name/value pairs. + * @param array $ids + * (deprecated) associated array with note id - preferably set $params['id']. * - * @return object $note CRM_Core_BAO_Note object - * @static + * @return object + * $note CRM_Core_BAO_Note object */ public static function &add(&$params, $ids = array()) { $dataExists = self::dataExists($params); @@ -215,10 +220,10 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { /** * Check if there is data to create the object * - * @param array $params (reference ) an assoc array of name/value pairs + * @param array $params + * (reference ) an assoc array of name/value pairs. * - * @return boolean - * @static + * @return bool */ public static function dataExists(&$params) { // return if no data present @@ -232,19 +237,22 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { * 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) + * @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 - * @static + * @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 = new CRM_Core_BAO_Note(); + $note->entity_id = $params['contact_id']; $note->entity_table = 'civicrm_contact'; // get the total count of notes @@ -275,16 +283,18 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { /** * Delete the notes * - * @param int $id note id - * @param boolean $showStatus do we need to set status or not + * @param int $id + * Note id. + * @param bool $showStatus + * Do we need to set status or not. * - * @return mixed|null $return no of deleted notes on success, false otherwise@access public - * @static + * @return int|NULL + * no of deleted notes on success, null otherwise */ public static function del($id, $showStatus = TRUE) { - $return = NULL; - $recent = array($id); - $note = new CRM_Core_DAO_Note(); + $return = NULL; + $recent = array($id); + $note = new CRM_Core_DAO_Note(); $note->id = $id; $note->find(); $note->fetch(); @@ -324,17 +334,17 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { /** * Delete all records for this contact id * - * @param int $id ID of the contact for which note needs to be deleted. + * @param int $id + * ID of the contact for which note needs to be deleted. * * @return void * - * @static */ public static function deleteContact($id) { // need to delete for both entity_id - $dao = new CRM_Core_DAO_Note(); + $dao = new CRM_Core_DAO_Note(); $dao->entity_table = 'civicrm_contact'; - $dao->entity_id = $id; + $dao->entity_id = $id; $dao->delete(); // and the creator contact id @@ -346,13 +356,14 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note { /** * Retrieve all records for this entity-id * - * @param int $id ID of the relationship for which records needs to be retrieved. + * @param int $id + * ID of the relationship for which records needs to be retrieved. * * @param string $entityTable * - * @return array $viewNote array of note properties + * @return array + * array of note properties * - * @static */ public static function &getNote($id, $entityTable = 'civicrm_relationship') { $viewNote = array(); @@ -381,13 +392,13 @@ ORDER BY modified_date desc"; * * @param int $contactID * - * @return int $count count of log records + * @return int + * $count count of log records * - * @static */ public static function getContactNoteCount($contactID) { - $note = new CRM_Core_DAO_Note(); - $note->entity_id = $contactID; + $note = new CRM_Core_DAO_Note(); + $note->entity_id = $contactID; $note->entity_table = 'civicrm_contact'; $note->find(); $count = 0; @@ -402,13 +413,16 @@ ORDER BY modified_date desc"; /** * Get all descendent notes of the note with given ID * - * @param int $parentId ID of the note to start from - * @param int $maxDepth Maximum number of levels to descend into the tree; if not given, will include all descendents. - * @param bool $snippet If TRUE, returned values will be pre-formatted for display in a table of notes. + * @param int $parentId + * ID of the note to start from. + * @param int $maxDepth + * Maximum number of levels to descend into the tree; if not given, will include all descendents. + * @param bool $snippet + * If TRUE, returned values will be pre-formatted for display in a table of notes. * - * @return array Nested associative array beginning with direct children of given note. + * @return array + * Nested associative array beginning with direct children of given note. * - * @static */ public static function getNoteTree($parentId, $maxDepth = 0, $snippet = FALSE) { return self::buildNoteTree($parentId, $maxDepth, $snippet); @@ -417,16 +431,17 @@ ORDER BY modified_date desc"; /** * Get total count of direct children visible to the current user * - * @param int $id Note ID + * @param int $id + * Note ID. * - * @return int $count Number of notes having the give note as parent + * @return int + * $count Number of notes having the give note as parent * - * @static */ public static function getChildCount($id) { - $note = new CRM_Core_DAO_Note(); + $note = new CRM_Core_DAO_Note(); $note->entity_table = 'civicrm_note'; - $note->entity_id = $id; + $note->entity_id = $id; $note->find(); $count = 0; while ($note->fetch()) { @@ -440,24 +455,29 @@ ORDER BY modified_date desc"; /** * Recursive function to get all descendent notes of the note with given ID * - * @param int $parentId ID of the note to start from - * @param int $maxDepth Maximum number of levels to descend into the tree; if not given, will include all descendents. - * @param bool $snippet If TRUE, returned values will be pre-formatted for display in a table of notes. - * @param array $tree (Reference) Variable to store all found descendents - * @param int $depth Depth of current iteration within the descendent tree (used for comparison against maxDepth) - * - * @return array Nested associative array beginning with direct children of given note. - * @static + * @param int $parentId + * ID of the note to start from. + * @param int $maxDepth + * Maximum number of levels to descend into the tree; if not given, will include all descendents. + * @param bool $snippet + * If TRUE, returned values will be pre-formatted for display in a table of notes. + * @param array $tree + * (Reference) Variable to store all found descendents. + * @param int $depth + * Depth of current iteration within the descendent tree (used for comparison against maxDepth). + * + * @return array + * Nested associative array beginning with direct children of given note. */ private static function buildNoteTree($parentId, $maxDepth = 0, $snippet = FALSE, &$tree = array(), $depth = 0) { if ($maxDepth && $depth > $maxDepth) { - return false; + return FALSE; } // get direct children of given parentId note - $note = new CRM_Core_DAO_Note(); + $note = new CRM_Core_DAO_Note(); $note->entity_table = 'civicrm_note'; - $note->entity_id = $parentId; + $note->entity_id = $parentId; $note->orderBy('modified_date asc'); $note->find(); while ($note->fetch()) { @@ -466,7 +486,7 @@ ORDER BY modified_date desc"; CRM_Core_DAO::storeValues($note, $tree[$note->id]); // get name of user that created this note - $contact = new CRM_Contact_DAO_Contact(); + $contact = new CRM_Contact_DAO_Contact(); $createdById = $note->contact_id; $contact->id = $createdById; $contact->find(); @@ -505,16 +525,19 @@ ORDER BY modified_date desc"; /** * Given a note id, get a list of the ids of all notes that are descendents of that note * - * @param int $parentId Id of the given note - * @param array $ids (reference) one-dimensional array to store found descendent ids + * @param int $parentId + * Id of the given note. + * @param array $ids + * (reference) one-dimensional array to store found descendent ids. * - * @return array $ids One-dimensional array containing ids of all desendent notes + * @return array + * One-dimensional array containing ids of all desendent notes */ public static function getDescendentIds($parentId, &$ids = array()) { // get direct children of given parentId note - $note = new CRM_Core_DAO_Note(); + $note = new CRM_Core_DAO_Note(); $note->entity_table = 'civicrm_note'; - $note->entity_id = $parentId; + $note->entity_id = $parentId; $note->find(); while ($note->fetch()) { // foreach child, add to ids list, and recurse @@ -527,10 +550,10 @@ ORDER BY modified_date desc"; /** * Delete all note related to contact when contact is deleted * - * @param int $contactID contact id whose notes to be deleted + * @param int $contactID + * Contact id whose notes to be deleted. * * @return void - * @static */ public static function cleanContactNotes($contactID) { $params = array(1 => array($contactID, 'Integer')); @@ -557,4 +580,5 @@ WHERE participant.contact_id = %1 AND note.entity_table = 'civicrm_participant' self::del($contactNoteId->id, FALSE); } } + }