<?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
*
*
* @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";
}
/**
- * 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;
}
/**
- * Function to retrieve statistics for grants.
+ * Retrieve statistics for grants.
*
* @static
*
*
* @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)) {
}
/**
- * 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);
$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];
);
}
- // add the recently created Grant
+ // add the recently created Grant
CRM_Utils_Recent::add($title,
$url,
$grant->id,
}
/**
- * 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
*
*/
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",
'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(
}
/**
- * 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();
}
/**
- * 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();
}
/**
- * 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();
);
$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,
));
}
/**
- * 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);
}
}
-