Fix case on Class names (actually they are case insensitive so this is just a tidy up
[civicrm-core.git] / CRM / Admin / Form / Persistent.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
232624b1 4 | CiviCRM version 4.4 |
6a488035
TO
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
7 +--------------------------------------------------------------------+
8 | This file is a part of CiviCRM. |
9 | |
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. |
13 | |
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. |
18 | |
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 +--------------------------------------------------------------------+
26*/
27
28/**
29 *
30 * @package CRM
31 * @copyright CiviCRM LLC (c) 2004-2013
32 * $Id$
33 *
34 */
35
36/**
37 * customize the output to meet our specific requirements
38 */
39class CRM_Admin_Form_Persistent extends CRM_Core_Form {
40
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);
45
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'));
49 parent::preProcess();
50 }
51
52 public function setDefaultValues() {
53 $defaults = array();
54
55 if ($this->_indexID && ($this->_action & (CRM_Core_Action::UPDATE))) {
56 $params = array('id' => $this->_indexID);
57 CRM_Core_BAO_Persistent::retrieve($params, $defaults);
58 if (CRM_Utils_Array::value('is_config', $defaults) == 1) {
59 $defaults['data'] = implode(',', $defaults['data']);
60 }
61 }
62 return $defaults;
63 }
64
65 public function buildQuickForm() {
66 $this->add('text', 'context', ts('Context:'), NULL, TRUE);
67 $this->add('text', 'name', ts('Name:'), NULL, TRUE);
68 $this->add('textarea', 'data', ts('Data:'), array('rows' => 4, 'cols' => 50), TRUE);
69 $this->addButtons(array(
70 array(
71 'type' => 'submit',
72 'name' => ts('Save'),
73 'isDefault' => TRUE,
74 ),
75 array(
76 'type' => 'cancel',
77 'name' => ts('Cancel'),
78 ),
79 )
80 );
81 }
82
83 public function postProcess() {
84 $params = $ids = array();
85 $params = $this->controller->exportValues($this->_name);
86
87 $params['is_config'] = $this->_config;
88
89 if ($this->_action & CRM_Core_Action::ADD) {
90 CRM_Core_Session::setStatus(ts('DB Template has been added successfully.'), ts("Saved"), "success");
91 }
92 if ($this->_action & CRM_Core_Action::UPDATE) {
93 $ids['persistent'] = $this->_indexID;
94 CRM_Core_Session::setStatus(ts('DB Template has been updated successfully.'), ts("Saved"), "success");
95 }
96 CRM_Core_BAO_Persistent::add($params, $ids);
97
98 CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/tplstrings', "reset=1"));
99 }
100}
101