Fix incorrect participantStatusClass options lookup
authorColeman Watts <coleman@civicrm.org>
Thu, 1 Jan 2015 18:26:20 +0000 (13:26 -0500)
committerColeman Watts <coleman@civicrm.org>
Fri, 2 Jan 2015 21:38:51 +0000 (16:38 -0500)
CRM/Admin/Form/ParticipantStatusType.php [moved from CRM/Admin/Form/ParticipantStatus.php with 92% similarity]
CRM/Admin/Page/ParticipantStatusType.php [moved from CRM/Admin/Page/ParticipantStatus.php with 97% similarity]
CRM/Event/PseudoConstant.php
CRM/Event/xml/Menu/Event.xml
CRM/Utils/Api.php
templates/CRM/Admin/Form/ParticipantStatusType.tpl [moved from templates/CRM/Admin/Form/ParticipantStatus.tpl with 100% similarity]
templates/CRM/Admin/Page/ParticipantStatusType.hlp [moved from templates/CRM/Admin/Page/ParticipantStatus.hlp with 100% similarity]
templates/CRM/Admin/Page/ParticipantStatusType.tpl [moved from templates/CRM/Admin/Page/ParticipantStatus.tpl with 96% similarity]
xml/schema/Event/ParticipantStatusType.xml

similarity index 92%
rename from CRM/Admin/Form/ParticipantStatus.php
rename to CRM/Admin/Form/ParticipantStatusType.php
index e9b7e153b266958cedb99d396e75553b744586cb..00df3508010bb12024c011abe6929792ed5832fe 100644 (file)
@@ -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));
   }
 
   /**
similarity index 97%
rename from CRM/Admin/Page/ParticipantStatus.php
rename to CRM/Admin/Page/ParticipantStatusType.php
index c40161bc35eb95ce1e13f5044141095c4c4a833d..70fbc9daa54630ae7047d435a9e8b098bcc728c1 100644 (file)
@@ -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';
   }
 
   /**
index e3966e7f8961f1e265faffb1fecb8b8af5956183..1b3250d066d8e7f3dcf71c0b82d5827cb298ff34 100644 (file)
@@ -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
    *
index bac9d23024d3cfbf9fb3e14a42e0aa5d1142011b..75885bc3d5a3fec9f9088268e4a610c9481104b1 100644 (file)
@@ -90,7 +90,7 @@
   <item>
      <path>civicrm/admin/participant_status</path>
      <title>Participant Status</title>
-     <page_callback>CRM_Admin_Page_ParticipantStatus</page_callback>
+     <page_callback>CRM_Admin_Page_ParticipantStatusType</page_callback>
      <desc>Define statuses for event participants here (e.g. Registered, Attended, Cancelled...). You can then assign statuses and search for participants by status.</desc>
      <access_arguments>administer CiviCRM,access CiviEvent</access_arguments>
      <adminGroup>CiviEvent</adminGroup>
index cd2eda3b21327551ec9df5e8c1696fba4f1a9514..e96d320c770a3128f5b6a39ecdb2ead4e4683de3 100644 (file)
@@ -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');
     }
similarity index 96%
rename from templates/CRM/Admin/Page/ParticipantStatus.tpl
rename to templates/CRM/Admin/Page/ParticipantStatusType.tpl
index b71ffd2b3d2ec512bc59977498463bb9825d4843..23394b221360a20bb1b25a3bc05626701052ee23 100644 (file)
@@ -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}
-  <div id="help">{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"}</div>
+  <div id="help">{ts}Manage event participant statuses below. Enable selected statuses to allow event waitlisting and/or participant approval.{/ts} {help id="id-disabled_statuses"}</div>
 
 <div class="crm-section participant-status">
   {strip}
index 2f112c633d71130d846ac3735cfa9c9c1f7f3e63..17dad28221b311850fcfd2d460e65b5ea97e3a60 100644 (file)
@@ -46,7 +46,7 @@
     <length>8</length>
     <comment>the general group of status type this one belongs to</comment>
     <pseudoconstant>
-      <callback>CRM_Event_PseudoConstant::participantStatusClass</callback>
+      <callback>CRM_Event_PseudoConstant::participantStatusClassOptions</callback>
     </pseudoconstant>
     <add>3.0</add>
     <html>