3 +--------------------------------------------------------------------+
4 | CiviCRM version 4.4 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2013 |
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-2013
37 * This class generates form components for processing a survey
40 class CRM_Campaign_Form_Survey
extends CRM_Core_Form
{
43 * The id of the object being edited
61 protected $_surveyTitle;
63 public function preProcess() {
64 if (!CRM_Campaign_BAO_Campaign
::accessCampaign()) {
65 CRM_Utils_System
::permissionDenied();
68 $this->_action
= CRM_Utils_Request
::retrieve('action', 'String', $this, FALSE, 'add', 'REQUEST');
69 $this->_surveyId
= CRM_Utils_Request
::retrieve('id', 'Positive', $this, FALSE);
71 if ($this->_surveyId
) {
72 $this->_single
= TRUE;
74 $params = array('id' => $this->_surveyId
);
75 CRM_Campaign_BAO_Survey
::retrieve($params, $surveyInfo);
76 $this->_surveyTitle
= $surveyInfo['title'];
77 $this->assign('surveyTitle', $this->_surveyTitle
);
78 CRM_Utils_System
::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle
)));
81 $this->assign('action', $this->_action
);
82 $this->assign('surveyId', $this->_surveyId
);
84 // CRM-11480, CRM-11682
85 // Preload libraries required by the "Questions" tab
86 CRM_UF_Page_ProfileEditor
::registerProfileScripts();
87 CRM_UF_Page_ProfileEditor
::registerSchemas(array('IndividualModel', 'ActivityModel'));
89 CRM_Campaign_Form_Survey_TabHeader
::build($this);
93 * Function to actually build the form
100 public function buildQuickForm() {
101 $session = CRM_Core_Session
::singleton();
102 if ($this->_surveyId
) {
106 'name' => ts('Save'),
111 'name' => ts('Save and Done'),
116 'name' => ts('Save and Next'),
117 'spacing' => ' ',
126 'name' => ts('Continue >>'),
127 'spacing' => ' ',
135 'name' => ts('Cancel'),
137 $this->addButtons($buttons);
139 $url = CRM_Utils_System
::url('civicrm/campaign', 'reset=1&subPage=survey');
140 $session->replaceUserContext($url);
143 function endPostProcess() {
144 // make submit buttons keep the current working tab opened.
145 if ($this->_action
& (CRM_Core_Action
::UPDATE | CRM_Core_Action
::ADD
)) {
146 $tabTitle = $className = CRM_Utils_String
::getClassName($this->_name
);
147 if ($tabTitle == 'Main') {
148 $tabTitle = 'Main settings';
150 $subPage = strtolower($className);
151 CRM_Core_Session
::setStatus(ts("'%1' have been saved.", array(1 => $tabTitle)), ts('Saved'), 'success');
153 $this->postProcessHook();
155 if ($this->_action
& CRM_Core_Action
::ADD
)
156 CRM_Utils_System
::redirect(CRM_Utils_System
::url("civicrm/survey/configure/questions",
157 "action=update&reset=1&id={$this->_surveyId}"));
159 if ($this->controller
->getButtonName('submit') == "_qf_{$className}_upload_done") {
160 CRM_Utils_System
::redirect(CRM_Utils_System
::url('civicrm/campaign', 'reset=1&subPage=survey'));
162 else if ($this->controller
->getButtonName('submit') == "_qf_{$className}_upload_next") {
163 $subPage = CRM_Campaign_Form_Survey_TabHeader
::getNextTab($this);
164 CRM_Utils_System
::redirect(CRM_Utils_System
::url("civicrm/survey/configure/{$subPage}",
165 "action=update&reset=1&id={$this->_surveyId}"));
168 CRM_Utils_System
::redirect(CRM_Utils_System
::url("civicrm/survey/configure/{$subPage}",
169 "action=update&reset=1&id={$this->_surveyId}"));
174 function getTemplateFileName() {
175 if ($this->controller
->getPrint() == CRM_Core_Smarty
::PRINT_NOFORM ||
176 $this->getVar('_surveyId') <= 0 ) {
177 return parent
::getTemplateFileName();
180 // hack lets suppress the form rendering for now
181 self
::$_template->assign('isForm', FALSE);
182 return 'CRM/Campaign/Form/Survey/Tab.tpl';