Example #1
0
 public function upgrade($previous_version)
 {
     if (version_compare($previous_version, '1.0.5') == -1) {
         $forms = GFAPI::get_forms(true);
         foreach ($forms as $form) {
             $entries = GFAPI::get_entries($form['id']);
             $fields = GFAPI::get_fields_by_type($form, 'repeater');
             foreach ($entries as $entry) {
                 foreach ($fields as $field) {
                     if (array_key_exists($field['id'], $entry)) {
                         $dataArray = GFFormsModel::unserialize($entry[$field['id']]);
                         $dataUpdated = false;
                         if (!is_array($dataArray)) {
                             continue;
                         }
                         foreach ($dataArray as $repeaterChildId => $repeaterChild) {
                             foreach ($repeaterChild as $repeatedFieldId => $repeatedField) {
                                 if (!is_array($repeatedField)) {
                                     if ($repeatedField !== '[gfRepeater-section]') {
                                         $dataUpdated = true;
                                         $dataArray[$repeaterChildId][$repeatedFieldId] = array($repeatedField);
                                     }
                                 } elseif (reset($repeatedField) == '[gfRepeater-section]') {
                                     $dataUpdated = true;
                                     $dataArray[$repeaterChildId][$repeatedFieldId] = reset($repeatedField);
                                 }
                             }
                         }
                         if ($dataUpdated) {
                             GFAPI::update_entry_field($entry['id'], $field['id'], maybe_serialize($dataArray));
                         }
                     }
                 }
             }
         }
     }
 }
 public static function delete_passwords($entry, $form)
 {
     $password_fields = GFAPI::get_fields_by_type($form, array('password'));
     foreach ($password_fields as $password_field) {
         GFAPI::update_entry_field($entry['id'], $password_field['id'], '');
     }
 }
 /**
  * Initiates deletion of the signature file and updates the entry to remove the filename.
  *
  * @param integer $lead_id The ID of the current entry.
  * @param integer $field_id The ID of the current field.
  *
  * @return bool
  */
 public function delete_signature($lead_id, $field_id)
 {
     global $wpdb;
     $lead = RGFormsModel::get_lead($lead_id);
     $this->delete_signature_file(rgar($lead, $field_id));
     return GFAPI::update_entry_field($lead_id, $field_id, '');
 }
 public static function update_entry_field($entry, $form)
 {
     if ($form['id'] == self::$formID) {
         GFAPI::update_entry_field($entry['id'], self::$fieldID, self::decrypt(rgar($entry, self::$fieldID)));
     }
 }