/**
* Get options for the called BAO object's field.
* This function can be overridden by each BAO to add more logic related to context.
+ * The overriding function will generally call the lower-level CRM_Core_PseudoConstant::get
*
* @param String $fieldName
* @param String $context: e.g. "search" "edit" "create" "view"
* @param Array $props: whatever is known about this bao object
*/
public static function buildOptions($fieldName, $context = NULL, $props = array()) {
- // If a given bao does not override this function, it can still be called on that bao
+ // If a given bao does not override this function
$baoName = get_called_class();
return CRM_Core_PseudoConstant::get($baoName, $fieldName);
}
$output = self::$cache[$cacheKey];
}
else {
- // Get list of fields for the option table
$daoName = CRM_Core_AllCoreTables::getClassForTable($pseudoconstant['table']);
+ if (!class_exists($daoName)) {
+ return FALSE;
+ }
+ // Get list of fields for the option table
$dao = new $daoName;
$availableFields = array_keys($dao->fieldKeys());
if (in_array('is_active', $availableFields)) {
$approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
- $pcpStatus = CRM_PCP_PseudoConstant::pcpStatus();
+ $pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
$params = array('id' => $pcpId);
CRM_Core_DAO::commonRetrieve('CRM_PCP_DAO_PCP', $params, $pcpInfo);
$pcpTitle = CRM_Core_DAO::getFieldValue('CRM_PCP_DAO_PCP', $id, 'title');
$pcpPageType = CRM_Core_DAO::getFieldValue( 'CRM_PCP_DAO_PCP', $id, 'page_type' );
- $pcpStatus = CRM_PCP_PseudoConstant::pcpStatus();
+ $pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
$pcpStatus = $pcpStatus[$is_active];
CRM_Core_Session::setStatus(ts("%1 status has been updated to %2.", array(1 => $pcpTitle, 2 => $pcpStatus)), 'Status Updated', 'success');
*
*/
static function sendStatusUpdate($pcpId, $newStatus, $isInitial = FALSE, $component = 'contribute') {
- $pcpStatus = CRM_PCP_PseudoConstant::pcpStatus();
+ $pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
$config = CRM_Core_Config::singleton();
if (!isset($pcpStatus[$newStatus])) {
}
else {
- $status = array('' => ts('- select -')) + CRM_PCP_PseudoConstant::pcpStatus();
- $types = array('' => ts('- select -')) + CRM_PCP_PseudoConstant::pcpType();
+ $status = array('' => ts('- select -')) + CRM_Core_OptionGroup::values("pcp_status");
+ $types = array(
+ '' => ts('- select -'),
+ 'contribute' => ts('Contribution'),
+ 'event' => ts('Event'),
+ );
$contribPages = array('' => ts('- select -')) + CRM_Contribute_PseudoConstant::contributionPage();
$eventPages = array('' => ts('- select -')) + CRM_Event_PseudoConstant::event(NULL, FALSE, "( is_template IS NULL OR is_template != 1 )");
CRM_Utils_System::setTitle($pcpInfo['title']);
$this->assign('pcp', $pcpInfo);
- $pcpStatus = CRM_PCP_PseudoConstant::pcpStatus();
+ $pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
$approvedId = CRM_Core_OptionGroup::getValue('pcp_status', 'Approved', 'name');
// check if PCP is created by anonymous user
+++ /dev/null
-<?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 PCP. This avoids
- * polluting the core class and isolates the Event
- */
-class CRM_PCP_PseudoConstant extends CRM_Core_PseudoConstant {
-
- /**
- * pcp types
- *
- * @var array
- * @static
- */
- private static $pcpType;
-
- /**
- * pcp status
- *
- * @var array
- * @static
- */
- private static $pcpStatus;
-
- /**
- * Get all the PCP types
- *
- * @access public
- *
- * @return array - array reference of all PCP types
- * @static
- */
- public static function &pcpType() {
- self::$pcpType = array();
- if (!self::$pcpType) {
- self::$pcpType = array(
- 'contribute' => 'Contribution',
- 'event' => 'Event',
- );
- }
- return self::$pcpType;
- }
-
- /**
- * Get all the PCP status
- *
- * @access public
- *
- * @return array - array reference of all PCP status
- * @static
- */
- public static function &pcpStatus() {
- self::$pcpStatus = array();
- if (!self::$pcpStatus) {
- self::$pcpStatus = CRM_Core_OptionGroup::values("pcp_status");
- }
- return self::$pcpStatus;
- }
-
- /**
- * 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) {
- if (isset(self::$$name)) {
- self::$$name = NULL;
- }
- }
-}
-
require_once 'CiviTest/CiviUnitTestCase.php';
/**
- * Tests for linking to resource files
+ * Tests for field options
*/
class CRM_Core_FieldOptionsTest extends CiviUnitTestCase {
function get_info() {
require_once 'CiviTest/CiviUnitTestCase.php';
/**
- * Tests for linking to resource files
+ * Tests for pseudoconstant retrieval
*/
class CRM_Core_PseudoConstantTest extends CiviUnitTestCase {
function get_info() {
'sample' => 'Yahoo',
),
),
+ 'CRM_Event_DAO_Participant' => array(
+ array(
+ 'fieldName' => 'status_id',
+ 'sample' => 'Registered',
+ ),
+ array(
+ 'fieldName' => 'role_id',
+ 'sample' => 'Speaker',
+ ),
+ ),
+ 'CRM_Event_DAO_Event' => array(
+ array(
+ 'fieldName' => 'event_type_id',
+ 'sample' => 'Fundraiser',
+ ),
+ ),
+ 'CRM_PCP_DAO_PCP' => array(
+ array(
+ 'fieldName' => 'status_id',
+ 'sample' => 'Approved',
+ ),
+ ),
);
foreach ($fields as $daoName => $daoFields) {
<title>Event Type ID</title>
<default>0</default>
<pseudoconstant>
- <name>eventType</name>
<optionGroupName>event_type</optionGroupName>
- <class>CRM_Event_PseudoConstant</class>
</pseudoconstant>
<comment>Event Type ID.Implicit FK to civicrm_option_value where option_group = event_type.</comment>
<add>1.7</add>
<comment>Participant status ID. FK to civicrm_participant_status_type. Default of 1 should map to status = Registered.</comment>
<add>1.7</add>
<pseudoconstant>
- <name>participantStatus</name>
- <table>civicrm_participant_status</table>
+ <table>civicrm_participant_status_type</table>
<keyColumn>id</keyColumn>
<labelColumn>name</labelColumn>
- <class>CRM_Event_PseudoConstant</class>
</pseudoconstant>
</field>
<foreignKey>
<uniqueName>participant_role_id</uniqueName>
<title>Participant Role Id</title>
<pseudoconstant>
- <name>participantRole</name>
<optionGroupName>participant_role</optionGroupName>
- <class>CRM_Event_PseudoConstant</class>
</pseudoconstant>
<headerPattern>/(participant.)?(role)$/i</headerPattern>
<import>true</import>
<required>true</required>
<type>int unsigned</type>
<add>2.2</add>
+ <pseudoconstant>
+ <optionGroupName>pcp_status</optionGroupName>
+ </pseudoconstant>
</field>
<field>
<name>title</name>
<type>varchar</type>
<length>64</length>
<default>'contribute'</default>
- <add>2.2</add>
+ <add>2.2</add>
</field>
<field>
<name>pcp_block_id</name>