Skip to content
Snippets Groups Projects
Commit fb1fd730 authored by colemanw's avatar colemanw
Browse files

Remove grant pseudoconstants CRM-12464

----------------------------------------
* CRM-12464: Search improvements in 4.4
  http://issues.civicrm.org/jira/browse/CRM-12464
parent d8ad616b
Branches
Tags
No related merge requests found
......@@ -65,7 +65,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
$status = array();
$summary = array();
$summary['total_grants'] = NULL;
$status = CRM_Grant_PseudoConstant::grantStatus();
$status = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
foreach ($status as $id => $name) {
$stats[$id] = array(
......@@ -204,7 +204,7 @@ class CRM_Grant_BAO_Grant extends CRM_Grant_DAO_Grant {
"action=view&reset=1&id={$grant->id}&cid={$grant->contact_id}&context=home"
);
$grantTypes = CRM_Grant_PseudoConstant::grantType();
$grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
if (!CRM_Utils_Array::value('skipRecentView', $params)) {
if(!isset($grant->contact_id) || !isset($grant->grant_type_id)){
$grant->find(TRUE);
......
......@@ -54,8 +54,8 @@ class CRM_Grant_Form_GrantView extends CRM_Core_Form {
$values = array();
$params['id'] = $this->_id;
CRM_Grant_BAO_Grant::retrieve($params, $values);
$grantType = CRM_Grant_PseudoConstant::grantType();
$grantStatus = CRM_Grant_PseudoConstant::grantStatus();
$grantType = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
$grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
$this->assign('grantType', $grantType[$values['grant_type_id']]);
$this->assign('grantStatus', $grantStatus[$values['status_id']]);
$grantTokens = array(
......
......@@ -63,7 +63,7 @@ class CRM_Grant_Form_Task_Update extends CRM_Grant_Form_Task {
* @return void
*/
function buildQuickForm() {
$grantStatus = CRM_Grant_PseudoConstant::grantStatus();
$grantStatus = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id');
$this->addElement('select', 'status_id', ts('Grant Status'), array('' => '') + $grantStatus);
$this->addElement('text', 'amount_granted', ts('Amount Granted'));
......
<?php
/*
+--------------------------------------------------------------------+
| CiviCRM version 4.3 |
+--------------------------------------------------------------------+
| Copyright CiviCRM LLC (c) 2004-2013 |
+--------------------------------------------------------------------+
| This file is a part of CiviCRM. |
| |
| CiviCRM is free software; you can copy, modify, and distribute it |
| under the terms of the GNU Affero General Public License |
| Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
| |
| CiviCRM is distributed in the hope that it will be useful, but |
| WITHOUT ANY WARRANTY; without even the implied warranty of |
| MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| See the GNU Affero General Public License for more details. |
| |
| You should have received a copy of the GNU Affero General Public |
| License and the CiviCRM Licensing Exception along |
| with this program; if not, contact CiviCRM LLC |
| at info[AT]civicrm[DOT]org. If you have questions about the |
| 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-2013
* $Id$
*
*/
/**
* This class holds all the Pseudo constants that are specific to Grant. This avoids
* polluting the core class and isolates the Grant
*/
class CRM_Grant_PseudoConstant extends CRM_Core_PseudoConstant {
/**
* Grant Status
*
* @var array
* @static
*/
private static $grantStatus;
/**
* grant Type
*
* @var array
* @static
*/
private static $grantType;
/**
* Get all the n grant statuses
*
* @access public
*
* @return array - array reference of all grant statuses if any
* @static
*/
public static function &grantStatus($id = NULL) {
if (!self::$grantStatus) {
self::$grantStatus = array();
self::$grantStatus = CRM_Core_OptionGroup::values('grant_status');
}
if ($id) {
return self::$grantStatus[$id];
}
return self::$grantStatus;
}
/**
* Get all the n grant types
*
* @access public
*
* @return array - array reference of all grant types if any
* @static
*/
public static function &grantType($id = NULL) {
if (!self::$grantType) {
self::$grantType = array();
self::$grantType = CRM_Core_OptionGroup::values('grant_type');
}
If ($id) {
return self::$grantType[$id];
}
return self::$grantType;
}
/**
* Flush given pseudoconstant so it can be reread from db
* nex time it's requested.
*
* @access public
* @static
*
* @param boolean $name pseudoconstant to be flushed
*
*/
public static function flush($name = 'cache') {
if (isset(self::$$name)) {
self::$$name = NULL;
}
}
}
......@@ -161,14 +161,14 @@ class CRM_Report_Form_Grant_Detail extends CRM_Report_Form {
'name' => 'grant_type_id',
'title' => ts('Grant Type'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Grant_PseudoConstant::grantType(),
'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'),
),
'status_id' =>
array(
'name' => 'status_id',
'title' => ts('Grant Status'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Grant_PseudoConstant::grantStatus(),
'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'),
),
'amount_granted' =>
array(
......@@ -360,13 +360,13 @@ class CRM_Report_Form_Grant_Detail extends CRM_Report_Form {
if (array_key_exists('civicrm_grant_grant_type_id', $row)) {
if ($value = $row['civicrm_grant_grant_type_id']) {
$rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Grant_PseudoConstant::grantType($value);
$rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'grant_type_id', $value);
}
$entryFound = TRUE;
}
if (array_key_exists('civicrm_grant_status_id', $row)) {
if ($value = $row['civicrm_grant_status_id']) {
$rows[$rowNum]['civicrm_grant_status_id'] = CRM_Grant_PseudoConstant::grantStatus($value);
$rows[$rowNum]['civicrm_grant_status_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'status_id', $value);
}
$entryFound = TRUE;
}
......
......@@ -114,14 +114,14 @@ class CRM_Report_Form_Grant_Statistics extends CRM_Report_Form {
'name' => 'grant_type_id',
'title' => ts('Grant Type'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Grant_PseudoConstant::grantType(),
'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'),
),
'status_id' =>
array(
'name' => 'status_id',
'title' => ts('Grant Status'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Grant_PseudoConstant::grantStatus(),
'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'),
),
'amount_requested' =>
array(
......@@ -285,7 +285,7 @@ class CRM_Report_Form_Grant_Statistics extends CRM_Report_Form {
}
function where() {
$approved = array_search( 'Approved', CRM_Grant_PseudoConstant::grantStatus( ) );
$approved = CRM_Core_PseudoConstant::getKey('CRM_Grant_DAO_Grant', 'status_id', 'Approved', array('labelColumn' => 'name'));
$whereClause = "
WHERE {$this->_aliases['civicrm_grant']}.amount_total IS NOT NULL
AND {$this->_aliases['civicrm_grant']}.amount_total > 0";
......@@ -381,7 +381,7 @@ WHERE {$this->_aliases['civicrm_grant']}.amount_total IS NOT NULL
$awardedGrantsAmount = $grantsReceived = $totalAmount = $awardedGrants = $grantReportsReceived = 0;
$grantStatistics = array();
$grantTypes = CRM_Grant_PseudoConstant::grantType();
$grantTypes = CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id');
$countries = CRM_Core_PseudoConstant::country();
$gender = CRM_Core_PseudoConstant::get('CRM_Contact_DAO_Contact', 'gender_id');
......
......@@ -477,6 +477,16 @@ class CRM_Core_PseudoConstantTest extends CiviUnitTestCase {
'sample' => 'Approved',
),
),
'CRM_Grant_DAO_Grant' => array(
array(
'fieldName' => 'status_id',
'sample' => 'Approved',
),
array(
'fieldName' => 'grant_type_id',
'sample' => 'Emergency',
),
),
);
foreach ($fields as $daoName => $daoFields) {
......
......@@ -34,7 +34,6 @@
*/
require_once 'CRM/Report/Form.php';
require_once 'CRM/Grant/PseudoConstant.php';
class org_civicrm_report_grant extends CRM_Report_Form {
protected $_addressField = FALSE; function __construct() {
......@@ -136,14 +135,14 @@ class org_civicrm_report_grant extends CRM_Report_Form {
'name' => 'grant_type_id',
'title' => ts('Grant Type'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Grant_PseudoConstant::grantType(),
'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'grant_type_id'),
),
'status_id' =>
array(
'name' => 'status_id',
'title' => ts('Grant Status'),
'operatorType' => CRM_Report_Form::OP_MULTISELECT,
'options' => CRM_Grant_PseudoConstant::grantStatus(),
'options' => CRM_Core_PseudoConstant::get('CRM_Grant_DAO_Grant', 'status_id'),
),
'amount_granted' =>
array(
......@@ -308,13 +307,13 @@ class org_civicrm_report_grant extends CRM_Report_Form {
foreach ($rows as $rowNum => $row) {
if (array_key_exists('civicrm_grant_grant_type_id', $row)) {
if ($value = $row['civicrm_grant_grant_type_id']) {
$rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Grant_PseudoConstant::grantType($value);
$rows[$rowNum]['civicrm_grant_grant_type_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'grant_type_id', $value);
}
$entryFound = TRUE;
}
if (array_key_exists('civicrm_grant_status_id', $row)) {
if ($value = $row['civicrm_grant_status_id']) {
$rows[$rowNum]['civicrm_grant_status_id'] = CRM_Grant_PseudoConstant::grantStatus($value);
$rows[$rowNum]['civicrm_grant_status_id'] = CRM_Core_PseudoConstant::getValue('CRM_Grant_DAO_Grant', 'status_id', $value);
}
$entryFound = TRUE;
}
......
......@@ -92,6 +92,9 @@
<index>
<name>index_grant_type_id</name>
<fieldName>grant_type_id</fieldName>
<pseudoconstant>
<optionGroupName>grant_type</optionGroupName>
</pseudoconstant>
<add>1.8</add>
</index>
<field>
......@@ -163,6 +166,9 @@
<import>true</import>
<export>false</export>
<comment>Id of Grant status.</comment>
<pseudoconstant>
<optionGroupName>grant_status</optionGroupName>
</pseudoconstant>
<add>1.8</add>
</field>
<index>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment