CFDBIntegrationJetPack

"Contact Form to Database" Copyright (C) 2011-2015 Michael Simpson (email : michael.d.simpson@gmail.com).

Defined (1)

The class is defined in the following location(s).

/CFDBIntegrationJetPack.php  
  1. class CFDBIntegrationJetPack { 
  2.  
  3. /** 
  4. * @var CF7DBPlugin 
  5. */ 
  6. var $plugin; 
  7.  
  8. /** 
  9. * @param $plugin CF7DBPlugin 
  10. */ 
  11. function __construct($plugin) { 
  12. $this->plugin = $plugin; 
  13.  
  14. public function registerHooks() { 
  15. add_action('grunion_pre_message_sent', array(&$this, 'saveFormData'), 10, 3); 
  16.  
  17. /** 
  18. * @param $post_id int 
  19. * @param $all_values array 
  20. * @param $extra_values array 
  21. * @return object 
  22. */ 
  23. public function saveFormData($post_id, $all_values, $extra_values) { 
  24. try { 
  25. $data = $this->convertData($post_id, $all_values); 
  26.  
  27. return $this->plugin->saveFormData($data); 
  28. } catch (Exception $ex) { 
  29. $this->plugin->getErrorLog()->logException($ex); 
  30. return true; 
  31.  
  32. public function convertData($post_id, $all_values) { 
  33.  
  34. // $errorLog = $this->plugin->getErrorLog(); 
  35. // $errorLog->log('POST=' . print_r($_POST, true)); 
  36. // $errorLog->log('$all_values=' . print_r($all_values, true)); 
  37. // $errorLog->log('$extra_values=' . print_r($extra_values, true)); 
  38.  
  39. $title = 'JetPack Contact Form'; 
  40. if (isset($_POST['contact-form-id'])) { 
  41. $title .= ' ' . $_POST['contact-form-id']; 
  42. //$all_values['contact-form-id'] = $_POST['contact-form-id']; 
  43. else { 
  44. $title .= ' ' . $post_id; 
  45.  
  46. $all_values['post_id'] = $post_id; 
  47. return (object) array( 
  48. 'title' => $title,  
  49. 'posted_data' => $all_values,  
  50. 'uploaded_files' => null); 
  51.  
  52.