INFRA-132 - Put space after flow-control (if/switch/for/foreach/while)
[civicrm-core.git] / CRM / Grant / BAO / Grant.php
index c4ae493175ad18f5e6c26e802bb9bae093b6172a..7873796c1804a214343c8592bb4c4d62f81793e9 100644 (file)
@@ -1,7 +1,7 @@
 <?php
 /*
  +--------------------------------------------------------------------+
- | CiviCRM version 4.5                                                |
+ | CiviCRM version 4.6                                                |
  +--------------------------------------------------------------------+
  | Copyright CiviCRM LLC (c) 2004-2014                                |
  +--------------------------------------------------------------------+
 class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
 
   /**
-   * static field for all the grant information that we can potentially export
+   * Static field for all the grant information that we can potentially export
    * @var array
    * @static
    */
   static $_exportableFields = NULL;
 
   /**
-   * class constructor
+   * Class constructor
    */
-  function __construct() {
+  public function __construct() {
     parent::__construct();
   }
 
   /**
-   * Function to get events Summary
+   * Get events Summary
    *
    * @static
    *
@@ -57,7 +57,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
    *
    * @return array Array of event summary values
    */
-  static function getGrantSummary($admin = FALSE) {
+  public static function getGrantSummary($admin = FALSE) {
     $query = "
             SELECT status_id, count(id) as status_total
             FROM civicrm_grant  GROUP BY status_id";
@@ -89,13 +89,13 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
   }
 
   /**
-   * Function to get events Summary
+   * Get events Summary
    *
    * @static
    *
    * @return array Array of event summary values
    */
-  static function getGrantStatusOptGroup() {
+  public static function getGrantStatusOptGroup() {
 
     $params = array();
     $params['name'] = CRM_Grant_BAO_Grant::$statusGroupName;
@@ -111,7 +111,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
   }
 
   /**
-   * Function to retrieve statistics for grants.
+   * Retrieve statistics for grants.
    *
    * @static
    *
@@ -119,25 +119,22 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
    *
    * @return array Array of grant summary statistics
    */
-  static function getGrantStatistics($admin = FALSE) {
+  public static function getGrantStatistics($admin = FALSE) {
     $grantStatuses = array();
   }
 
   /**
-   * Takes a bunch of params that are needed to match certain criteria and
-   * retrieves the relevant objects. Typically the valid params are only
-   * contact_id. We'll tweak this function to be more full featured over a period
-   * of time. This is the inverse function of create. It also stores all the retrieved
-   * values in the default array
+   * Fetch object based on array of properties
    *
-   * @param array $params   (reference ) an assoc array of name/value pairs
-   * @param array $defaults (reference ) an assoc array to hold the flattened values
+   * @param array $params
+   *   (reference ) an assoc array of name/value pairs.
+   * @param array $defaults
+   *   (reference ) an assoc array to hold the flattened values.
    *
-   * @return object CRM_Grant_BAO_ManageGrant object
-   * @access public
+   * @return CRM_Grant_BAO_ManageGrant object
    * @static
    */
-  static function retrieve(&$params, &$defaults) {
+  public static function retrieve(&$params, &$defaults) {
     $grant = new CRM_Grant_DAO_Grant();
     $grant->copyValues($params);
     if ($grant->find(TRUE)) {
@@ -148,17 +145,18 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
   }
 
   /**
-   * function to add grant
+   * Add grant
    *
-   * @param array $params reference array contains the values submitted by the form
-   * @param array $ids    reference array contains the id
+   * @param array $params
+   *   Reference array contains the values submitted by the form.
+   * @param array $ids
+   *   Reference array contains the id.
    *
-   * @access public
    * @static
    *
    * @return object
    */
-  static function add(&$params, &$ids) {
+  public static function add(&$params, &$ids) {
 
     if (!empty($ids['grant_id'])) {
       CRM_Utils_Hook::pre('edit', 'Grant', $ids['grant_id'], $params);
@@ -210,7 +208,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
 
     $grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
     if (empty($params['skipRecentView'])) {
-      if(!isset($grant->contact_id) || !isset($grant->grant_type_id)){
+      if (!isset($grant->contact_id) || !isset($grant->grant_type_id)){
         $grant->find(TRUE);
       }
       $title = CRM_Contact_BAO_Contact::displayName($grant->contact_id) . ' - ' . ts('Grant') . ': ' . $grantTypes[$grant->grant_type_id];
@@ -227,7 +225,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
         );
       }
 
-    // add the recently created Grant
+      // add the recently created Grant
       CRM_Utils_Recent::add($title,
         $url,
         $grant->id,
@@ -249,13 +247,14 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
   }
 
   /**
-   * function to create the event
+   * Create the event
    *
-   * @param array $params reference array contains the values submitted by the form
-   * @param array $ids reference array contains the id
+   * @param array $params
+   *   Reference array contains the values submitted by the form.
+   * @param array $ids
+   *   Reference array contains the id.
    *
    * @return object
-   * @access public
    * @static
    *
    */
@@ -274,7 +273,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
     if (!$id) {
       $id = CRM_Utils_Array::value('contact_id', $params);
     }
-    if (!empty($params['note']) || CRM_Utils_Array::value('id', CRM_Utils_Array::value('note',$ids))) {
+    if (!empty($params['note']) || CRM_Utils_Array::value('id', CRM_Utils_Array::value('note', $ids))) {
       $noteParams = array(
         'entity_table' => 'civicrm_grant',
         'note' => $params['note'] = $params['note'] ? $params['note'] : "null",
@@ -283,7 +282,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
         'modified_date' => date('Ymd'),
       );
 
-      CRM_Core_BAO_Note::add($noteParams, $ids['note']);
+      CRM_Core_BAO_Note::add($noteParams, (array) CRM_Utils_Array::value('note', $ids));
     }
     // Log the information on successful add/edit of Grant
     $logParams = array(
@@ -312,17 +311,16 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
   }
 
   /**
-   * Function to delete the Contact
+   * Delete the Contact
    *
-   * @param $id
+   * @param int $id
+   *   Contact id.
    *
    * @return bool
-   * @internal param int $cid contact id
    *
-   * @access public
    * @static
    */
-  static function deleteContact($id) {
+  public static function deleteContact($id) {
     $grant = new CRM_Grant_DAO_Grant();
     $grant->contact_id = $id;
     $grant->delete();
@@ -330,16 +328,16 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
   }
 
   /**
-   * Function to delete the grant
+   * Delete the grant
    *
-   * @param int $id grant id
+   * @param int $id
+   *   Grant id.
    *
    * @return bool|mixed
-   * @access public
    * @static
    *
    */
-  static function del($id) {
+  public static function del($id) {
     CRM_Utils_Hook::pre('delete', 'Grant', $id, CRM_Core_DAO::$_nullArray);
 
     $grant = new CRM_Grant_DAO_Grant();
@@ -363,13 +361,12 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
   }
 
   /**
-   * combine all the exportable fields from the lower levels object
+   * Combine all the exportable fields from the lower levels object
    *
    * @return array array of exportable Fields
-   * @access public
    * @static
    */
-  static function &exportableFields() {
+  public static function &exportableFields() {
     if (!self::$_exportableFields) {
       if (!self::$_exportableFields) {
         self::$_exportableFields = array();
@@ -404,7 +401,9 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
       );
 
       $fields = CRM_Grant_DAO_Grant::export();
-      $grantNote = array('grant_note' => array('title' => ts('Grant Note'),
+      $grantNote = array(
+      'grant_note' => array(
+      'title' => ts('Grant Note'),
           'name' => 'grant_note',
           'data_type' => CRM_Utils_Type::T_TEXT,
         ));
@@ -418,19 +417,15 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
   }
 
   /**
-   * Function to get grant record count for a Contact
+   * Get grant record count for a Contact
    *
-   * @param $contactID
-   *
-   * @internal param int $contactId Contact ID
+   * @param int $contactID
    *
    * @return int count of grant records
-   * @access public
    * @static
    */
-  static function getContactGrantCount($contactID) {
+  public static function getContactGrantCount($contactID) {
     $query = "SELECT count(*) FROM civicrm_grant WHERE civicrm_grant.contact_id = {$contactID} ";
     return CRM_Core_DAO::singleValueQuery($query);
   }
 }
-