CRM-21634 Stdise search fields as they relate to contacts
authoreileen <emcnaughton@wikimedia.org>
Wed, 3 Jan 2018 21:01:46 +0000 (10:01 +1300)
committereileen <emcnaughton@wikimedia.org>
Mon, 15 Jan 2018 23:25:42 +0000 (12:25 +1300)
CRM/Contribute/Form/Search.php
CRM/Core/Form/Search.php
CRM/Event/Form/Search.php
CRM/Member/Form/Search.php
CRM/Pledge/Form/Search.php
templates/CRM/Contact/Form/Search/ContactSearchFields.tpl [new file with mode: 0644]
templates/CRM/Contribute/Form/Search.tpl
templates/CRM/Event/Form/Search.tpl
templates/CRM/Member/Form/Search.tpl
templates/CRM/Pledge/Form/Search.tpl

index b0174523f6bb2f150323d1b28f746136c236f6fe..3eecbe8f5be55b76b7943ccc6a6afda9b170228e 100644 (file)
@@ -166,25 +166,7 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
    */
   public function buildQuickForm() {
     parent::buildQuickForm();
-    $this->addSortNameField();
-
-    $this->_group = CRM_Core_PseudoConstant::nestedGroup();
-
-    // multiselect for groups
-    if ($this->_group) {
-      $this->add('select', 'group', ts('Groups'), $this->_group, FALSE,
-        array('id' => 'group', 'multiple' => 'multiple', 'class' => 'crm-select2')
-      );
-    }
-
-    // multiselect for tags
-    $contactTags = CRM_Core_BAO_Tag::getTags();
-
-    if ($contactTags) {
-      $this->add('select', 'contact_tags', ts('Tags'), $contactTags, FALSE,
-        array('id' => 'contact_tags', 'multiple' => 'multiple', 'class' => 'crm-select2')
-      );
-    }
+    $this->addContactSearchFields();
 
     CRM_Contribute_BAO_Query::buildSearchForm($this);
 
@@ -229,6 +211,36 @@ class CRM_Contribute_Form_Search extends CRM_Core_Form_Search {
     return ts('Contributor Name');
   }
 
+  /**
+   * Get the label for the tag field.
+   *
+   * We do this in a function so the 'ts' wraps the whole string to allow
+   * better translation.
+   *
+   * @return string
+   */
+  protected function getTagLabel() {
+    return ts('Contributor Tag(s)');
+  }
+
+  /**
+   * Get the label for the group field.
+   *
+   * @return string
+   */
+  protected function getGroupLabel() {
+    return ts('Contributor Group(s)');
+  }
+
+  /**
+   * Get the label for the group field.
+   *
+   * @return string
+   */
+  protected function getContactTypeLabel() {
+    return ts('Contributor Contact Type');
+  }
+
   /**
    * The post processing of the form gets done here.
    *
index ec2ef4844c7e61cb28581a1af5b0e40347fb8002..dabab8620fea49eee3536dcd815b070033bf7e74 100644 (file)
@@ -199,4 +199,39 @@ class CRM_Core_Form_Search extends CRM_Core_Form {
     return 'search';
   }
 
+  /**
+   * Add generic fields that specify the contact.
+   */
+  protected function addContactSearchFields() {
+    $this->addSortNameField();
+
+    $this->_group = CRM_Core_PseudoConstant::nestedGroup();
+    if ($this->_group) {
+      $this->add('select', 'group', $this->getGroupLabel(), $this->_group, FALSE,
+        array(
+          'id' => 'group',
+          'multiple' => 'multiple',
+          'class' => 'crm-select2',
+        )
+      );
+    }
+
+    $contactTags = CRM_Core_BAO_Tag::getTags();
+    if ($contactTags) {
+      $this->add('select', 'contact_tags', $this->getTagLabel(), $contactTags, FALSE,
+        array(
+          'id' => 'contact_tags',
+          'multiple' => 'multiple',
+          'class' => 'crm-select2',
+        )
+      );
+    }
+    $this->addField('contact_type', array('entity' => 'Contact'));
+
+    if (CRM_Core_Permission::check('access deleted contacts') && Civi::settings()->get('contact_undelete')) {
+      $this->addElement('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
+    }
+
+  }
+
 }
index 455210313596d6ff05200413180e7fe24d3fc631..5f5783d575e4603577dd1d87a7740d5a855cc0ee 100644 (file)
@@ -29,8 +29,6 @@
  *
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2017
- * $Id$
- *
  */
 
 /**
@@ -168,11 +166,7 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search {
    */
   public function buildQuickForm() {
     parent::buildQuickForm();
-    $this->addSortNameField();
-
-    if (CRM_Core_Permission::check('access deleted contacts') and Civi::settings()->get('contact_undelete')) {
-      $this->addElement('checkbox', 'deleted_contacts', ts('Search in Trash') . '<br />' . ts('(deleted contacts)'));
-    }
+    $this->addContactSearchFields();
 
     CRM_Event_BAO_Query::buildSearchForm($this);
 
@@ -272,6 +266,36 @@ class CRM_Event_Form_Search extends CRM_Core_Form_Search {
     return ts('Participant Name');
   }
 
+  /**
+   * Get the label for the tag field.
+   *
+   * We do this in a function so the 'ts' wraps the whole string to allow
+   * better translation.
+   *
+   * @return string
+   */
+  protected function getTagLabel() {
+    return ts('Participant Tag(s)');
+  }
+
+  /**
+   * Get the label for the group field.
+   *
+   * @return string
+   */
+  protected function getGroupLabel() {
+    return ts('Participant Group(s)');
+  }
+
+  /**
+   * Get the label for the group field.
+   *
+   * @return string
+   */
+  protected function getContactTypeLabel() {
+    return ts('Participant Contact Type');
+  }
+
   /**
    * The post processing of the form gets done here.
    *
index e21293931a3b337512bf6f77fb317405da8322f5..0890a4bcce00283a69c303d33b9262d32521f7fd 100644 (file)
@@ -153,7 +153,7 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
    */
   public function buildQuickForm() {
     parent::buildQuickForm();
-    $this->addSortNameField();
+    $this->addContactSearchFields();
 
     CRM_Member_BAO_Query::buildSearchForm($this);
 
@@ -192,6 +192,36 @@ class CRM_Member_Form_Search extends CRM_Core_Form_Search {
     return ts('Member Name');
   }
 
+  /**
+   * Get the label for the tag field.
+   *
+   * We do this in a function so the 'ts' wraps the whole string to allow
+   * better translation.
+   *
+   * @return string
+   */
+  protected function getTagLabel() {
+    return ts('Member Tag(s)');
+  }
+
+  /**
+   * Get the label for the group field.
+   *
+   * @return string
+   */
+  protected function getGroupLabel() {
+    return ts('Member Group(s)');
+  }
+
+  /**
+   * Get the label for the group field.
+   *
+   * @return string
+   */
+  protected function getContactTypeLabel() {
+    return ts('Member Contact Type');
+  }
+
   /**
    * The post processing of the form gets done here.
    *
index e0e23cfa061882f1995621865bf47808f9a53036..6859f79545b96ab067ddd95de1e29f8a3c33623f 100644 (file)
@@ -145,7 +145,7 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search {
    */
   public function buildQuickForm() {
     parent::buildQuickForm();
-    $this->addSortNameField();
+    $this->addContactSearchFields();
 
     CRM_Pledge_BAO_Query::buildSearchForm($this);
 
@@ -184,6 +184,36 @@ class CRM_Pledge_Form_Search extends CRM_Core_Form_Search {
     return ts('Pledger Name');
   }
 
+  /**
+   * Get the label for the tag field.
+   *
+   * We do this in a function so the 'ts' wraps the whole string to allow
+   * better translation.
+   *
+   * @return string
+   */
+  protected function getTagLabel() {
+    return ts('Pledger Tag(s)');
+  }
+
+  /**
+   * Get the label for the group field.
+   *
+   * @return string
+   */
+  protected function getGroupLabel() {
+    return ts('Pledger Group(s)');
+  }
+
+  /**
+   * Get the label for the group field.
+   *
+   * @return string
+   */
+  protected function getContactTypeLabel() {
+    return ts('Pledger Contact Type');
+  }
+
   /**
    * The post processing of the form gets done here.
    *
diff --git a/templates/CRM/Contact/Form/Search/ContactSearchFields.tpl b/templates/CRM/Contact/Form/Search/ContactSearchFields.tpl
new file mode 100644 (file)
index 0000000..53aef68
--- /dev/null
@@ -0,0 +1,31 @@
+<tr>
+  <td class="font-size12pt">
+    {$form.sort_name.label}&nbsp;&nbsp;{$form.sort_name.html|crmAddClass:'twenty'}
+  </td>
+  <td>{$form.buttons.html}</td>
+</tr>
+<tr>
+  {if $form.contact_tags}
+    <td><label>{$form.contact_tags.label}</label>
+      {$form.contact_tags.html}
+    </td>
+  {else}
+    <td>&nbsp;</td>
+  {/if}
+
+  {if $form.group}
+    <td><label>{$form.group.label}</label>
+      {$form.group.html}
+    </td>
+  {else}
+    <td>&nbsp;</td>
+  {/if}
+</tr>
+<tr class="crm-event-search-form-block-deleted_contacts">
+  <td>{$form.contact_type.label}&nbsp;&nbsp;{$form.contact_type.html}<br></td>
+  <td>
+    {if $form.deleted_contacts}
+      {$form.deleted_contacts.html}&nbsp;&nbsp;{$form.deleted_contacts.label}
+    {/if}
+  </td>
+</tr>
index bf8c8e88c33e59527a76e81e4b79ebbfac6b9545..aa54b7f8a06eeae94e8c6386fa09b41e23a7711b 100644 (file)
       <div class="crm-accordion-body">
         {strip}
           <table class="form-layout">
-            <tr>
-              <td class="font-size12pt" colspan="2">                    {$form.sort_name.label}&nbsp;&nbsp;{$form.sort_name.html|crmAddClass:'twenty'}&nbsp;&nbsp;&nbsp;{$form.buttons.html}
-              </td>
-            </tr>
-            <tr>
-              {if $form.contact_tags}
-                <td><label>{ts}Contributor Tag(s){/ts}</label>
-                    {$form.contact_tags.html}
-                </td>
-              {else}
-                <td>&nbsp;</td>
-              {/if}
-
-              {if $form.group}
-                <td><label>{ts}Contributor Group(s){/ts}</label>
-                    {$form.group.html}
-                </td>
-              {else}
-                <td>&nbsp;</td>
-              {/if}
-            </tr>
-{include file="CRM/Contribute/Form/Search/Common.tpl"}
+            {include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"}
+            {include file="CRM/Contribute/Form/Search/Common.tpl"}
             <tr>
                <td colspan="2">{$form.buttons.html}</td>
             </tr>
index 5921830790319bd21f55574ad518b04ea78fbf7b..624702e39ddf534df0580615fd2a416f5a12bd60 100644 (file)
 <div id="searchForm">
     {strip}
         <table class="form-layout">
-        <tr class="crm-event-search-form-block-sort_name">
-           <td class="font-size12pt" colspan="2">
-               {$form.sort_name.label}&nbsp;&nbsp;{$form.sort_name.html|crmAddClass:'twenty'}&nbsp;&nbsp;&nbsp;{$form.buttons.html}
-           </td>
-        </tr>
-        {if $form.deleted_contacts}
-        <tr class="crm-event-search-form-block-deleted_contacts">
-          <td colspan="2">
-            {$form.deleted_contacts.html}&nbsp;&nbsp;{$form.deleted_contacts.label}
-          </td>
-        </tr>
-        {/if}
+        {include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"}
 
         {include file="CRM/Event/Form/Search/Common.tpl"}
 
index 64e805639af5be223f914a6c2374fecd3755fcd9..705df016aa81024dc67482781679f54c710d8850 100644 (file)
   <div class="crm-accordion-body">
   {strip}
        <table class="form-layout">
-          <tr>
-              <td class="font-size12pt" colspan="2">
-                  {$form.sort_name.label}&nbsp;&nbsp;{$form.sort_name.html|crmAddClass:'twenty'}&nbsp;&nbsp;&nbsp;{$form.buttons.html}
-              </td>
-          </tr>
-
+          {include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"}
           {include file="CRM/Member/Form/Search/Common.tpl"}
 
           <tr>
index dfe749e50289050da6d1af8d3041789d10b81274..d5f205f1ce12b733f83ac867015ccc3b63719b0f 100644 (file)
 <div id="searchForm">
     {strip}
         <table class="form-layout">
-        <tr>
-           <td class="font-size12pt" colspan="2">
-               {$form.sort_name.label}&nbsp;&nbsp;{$form.sort_name.html|crmAddClass:'twenty'}&nbsp;&nbsp;&nbsp;{$form.buttons.html}
-           </td>
-        </tr>
+        {include file="CRM/Contact/Form/Search/ContactSearchFields.tpl"}
         {include file="CRM/Pledge/Form/Search/Common.tpl"}
 
         <tr>