<?php
/*
+--------------------------------------------------------------------+
- | CiviCRM version 5 |
- +--------------------------------------------------------------------+
- | Copyright CiviCRM LLC (c) 2004-2019 |
- +--------------------------------------------------------------------+
- | This file is a part of CiviCRM. |
- | |
- | CiviCRM is free software; you can copy, modify, and distribute it |
- | under the terms of the GNU Affero General Public License |
- | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
- | |
- | CiviCRM is distributed in the hope that it will be useful, but |
- | WITHOUT ANY WARRANTY; without even the implied warranty of |
- | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
- | See the GNU Affero General Public License for more details. |
+ | Copyright CiviCRM LLC. All rights reserved. |
| |
- | You should have received a copy of the GNU Affero General Public |
- | License and the CiviCRM Licensing Exception along |
- | with this program; if not, contact CiviCRM LLC |
- | at info[AT]civicrm[DOT]org. If you have questions about the |
- | GNU Affero General Public License or the licensing of CiviCRM, |
- | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+--------------------------------------------------------------------+
*/
/**
*
* @package CRM
- * @copyright CiviCRM LLC (c) 2004-2019
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
* $Id$
*
*/
/**
* The option group ID
+ * @var int
*/
protected $_optionGroupID = NULL;
* array of default values
*/
public function setDefaultValues() {
- $defaults = $fieldDefaults = array();
+ $defaults = $fieldDefaults = [];
if (isset($this->_id)) {
- $params = array('id' => $this->_id);
+ $params = ['id' => $this->_id];
CRM_Core_BAO_CustomOption::retrieve($params, $defaults);
- $paramsField = array('id' => $this->_fid);
+ $paramsField = ['id' => $this->_fid];
CRM_Core_BAO_CustomField::retrieve($paramsField, $fieldDefaults);
if ($fieldDefaults['html_type'] == 'CheckBox'
}
if ($this->_action & CRM_Core_Action::ADD) {
- $fieldValues = array('option_group_id' => $this->_optionGroupID);
+ $fieldValues = ['option_group_id' => $this->_optionGroupID];
$defaults['weight'] = CRM_Utils_Weight::getDefaultWeight('CRM_Core_DAO_OptionValue', $fieldValues);
}
*/
public function buildQuickForm() {
if ($this->_action == CRM_Core_Action::DELETE) {
- $option = civicrm_api3('option_value', 'getsingle', array('id' => $this->_id));
+ $option = civicrm_api3('option_value', 'getsingle', ['id' => $this->_id]);
$this->assign('label', $option['label']);
- $this->addButtons(array(
- array(
- 'type' => 'next',
- 'name' => ts('Delete'),
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- )
- );
+ $this->addButtons([
+ [
+ 'type' => 'next',
+ 'name' => ts('Delete'),
+ 'isDefault' => TRUE,
+ ],
+ [
+ 'type' => 'cancel',
+ 'name' => ts('Cancel'),
+ ],
+ ]);
}
else {
// lets trim all the whitespace
$this->add('checkbox', 'default_value', ts('Default'));
// add a custom form rule
- $this->addFormRule(array('CRM_Custom_Form_Option', 'formRule'), $this);
+ $this->addFormRule(['CRM_Custom_Form_Option', 'formRule'], $this);
// add buttons
- $this->addButtons(array(
- array(
- 'type' => 'next',
- 'name' => ts('Save'),
- 'isDefault' => TRUE,
- ),
- array(
- 'type' => 'next',
- 'name' => ts('Save and New'),
- 'subName' => 'new',
- ),
- array(
- 'type' => 'cancel',
- 'name' => ts('Cancel'),
- ),
- )
- );
+ $this->addButtons([
+ [
+ 'type' => 'next',
+ 'name' => ts('Save'),
+ 'isDefault' => TRUE,
+ ],
+ [
+ 'type' => 'next',
+ 'name' => ts('Save and New'),
+ 'subName' => 'new',
+ ],
+ [
+ 'type' => 'cancel',
+ 'name' => ts('Cancel'),
+ ],
+ ]);
// if view mode pls freeze it with the done button.
if ($this->_action & CRM_Core_Action::VIEW) {
$this->addElement('button',
'done',
ts('Done'),
- array('onclick' => "location.href='$url'", 'class' => 'crm-form-submit cancel', 'crm-icon' => 'fa-times')
+ ['onclick' => "location.href='$url'", 'class' => 'crm-form-submit cancel', 'crm-icon' => 'fa-times']
);
}
}
$fieldId = $form->_fid;
$optionGroupId = $form->_optionGroupID;
- $temp = array();
+ $temp = [];
if (empty($form->_id)) {
$query = "
SELECT count(*)
FROM civicrm_option_value
WHERE option_group_id = %1
AND label = %2";
- $params = array(
- 1 => array($optionGroupId, 'Integer'),
- 2 => array($optionLabel, 'String'),
- );
+ $params = [
+ 1 => [$optionGroupId, 'Integer'],
+ 2 => [$optionLabel, 'String'],
+ ];
if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) {
$errors['label'] = ts('There is an entry with the same label.');
}
FROM civicrm_option_value
WHERE option_group_id = %1
AND value = %2";
- $params = array(
- 1 => array($optionGroupId, 'Integer'),
- 2 => array($optionValue, 'String'),
- );
+ $params = [
+ 1 => [$optionGroupId, 'Integer'],
+ 2 => [$optionValue, 'String'],
+ ];
if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) {
$errors['value'] = ts('There is an entry with the same value.');
}
WHERE option_group_id = %1
AND id != %2
AND label = %3";
- $params = array(
- 1 => array($optionGroupId, 'Integer'),
- 2 => array($optionId, 'Integer'),
- 3 => array($optionLabel, 'String'),
- );
+ $params = [
+ 1 => [$optionGroupId, 'Integer'],
+ 2 => [$optionId, 'Integer'],
+ 3 => [$optionLabel, 'String'],
+ ];
if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) {
$errors['label'] = ts('There is an entry with the same label.');
}
WHERE option_group_id = %1
AND id != %2
AND value = %3";
- $params = array(
- 1 => array($optionGroupId, 'Integer'),
- 2 => array($optionId, 'Integer'),
- 3 => array($optionValue, 'String'),
- );
+ $params = [
+ 1 => [$optionGroupId, 'Integer'],
+ 2 => [$optionId, 'Integer'],
+ 3 => [$optionValue, 'String'],
+ ];
if (CRM_Core_DAO::singleValueQuery($query, $params) > 0) {
$errors['value'] = ts('There is an entry with the same value.');
}
SELECT data_type
FROM civicrm_custom_field
WHERE id = %1";
- $params = array(1 => array($fieldId, 'Integer'));
+ $params = [1 => [$fieldId, 'Integer']];
$dao = CRM_Core_DAO::executeQuery($query, $params);
if ($dao->fetch()) {
switch ($dao->data_type) {
case 'Country':
if (!empty($fields["value"])) {
- $params = array(1 => array($fields['value'], 'String'));
+ $params = [1 => [$fields['value'], 'String']];
$query = "SELECT count(*) FROM civicrm_country WHERE name = %1 OR iso_code = %1";
if (CRM_Core_DAO::singleValueQuery($query, $params) <= 0) {
$errors['value'] = ts('Invalid default value for country.');
case 'StateProvince':
if (!empty($fields["value"])) {
- $params = array(1 => array($fields['value'], 'String'));
+ $params = [1 => [$fields['value'], 'String']];
$query = "
SELECT count(*)
FROM civicrm_state_province
$params = $this->controller->exportValues('Option');
if ($this->_action == CRM_Core_Action::DELETE) {
- $option = civicrm_api3('option_value', 'getsingle', array('id' => $this->_id));
- $fieldValues = array('option_group_id' => $this->_optionGroupID);
+ $option = civicrm_api3('option_value', 'getsingle', ['id' => $this->_id]);
+ $fieldValues = ['option_group_id' => $this->_optionGroupID];
CRM_Utils_Weight::delWeight('CRM_Core_DAO_OptionValue', $this->_id, $fieldValues);
CRM_Core_BAO_CustomOption::del($this->_id);
- CRM_Core_Session::setStatus(ts('Option "%1" has been deleted.', array(1 => $option['label'])), ts('Deleted'), 'success');
+ CRM_Core_Session::setStatus(ts('Option "%1" has been deleted.', [1 => $option['label']]), ts('Deleted'), 'success');
return;
}
$oldWeight = CRM_Core_DAO::getFieldValue('CRM_Core_DAO_OptionValue', $this->_id, 'weight', 'id');
}
- $fieldValues = array('option_group_id' => $this->_optionGroupID);
+ $fieldValues = ['option_group_id' => $this->_optionGroupID];
$customOption->weight
= CRM_Utils_Weight::updateOtherWeights(
'CRM_Core_DAO_OptionValue',
if (!empty($params['default_value'])) {
if (!in_array($customOption->value, $defVal)) {
if (empty($defVal[0])) {
- $defVal = array($customOption->value);
+ $defVal = [$customOption->value];
}
else {
$defVal[] = $customOption->value;
}
}
elseif (in_array($customOption->value, $defVal)) {
- $tempVal = array();
+ $tempVal = [];
foreach ($defVal as $v) {
if ($v != $customOption->value) {
$tempVal[] = $v;
$customOption->save();
- $msg = ts('Your multiple choice option \'%1\' has been saved', array(1 => $customOption->label));
+ $msg = ts('Your multiple choice option \'%1\' has been saved', [1 => $customOption->label]);
CRM_Core_Session::setStatus($msg, '', 'success');
$buttonName = $this->controller->getButtonName();
$session = CRM_Core_Session::singleton();