Created
June 11, 2015 16:18
-
-
Save tomflanagan/2ba17c88cd55217f3f78 to your computer and use it in GitHub Desktop.
Webform submission
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /** | |
| * @file | |
| * Contains \RestfulQueryVariable | |
| */ | |
| class RestfulQueryWebform extends \RestfulDataProviderDbQuery implements \RestfulDataProviderDbQueryInterface, \RestfulDataProviderInterface { | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function publicFieldsInfo() { | |
| module_load_include('inc', 'webform', 'webform.module'); | |
| module_load_include('inc', 'webform', 'includes/webform.submissions'); | |
| return array( | |
| 'sid' => array( | |
| 'property' => 'sid', | |
| ), | |
| 'nid' => array( | |
| 'property' => 'nid', | |
| ), | |
| ); | |
| } | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function create() { | |
| $request = $this->getRequest(); | |
| $webform_nid = 18; | |
| $node = node_load($webform_nid); | |
| module_load_include('inc', 'webform', 'webform.module'); | |
| module_load_include('inc', 'webform', 'includes/webform.submissions'); | |
| $serial = _webform_submission_serial_next_value($webform_nid); | |
| $data = array( | |
| 1 => array($request['param1']), | |
| 2 => array($request['param2']), | |
| ); | |
| $submission = (object) array( | |
| 'nid' => $webform_nid, | |
| 'uid' => 0, | |
| 'submitted' => REQUEST_TIME, | |
| 'remote_addr' => ip_address(), | |
| 'is_draft' => FALSE, | |
| 'serial' => $serial, | |
| 'data' => $data, | |
| ); | |
| $sid = webform_submission_insert($node, $submission); | |
| die($request['param1']); | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $plugin = array( | |
| 'label' => t('Webform'), | |
| 'description' => t('Webform module.'), | |
| 'resource' => 'webforms', | |
| 'class' => 'RestfulQueryWebform', | |
| 'data_provider_options' => array( | |
| 'table_name' => 'webform_submissions', | |
| 'id_column' => 'sid', | |
| ), | |
| 'authentication_types' => TRUE, | |
| 'authentication_optional' => TRUE, | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment