Merge pull request #15168 from MegaphoneJon/class-fixes
[civicrm-core.git] / CRM / Campaign / Form / Petition / Signature.php
index 74fa32114f5471e5650ce18d0ec08392ad831b5d..29e398ef185053e0b2029774e21aa8087cae62ea 100644 (file)
@@ -181,7 +181,7 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
     }
     //check petition is valid and active
     $params['id'] = $this->_surveyId;
-    $this->petition = array();
+    $this->petition = [];
     CRM_Campaign_BAO_Survey::retrieve($params, $this->petition);
     if (empty($this->petition)) {
       CRM_Core_Error::fatal('Petition doesn\'t exist.');
@@ -201,12 +201,12 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
 
     // add the custom contact and activity profile fields to the signature form
 
-    $ufJoinParams = array(
+    $ufJoinParams = [
       'entity_id' => $this->_surveyId,
       'entity_table' => 'civicrm_survey',
       'module' => 'CiviCampaign',
       'weight' => 2,
-    );
+    ];
 
     $this->_contactProfileId = CRM_Core_BAO_UFJoin::findUFGroupId($ufJoinParams);
     if ($this->_contactProfileId) {
@@ -231,7 +231,7 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
    * Set default values for the form.
    */
   public function setDefaultValues() {
-    $this->_defaults = array();
+    $this->_defaults = [];
     if ($this->_contactId) {
       CRM_Core_BAO_UFGroup::setProfileDefaults($this->_contactId, $this->_contactProfileFields, $this->_defaults, TRUE);
       if ($this->_activityProfileId) {
@@ -296,14 +296,13 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
       $this->buildCustom($this->_activityProfileId, 'petitionActivityProfile');
     }
     // add buttons
-    $this->addButtons(array(
-        array(
-          'type' => 'upload',
-          'name' => ts('Sign the Petition'),
-          'isDefault' => TRUE,
-        ),
-      )
-    );
+    $this->addButtons([
+      [
+        'type' => 'upload',
+        'name' => ts('Sign the Petition'),
+        'isDefault' => TRUE,
+      ],
+    ]);
   }
 
   /**
@@ -318,7 +317,7 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
    * @return array|bool
    */
   public static function formRule($fields, $files, $errors) {
-    $errors = array();
+    $errors = [];
 
     return empty($errors) ? TRUE : $errors;
   }
@@ -371,11 +370,11 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
       $ids[0] = $this->_contactId;
     }
     else {
-      $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $this->_ctype, 'Unsupervised', array(), FALSE);
+      $ids = CRM_Contact_BAO_Contact::getDuplicateContacts($params, $this->_ctype, 'Unsupervised', [], FALSE);
     }
 
     $petition_params['id'] = $this->_surveyId;
-    $petition = array();
+    $petition = [];
     CRM_Campaign_BAO_Survey::retrieve($petition_params, $petition);
 
     switch (count($ids)) {
@@ -606,9 +605,7 @@ class CRM_Campaign_Form_Petition_Signature extends CRM_Core_Form {
         }
 
         if ($addCaptcha && !$viewOnly) {
-          $captcha = CRM_Utils_ReCAPTCHA::singleton();
-          $captcha->add($this);
-          $this->assign("isCaptcha", TRUE);
+          CRM_Utils_ReCAPTCHA::enableCaptchaOnForm($this);
         }
       }
     }