/** * Delete the notes. * * @param int $id * Note id. * @param bool $showStatus * Do we need to set status or not. * * @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(); $note->id = $id; $note->find(); $note->fetch(); if ($note->entity_table == 'civicrm_note') { $status = ts('Selected Comment has been deleted successfully.'); } else { $status = ts('Selected Note has been deleted successfully.'); } // Delete all descendents of this Note foreach (self::getDescendentIds($id) as $childId) { $childNote = new CRM_Core_DAO_Note(); $childNote->id = $childId; $childNote->delete(); $childNote->free(); $recent[] = $childId; } $return = $note->delete(); $note->free(); if ($showStatus) { CRM_Core_Session::setStatus($status, ts('Deleted'), 'success'); } // delete the recently created Note foreach ($recent as $recentId) { $noteRecent = array('id' => $recentId, 'type' => 'Note'); CRM_Utils_Recent::del($noteRecent); } return $return; }