<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 4.5 |
+ | CiviCRM version 4.6 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2014 |
+--------------------------------------------------------------------+
class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
/**
- * const the max number of notes we display at any given time
+ * Const the max number of notes we display at any given time
* @var int
*/
- CONST MAX_NOTES = 3;
+ const MAX_NOTES = 3;
/**
- * given a note id, retrieve the note text
+ * 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
*
- * @access public
* @static
*/
- static function getNoteText($id) {
+ public static function getNoteText($id) {
return CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $id, 'note');
}
/**
- * given a note id, retrieve the note subject
+ * 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
*
- * @access public
* @static
*/
- static function getNoteSubject($id) {
+ public static function getNoteSubject($id) {
return CRM_Core_DAO::getFieldValue('CRM_Core_DAO_Note', $id, 'subject');
}
/**
- * given a note id, decide if the note should be displayed based on privacy setting
+ * 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
*
- * @access public
* @static
*/
- static function getNotePrivacyHidden($note) {
+ public static function getNotePrivacyHidden($note) {
if (CRM_Core_Permission::check('view all notes')) {
return FALSE;
}
}
/**
- * takes an associative array and creates a note object
+ * Takes an associative array and creates a note object
*
* the function extract all the params it needs to initialize the create a
* 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
- * @access public
* @static
*/
- static function &add(&$params, $ids = array()) {
+ public static function &add(&$params, $ids = array()) {
$dataExists = self::dataExists($params);
if (!$dataExists) {
return CRM_Core_DAO::$_nullObject;
/**
* 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
- * @access public
* @static
*/
- static function dataExists(&$params) {
+ public static function dataExists(&$params) {
// return if no data present
if (!strlen($params['note'])) {
return FALSE;
* 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).
*
- * @internal param array $ids the array that holds all the db ids
* @return object $notes Object of CRM_Core_BAO_Note
- * @access public
* @static
*/
- static function &getValues(&$params, &$values, $numNotes = self::MAX_NOTES) {
+ public static function &getValues(&$params, &$values, $numNotes = self::MAX_NOTES) {
if (empty($params)) {
return NULL;
}
}
/**
- * Function to delete the notes
+ * 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
+ * @return mixed|NULL $return no of deleted notes on success, FALSE otherwise
+ * @access public
* @static
*/
- static function del($id, $showStatus = TRUE) {
+ public static function del($id, $showStatus = TRUE) {
$return = NULL;
$recent = array($id);
$note = new CRM_Core_DAO_Note();
}
/**
- * delete all records for this contact id
+ * 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
*
- * @access public
* @static
*/
public static function deleteContact($id) {
}
/**
- * retrieve all records for this entity-id
+ * 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
*
- * @access public
* @static
*/
public static function &getNote($id, $entityTable = 'civicrm_relationship') {
}
/**
- * Function to get log record count for a Contact
- *
- * @param $contactID
+ * Get log record count for a Contact
*
- * @internal param int $contactId Contact ID
+ * @param int $contactID
*
* @return int $count count of log records
*
- * @access public
* @static
*/
- static function getContactNoteCount($contactID) {
+ public static function getContactNoteCount($contactID) {
$note = new CRM_Core_DAO_Note();
$note->entity_id = $contactID;
$note->entity_table = 'civicrm_contact';
}
/**
- * Function to get all descendent notes of the note with given ID
+ * 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.
*
* @static
- * @access public
*/
public static function getNoteTree($parentId, $maxDepth = 0, $snippet = FALSE) {
return self::buildNoteTree($parentId, $maxDepth, $snippet);
/**
* 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
*
* @static
- * @access public
*/
public static function getChildCount($id) {
$note = new CRM_Core_DAO_Note();
/**
* 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)
+ * @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
*/
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
}
/**
- * given a note id, get a list of the ids of all notes that are descendents of that note
+ * 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
*/
- public static function getDescendentIds($parentId, &$ids = array(
- )) {
+ public static function getDescendentIds($parentId, &$ids = array()) {
// get direct children of given parentId note
$note = new CRM_Core_DAO_Note();
$note->entity_table = 'civicrm_note';
}
/**
- * function to delete all note related to contact when contact is deleted
+ * Delete all note related to contact when contact is deleted
*
- * @param int $contactID contact id whose notes to be deleted
- *
- * @internal param array $deleteNoteID to store all deleted note ids
+ * @param int $contactID
+ * Contact id whose notes to be deleted.
*
* @return void
* @static
*/
- static function cleanContactNotes($contactID) {
+ public static function cleanContactNotes($contactID) {
$params = array(1 => array($contactID, 'Integer'));
// delete all notes related to contribution
}
}
}
-