3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
10 | CiviCRM is free software; you can copy, modify, and distribute it |
11 | under the terms of the GNU Affero General Public License |
12 | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
14 | CiviCRM is distributed in the hope that it will be useful, but |
15 | WITHOUT ANY WARRANTY; without even the implied warranty of |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
17 | See the GNU Affero General Public License for more details. |
19 | You should have received a copy of the GNU Affero General Public |
20 | License and the CiviCRM Licensing Exception along |
21 | with this program; if not, contact CiviCRM LLC |
22 | at info[AT]civicrm[DOT]org. If you have questions about the |
23 | GNU Affero General Public License or the licensing of CiviCRM, |
24 | see the CiviCRM license FAQ at http://civicrm.org/licensing |
25 +--------------------------------------------------------------------+
31 * @copyright CiviCRM LLC (c) 2004-2013
37 * This class generates form components for Option Group
40 class CRM_Admin_Form_OptionGroup
extends CRM_Admin_Form
{
43 * Function to build the form
48 public function buildQuickForm() {
49 parent
::buildQuickForm();
50 if ($this->_action
& CRM_Core_Action
::DELETE
) {
53 CRM_Utils_System
::setTitle(ts('Dropdown Options'));
55 $this->applyFilter('__ALL__', 'trim');
59 CRM_Core_DAO
::getAttribute('CRM_Core_DAO_OptionGroup', 'name'),
62 $this->addRule('name',
63 ts('Name already exists in Database.'),
65 array('CRM_Core_DAO_OptionGroup', $this->_id
)
71 CRM_Core_DAO
::getAttribute('CRM_Core_DAO_OptionGroup', 'title')
77 CRM_Core_DAO
::getAttribute('CRM_Core_DAO_OptionGroup', 'description')
80 $element = $this->add('checkbox', 'is_active', ts('Enabled?'));
81 if ($this->_action
& CRM_Core_Action
::UPDATE
) {
82 if (in_array($this->_values
['name'], array(
83 'encounter_medium', 'case_type', 'case_status'))) {
84 static $caseCount = NULL;
85 if (!isset($caseCount)) {
86 $caseCount = CRM_Case_BAO_Case
::caseCount(NULL, FALSE);
93 if (CRM_Utils_Array
::value('is_reserved', $this->_values
)) {
94 $this->freeze(array('name', 'is_active'));
98 $this->assign('id', $this->_id
);
102 * Function to process the form
108 public function postProcess() {
109 CRM_Utils_System
::flushCache();
111 $params = $this->exportValues();
112 if ($this->_action
& CRM_Core_Action
::DELETE
) {
113 CRM_Core_BAO_OptionGroup
::del($this->_id
);
114 CRM_Core_Session
::setStatus(ts('Selected option group has been deleted.'), ts('Record Deleted'), 'success');
118 $params = $ids = array();
119 // store the submitted values in an array
120 $params = $this->exportValues();
122 if ($this->_action
& CRM_Core_Action
::UPDATE
) {
123 $ids['optionGroup'] = $this->_id
;
126 $optionGroup = CRM_Core_BAO_OptionGroup
::add($params, $ids);
127 CRM_Core_Session
::setStatus(ts('The Option Group \'%1\' has been saved.', array(1 => $optionGroup->name
)), ts('Saved'), 'success');