当前位置: 首页>>代码示例>>PHP>>正文


PHP data_entry_helper::http_post方法代码示例

本文整理汇总了PHP中data_entry_helper::http_post方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::http_post方法的具体用法?PHP data_entry_helper::http_post怎么用?PHP data_entry_helper::http_post使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在data_entry_helper的用法示例。


在下文中一共展示了data_entry_helper::http_post方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: ajax_bulk_verify

 /**
  * Ajax method to proxy requests for bulk verification on to the warehouse, attaching write auth
  * as it goes.
  */
 public static function ajax_bulk_verify($website_id, $password)
 {
     iform_load_helpers(array('data_entry_helper'));
     $auth = data_entry_helper::get_read_write_auth($website_id, $password);
     $url = data_entry_helper::$base_url . "index.php/services/data_utils/bulk_verify";
     $params = array_merge($_POST, $auth['write_tokens']);
     $response = data_entry_helper::http_post($url, $params);
     echo $response['output'];
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:13,代码来源:verification_4.php

示例2: send_file_to_warehouse

 /**
  * Takes a file that has been uploaded to the client website upload folder, and moves it to the warehouse upload folder using the
  * data services.
  *
  * @param string $path Path to the file to upload, relative to the interim image path folder (normally the
  * client_helpers/upload folder.
  * @param boolean $persist_auth Allows the write nonce to be preserved after sending the file, useful when several files
  * are being uploaded.
  * @return string Error message, or true if successful.
  */
 private static function send_file_to_warehouse($path, $persist_auth = false)
 {
     $interim_image_folder = isset(parent::$interim_image_folder) ? parent::$interim_image_folder : 'upload/';
     $uploadpath = data_entry_helper::relative_client_helper_path() . $interim_image_folder;
     $serviceUrl = parent::$base_url . "/index.php/services/data/handle_media";
     // This is used by the file box control which renames uploaded files using a guid system, so disable renaming on the server.
     $postargs = array('name_is_guid' => 'true');
     // attach authentication details
     if (array_key_exists('auth_token', $_POST)) {
         $postargs['auth_token'] = $_POST['auth_token'];
     }
     if (array_key_exists('nonce', $_POST)) {
         $postargs['nonce'] = $_POST['nonce'];
     }
     if ($persist_auth) {
         $postargs['persist_auth'] = 'true';
     }
     $file_to_upload = array('media_upload' => '@' . realpath($uploadpath . $path));
     $response = data_entry_helper::http_post($serviceUrl, $file_to_upload + $postargs);
     $output = json_decode($response['output'], true);
     $r = true;
     // default is success
     if (is_array($output)) {
         //an array signals an error
         if (array_key_exists('error', $output)) {
             // return the most detailed bit of error information
             if (isset($output['errors']['media_upload'])) {
                 $r = $output['errors']['media_upload'];
             } else {
                 $r = $output['error'];
             }
         }
     }
     //remove local copy
     //unlink(realpath($uploadpath.$path));
     watchdog('file exists', realpath($uploadpath . $path));
     return $r;
 }
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:48,代码来源:data_entry_helper.php

示例3: subscribe

 /**
  * Method called when posting the form. Saves the subscription details to the warehouse.
  * @param $args
  * @param $auth
  * @throws \exception
  */
 private static function subscribe($args, $auth)
 {
     $url = data_entry_helper::$base_url . 'index.php/services/species_alerts/register?';
     $params = array('auth_token' => $auth['write_tokens']['auth_token'], 'nonce' => $auth['write_tokens']['nonce'], 'first_name' => $_POST['first_name'], 'surname' => $_POST['surname'], 'email' => $_POST['email'], 'website_id' => $args['website_id'], 'alert_on_entry' => $_POST['species_alert:alert_on_entry'] ? 't' : 'f', 'alert_on_verify' => $_POST['species_alert:alert_on_verify'] ? 't' : 'f');
     if (!empty($_POST['species_alert:id'])) {
         $params['id'] = $_POST['species_alert:id'];
     }
     if (!empty($_POST['species_alert:taxon_list_id'])) {
         $params['taxon_list_id'] = $_POST['species_alert:taxon_list_id'];
     }
     if (!empty($_POST['species_alert:location_id'])) {
         $params['location_id'] = $_POST['species_alert:location_id'];
     }
     if (!empty($_POST['user_id'])) {
         $params['user_id'] = $_POST['user_id'];
     }
     if (!empty($_POST['taxa_taxon_list_id'])) {
         // We've got a taxa_taxon_list_id in the post data. But, it is better to subscribe via a taxon
         // meaning ID, or even better, the external key.
         $taxon = data_entry_helper::get_population_data(array('table' => 'taxa_taxon_list', 'extraParams' => $auth['read'] + array('id' => $_POST['taxa_taxon_list_id'], 'view' => 'cache')));
         if (count($taxon) !== 1) {
             throw new exception('Unable to find unique taxon when attempting to subscribe');
         }
         $taxon = $taxon[0];
         if (!empty($taxon['external_key'])) {
             $params['external_key'] = $taxon['external_key'];
         } else {
             $params['taxon_meaning_id'] = $taxon['taxon_meaning_id'];
         }
     } elseif (!empty($_POST['species_alert:external_key'])) {
         $params['external_key'] = $_POST['species_alert:external_key'];
     } elseif (!empty($_POST['species_alert:taxon_meaning_id'])) {
         $params['taxon_meaning_id'] = $_POST['species_alert:taxon_meaning_id'];
     }
     $url .= data_entry_helper::array_to_query_string($params, true);
     $result = data_entry_helper::http_post($url);
     if ($result['result']) {
         hostsite_show_message(lang::get('Your subscription has been saved.'));
     } else {
         hostsite_show_message(lang::get('There was a problem saving your subscription.'));
         if (function_exists('watchdog')) {
             watchdog('iform', 'Species alert error on save: ' . print_r($result, true));
         }
     }
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:51,代码来源:subscribe_species_alert.php

示例4: callGetUserIdService

 /**
  * Private helper function to call the get_user_id service.
  */
 private function callGetUserIdService($auth, $identifiers, $cmsUserId, $firstName, $surname, $extras = '')
 {
     $url = data_entry_helper::$base_url . 'index.php/services/user_identifier/get_user_id';
     $url .= '?nonce=' . $auth['write_tokens']['nonce'] . '&auth_token=' . $auth['write_tokens']['auth_token'];
     $identifiers = urlencode(json_encode($identifiers));
     $params = "cms_user_id={$cmsUserId}&first_name={$firstName}&surname={$surname}&identifiers={$identifiers}";
     if (!empty($extras)) {
         $params .= "&{$extras}";
     }
     return data_entry_helper::http_post($url, $params);
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:14,代码来源:user_identifierTest.php

示例5: get_form


//.........这里部分代码省略.........
                       }
                   }
               }
           }
       } else {
           if (array_key_exists('merge_sample_id1', $_GET) && array_key_exists('merge_sample_id2', $_GET) && user_access($args['edit_permission'])) {
               $mode = 2;
               // first check can access the 2 samples given
               $parentLoadID = $_GET['merge_sample_id1'];
               $url = $svcUrl . '/data/sample/' . $parentLoadID . "?mode=json&view=detail&auth_token=" . $readAuth['auth_token'] . "&nonce=" . $readAuth["nonce"];
               $session = curl_init($url);
               curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
               $entity = json_decode(curl_exec($session), true);
               if (count($entity) == 0 || $entity[0]["parent_id"]) {
                   return '<p>' . lang::get('LANG_No_Access_To_Sample') . ' ' . $parentLoadID . '</p>';
               }
               // The check for id2 is slightly different: there is the possiblity that someone will F5/refresh their browser, after the transfer and delete have taken place.
               // In this case we carry on, but do not do the transfer and delete.
               $url = $svcUrl . '/data/sample/' . $_GET['merge_sample_id2'] . "?mode=json&view=detail&auth_token=" . $readAuth['auth_token'] . "&nonce=" . $readAuth["nonce"];
               $session = curl_init($url);
               curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
               $entity = json_decode(curl_exec($session), true);
               if (count($entity) > 0 && !$entity[0]["parent_id"]) {
                   // now get child samples and point to new parent.
                   $url = $svcUrl . '/data/sample?mode=json&view=detail&auth_token=' . $readAuth['auth_token'] . "&nonce=" . $readAuth["nonce"] . '&parent_id=' . $_GET['merge_sample_id2'];
                   $session = curl_init($url);
                   curl_setopt($session, CURLOPT_RETURNTRANSFER, true);
                   $entities = json_decode(curl_exec($session), true);
                   if (count($entities) > 0) {
                       foreach ($entities as $entity) {
                           $Model = data_entry_helper::wrap(array('id' => $entity['id'], 'parent_id' => $_GET['merge_sample_id1']), 'sample');
                           $request = data_entry_helper::$base_url . "/index.php/services/data/save";
                           $postargs = 'submission=' . json_encode($Model) . '&auth_token=' . $auth['write_tokens']['auth_token'] . '&nonce=' . $auth['write_tokens']['nonce'] . '&persist_auth=true';
                           $postresponse = data_entry_helper::http_post($request, $postargs, false);
                           // the response array will always feature an output, which is the actual response or error message. if it is not json format, assume error text, and json encode that.
                           $response = $postresponse['output'];
                           if (!json_decode($response, true)) {
                               return "<p>" . lang::get('LANG_Error_When_Moving_Sample') . ": id " . $entity['id'] . " : " . $response;
                           }
                       }
                   }
                   // finally delete the no longer used sample
                   $Model = data_entry_helper::wrap(array('id' => $_GET['merge_sample_id2'], 'deleted' => 'true'), 'sample');
                   $request = data_entry_helper::$base_url . "/index.php/services/data/save";
                   $postargs = 'submission=' . json_encode($Model) . '&auth_token=' . $auth['write_tokens']['auth_token'] . '&nonce=' . $auth['write_tokens']['nonce'] . '&persist_auth=true';
                   $postresponse = data_entry_helper::http_post($request, $postargs, false);
                   // the response array will always feature an output, which is the actual response or error message. if it is not json format, assume error text, and json encode that.
                   $response = $postresponse['output'];
                   if (!json_decode($response, true)) {
                       return "<p>" . lang::get('LANG_Error_When_Deleting_Sample') . ": id " . $entity['id'] . " : " . $response;
                   }
               }
           } else {
               if (array_key_exists('sample_id', $_GET)) {
                   $mode = 2;
                   $parentLoadID = $_GET['sample_id'];
               } else {
                   if (array_key_exists('occurrence_id', $_GET)) {
                       $mode = 3;
                       $childLoadID = $_GET['occurrence_id'];
                       $thisOccID = $childLoadID;
                   } else {
                       if (array_key_exists('new', $_GET)) {
                           $mode = 1;
                       }
                   }
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:67,代码来源:mnhnl_bird_transect_walks.php

示例6: ajax_save

 public static function ajax_save($website_id, $password, $node)
 {
     iform_load_helpers(array('data_entry_helper'));
     //Build submission
     $Model = self::build_three_level_sample_with_occ_submission($_POST, $website_id, $password, $node->params['gpx_data_attr_id'], $node->params['dive_start_time_attr_id'], $node->params['exif_date_time_attr_id']);
     $node = node_load($nid);
     $conn = iform_get_connection_details($node);
     $postargs = "website_id=" . $conn['website_id'];
     $response = data_entry_helper::http_post(data_entry_helper::$base_url . '/index.php/services/security/get_nonce', $postargs, false);
     $nonce = $response['output'];
     $writeTokens = array('nonce' => $nonce, 'auth_token' => sha1($nonce . ":" . $conn['password']));
     //When the first page is saved we create a sample but we don't have a spatial reference. An attempt is made to read
     //a position from the first photo exif (elsewhere in code), however if GPS data can't be found on photo, then just fall back on a point on the Isle of Wight (as it is on land it won't get confused with a real position.
     if (empty($Model['fields']['entered_sref']['value'])) {
         drupal_set_message('Unable to find any GPS information, please correct this manually using the GPX upload or map tools');
         $Model['fields']['entered_sref_system']['value'] = '4277';
         $Model['fields']['entered_sref']['value'] = '50:41.0994N, 1:17.1864W';
     }
     //Save submission
     $response = data_entry_helper::forward_post_to('save', $Model, $writeTokens);
     echo json_encode($response);
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:22,代码来源:dynamic_progressive_seasearch_survey.php

示例7: testDateOutOfRange

 /** 
  * Test that a basic date out of range test works.
  */
 public function testDateOutOfRange()
 {
     // Need a test rule we can use to check it works
     $ruleArr = array('verification_rule:title' => 'test', 'verification_rule:test_type' => 'PeriodWithinYear', 'verification_rule:error_message' => 'test error', 'metaFields:metadata' => "Tvk=TESTKEY\nStartDate=0801\nEndDate=0831", 'metaFields:data' => "");
     $rule = ORM::Factory('verification_rule');
     $rule->set_submission_data($ruleArr, false);
     if (!$rule->submit()) {
         echo kohana::debug($rule->getAllErrors());
         throw new exception('Failed to create test rule');
     }
     try {
         $response = data_entry_helper::http_post($this->request, array('sample' => json_encode(array('sample:survey_id' => 1, 'sample:date' => '12/09/2012', 'sample:entered_sref' => 'SU1234', 'sample:entered_sref_system' => 'osgb')), 'occurrences' => json_encode(array(array('occurrence:taxa_taxon_list_id' => $this->ttl->id))), 'rule_types' => json_encode(array('PeriodWithinYear'))));
         $errors = json_decode($response['output'], true);
         $this->assertTrue(is_array($errors), 'Errors list not returned');
         $this->assertTrue(isset($errors[0]['taxa_taxon_list_id']) && $errors[0]['taxa_taxon_list_id'] === $this->ttl->id, 'Incorrect taxa_taxon_list_id returned');
         $this->assertTrue(isset($errors[0]['message']) && $errors[0]['message'] === 'test error', 'Incorrect message returned');
         foreach ($rule->verification_rule_metadata as $m) {
             $m->delete();
         }
         $rule->delete();
     } catch (Exception $e) {
         foreach ($rule->verification_rule_metadata as $m) {
             $m->delete();
         }
         $rule->delete();
     }
 }
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:30,代码来源:data_cleanerTest.php

示例8: handle_media

 /**
  * Takes uploaded files from the form submission and saves them on the server. Optionally sends it
  * to the warehouse via the data services handle_media method, in which case the local copy is
  * deleted.
  *
  * @param String $media_id Base name of the file entry in the $_FILES array e.g. occurrence:image.
  * Multiple files can be uploaded if they have a suffix 0f :0, :1 ... :n
  * @param Boolean $submit If true (default), then the file is uploaded first into the local
  * server's directory structure, then sent to the Indicia Warehouse using the data services.
  * If false, then it is uploaded to the local server only.
  * @return Array Returns with key success, set to true if files were uploaded, false if nothing was uploaded or there
  * was an error. If an error, then there can be a single error key or an array caller errors with details of errors encountered 
  * when uploading. On success, the return array also has a key 'files' populated with final filenames of the uploaded files 
  * so that they can be inserted in a field which stores the file path.
  */
 public static function handle_media($media_id, $submit = true)
 {
     $files = self::get_uploaded_files($media_id);
     $return = array();
     $uploadpath = parent::$upload_path;
     $target_url = parent::$base_url . "/index.php/services/data/handle_media";
     $i = 0;
     foreach ($files as $file) {
         $name = $file['name'];
         $fname = $file['tmp_name'];
         $parts = explode(".", $name);
         $fext = array_pop($parts);
         // Generate a file id to store the image as
         $destination = time() . rand(0, 1000) . "." . $fext;
         if (move_uploaded_file($fname, $uploadpath . $destination)) {
             //successfully stored locally
             if ($submit) {
                 //send to the warehouse
                 $postargs = array();
                 if (array_key_exists('auth_token', $_POST)) {
                     $postargs['auth_token'] = $_POST['auth_token'];
                 }
                 if (array_key_exists('nonce', $_POST)) {
                     $postargs['nonce'] = $_POST['nonce'];
                 }
                 $file_to_upload = array('media_upload' => '@' . realpath($uploadpath . $destination));
                 $response = data_entry_helper::http_post($target_url, $file_to_upload + $postargs);
                 $output = json_decode($response['output'], true);
                 if (is_array($output)) {
                     //an array signals an error
                     if (array_key_exists('error', $output)) {
                         $return['error'] = $output['error'];
                         //attach the errors to the control that caused them
                         //PROBLEM assumes numeric suffix
                         if (array_key_exists('errors', $output)) {
                             $return['errors']["{$media_id}:{$i}"] = $output['errors']['media_upload'];
                         }
                     }
                 } else {
                     //filenames are returned without structure
                     //the output of json_decode may not be valid.
                     $return['files'][] = $response['output'];
                 }
                 //remove local copy
                 unlink($uploadpath . $destination);
             } else {
                 // store locally so create the thumbnails or other image sizes.
                 Image::create_image_files($uploadpath, $destination);
                 $return['files'][] = $destination;
             }
         } else {
             $return['error'] = 'Upload error';
             //attach the errors to the control that caused them
             //PROBLEM assumes numeric suffix
             $return['errors']["{$media_id}:{$i}"] = 'Sorry, there was a problem uploading this file.';
         }
         $i++;
     }
     //finished looping through files. If no errors in the response array, all went well.
     $return['success'] = !(array_key_exists('error', $return) || array_key_exists('errors', $return)) && count($files) > 0;
     return $return;
 }
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:77,代码来源:submission_builder.php

示例9: upload_mappings_form

 /**
  * Outputs the form for mapping columns to the import fields.
  * @param array $options Options array passed to the import control.
  */
 private static function upload_mappings_form($options)
 {
     //The Shorewatch importer only supports 4326 as this is required for the occurrence sample grid reference
     //calculations to work. This can be hardcoded.
     $_POST['sample:entered_sref_system'] = 4326;
     $_SESSION['importSettingsToCarryForward'] = $_POST;
     if (!file_exists($_SESSION['uploaded_file'])) {
         return lang::get('upload_not_available');
     }
     data_entry_helper::add_resource('jquery_ui');
     $filename = basename($_SESSION['uploaded_file']);
     // If the last step was skipped because the user did not have any settings to supply, presetSettings contains the presets.
     // Otherwise we'll use the settings form content which already in $_POST so will overwrite presetSettings.
     if (isset($options['presetSettings'])) {
         $settings = array_merge($options['presetSettings'], $_POST);
     } else {
         $settings = $_POST;
     }
     // only want defaults that actually have a value - others can be set on a per-row basis by mapping to a column
     foreach ($settings as $key => $value) {
         if (empty($value)) {
             unset($settings[$key]);
         }
     }
     //The Shorewatch importer only supports 4326 as this is required for the occurrence sample grid reference
     //calculations to work. This can be hardcoded.
     $settings['sample:entered_sref_system'] = 4326;
     // cache the mappings
     $metadata = array('settings' => json_encode($settings));
     $post = array_merge($options['auth']['write_tokens'], $metadata);
     $request = data_entry_helper::$base_url . "index.php/services/import/cache_upload_metadata?uploaded_csv={$filename}";
     $response = data_entry_helper::http_post($request, $post);
     if (!isset($response['output']) || $response['output'] != 'OK') {
         return "Could not upload the settings metadata. <br/>" . print_r($response, true);
     }
     $request = data_entry_helper::$base_url . "index.php/services/import/get_import_fields/" . $options['model'];
     $request .= '?' . data_entry_helper::array_to_query_string($options['auth']['read']);
     // include survey and website information in the request if available, as this limits the availability of custom attributes
     if (!empty($settings['website_id'])) {
         $request .= '&website_id=' . trim($settings['website_id']);
     }
     if (!empty($settings['survey_id'])) {
         $request .= '&survey_id=' . trim($settings['survey_id']);
     }
     $response = data_entry_helper::http_post($request, array());
     $fields = json_decode($response['output'], true);
     if (!is_array($fields)) {
         return "curl request to {$request} failed. Response " . print_r($response, true);
     }
     $request = str_replace('get_import_fields', 'get_required_fields', $request);
     $response = data_entry_helper::http_post($request);
     $responseIds = json_decode($response['output'], true);
     if (!is_array($responseIds)) {
         return "curl request to {$request} failed. Response " . print_r($response, true);
     }
     $model_required_fields = self::expand_ids_to_fks($responseIds);
     if (!empty($settings)) {
         $preset_fields = self::expand_ids_to_fks(array_keys($settings));
     } else {
         $preset_fields = array();
     }
     if (!empty($preset_fields)) {
         $unlinked_fields = array_diff_key($fields, array_combine($preset_fields, $preset_fields));
     } else {
         $unlinked_fields = $fields;
     }
     // only use the required fields that are available for selection - the rest are handled somehow else
     $unlinked_required_fields = array_intersect($model_required_fields, array_keys($unlinked_fields));
     ini_set('auto_detect_line_endings', 1);
     $handle = fopen($_SESSION['uploaded_file'], "r");
     $columns = fgetcsv($handle, 1000, ",");
     $reload = data_entry_helper::get_reload_link_parts();
     $reloadpath = $reload['path'] . '?' . data_entry_helper::array_to_query_string($reload['params']);
     self::clear_website_survey_fields($unlinked_fields, $settings);
     self::clear_website_survey_fields($unlinked_required_fields, $settings);
     $savedFieldMappings = array();
     // Note the Shorewatch importer doesn't currently support remembered fields, so set this to false (we are reusing a lot of the import_helper code, so leave the variable in the code as it already has proven reliability).
     self::$rememberingMappings = false;
     //  if the user checked the Remember All checkbox, save it in a variable
     if (isset($savedFieldMappings['RememberAll'])) {
         $checked['RememberAll'] = 'checked';
     }
     $r = "<form method=\"post\" id=\"entry_form\" action=\"{$reloadpath}\" class=\"iform\">\n" . '<p>' . lang::get('column_mapping_instructions') . '</p>' . '<div class="ui-helper-clearfix import-mappings-table"><table class="ui-widget ui-widget-content">' . '<thead class="ui-widget-header">' . "<tr><th>Column in CSV File</th><th>Maps to attribute</th>";
     if (self::$rememberingMappings) {
         $r .= "<th id='remember-all-header' name='remember-all-header'>" . lang::get('Remember choice?') . "<br/><input type='checkbox' name='RememberAll' id='RememberAll' value='1' title='Tick all boxes to remember every column mapping next time you import.' {$checked['RememberAll']} onclick='\n           if (this.checked) {\n             \$(\".rememberField\").attr(\"checked\",\"checked\")\n           } else {\n             \$(\".rememberField\").removeAttr(\"checked\")\n           }'/></th>";
     }
     $r .= '</tr></thead><tbody>';
     foreach ($columns as $column) {
         $colFieldName = preg_replace('/[^A-Za-z0-9]/', '_', $column);
         $r .= "<tr><td>{$column}</td><td><select name=\"{$colFieldName}\" id=\"{$colFieldName}\">";
         $r .= self::get_column_options($options['model'], $unlinked_fields, $column, ' ', $savedFieldMappings);
         $r .= "</select></td></tr>\n";
     }
     $r .= '</tbody>';
     $r .= '</table>';
     $r .= '<div id="required-instructions" class="import-mappings-instructions"><h2>' . lang::get('Tasks') . '</h2><span>' . lang::get('The following database attributes must be matched to a column in your import file before you can continue') . ':</span><ul></ul><br/></div>';
//.........这里部分代码省略.........
开发者ID:BirenRathod,项目名称:indicia-code,代码行数:101,代码来源:dynamic_shorewatch_importer.php

示例10: create_personal_site

 /**
  * Creates a site using the form submission data and attaches the location_id to the
  * sample information in the submission.
  * @param array Form submission data. 
  */
 private static function create_personal_site(&$array)
 {
     // Check we don't already have a location ID, and have the other stuff we require
     if (!empty($array['sample:location_id']) || !array_key_exists('imp-location:name', $array) || !array_key_exists('sample:entered_sref', $array) || !array_key_exists('sample:entered_sref_system', $array)) {
         return;
     }
     $loc = array('location:name' => $array['imp-location:name'], 'location:centroid_sref' => $array['sample:entered_sref'], 'location:centroid_sref_system' => $array['sample:entered_sref_system'], 'locations_website:website_id' => $array['website_id']);
     if (!empty($array['sample:geom'])) {
         $loc['location:centroid_geom'] = $array['sample:geom'];
     }
     $submission = self::build_submission($loc, array('model' => 'location', 'subModels' => array('locations_website' => array('fk' => 'location_id'))));
     $request = parent::$base_url . "index.php/services/data/save";
     $postargs = 'submission=' . urlencode(json_encode($submission));
     // Setting persist_auth allows the write tokens to be re-used
     $postargs .= '&persist_auth=true&auth_token=' . $array['auth_token'];
     $postargs .= '&nonce=' . $array['nonce'];
     if (function_exists('hostsite_get_user_field')) {
         $postargs .= '&user_id=' . hostsite_get_user_field('indicia_user_id');
     }
     $response = data_entry_helper::http_post($request, $postargs);
     // The response should be in JSON if it worked
     if (isset($response['output'])) {
         $output = json_decode($response['output'], true);
         if (!$output) {
             throw new exception(print_r($response, true));
         } elseif (isset($output['success']) && $output['success'] === 'multiple records') {
             $array['sample:location_id'] = $output['outer_id'];
         } elseif (isset($output['success'])) {
             $array['sample:location_id'] = $output['success'];
         } else {
             throw new exception(print_r($response, true));
         }
     }
 }
开发者ID:BirenRathod,项目名称:drupal-6,代码行数:39,代码来源:submission_builder.php


注:本文中的data_entry_helper::http_post方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。