public function saveFormData($form_id)
 {
     try {
         $title = get_the_title($form_id);
         $converter = new CFDBPostDataConverter();
         $converter->addExcludeField('post_nonce_field');
         $converter->addExcludeField('form-type');
         $converter->addExcludeField('fms-ajax');
         $converter->addExcludeField('action');
         $data = $converter->convert($title);
         // CFDBPostDataConverter won't capture files how they are organized here
         if (is_array($_FILES) && !empty($_FILES)) {
             foreach ($_FILES as $key => $file) {
                 if (is_array($file['tmp_name'])) {
                     for ($idx = 0; $idx < count($file['tmp_name']); ++$idx) {
                         if (is_uploaded_file($file['tmp_name'][$idx])) {
                             $fileKey = $idx > 0 ? $key . $idx : $key;
                             $data->posted_data[$fileKey] = $file['name'][$idx];
                             $data->uploaded_files[$fileKey] = $file['tmp_name'][$idx];
                         }
                     }
                 }
             }
         }
         return $this->plugin->saveFormData($data);
     } catch (Exception $ex) {
         $this->plugin->getErrorLog()->logException($ex);
     }
     return true;
 }
 /**
  * @param $form_data
  * @return bool
  */
 public function saveFormData($form_data) {
     try {
         $data = $this->convertData($form_data);
         return $this->plugin->saveFormData($data);
     } catch (Exception $ex) {
         $this->plugin->getErrorLog()->logException($ex);
     }
     return true;
 }
 /**
  * @param $dataForms array
  * @param $postID array
  * @param $post array
  * @param $submissionsData array
  * @param $dataContentEmail array
  * @param $nameFileByIdentifier array
  * @param $requiredField array
  * @param $fileAttach array
  * @return bool
  */
 public function saveFormData($dataForms, $postID, $post, $submissionsData, $dataContentEmail, $nameFileByIdentifier, $requiredField, $fileAttach)
 {
     try {
         $data = $this->convertData($dataForms, $postID, $post, $submissionsData, $dataContentEmail, $nameFileByIdentifier, $requiredField, $fileAttach);
         return $this->plugin->saveFormData($data);
     } catch (Exception $ex) {
         $this->plugin->getErrorLog()->logException($ex);
     }
     return true;
 }
 /**
  * @param $post_id int
  * @param $all_values array
  * @param $extra_values array
  * @return object
  */
 public function saveFormData($post_id, $all_values, $extra_values)
 {
     try {
         $data = $this->convertData($post_id, $all_values);
         return $this->plugin->saveFormData($data);
     } catch (Exception $ex) {
         $this->plugin->getErrorLog()->logException($ex);
     }
     return true;
 }
 /**
  * Very Simple Signup Form
  * @param $form_data
  * @return bool
  */
 public function saveVssfFormData($form_data)
 {
     try {
         $title = 'Very Simple Signup Form';
         $data = $this->convertData($form_data, $title);
         return $this->plugin->saveFormData($data);
     } catch (Exception $ex) {
         $this->plugin->getErrorLog()->logException($ex);
     }
     return true;
 }
 /**
  * @param $form array
  * @param $referrer array
  * @param $process_id string
  * @return bool
  */
 public function saveFormData($form, $referrer, $process_id)
 {
     try {
         // debug
         //            $this->plugin->getErrorLog()->log('$form: ' . print_r($form, true));
         //            $this->plugin->getErrorLog()->log('$referrer: ' . print_r($referrer, true));
         //            $this->plugin->getErrorLog()->log('$process_id: ' . print_r($process_id, true));
         //            global $processed_data;
         //            $this->plugin->getErrorLog()->log('$processed_data: ' . print_r($processed_data, true));
         $data = $this->convertData($form);
         return $this->plugin->saveFormData($data);
     } catch (Exception $ex) {
         $this->plugin->getErrorLog()->logException($ex);
     }
     return true;
 }
 /**
  * @param $form array
  * @param $referrer array
  * @param $process_id string
  * @param int $entry_id
  * @return bool
  */
 public function saveFormData($form, $referrer, $process_id, $entry_id)
 {
     if (!class_exists('Caldera_Forms')) {
         // Caldera not installed
         return true;
     }
     try {
         // debug
         //            $this->plugin->getErrorLog()->log('$form: ' . print_r($form, true));
         //            $this->plugin->getErrorLog()->log('$referrer: ' . print_r($referrer, true));
         //            $this->plugin->getErrorLog()->log('$process_id: ' . print_r($process_id, true));
         //            $this->plugin->getErrorLog()->log('$entry_id: ' . print_r($entry_id, true));
         $data = $this->convertData($form, $entry_id);
         return $this->plugin->saveFormData($data);
     } catch (Exception $ex) {
         $this->plugin->getErrorLog()->logException($ex);
     }
     return true;
 }
示例#8
0
文件: functions.php 项目: jackey/xy
function ajax_action_submit_contact_form()
{
    $content = file_get_contents("php://input");
    if ($content) {
        $contactData = json_decode($content, true);
        $data = array('title' => '联系我们', 'posted_data' => $contactData);
        $data = (object) $data;
        require_once ABSPATH . 'wp-content/plugins/contact-form-7-to-database-extension/CF7DBPlugin.php';
        $plugin = new CF7DBPlugin();
        $plugin->saveFormData($data);
    }
    die;
}
 public function saveFormData($bool, $new_post, $form_params)
 {
     //        $msg = '$new_post=' . print_r($new_post, true) . "\n" .
     //                '$form_params=' . print_r($form_params, true);
     //        $this->plugin->getErrorLog()->log($msg);
     try {
         if (is_array($new_post)) {
             $postedData = array();
             foreach ($new_post as $key => $value) {
                 $postedData[$key] = urldecode($value);
             }
             $title = 'Enfold';
             if (is_array($form_params) && isset($form_params['heading']) && $form_params['heading']) {
                 $title = strip_tags($form_params['heading']);
             }
             $data = (object) array('title' => $title, 'posted_data' => $postedData, 'uploaded_files' => array());
             $this->plugin->saveFormData($data);
         }
     } catch (Exception $ex) {
     }
     return true;
 }
 /**
  * @param int $entry_id
  * @param int $form_id
  * @return bool
  */
 public function saveFormData($entry_id, $form_id)
 {
     global $wpdb;
     // Get form title
     $sql = "SELECT name FROM {$wpdb->prefix}frm_forms WHERE id = %d";
     $sql = $wpdb->prepare($sql, $form_id);
     $title = $wpdb->get_var($sql);
     if (!$title) {
         return true;
     }
     // Get submission values
     $sql = "SELECT f.name AS 'key', m.meta_value AS 'value' FROM {$wpdb->prefix}frm_item_metas m, wp_frm_fields f WHERE m.field_id = f.id AND m.item_id = %d";
     $sql = $wpdb->prepare($sql, $entry_id);
     $results = $wpdb->get_results($sql, ARRAY_A);
     if (!$results) {
         return true;
     }
     $postedData = array();
     foreach ($results as $result) {
         $key = $result['key'];
         $value = $result['value'];
         if (is_serialized($value)) {
             $value = unserialize($value);
             if (is_array($value)) {
                 $value = implode(',', $value);
             } else {
                 $value = (string) $value;
                 // shouldn't get here
             }
         }
         $postedData[$key] = $value;
     }
     // Save submission
     $data = (object) array('title' => $title, 'posted_data' => $postedData, 'uploaded_files' => array());
     // todo
     $this->plugin->saveFormData($data);
     return true;
 }