+--------------------------------------------------------------------+
| CiviCRM version 4.6 |
+--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2014 |
+ | Copyright CiviCRM LLC (c) 2004-2015 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| GNU Affero General Public License or the licensing of CiviCRM, |
| see the CiviCRM license FAQ at http://civicrm.org/licensing |
+--------------------------------------------------------------------+
-*/
+ */
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2014
+ * @copyright CiviCRM LLC (c) 2004-2015
* $Id$
*
*/
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;
* @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');
* @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');
* @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')) {
}
/**
- * 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
* @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()) {
+ 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
+ * Check if there is data to create the object.
*
* @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
* @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
}
/**
- * Delete the notes
+ * Delete the notes.
*
* @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();
}
/**
- * 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.
*
* @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
*
* @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();
}
/**
- * Get log record count for a Contact
+ * Get log record count for a Contact.
*
* @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;
}
/**
- * 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 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);
}
/**
- * Get total count of direct children visible to the current user
+ * Get total count of direct children visible to the current user.
*
* @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()) {
}
/**
- * Recursive function to get all descendent notes of the note with given ID
+ * 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 $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
+ * @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) {
}
// 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()) {
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();
* @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
}
/**
- * 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.
*
* @return void
- * @static
*/
public static function cleanContactNotes($contactID) {
$params = array(1 => array($contactID, 'Integer'));
self::del($contactNoteId->id, FALSE);
}
}
+
}