From 84403e233f55fae161b43755982bb5800dc1c50b Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Thu, 1 Jan 2015 13:26:20 -0500 Subject: [PATCH] Fix incorrect participantStatusClass options lookup --- ...ticipantStatus.php => ParticipantStatusType.php} | 13 +++---------- ...ticipantStatus.php => ParticipantStatusType.php} | 4 ++-- CRM/Event/PseudoConstant.php | 9 +++++++++ CRM/Event/xml/Menu/Event.xml | 2 +- CRM/Utils/Api.php | 12 ++++++++++++ ...ticipantStatus.tpl => ParticipantStatusType.tpl} | 0 ...ticipantStatus.hlp => ParticipantStatusType.hlp} | 0 ...ticipantStatus.tpl => ParticipantStatusType.tpl} | 4 ++-- xml/schema/Event/ParticipantStatusType.xml | 2 +- 9 files changed, 30 insertions(+), 16 deletions(-) rename CRM/Admin/Form/{ParticipantStatus.php => ParticipantStatusType.php} (92%) rename CRM/Admin/Page/{ParticipantStatus.php => ParticipantStatusType.php} (97%) rename templates/CRM/Admin/Form/{ParticipantStatus.tpl => ParticipantStatusType.tpl} (100%) rename templates/CRM/Admin/Page/{ParticipantStatus.hlp => ParticipantStatusType.hlp} (100%) rename templates/CRM/Admin/Page/{ParticipantStatus.tpl => ParticipantStatusType.tpl} (96%) diff --git a/CRM/Admin/Form/ParticipantStatus.php b/CRM/Admin/Form/ParticipantStatusType.php similarity index 92% rename from CRM/Admin/Form/ParticipantStatus.php rename to CRM/Admin/Form/ParticipantStatusType.php index e9b7e153b2..00df350801 100644 --- a/CRM/Admin/Form/ParticipantStatus.php +++ b/CRM/Admin/Form/ParticipantStatusType.php @@ -32,7 +32,7 @@ * $Id$ * */ -class CRM_Admin_Form_ParticipantStatus extends CRM_Admin_Form { +class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form { public function buildQuickForm() { parent::buildQuickForm(); @@ -50,21 +50,14 @@ class CRM_Admin_Form_ParticipantStatus extends CRM_Admin_Form { $this->add('text', 'label', ts('Label'), $attributes['label'], TRUE); - $classes = array( - 'Positive' => ts('Positive'), - 'Pending' => ts('Pending'), - 'Waiting' => ts('Waiting'), - 'Negative' => ts('Negative'), - ); - - $this->add('select', 'class', ts('Class'), $classes, TRUE); + $this->addSelect('class', array('required' => TRUE)); $this->add('checkbox', 'is_active', ts('Active?')); $this->add('checkbox', 'is_counted', ts('Counted?')); $this->add('text', 'weight', ts('Order'), $attributes['weight'], TRUE); - $this->add('select', 'visibility_id', ts('Visibility'), CRM_Core_PseudoConstant::visibility(), TRUE); + $this->addSelect('visibility_id', array('label' => ts('Visibility'), 'required' => TRUE)); } /** diff --git a/CRM/Admin/Page/ParticipantStatus.php b/CRM/Admin/Page/ParticipantStatusType.php similarity index 97% rename from CRM/Admin/Page/ParticipantStatus.php rename to CRM/Admin/Page/ParticipantStatusType.php index c40161bc35..70fbc9daa5 100644 --- a/CRM/Admin/Page/ParticipantStatus.php +++ b/CRM/Admin/Page/ParticipantStatusType.php @@ -32,7 +32,7 @@ * $Id$ * */ -class CRM_Admin_Page_ParticipantStatus extends CRM_Core_Page_Basic { +class CRM_Admin_Page_ParticipantStatusType extends CRM_Core_Page_Basic { public $useLivePageJS = TRUE; @@ -118,7 +118,7 @@ class CRM_Admin_Page_ParticipantStatus extends CRM_Core_Page_Basic { * @return string */ public function editForm() { - return 'CRM_Admin_Form_ParticipantStatus'; + return 'CRM_Admin_Form_ParticipantStatusType'; } /** diff --git a/CRM/Event/PseudoConstant.php b/CRM/Event/PseudoConstant.php index e3966e7f89..1b3250d066 100644 --- a/CRM/Event/PseudoConstant.php +++ b/CRM/Event/PseudoConstant.php @@ -161,6 +161,15 @@ class CRM_Event_PseudoConstant extends CRM_Core_PseudoConstant { return self::$participantStatus[$index]; } + public static function participantStatusClassOptions() { + return array( + 'Positive' => ts('Positive'), + 'Pending' => ts('Pending'), + 'Waiting' => ts('Waiting'), + 'Negative' => ts('Negative'), + ); + } + /** * Return a status-type-keyed array of status classes * diff --git a/CRM/Event/xml/Menu/Event.xml b/CRM/Event/xml/Menu/Event.xml index bac9d23024..75885bc3d5 100644 --- a/CRM/Event/xml/Menu/Event.xml +++ b/CRM/Event/xml/Menu/Event.xml @@ -90,7 +90,7 @@ civicrm/admin/participant_status Participant Status - CRM_Admin_Page_ParticipantStatus + CRM_Admin_Page_ParticipantStatusType Define statuses for event participants here (e.g. Registered, Attended, Cancelled...). You can then assign statuses and search for participants by status. administer CiviCRM,access CiviEvent CiviEvent diff --git a/CRM/Utils/Api.php b/CRM/Utils/Api.php index cd2eda3b21..e96d320c77 100644 --- a/CRM/Utils/Api.php +++ b/CRM/Utils/Api.php @@ -31,6 +31,7 @@ class CRM_Utils_Api { /** * Attempts to retrieve the API entity name from any calling class. + * FIXME: This is a bit hackish but the naming convention for forms is not very strict * * @param string|object $classNameOrObject * @@ -63,6 +64,17 @@ class CRM_Utils_Api { $daoName = "CRM_Core_DAO_$child"; $shortName = CRM_Core_DAO_AllCoreTables::getBriefName($daoName); } + + // If that didn't work, try using just the trailing name + if (!$shortName) { + $shortName = CRM_Core_DAO_AllCoreTables::getFullName($child) ? $child : NULL; + } + + // If that didn't work, try using just the leading name + if (!$shortName) { + $shortName = CRM_Core_DAO_AllCoreTables::getFullName($parent) ? $parent : NULL; + } + if (!$shortName) { throw new CRM_Core_Exception('Could not find api name for supplied class'); } diff --git a/templates/CRM/Admin/Form/ParticipantStatus.tpl b/templates/CRM/Admin/Form/ParticipantStatusType.tpl similarity index 100% rename from templates/CRM/Admin/Form/ParticipantStatus.tpl rename to templates/CRM/Admin/Form/ParticipantStatusType.tpl diff --git a/templates/CRM/Admin/Page/ParticipantStatus.hlp b/templates/CRM/Admin/Page/ParticipantStatusType.hlp similarity index 100% rename from templates/CRM/Admin/Page/ParticipantStatus.hlp rename to templates/CRM/Admin/Page/ParticipantStatusType.hlp diff --git a/templates/CRM/Admin/Page/ParticipantStatus.tpl b/templates/CRM/Admin/Page/ParticipantStatusType.tpl similarity index 96% rename from templates/CRM/Admin/Page/ParticipantStatus.tpl rename to templates/CRM/Admin/Page/ParticipantStatusType.tpl index b71ffd2b3d..23394b2213 100644 --- a/templates/CRM/Admin/Page/ParticipantStatus.tpl +++ b/templates/CRM/Admin/Page/ParticipantStatusType.tpl @@ -24,9 +24,9 @@ +--------------------------------------------------------------------+ *} {if $action eq 1 or $action eq 2 or $action eq 8} - {include file="CRM/Admin/Form/ParticipantStatus.tpl"} + {include file="CRM/Admin/Form/ParticipantStatusType.tpl"} {else} -
{ts}Manage event participant statuses below. Enable selected statuses to allow event waitlisting and/or participant approval.{/ts} {help id="id-disabled_statuses" file="CRM/Admin/Page/ParticipantStatus.hlp"}
+
{ts}Manage event participant statuses below. Enable selected statuses to allow event waitlisting and/or participant approval.{/ts} {help id="id-disabled_statuses"}
{strip} diff --git a/xml/schema/Event/ParticipantStatusType.xml b/xml/schema/Event/ParticipantStatusType.xml index 2f112c633d..17dad28221 100644 --- a/xml/schema/Event/ParticipantStatusType.xml +++ b/xml/schema/Event/ParticipantStatusType.xml @@ -46,7 +46,7 @@ 8 the general group of status type this one belongs to - CRM_Event_PseudoConstant::participantStatusClass + CRM_Event_PseudoConstant::participantStatusClassOptions 3.0 -- 2.25.1