further comment fixes
[civicrm-core.git] / CRM / Admin / Form / Persistent.php
CommitLineData
6a488035
TO
1<?php
2/*
3 +--------------------------------------------------------------------+
7e9e8871 4 | CiviCRM version 4.7 |
6a488035 5 +--------------------------------------------------------------------+
e7112fa7 6 | Copyright CiviCRM LLC (c) 2004-2015 |
6a488035
TO
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 +--------------------------------------------------------------------+
d25dd0ee 26 */
6a488035
TO
27
28/**
29 *
30 * @package CRM
e7112fa7 31 * @copyright CiviCRM LLC (c) 2004-2015
6a488035
TO
32 */
33
34/**
ce064e4f 35 * Customize the output to meet our specific requirements.
6a488035
TO
36 */
37class CRM_Admin_Form_Persistent extends CRM_Core_Form {
38
ce064e4f 39 /**
40 * Pre-process form.
41 */
6a488035
TO
42 public function preProcess() {
43 $this->_indexID = CRM_Utils_Request::retrieve('id', 'Integer', $this, FALSE);
353ffa53
TO
44 $this->_config = CRM_Utils_Request::retrieve('config', 'Integer', $this, 0);
45 $this->_action = CRM_Utils_Request::retrieve('action', 'String', $this, FALSE);
6a488035
TO
46
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'));
50 parent::preProcess();
51 }
52
e0ef6999 53 /**
ce064e4f 54 * Set default values.
55 *
e0ef6999
EM
56 * @return array
57 */
6a488035
TO
58 public function setDefaultValues() {
59 $defaults = array();
60
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']);
66 }
67 }
68 return $defaults;
69 }
70
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(
76 array(
77 'type' => 'submit',
78 'name' => ts('Save'),
79 'isDefault' => TRUE,
80 ),
81 array(
82 'type' => 'cancel',
83 'name' => ts('Cancel'),
84 ),
85 )
86 );
87 }
88
89 public function postProcess() {
90 $params = $ids = array();
91 $params = $this->controller->exportValues($this->_name);
92
93 $params['is_config'] = $this->_config;
94
95 if ($this->_action & CRM_Core_Action::ADD) {
96 CRM_Core_Session::setStatus(ts('DB Template has been added successfully.'), ts("Saved"), "success");
97 }
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");
101 }
102 CRM_Core_BAO_Persistent::add($params, $ids);
103
104 CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/tplstrings', "reset=1"));
105 }
96025800 106
6a488035 107}