CRM-13970 - Option form url fix & test cleanup
authorColeman Watts <coleman@civicrm.org>
Sat, 8 Feb 2014 04:23:23 +0000 (20:23 -0800)
committerColeman Watts <coleman@civicrm.org>
Sat, 8 Feb 2014 05:42:15 +0000 (21:42 -0800)
CRM/Admin/Form/Options.php
CRM/Admin/Page/Options.php
CRM/Core/Controller.php
CRM/Core/Form.php
templates/CRM/ACL/Page/ACLBasic.tpl
templates/CRM/Admin/Page/ConfigTaskList.tpl
templates/CRM/Admin/Page/Options.tpl
tests/phpunit/CiviTest/CiviSeleniumTestCase.php
tests/phpunit/WebTest/ACL/AssignUsersToRolesTest.php
tests/phpunit/WebTest/Contribute/OfflineContributionTest.php
tests/phpunit/WebTest/Grant/CustomFieldsetTest.php

index 2e610fe438c92cc14e4317259c7f5f2b24295970..04a6908b8c9aa76013651cca76484a3bb0f88ffd 100644 (file)
@@ -64,13 +64,11 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
   public function preProcess() {
     parent::preProcess();
     $session = CRM_Core_Session::singleton();
-    if (!$this->_gName) {
-      $this->_gName = CRM_Utils_Request::retrieve('group', 'String', $this, FALSE, 0);
-      $this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
-        $this->_gName,
-        'id',
-        'name'
-      );
+    if (!$this->_gName && !empty($this->urlPath[3])) {
+      $this->_gName = $this->urlPath[3];
+    }
+    if (!$this->_gName && !empty($_GET['gid'])) {
+      $this->_gName = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', (int) $_GET['gid'], 'name');
     }
     if ($this->_gName) {
       $this->set('gName', $this->_gName);
@@ -78,6 +76,11 @@ class CRM_Admin_Form_Options extends CRM_Admin_Form {
     else {
       $this->_gName = $this->get('gName');
     }
+    $this->_gid = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup',
+      $this->_gName,
+      'id',
+      'name'
+    );
     $this->_gLabel = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionGroup', $this->_gid, 'title');
     $url          = "civicrm/admin/options/{$this->_gName}";
     $params       = "reset=1";
index 270a5c8c0fb576d1d5ec87bcc9bb4d33f9672c7e..dfe1102de17520018c919fee4da5d5ecf1fb52c5 100644 (file)
@@ -171,7 +171,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic {
         CRM_Core_Action::UPDATE => array(
           'name' => ts('Edit'),
           'url' => 'civicrm/admin/options/' . self::$_gName,
-          'qs' => 'group=' . self::$_gName . '&action=update&id=%%id%%&reset=1',
+          'qs' => 'action=update&id=%%id%%&reset=1',
           'title' => ts('Edit %1', array(1 => self::$_gName)),
         ),
         CRM_Core_Action::DISABLE => array(
@@ -187,7 +187,7 @@ class CRM_Admin_Page_Options extends CRM_Core_Page_Basic {
         CRM_Core_Action::DELETE => array(
           'name' => ts('Delete'),
           'url' => 'civicrm/admin/options/' . self::$_gName,
-          'qs' => 'group=' . self::$_gName . '&action=delete&id=%%id%%',
+          'qs' => 'action=delete&id=%%id%%',
           'title' => ts('Delete %1 Type', array(1 => self::$_gName)),
         ),
       );
index 75230c1a9b1c0a1e997b8cb26bf5bd2368ef13b3..3b23add7948f527ffb292efd7767cc1cf8a95472 100644 (file)
@@ -461,6 +461,9 @@ class CRM_Core_Controller extends HTML_QuickForm_Controller {
       if ($options) {
         $$stateName->setOptions($options);
       }
+      if (property_exists($$stateName, 'urlPath')) {
+        $$stateName->urlPath = explode('/', $_GET[CRM_Core_Config::singleton()->userFrameworkURLVar]);
+      }
       $this->addPage($$stateName);
       $this->addAction($stateName, new HTML_QuickForm_Action_Direct());
 
index 382a76ce35375f9bd2b9f4d9d2b47987fbb7920d..b3f6f1552dc7fcdb911ce2b7baff0ef26cd47968 100644 (file)
@@ -105,6 +105,13 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
    */
   public $ajaxResponse = array();
 
+  /**
+   * Url path used to reach this page
+   *
+   * @var array
+   */
+  public $urlPath = array();
+
   /**
    * Stores info about reference fields for preprocessing
    * Public so that hooks can access it
@@ -924,7 +931,7 @@ class CRM_Core_Form extends HTML_QuickForm_Page {
     if (!array_key_exists('placeholder', $props)) {
       $props['placeholder'] = $required ? ts('- select -') : ts('- none -');
     }
-    if (!empty($props['placeholder']) && empty($props['multiple'])) {
+    if ($props['placeholder'] !== NULL && empty($props['multiple'])) {
       $options = array('' => '') + $options;
     }
     // Handle custom field
index 3f8badf510e2552d5d6f39ebc339d5ad387c8dc5..bf95eeddb4206d8b763c3426904bc873b894440f 100644 (file)
@@ -24,7 +24,7 @@
  +--------------------------------------------------------------------+
 *}
 {capture assign=erURL}{crmURL p='civicrm/acl/entityrole' q='reset=1'}{/capture}
-{capture assign=rolesURL}{crmURL p='civicrm/admin/options' q='group=acl_role&reset=1'}{/capture}
+{capture assign=rolesURL}{crmURL p='civicrm/admin/options/acl_role' q='reset=1'}{/capture}
 {capture assign=docLink}{docURL page='user/initial-set-up/access-control' text='Access Control Documentation'}{/capture}
 
 <div id="help">
index 9082446f71bc81bf7f514437b91a1b45ffbc2ea9..8aa11ee9907c6e0ebccd33c811c68cca2cc6ebf0 100644 (file)
@@ -95,7 +95,7 @@
         <td>{ts}Settings for outbound email - either SMTP server, port and authentication or Sendmail path and argument.{/ts}</td>
     </tr>
     <tr class="even">
-        <td class="tasklist nowrap"><a href="{crmURL p="civicrm/admin/options/from_email_address" q="group=from_email_address`$fromAction`&reset=1&civicrmDestination=`$destination`"}" title="{$linkTitle}">{ts}From Email Addresses{/ts}</a></td>
+        <td class="tasklist nowrap"><a href="{crmURL p="civicrm/admin/options/from_email_address" q="reset=1`$fromAction`&civicrmDestination=`$destination`"}" title="{$linkTitle}">{ts}From Email Addresses{/ts}</a></td>
         <td>{ts}Define general email address(es) that can be used as the FROM address when sending email to contacts from within CiviCRM (e.g. info@example.org){/ts}</td>
     </tr>
 
index 36474d1b203b0299d79b7df43cca872d997952d7..87aaa6056a80fc047df6b9c5e6444b775247cbc8 100644 (file)
@@ -72,7 +72,7 @@
 {if $rows}
 {if $action ne 1 and $action ne 2}
     <div class="action-link">
-        <a href="{crmURL q="group="|cat:$gName|cat:"&action=add&reset=1"}" class="button new-option"><span><div class="icon add-icon"></div>{ts 1=$gLabel}Add %1{/ts}</span></a>
+        <a href="{crmURL p="civicrm/admin/options/$gName" q='action=add&reset=1'}" class="button new-option"><span><div class="icon add-icon"></div>{ts 1=$gLabel}Add %1{/ts}</span></a>
     </div>
 {/if}
 <div id={$gName}>
 
         {if $action ne 1 and $action ne 2}
             <div class="action-link">
-                <a href="{crmURL q="group="|cat:$gName|cat:"&action=add&reset=1"}" class="button new-option"><span><div class="icon add-icon"></div>{ts 1=$gLabel}Add %1{/ts}</span></a>
+                <a href="{crmURL p="civicrm/admin/options/$gName" q='action=add&reset=1'}" class="button new-option"><span><div class="icon add-icon"></div>{ts 1=$gLabel}Add %1{/ts}</span></a>
             </div>
         {/if}
 </div>
 {else}
     <div class="messages status no-popup">
          <div class="icon inform-icon"></div>
-        {capture assign=crmURL}{crmURL  q="group="|cat:$gName|cat:"&action=add&reset=1"}{/capture}
+        {capture assign=crmURL}{crmURL p="civicrm/admin/options/$gName" q='action=add&reset=1'}{/capture}
         {ts 1=$crmURL}There are no option values entered. You can <a href='%1'>add one</a>.{/ts}
     </div>
 {/if}
index 868b4e106ad5434c3ba8433b3e6554fb9fa4c412..b8924114381b69a3305f66f5b6252a1b1ea06f6d 100644 (file)
@@ -1747,7 +1747,7 @@ class CiviSeleniumTestCase extends PHPUnit_Extensions_SeleniumTestCase {
   }
 
   function addPaymentInstrument($label, $financialAccount) {
-    $this->openCiviPage('admin/options/payment_instrument', 'group=payment_instrument&action=add&reset=1', "_qf_Options_next-bottom");
+    $this->openCiviPage('admin/options/payment_instrument', 'action=add&reset=1', "_qf_Options_next-bottom");
     $this->type("label", $label);
     $this->select("financial_account_id", "value=$financialAccount");
     $this->click("_qf_Options_next-bottom");
index 0e2886175a0c197050ee2bb7b773ac3aa615cacf..8642442a1ebddf781cd554df38e9f72d18f0b858 100755 (executable)
@@ -44,7 +44,7 @@ class WebTest_ACL_AssignUsersToRolesTest extends CiviSeleniumTestCase {
 
     $this->waitForText('crm-notification-container', "The Group '{$groupTitle}' has been saved.");
 
-    $this->openCiviPage("admin/options/acl_role", "group=acl_role&action=add&reset=1", "_qf_Options_cancel-bottom");
+    $this->openCiviPage("admin/options/acl_role", "action=add&reset=1", "_qf_Options_cancel-bottom");
 
     $label = "TestAclRole" . substr(sha1(rand()), 0, 4);
     $this->type("label", $label);
index 255e209e3edeb8fa487faa0286d48f87d92e448a..5d051f1b01faa5d241dd0811b80fe16ff3d29d7c 100644 (file)
@@ -42,7 +42,7 @@ class WebTest_Contribute_OfflineContributionTest extends CiviSeleniumTestCase {
     $this->webtestAddContact($softCreditFname, $softCreditLname, FALSE);
 
     //financial account for check
-    $this->openCiviPage("admin/options/payment_instrument", "group=payment_instrument&reset=1");
+    $this->openCiviPage("admin/options/payment_instrument", "reset=1");
     $financialAccount = $this->getText("xpath=//div[@id='payment_instrument']/div[2]/table/tbody//tr/td[1][text()='Check']/../td[3]");
 
     // Add new Financial Account
index a0c5ebef4abec5c144ea44b64bf8f0fc1ce4251b..1dc682d8b94f27b3216e4b4d3a66bcfddd509a7a 100644 (file)
@@ -49,7 +49,7 @@ class WebTest_Grant_CustomFieldsetTest extends CiviSeleniumTestCase {
     $rand = substr(sha1(rand()), 0, 7);
 
     // Add new Grant Type
-    $this->openCiviPage('admin/options/grant_type', 'group=grant_type&reset=1');
+    $this->openCiviPage('admin/options/grant_type', 'reset=1');
     $this->click("css=#grant_type > div.action-link > #new > span");
     $this->waitForPageToLoad($this->getTimeoutMsec());
     $grantType = 'GrantType' . $rand;