3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.6 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2014 |
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-2014
37 * This class is to build the form for Deleting Group
39 class CRM_Custom_Form_MoveField
extends CRM_Core_Form
{
70 * The title of the field being moved
74 protected $_srcFieldLabel;
77 * Set up variables to build the form
82 public function preProcess() {
83 $this->_srcFID
= CRM_Utils_Request
::retrieve('fid', 'Positive',
87 $this->_srcGID
= CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomField',
92 $this->_srcFieldLabel
= CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomField',
97 CRM_Utils_System
::setTitle(ts('Custom Field Move: %1',
98 array(1 => $this->_srcFieldLabel
)
101 $session = CRM_Core_Session
::singleton();
102 $session->pushUserContext(CRM_Utils_System
::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_srcGID}"));
106 * Build the form object
110 public function buildQuickForm() {
112 $customGroup = CRM_Core_PseudoConstant
::get('CRM_Core_DAO_CustomField', 'custom_group_id');
113 unset($customGroup[$this->_srcGID
]);
114 if (empty($customGroup)) {
115 CRM_Core_Error
::statusBounce(ts('You need more than one custom group to move fields'));
118 $customGroup = array(
119 '' => ts('- select -')) +
$customGroup;
127 $this->addButtons(array(
130 'name' => ts('Move Custom Field'),
135 'name' => ts('Cancel'),
140 $this->addFormRule(array('CRM_Custom_Form_MoveField', 'formRule'), $this);
150 public static function formRule($fields, $files, $self) {
151 $self->_dstGID
= $fields['dst_group_id'];
152 $tmp = CRM_Core_BAO_CustomField
::_moveFieldValidate($self->_srcFID
, $self->_dstGID
);
154 if ($tmp['newGroupID']) {
155 $errors['dst_group_id'] = $tmp['newGroupID'];
157 return empty($errors) ?
TRUE : $errors;
161 * Process the form when submitted
165 public function postProcess() {
166 CRM_Core_BAO_CustomField
::moveField($this->_srcFID
, $this->_dstGID
);
168 $dstGroup = CRM_Core_DAO
::getFieldValue('CRM_Core_DAO_CustomGroup',
172 $srcUrl = CRM_Utils_System
::url('civicrm/admin/custom/group/field', "reset=1&action=browse&gid={$this->_dstGID}");
173 CRM_Core_Session
::setStatus(ts("%1 has been moved to the custom set <a href='%3'>%2</a>.",
175 1 => $this->_srcFieldLabel
,