*/
public function buildQuickForm() {
parent::buildQuickForm();
- $this->addElement('text', 'sort_name', ts('Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
+ $this->addSortNameField();
CRM_Activity_BAO_Query::buildSearchForm($this);
*/
public function buildQuickForm() {
parent::buildQuickForm();
- $this->addElement('text',
- 'sort_name',
- ts('Client Name or Email'),
- CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')
- );
+ $this->addSortNameField();
CRM_Case_BAO_Query::buildSearchForm($this);
}
+ /**
+ * Get the label for the sortName field if email searching is on.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithEmail() {
+ return ts('Client Name or Email');
+ }
+
+ /**
+ * Get the label for the sortName field if email searching is off.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithOutEmail() {
+ return ts('Client Name');
+ }
+
/**
* The post processing of the form gets done here.
*
* @return void
*/
public function buildQuickForm() {
- // text for sort_name or email criteria
- $config = CRM_Core_Config::singleton();
- $label = empty($config->includeEmailInName) ? ts('Name') : ts('Name or Email');
- $this->add('text', 'sort_name', $label);
+ $this->addSortNameField();
$searchOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME,
'advanced_search_options'
*/
public function buildQuickForm() {
parent::buildQuickForm();
- // text for sort_name
- $this->addElement('text',
- 'sort_name',
- ts('Contributor Name or Email'),
- CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact',
- 'sort_name'
- )
- );
+ $this->addSortNameField();
$this->_group = CRM_Core_PseudoConstant::nestedGroup();
}
+ /**
+ * Get the label for the sortName field if email searching is on.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithEmail() {
+ return ts('Contributor Name or Email');
+ }
+
+ /**
+ * Get the label for the sortName field if email searching is off.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithOutEmail() {
+ return ts('Contributor Name');
+ }
+
/**
* The post processing of the form gets done here.
*
}
}
+ /**
+ * Add the sort-name field to the form.
+ *
+ * There is a setting to determine whether email is included in the search & we look this up to determine
+ * which text to choose.
+ *
+ * Note that for translation purposes the full string works better than using 'prefix' hence we use override-able functions
+ * to define the string.
+ */
+ protected function addSortNameField() {
+ $this->addElement(
+ 'text',
+ 'sort_name',
+ civicrm_api3('setting', 'getvalue', array('name' => 'includeEmailInName', 'group' => 'Search Preferences')) ? $this->getSortNameLabelWithEmail() : $this->getSortNameLabelWithOutEmail(),
+ CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name')
+ );
+ }
+
+ /**
+ * Get the label for the sortName field if email searching is on.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithEmail() {
+ return ts('Name or Email');
+ }
+
+ /**
+ * Get the label for the sortName field if email searching is off.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithOutEmail() {
+ return ts('Name');
+ }
+
}
*/
public function buildQuickForm() {
parent::buildQuickForm();
- $this->addElement('text', 'sort_name', ts('Participant Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
+ $this->addSortNameField();
CRM_Event_BAO_Query::buildSearchForm($this);
}
+ /**
+ * Get the label for the sortName field if email searching is on.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithEmail() {
+ return ts('Participant Name or Email');
+ }
+
+ /**
+ * Get the label for the sortName field if email searching is off.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithOutEmail() {
+ return ts('Participant Name');
+ }
+
/**
* The post processing of the form gets done here.
*
*/
public function buildQuickForm() {
parent::buildQuickForm();
- $this->addElement('text', 'sort_name', ts('Name or Email'), array('class' => 'twenty') + CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
+ $this->addSortNameField();
CRM_Grant_BAO_Query::buildSearchForm($this);
*/
public function buildQuickForm() {
parent::buildQuickForm();
- $this->addElement('text', 'sort_name', ts('Member Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
+ $this->addSortNameField();
CRM_Member_BAO_Query::buildSearchForm($this);
}
+ /**
+ * Get the label for the sortName field if email searching is on.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithEmail() {
+ return ts('Member Name or Email');
+ }
+
+ /**
+ * Get the label for the sortName field if email searching is off.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithOutEmail() {
+ return ts('Member Name');
+ }
+
/**
* The post processing of the form gets done here.
*
*/
public function buildQuickForm() {
parent::buildQuickForm();
- $this->addElement('text', 'sort_name', ts('Pledger Name or Email'), CRM_Core_DAO::getAttribute('CRM_Contact_DAO_Contact', 'sort_name'));
+ $this->addSortNameField();
CRM_Pledge_BAO_Query::buildSearchForm($this);
}
+ /**
+ * Get the label for the sortName field if email searching is on.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithEmail() {
+ return ts('Pledger Name or Email');
+ }
+
+ /**
+ * Get the label for the sortName field if email searching is off.
+ *
+ * (email searching is a setting under search preferences).
+ *
+ * @return string
+ */
+ protected function getSortNameLabelWithOutEmail() {
+ return ts('Pledger Name');
+ }
+
/**
* The post processing of the form gets done here.
*