3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.5 |
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 * customize the output to meet our specific requirements
39 class CRM_Admin_Form_Persistent
extends CRM_Core_Form
{
41 public function preProcess() {
42 $this->_indexID
= CRM_Utils_Request
::retrieve('id', 'Integer', $this, FALSE);
43 $this->_config
= CRM_Utils_Request
::retrieve('config', 'Integer', $this, 0);
44 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE);
46 $session = CRM_Core_Session
::singleton();
47 $session->pushUserContext(CRM_Utils_System
::url('civicrm/admin/tplstrings', 'reset=1'));
48 CRM_Utils_System
::setTitle(ts('DB Template Strings'));
55 public function setDefaultValues() {
58 if ($this->_indexID
&& ($this->_action
& (CRM_Core_Action
::UPDATE
))) {
59 $params = array('id' => $this->_indexID
);
60 CRM_Core_BAO_Persistent
::retrieve($params, $defaults);
61 if (CRM_Utils_Array
::value('is_config', $defaults) == 1) {
62 $defaults['data'] = implode(',', $defaults['data']);
68 public function buildQuickForm() {
69 $this->add('text', 'context', ts('Context:'), NULL, TRUE);
70 $this->add('text', 'name', ts('Name:'), NULL, TRUE);
71 $this->add('textarea', 'data', ts('Data:'), array('rows' => 4, 'cols' => 50), TRUE);
72 $this->addButtons(array(
80 'name' => ts('Cancel'),
86 public function postProcess() {
87 $params = $ids = array();
88 $params = $this->controller
->exportValues($this->_name
);
90 $params['is_config'] = $this->_config
;
92 if ($this->_action
& CRM_Core_Action
::ADD
) {
93 CRM_Core_Session
::setStatus(ts('DB Template has been added successfully.'), ts("Saved"), "success");
95 if ($this->_action
& CRM_Core_Action
::UPDATE
) {
96 $ids['persistent'] = $this->_indexID
;
97 CRM_Core_Session
::setStatus(ts('DB Template has been updated successfully.'), ts("Saved"), "success");
99 CRM_Core_BAO_Persistent
::add($params, $ids);
101 CRM_Utils_System
::redirect(CRM_Utils_System
::url('civicrm/admin/tplstrings', "reset=1"));