3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.7 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2017 |
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-2017
35 * Customize the output to meet our specific requirements.
37 class CRM_Admin_Form_Persistent
extends CRM_Core_Form
{
42 public function preProcess() {
43 $this->_indexID
= CRM_Utils_Request
::retrieve('id', 'Integer', $this, FALSE);
44 $this->_config
= CRM_Utils_Request
::retrieve('config', 'Integer', $this, 0);
45 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE);
47 $session = CRM_Core_Session
::singleton();
48 $session->pushUserContext(CRM_Utils_System
::url('civicrm/admin/tplstrings', 'reset=1'));
49 CRM_Utils_System
::setTitle(ts('DB Template Strings'));
58 public function setDefaultValues() {
61 if ($this->_indexID
&& ($this->_action
& (CRM_Core_Action
::UPDATE
))) {
62 $params = array('id' => $this->_indexID
);
63 CRM_Core_BAO_Persistent
::retrieve($params, $defaults);
64 if (CRM_Utils_Array
::value('is_config', $defaults) == 1) {
65 $defaults['data'] = implode(',', $defaults['data']);
71 public function buildQuickForm() {
72 $this->add('text', 'context', ts('Context:'), NULL, TRUE);
73 $this->add('text', 'name', ts('Name:'), NULL, TRUE);
74 $this->add('textarea', 'data', ts('Data:'), array('rows' => 4, 'cols' => 50), TRUE);
75 $this->addButtons(array(
83 'name' => ts('Cancel'),
89 public function postProcess() {
90 $params = $ids = array();
91 $params = $this->controller
->exportValues($this->_name
);
93 $params['is_config'] = $this->_config
;
95 if ($this->_action
& CRM_Core_Action
::ADD
) {
96 CRM_Core_Session
::setStatus(ts('DB Template has been added successfully.'), ts("Saved"), "success");
98 if ($this->_action
& CRM_Core_Action
::UPDATE
) {
99 $ids['persistent'] = $this->_indexID
;
100 CRM_Core_Session
::setStatus(ts('DB Template has been updated successfully.'), ts("Saved"), "success");
102 CRM_Core_BAO_Persistent
::add($params, $ids);
104 CRM_Utils_System
::redirect(CRM_Utils_System
::url('civicrm/admin/tplstrings', "reset=1"));