Merge pull request #4997 from monishdeb/CRM-15536
[civicrm-core.git] / CRM / Core / BAO / Note.php
index d3d51138cec39b4b31705d1736ca99d5811ecdf4..08ad15333bac4d8b33d699cb576c3b987323350d 100644 (file)
@@ -23,7 +23,7 @@
  | GNU Affero General Public License or the licensing of CiviCRM,     |
  | see the CiviCRM license FAQ at http://civicrm.org/licensing        |
  +--------------------------------------------------------------------+
-*/
+ */
 
 /**
  *
@@ -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')) {
@@ -141,7 +138,6 @@ 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()) {
     $dataExists = self::dataExists($params);
@@ -227,8 +223,7 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
    * @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,14 +246,13 @@ 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)) {
       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
@@ -294,14 +288,13 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
    * @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();
@@ -346,13 +339,12 @@ class CRM_Core_BAO_Note extends CRM_Core_DAO_Note {
    *
    * @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
@@ -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();
@@ -404,11 +395,10 @@ ORDER BY  modified_date desc";
    * @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;
@@ -433,7 +423,6 @@ 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);
@@ -448,12 +437,11 @@ 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();
+    $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()) {
@@ -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) {
@@ -488,9 +475,9 @@ ORDER BY  modified_date desc";
     }
 
     // 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()) {
@@ -499,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();
@@ -548,9 +535,9 @@ ORDER BY  modified_date desc";
    */
   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
@@ -567,7 +554,6 @@ ORDER BY  modified_date desc";
    *   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);
     }
   }
+
 }