X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=CRM%2FCampaign%2FForm%2FSurvey.php;h=05eec10ceee63cc18d5fc6145bad5e53f3e3a8a3;hb=9585cabb995de30da705ab3349d15f048f128ab4;hp=1839334282cb167127e407e99ba217459fabb213;hpb=aa31a7a02e13acfc02a1519de90017ebff06e42d;p=civicrm-core.git diff --git a/CRM/Campaign/Form/Survey.php b/CRM/Campaign/Form/Survey.php index 1839334282..05eec10cee 100644 --- a/CRM/Campaign/Form/Survey.php +++ b/CRM/Campaign/Form/Survey.php @@ -57,6 +57,22 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form { */ protected $_surveyTitle; + /** + * Explicitly declare the entity api name. + */ + public function getDefaultEntity() { + return 'Survey'; + } + + /** + * Get the entity id being edited. + * + * @return int|null + */ + public function getEntityId() { + return $this->_surveyId; + } + public function preProcess() { if (!CRM_Campaign_BAO_Campaign::accessCampaign()) { CRM_Utils_System::permissionDenied(); @@ -68,29 +84,23 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form { if ($this->_surveyId) { $this->_single = TRUE; - $params = array('id' => $this->_surveyId); + $params = ['id' => $this->_surveyId]; CRM_Campaign_BAO_Survey::retrieve($params, $surveyInfo); $this->_surveyTitle = $surveyInfo['title']; $this->assign('surveyTitle', $this->_surveyTitle); - CRM_Utils_System::setTitle(ts('Configure Survey - %1', array(1 => $this->_surveyTitle))); + CRM_Utils_System::setTitle(ts('Configure Survey - %1', [1 => $this->_surveyTitle])); } $this->assign('action', $this->_action); $this->assign('surveyId', $this->_surveyId); - // when custom data is included in this page - if (!empty($_POST['hidden_custom'])) { - $this->set('type', 'Survey'); - $this->set('entityId', $this->_surveyId); - CRM_Custom_Form_CustomData::preProcess($this, NULL, NULL, 1, 'Survey', $this->_surveyId); - CRM_Custom_Form_CustomData::buildQuickForm($this); - CRM_Custom_Form_CustomData::setDefaultValues($this); - } + // Add custom data to form + CRM_Custom_Form_CustomData::addToForm($this); // CRM-11480, CRM-11682 // Preload libraries required by the "Questions" tab CRM_UF_Page_ProfileEditor::registerProfileScripts(); - CRM_UF_Page_ProfileEditor::registerSchemas(array('IndividualModel', 'ActivityModel')); + CRM_UF_Page_ProfileEditor::registerSchemas(['IndividualModel', 'ActivityModel']); CRM_Campaign_Form_Survey_TabHeader::build($this); } @@ -101,39 +111,39 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form { public function buildQuickForm() { $session = CRM_Core_Session::singleton(); if ($this->_surveyId) { - $buttons = array( - array( + $buttons = [ + [ 'type' => 'upload', 'name' => ts('Save'), 'isDefault' => TRUE, - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and Done'), 'subName' => 'done', - ), - array( + ], + [ 'type' => 'upload', 'name' => ts('Save and Next'), 'spacing' => '                 ', 'subName' => 'next', - ), - ); + ], + ]; } else { - $buttons = array( - array( + $buttons = [ + [ 'type' => 'upload', 'name' => ts('Continue'), 'spacing' => '                 ', 'isDefault' => TRUE, - ), - ); + ], + ]; } - $buttons[] = array( + $buttons[] = [ 'type' => 'cancel', 'name' => ts('Cancel'), - ); + ]; $this->addButtons($buttons); $url = CRM_Utils_System::url('civicrm/campaign', 'reset=1&subPage=survey'); @@ -148,7 +158,7 @@ class CRM_Campaign_Form_Survey extends CRM_Core_Form { $tabTitle = 'Main settings'; } $subPage = strtolower($className); - CRM_Core_Session::setStatus(ts("'%1' have been saved.", array(1 => $tabTitle)), ts('Saved'), 'success'); + CRM_Core_Session::setStatus(ts("'%1' have been saved.", [1 => $tabTitle]), ts('Saved'), 'success'); $this->postProcessHook();