/**
* Add fields in the metadata to the template.
+ *
+ * @throws \CRM_Core_Exception
*/
protected function addFieldsDefinedInSettingsMetadata() {
$settingMetaData = $this->getSettingsMetaData();
}
$add = 'add' . $quickFormType;
- if ($add == 'addElement') {
+ if ($add === 'addElement') {
$this->$add(
$props['html_type'],
$setting,
($options !== NULL) ? CRM_Utils_Array::value('html_attributes', $props, []) : NULL
);
}
- elseif ($add == 'addSelect') {
+ elseif ($add === 'addSelect') {
$this->addElement('select', $setting, $props['title'], $options, CRM_Utils_Array::value('html_attributes', $props));
}
- elseif ($add == 'addCheckBox') {
+ elseif ($add === 'addCheckBox') {
$this->addCheckBox($setting, '', $options, NULL, CRM_Utils_Array::value('html_attributes', $props), NULL, NULL, [' ']);
}
- elseif ($add == 'addCheckBoxes') {
+ elseif ($add === 'addCheckBoxes') {
$newOptions = array_flip($options);
$classes = 'crm-checkbox-list';
if (!empty($props['sortable'])) {
'</li><li>'
);
}
- elseif ($add == 'addChainSelect') {
+ elseif ($add === 'addChainSelect') {
$this->addChainSelect($setting, [
'label' => $props['title'],
]);
}
- elseif ($add == 'addMonthDay') {
+ elseif ($add === 'addMonthDay') {
$this->add('date', $setting, $props['title'], CRM_Core_SelectValues::date(NULL, 'M d'));
}
elseif ($add === 'addEntityRef') {
$description = CRM_Utils_Array::value('description', $props);
$descriptions[$setting] = $description;
$this->assign("{$setting}_description", $description);
- if ($setting == 'max_attachments') {
+ if ($setting === 'max_attachments') {
//temp hack @todo fix to get from metadata
$this->addRule('max_attachments', ts('Value should be a positive number'), 'positiveInteger');
}
- if ($setting == 'max_attachments_backend') {
+ if ($setting === 'max_attachments_backend') {
//temp hack @todo fix to get from metadata
$this->addRule('max_attachments_backend', ts('Value should be a positive number'), 'positiveInteger');
}
- if ($setting == 'maxFileSize') {
+ if ($setting === 'maxFileSize') {
//temp hack
$this->addRule('maxFileSize', ts('Value should be a positive number'), 'positiveInteger');
}
* Get the defaults for all fields defined in the metadata.
*
* All others are pending conversion.
+ *
+ * @throws \CiviCRM_API3_Exception
+ * @throws \CRM_Core_Exception
*/
protected function setDefaultsForMetadataDefinedFields() {
CRM_Core_BAO_ConfigSetting::retrieve($this->_defaults);
foreach (array_keys($this->_settings) as $setting) {
$this->_defaults[$setting] = civicrm_api3('setting', 'getvalue', ['name' => $setting]);
- $spec = $this->getSettingsMetadata()[$setting];
+ $spec = $this->getSettingsMetaData()[$setting];
if (!empty($spec['serialize'])) {
$this->_defaults[$setting] = CRM_Core_DAO::unSerializeField($this->_defaults[$setting], $spec['serialize']);
}
* @param array $settingValue
*
* @return array
+ *
+ * @throws \CRM_Core_Exception
*/
private function getReorderedSettingData($setting, $settingValue) {
// Get order from $_POST as $_POST maintains the order the sorted setting
'month' => ts('month'),
'year' => ts('year'),
];
- if ($unitType == 'duration') {
+ if ($unitType === 'duration') {
$unitList['lifetime'] = ts('lifetime');
}
return $unitList;
*/
public static function emailSelectMethods() {
return [
- 'automatic' => ts("Automatic"),
- 'location-only' => ts("Only send to email addresses assigned to the specified location"),
- 'location-prefer' => ts("Prefer email addresses assigned to the specified location"),
- 'location-exclude' => ts("Exclude email addresses assigned to the specified location"),
+ 'automatic' => ts('Automatic'),
+ 'location-only' => ts('Only send to email addresses assigned to the specified location'),
+ 'location-prefer' => ts('Prefer email addresses assigned to the specified location'),
+ 'location-exclude' => ts('Exclude email addresses assigned to the specified location'),
];
}
*
* @return array
* the date array
- * @throws \Exception
+ * @throws CRM_Core_Exception
*/
public static function date($type = NULL, $format = NULL, $minOffset = NULL, $maxOffset = NULL, $context = 'display') {
// These options are deprecated. Definitely not used in datepicker. Possibly not even in jcalendar+addDateTime.
$dao = new CRM_Core_DAO_PreferencesDate();
$dao->name = $type;
if (!$dao->find(TRUE)) {
- CRM_Core_Error::fatal();
+ throw new CRM_Core_Exception('Date preferences not configured.');
}
if (!$maxOffset) {
$maxOffset = $dao->end;
}
if (empty($date['format'])) {
- if ($context == 'Input') {
+ if ($context === 'Input') {
$date['format'] = Civi::settings()->get('dateInputFormat');
}
else {
*
* @return array
*/
- public static function getSearchBuilderOperators($fieldType = NULL) {
+ public static function getSearchBuilderOperators() {
return [
'=' => '=',
'!=' => '≠',
* Dropdown options for quicksearch in the menu
*
* @return array
+ * @throws \CiviCRM_API3_Exception
*/
public static function quicksearchOptions() {
$includeEmail = civicrm_api3('setting', 'getvalue', ['name' => 'includeEmailInName', 'group' => 'Search Preferences']);