CRM-16367 (Backoffice Contribution Form) centralisation & testing of setting premium...
[civicrm-core.git] / CRM / Core / BAO / Note.php
index 4a70cf516c0b29b8617cbfb7996bbb89a4f99740..038dbf77447c936bcd1448192ae887ec99c40a47 100644 (file)
@@ -3,7 +3,7 @@
  +--------------------------------------------------------------------+
  | 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$
  *
  */
@@ -39,7 +39,7 @@
 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;
@@ -53,7 +53,6 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
    * @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');
@@ -68,7 +67,6 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
    * @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');
@@ -80,10 +78,9 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
    * @param object $note
    *   Either the id of the note to retrieve, or the CRM_Core_DAO_Note object itself.
    *
-   * @return boolean
+   * @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,7 +125,7 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
   }
 
   /**
-   * 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
@@ -141,9 +138,8 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
    *
    * @return object
    *   $note CRM_Core_BAO_Note object
-   * @static
    */
-  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;
@@ -222,13 +218,12 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
   }
 
   /**
-   * 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
@@ -251,7 +246,6 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
    *
    * @return object
    *   $notes  Object of CRM_Core_BAO_Note
-   * @static
    */
   public static function &getValues(&$params, &$values, $numNotes = self::MAX_NOTES) {
     if (empty($params)) {
@@ -287,16 +281,15 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
   }
 
   /**
-   * 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;
@@ -339,14 +332,13 @@ class CRM_Core_BAO_Note extends 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.
    *
    * @return void
    *
-   * @static
    */
   public static function deleteContact($id) {
     // need to delete for both entity_id
@@ -372,7 +364,6 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
    * @return array
    *   array of note properties
    *
-   * @static
    */
   public static function &getNote($id, $entityTable = 'civicrm_relationship') {
     $viewNote = array();
@@ -397,14 +388,13 @@ ORDER BY  modified_date desc";
   }
 
   /**
-   * Get log record count for a Contact
+   * Get log record count for a Contact.
    *
    * @param int $contactID
    *
    * @return int
    *   $count count of log records
    *
-   * @static
    */
   public static function getContactNoteCount($contactID) {
     $note = new CRM_Core_DAO_Note();
@@ -421,7 +411,7 @@ ORDER BY  modified_date desc";
   }
 
   /**
-   * 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.
@@ -433,14 +423,13 @@ ORDER BY  modified_date desc";
    * @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.
@@ -448,7 +437,6 @@ ORDER BY  modified_date desc";
    * @return int
    *   $count Number of notes having the give note as parent
    *
-   * @static
    */
   public static function getChildCount($id) {
     $note = new CRM_Core_DAO_Note();
@@ -465,7 +453,7 @@ ORDER BY  modified_date desc";
   }
 
   /**
-   * 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.
@@ -480,7 +468,6 @@ ORDER BY  modified_date desc";
    *
    * @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) {
@@ -561,13 +548,12 @@ ORDER BY  modified_date desc";
   }
 
   /**
-   * 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'));
@@ -594,4 +580,5 @@ WHERE participant.contact_id = %1 AND  note.entity_table = 'civicrm_participant'
       self::del($contactNoteId->id, FALSE);
     }
   }
+
 }