本文整理汇总了PHP中data_entry_helper::forward_post_to方法的典型用法代码示例。如果您正苦于以下问题:PHP data_entry_helper::forward_post_to方法的具体用法?PHP data_entry_helper::forward_post_to怎么用?PHP data_entry_helper::forward_post_to使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类data_entry_helper
的用法示例。
在下文中一共展示了data_entry_helper::forward_post_to方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_form
/**
* Return the generated form output.
* @param array $args List of parameter values passed through to the form depending on how the form has been configured.
* This array always contains a value for language.
* @param object $node The Drupal node object.
* @param array $response When this form is reloading after saving a submission, contains the response from the service call.
* Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data).
* @return Form HTML.
*/
public static function get_form($args, $node, $response = null)
{
if (!($user_id = hostsite_get_user_field('indicia_user_id'))) {
return self::abort('Please ensure that you\'ve filled in your surname on your user profile before leaving a group.', $args);
}
if (empty($_GET['group_id'])) {
return self::abort('This form must be called with a group_id in the URL parameters.', $args);
}
$r = '';
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
$group = data_entry_helper::get_population_data(array('table' => 'group', 'extraParams' => $auth['read'] + array('id' => $_GET['group_id']), 'nocache' => true));
if (count($group) !== 1) {
return self::abort('The group you\'ve requested membership of does not exist.', $args);
}
iform_load_helpers(array('submission_builder'));
$group = $group[0];
// Check for an existing group user record
$existing = data_entry_helper::get_population_data(array('table' => 'groups_user', 'extraParams' => $auth['read'] + array('group_id' => $_GET['group_id'], 'user_id' => $user_id), 'nocache' => true));
if (count($existing) !== 1) {
return self::abort('You are not a member of this group.', $args);
}
if (!empty($_POST['response']) && $_POST['response'] === lang::get('Cancel')) {
drupal_goto($args['groups_page_path']);
} elseif (!empty($_POST['response']) && $_POST['response'] === lang::get('Confirm')) {
$data = array('groups_user:id' => $existing[0]['id'], 'groups_user:group_id' => $group['id'], 'groups_user:user_id' => $user_id, 'deleted' => 't');
$wrap = submission_builder::wrap($data, 'groups_user');
$response = data_entry_helper::forward_post_to('groups_user', $wrap, $auth['write_tokens']);
if (isset($response['success'])) {
hostsite_show_message("You are no longer participating in {$group['title']}!");
drupal_goto($args['groups_page_path']);
} else {
return self::abort('An error occurred whilst trying to update your group membership.');
}
} else {
// First access of the form. Let's get confirmation
$reload = data_entry_helper::get_reload_link_parts();
$reloadpath = $reload['path'] . '?' . data_entry_helper::array_to_query_string($reload['params']);
$r = '<form action="' . $reloadpath . '" method="POST"><fieldset>';
$r .= '<legend>' . lang::get('Confirmation') . '</legend>';
$r .= '<input type="hidden" name="leave" value="1" />';
$r .= '<p>' . lang::get('Are you sure you want to stop participating in {1}?', $group['title']) . '</p>';
$r .= '<input type="submit" value="' . lang::get('Confirm') . '" name="response" />';
$r .= '<input type="submit" value="' . lang::get('Cancel') . '" name="response" />';
$r .= '</fieldset></form>';
}
return $r;
}
示例2: clear_moderation_task_notifications
/**
* Clears moderation notifications for a moderator automatically on visiting the page, so then they
* will get notified about new incoming records.
*/
public static function clear_moderation_task_notifications($auth, $args, $tabalias, $options, $path)
{
//Using 'submission_list' and 'entries' allows us to specify several top-level submissions to the system
//i.e. we need to be able to submit several notifications.
$submission['submission_list']['entries'] = array();
$submission['id'] = 'notification';
$notifications = data_entry_helper::get_population_data(array('table' => 'notification', 'extraParams' => $auth['read'] + array('acknowledged' => 'f', 'user_id' => hostsite_get_user_field('indicia_user_id'), 'source_type' => 'PT'), 'nocache' => true));
if (count($notifications) > 0) {
$auth = data_entry_helper::get_read_write_auth(variable_get('indicia_website_id', 0), variable_get('indicia_password', ''));
//Setup the structure we need to submit.
foreach ($notifications as $notification) {
$data['id'] = 'notification';
$data['fields']['id']['value'] = $notification['id'];
$data['fields']['acknowledged']['value'] = 't';
$submission['submission_list']['entries'][] = $data;
}
//Submit the stucture for processing
$response = data_entry_helper::forward_post_to('save', $submission, $auth['write_tokens']);
if (!is_array($response) || !array_key_exists('success', $response)) {
drupal_set_message(print_r($response, true));
}
}
return '';
}
示例3: reject
/**
* Given a reject response, delete the invite, and redirect to the groups home page.
* @param array $args Form config arguments
* @param array $invite Invitation record
*/
private static function reject($args, $invite, $auth)
{
$values = array('id' => $invite['id'], 'deleted' => 't');
$s = submission_builder::build_submission($values, array('model' => 'group_invitation'));
$r = data_entry_helper::forward_post_to('group_invitation', $s, $auth['write_tokens']);
hostsite_show_message(lang::get("OK, thanks anyway. We've removed your invitation to join this group."));
hostsite_goto_page($args['groups_page_path']);
}
示例4: array
$readAuth = data_entry_helper::get_read_auth($config['website_id'], $config['password']);
// Store data from the previous page into the session
data_entry_helper::add_post_to_session();
// To post our data, we need to get the whole lot from the session
$data = data_entry_helper::extract_session_array();
// Collect up the sample, sample attributes and grid data
$sampleMod = data_entry_helper::wrap($data, 'sample');
$smpAttrs = data_entry_helper::wrap_attributes($data, 'sample');
$occurrences = data_entry_helper::wrap_species_checklist($data);
// Add the occurrences in as submodels
$sampleMod['subModels'] = $occurrences;
// and link in the attributes of the sample
$sampleMod['metaFields']['smpAttributes']['value'] = $smpAttrs;
// Wrap submission and submit
$submission = array('submission' => array('entries' => array(array('model' => $sampleMod))));
$response = data_entry_helper::forward_post_to('save', $submission);
if (array_key_exists('success', $response)) {
// on success, redirect to the thank you page
header('Location:success.php');
die;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Saving data</title>
<link rel="stylesheet" href="advanced.css" type="text/css" media="screen" />
<link rel="stylesheet" href="../../../media/css/default_site.css" type="text/css" media="screen">
</head>
<body>
<div id="wrap">
示例5: get_form
/**
* Return the generated form output.
* @param array $args List of parameter values passed through to the form depending on how the form has been configured.
* This array always contains a value for language.
* @param object $node The Drupal node object.
* @param array $response When this form is reloading after saving a submission, contains the response from the service call.
* Note this does not apply when redirecting (in this case the details of the saved object are in the $_GET data).
* @return Form HTML.
*/
public static function get_form($args, $node, $response = null)
{
if (!($user_id = hostsite_get_user_field('indicia_user_id'))) {
return self::abort('Please ensure that you\'ve filled in your surname on your user profile before joining a group.', $args);
}
if (empty($_GET['group_id'])) {
return self::abort('This form must be called with a group_id in the URL parameters.', $args);
}
$r = '';
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
$group = data_entry_helper::get_population_data(array('table' => 'group', 'extraParams' => $auth['read'] + array('id' => $_GET['group_id']), 'nocache' => true));
if (count($group) !== 1) {
return self::abort('The group you\'ve requested membership of does not exist.', $args);
}
iform_load_helpers(array('submission_builder'));
$group = $group[0];
// Check for an existing group user record
$existing = data_entry_helper::get_population_data(array('table' => 'groups_user', 'extraParams' => $auth['read'] + array('group_id' => $_GET['group_id'], 'user_id' => $user_id), 'nocache' => true));
if (count($existing)) {
if ($existing[0]['pending'] === 'true') {
// if a previous request was made and unapproved when the group was request only, but the group is now public, we can approve their existing
// groups_user record.
if ($group['joining_method'] === 'P') {
$data = array('groups_user:id' => $existing[0]['id'], 'groups_user:pending' => 'f');
$wrap = submission_builder::wrap($data, 'groups_user');
$r = data_entry_helper::forward_post_to('groups_user', $wrap, $auth['write_tokens']);
return self::success($auth, $group, $args);
} else {
return self::abort("You've already got a membership request for {$group['title']} pending approval.", $args);
}
} else {
return self::abort("You're already a member of {$group['title']}.", $args);
}
} else {
$data = array('groups_user:group_id' => $group['id'], 'groups_user:user_id' => $user_id);
// request only, so make the groups_user record pending approval
if ($group['joining_method'] === 'R') {
$data['groups_user:pending'] = 't';
}
$wrap = submission_builder::wrap($data, 'groups_user');
$r = data_entry_helper::forward_post_to('groups_user', $wrap, $auth['write_tokens']);
if (!isset($r['success'])) {
return self::abort('An error occurred whilst trying to update your group membership.', $args);
} elseif ($group['joining_method'] === 'R') {
return self::abort("Your request to join {$group['title']} is now awaiting approval.", $args);
} else {
return self::success($auth, $group, $args);
}
}
return $r;
}
示例6: get_form
/**
* Return the Indicia form code.
* Expects there to be a sample attribute with caption 'Email' containing the email
* address.
* @param array $args Input parameters.
* @param array $node Drupal node object
* @param array $response Response from Indicia services after posting a verification.
* @return HTML string
*/
public static function get_form($args, $node, $response)
{
global $user, $indicia_templates;
// put each param control in a div, which makes it easier to layout with CSS
$indicia_templates['prefix'] = '<div id="container-{fieldname}" class="param-container">';
$indicia_templates['suffix'] = '</div>';
$indicia_user_id = self::get_indicia_user_id($args);
$auth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
$r = '';
if ($_POST) {
// dump out any errors that occurred on verification
if (data_entry_helper::$validation_errors) {
$r .= '<div class="page-notice ui-state-highlight ui-corner-all"><p>' . implode('</p></p>', array_values(data_entry_helper::$validation_errors)) . '</p></div>';
} else {
if (isset($_POST['email']) && !isset($response['error'])) {
// To send HTML mail, the Content-type header must be set
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $user->mail . PHP_EOL . "\r\n";
$headers .= 'Return-Path: ' . $user->mail . "\r\n";
if (isset($_POST['photoHTML'])) {
$emailBody = str_replace('[photo]', '<br/>' . $_POST['photoHTML'], $_POST['email_content']);
} else {
$emailBody = $_POST['email_content'];
}
$emailBody = str_replace("\n", "<br/>", $emailBody);
// Send email. Depends upon settings in php.ini being correct
$success = mail($_POST['email_to'], $_POST['email_subject'], wordwrap($emailBody, 70), $headers);
if ($success) {
$r .= '<div class="page-notice ui-state-highlight ui-corner-all"><p>An email was sent to ' . $_POST['email_to'] . '.</p></div>';
} else {
$r .= '<div class="page-notice ui-widget-content ui-corner-all ui-state-highlight left">The webserver is not correctly configured to send emails. Please send the following email manually: <br/>' . '<div id="manual-email"><span>To:</span><div>' . $_POST['email_to'] . '</div>' . '<span>Subject:</span><div>' . $_POST['email_subject'] . '</div>' . '<span>Content:</span><div>' . $emailBody . '</div>' . '</div></div><div style="clear: both">';
}
} else {
if (isset($_POST['occurrence:record_status']) && isset($response['success']) && $args['emails_enabled']) {
$r .= self::get_notification_email_form($args, $response, $auth);
}
}
}
if (isset($_POST['action']) && $_POST['action'] == 'send_to_verifier' && $args['log_send_to_verifier']) {
$comment = str_replace(array('%email%', '%date%', '%user%'), array($_POST['email_to'], date('jS F Y'), $user->name), $args['log_send_to_verifier_comment']);
} elseif (isset($_POST['action']) && ($_POST['action'] = 'general_comment')) {
$comment = $_POST['comment'];
}
// If there is a comment to save, add it to the occurrence comments
if (isset($comment)) {
// get our own write tokens for this submission, as the main ones are used in the JavaScript form.
$loggingAuth = data_entry_helper::get_read_write_auth($args['website_id'], $args['password']);
$sub = data_entry_helper::wrap(array('comment' => $comment, 'occurrence_id' => $_POST['occurrence:id'], 'created_by_id' => $indicia_user_id), 'occurrence_comment');
$logResponse = data_entry_helper::forward_post_to('occurrence_comment', $sub, $loggingAuth['write_tokens']);
if (!array_key_exists('success', $logResponse)) {
$r .= data_entry_helper::dump_errors($response, false);
}
}
}
//extract fixed parameters for report grid.
$params = explode(",", $args['fixed_params']);
foreach ($params as $param) {
$keyvals = explode("=", $param);
$key = trim($keyvals[0]);
$val = trim($keyvals[1]);
$extraParams[$key] = $val;
}
// plus defaults which are not fixed
$params = explode("\n", $args['param_defaults']);
foreach ($params as $param) {
$keyvals = explode("=", $param);
$key = trim($keyvals[0]);
$val = trim($keyvals[1]);
$paramDefaults[$key] = $val;
}
$actions = array();
if ($args['send_for_verification']) {
// store authorisation details as a global in js, since some of the JavaScript needs to be able to access Indicia data
data_entry_helper::$javascript .= 'auth=' . json_encode($auth) . ';';
$actions[] = array('caption' => str_replace(' ', ' ', lang::get('Send to verifier')), 'class' => 'send_for_verification_btn', 'javascript' => 'indicia_send_to_verifier(\'{taxon}\', {occurrence_id}, ' . $user->uid . ', ' . $args['website_id'] . '); return false;');
$r .= self::get_send_for_verification_form();
}
$actions[] = array('caption' => str_replace(' ', ' ', lang::get('Verify')), 'javascript' => 'indicia_verify(\'{taxon}\', {occurrence_id}, true, ' . $user->uid . '); return false;');
$actions[] = array('caption' => str_replace(' ', ' ', lang::get('Reject')), 'javascript' => 'indicia_verify(\'{taxon}\', {occurrence_id}, false, ' . $user->uid . '); return false;');
$actions[] = array('caption' => str_replace(' ', ' ', lang::get('Comments')), 'javascript' => 'indicia_comments(\'{taxon}\', {occurrence_id}, ' . $user->uid . ', \'' . $auth['read']['nonce'] . '\', \'' . $auth['read']['auth_token'] . '\'); return false;');
if (isset($args['path_to_record_details_page']) && $args['path_to_record_details_page']) {
$actions[] = array('caption' => str_replace(' ', ' ', lang::get('View details')), 'url' => '{rootFolder}' . $args['path_to_record_details_page'], 'urlParams' => array('occurrence_id' => '{occurrence_id}'));
}
// default columns behaviour is to just include anything returned by the report plus add an actions column
$columns = array(array('display' => 'Actions', 'actions' => $actions));
// this can be overridden
if (isset($args['columns_config']) && !empty($args['columns_config'])) {
$columns = array_merge(json_decode($args['columns_config'], true), $columns);
}
$r .= data_entry_helper::report_grid(array('id' => 'verification-grid', 'dataSource' => $args['report_name'], 'mode' => 'report', 'readAuth' => $auth['read'], 'columns' => $columns, 'rowId' => 'occurrence_id', 'itemsPerPage' => 10, 'autoParamsForm' => $args['auto_params_form'], 'extraParams' => $extraParams, 'paramDefaults' => $paramDefaults));
//.........这里部分代码省略.........
示例7: build_notifications_removal_submission
/**
* Build a submission that the system can understand that includes the notifications we
* want to remove.
* @param type $auth
* @param integer $user_id
* @param array $options
*
*/
private static function build_notifications_removal_submission($user_id, $options)
{
// rebuild the auth token since this is a reporting page but we need to submit data.
$auth = data_entry_helper::get_read_write_auth(variable_get('indicia_website_id', ''), variable_get('indicia_password', ''));
//Using 'submission_list' and 'entries' allows us to specify several top-level submissions to the system
//i.e. we need to be able to submit several notifications.
$submission['submission_list']['entries'] = array();
$submission['id'] = 'notification';
$extraParams = array('user_id' => $user_id, 'system_name' => 'indicia', 'default_edit_page_path' => '', 'view_record_page_path' => '', 'website_id' => variable_get('indicia_website_id', ''));
//If the page is using a filter drop-down option, then collect the type of notification
//to remove from the filter drop-down
$extraParams['source_filter'] = empty($_POST['source-filter']) ? 'all' : $_POST['source-filter'];
//Get the source types to remove from a hidden field if the user has configured the page
//to use a user specified option to specify exactly what kind of notifications to display
if (!empty($options['sourceType'])) {
$sourceTypesToClearFromConfig = explode(',', $options['sourceType']);
}
//Place quotes around the source type letters for the report to accept as strings
if (!empty($sourceTypesToClearFromConfig)) {
if (array_key_exists(0, $sourceTypesToClearFromConfig) && !empty($sourceTypesToClearFromConfig[0])) {
foreach ($sourceTypesToClearFromConfig as &$type) {
$type = "'" . $type . "'";
}
$extraParams['source_types'] = implode(',', $sourceTypesToClearFromConfig);
}
}
//If the user has supplied some config options for the different source types
if (!empty($options['sourceTypes'])) {
// this disables the param for picking a single source type
$extraParams['source_filter'] = 'all';
}
//Only include notifications associated with a set of recording group ids if option is supplied.
if (!empty($options['groupIds'])) {
$extraParams['group_ids'] = $options['groupIds'];
}
// respect training mode
if (hostsite_get_user_field('training')) {
$extraParams['training'] = 'true';
}
$notifications = data_entry_helper::get_report_data(array('dataSource' => 'library/notifications/notifications_list_for_notifications_centre', 'readAuth' => $auth['read'], 'extraParams' => $extraParams));
$count = 0;
if (count($notifications) > 0) {
//Setup the structure we need to submit.
foreach ($notifications as $notification) {
$data['id'] = 'notification';
$data['fields']['id']['value'] = $notification['notification_id'];
$data['fields']['acknowledged']['value'] = 't';
$submission['submission_list']['entries'][] = $data;
$count++;
}
//Submit the stucture for processing
$response = data_entry_helper::forward_post_to('save', $submission, $auth['write_tokens']);
if (is_array($response) && array_key_exists('success', $response)) {
if ($count === 1) {
drupal_set_message(lang::get("1 notification has been removed."));
} else {
drupal_set_message(lang::get("{1} notifications have been removed.", $count));
}
} else {
drupal_set_message(print_r($response, true));
}
}
}
示例8: sendInvites
/**
* Performs the sending of invitation emails.
* @param array $args Form configuration arguments
* @param array $auth Authorisation tokens
* @todo Integrate with notifications for logged in users.
*/
private static function sendInvites($args, $auth)
{
$emails = helper_base::explode_lines($_POST['invitee_emails']);
// first task is to populate the groups_invitations table
$base = uniqid();
$success = true;
$failedRecipients = array();
foreach ($emails as $idx => $email) {
$values = array('group_invitation:group_id' => $_GET['group_id'], 'group_invitation:email' => $email, 'group_invitation:token' => $base . $idx, 'website_id' => $args['website_id']);
$s = submission_builder::build_submission($values, array('model' => 'group_invitation'));
$r = data_entry_helper::forward_post_to('group_invitation', $s, $auth['write_tokens']);
$pathParam = function_exists('variable_get') && variable_get('clean_url', 0) == '0' ? 'q' : '';
$rootFolder = data_entry_helper::getRootFolder() . (empty($pathParam) ? '' : "?{$pathParam}=");
$protocol = !empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off' || $_SERVER['SERVER_PORT'] == 443 ? "https://" : "http://";
$acceptUrl = $protocol . $_SERVER['HTTP_HOST'] . $rootFolder . $args['accept_invite_path'] . (empty($pathParam) ? '?' : '&') . 'token=' . $base . $idx;
$body = $_POST['invite_message'] . "<br/><br/>" . '<a href="' . $acceptUrl . '">' . lang::get('Accept this invitation') . '</a>';
$message = array('id' => 'iform_group_invite', 'to' => implode(',', $emails), 'subject' => 'Invitation to join a recording group', 'body' => $body, 'headers' => array('MIME-Version' => '1.0', 'Content-type' => 'text/html; charset=iso-8859-1'));
$mimeheaders = array();
foreach ($message['headers'] as $name => $value) {
$mimeheaders[] = $name . ': ' . mime_header_encode($value);
}
$thismailsuccess = mail($message['to'], mime_header_encode($message['subject']), str_replace("\r", '', $message['body']), join("\n", $mimeheaders));
if (!$thismailsuccess) {
$failedRecipients[$message['to']] = $acceptUrl;
}
$success = $success && $thismailsuccess;
}
if ($success) {
drupal_set_message(lang::get('Invitation emails sent'));
} else {
drupal_set_message(lang::get('The emails could not be sent due to a server configuration issue. Please contact the site admin. ' . 'The list below gives the emails and the links you need to send to each invitee which they need to click on in order to join the group.'), 'warning');
$list = array();
foreach ($failedRecipients as $email => $link) {
$list[] = lang::get("Send link {1} to {2}.", $link, $email);
}
drupal_set_message(implode('<br/>', $list), 'warning');
}
drupal_goto($args['redirect_on_success']);
}
示例9: build_notifications_removal_submission
/**
* Build a submission that the system can understand that includes the notifications we
* want to remove.
* @param type $_POST
* @param type $auth
*/
private static function build_notifications_removal_submission($_POST, $auth)
{
//Using 'submission_list' and 'entries' allows us to specify several top-level submissions to the system
//i.e. we need to be able to submit several notifications.
$submission['submission_list']['entries'] = array();
$submission['id'] = 'notification';
//Get the types (auto-check, comment or verification) of notification from the hidden field.
$sourceTypesToClear = explode(',', $_POST['source_types']);
$notifications = data_entry_helper::get_population_data(array('table' => 'notification', 'extraParams' => $auth['read'] + array('acknowledged' => 'f', 'user_id' => hostsite_get_user_field('indicia_user_id'), 'query' => json_encode(array('in' => array('source_type' => $sourceTypesToClear)))), 'nocache' => true));
$count = 0;
if (count($notifications) > 0) {
//Setup the structure we need to submit.
foreach ($notifications as $notification) {
$data['id'] = 'notification';
$data['fields']['id']['value'] = $notification['id'];
$data['fields']['acknowledged']['value'] = 't';
$submission['submission_list']['entries'][] = $data;
$count++;
}
//Submit the stucture for processing
$response = data_entry_helper::forward_post_to('save', $submission, $auth['write_tokens']);
if (is_array($response) && array_key_exists('success', $response)) {
if ($count === 1) {
drupal_set_message(lang::get("1 notification has been removed."));
} else {
drupal_set_message(lang::get("{1} notifications have been removed.", $count));
}
} else {
drupal_set_message(print_r($response, true));
}
}
}
示例10: 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);
}
示例11: submit_data_if_new_parent_sample_required
protected function submit_data_if_new_parent_sample_required(&$values, $data, $args, $writeAuth, $occurrenceNumber, &$submission)
{
//There are 2 arrays we are dealing with. $_POST contains the name of the column as a key and then the format
//of the key required for submission as its value. The $data array is a numbered list of columns with a data
//value. So in order to submit to the database, we need to use the $_POST data value as the key and the value from the $data
//array as the value. The two arrays match up with each other e.g. the second item in the $_POST array relates to the
//second item in the data array. So by counting as we look at each item in the $_POST array, we can then get the equivalent
//item in the $data array as required.
$postCounter = 0;
//Assume to start with that we are going to use the parent sample from the previous row.
$newSampleRequired = false;
foreach ($_POST as $fieldName => $fieldInPostFormat) {
//Check if any of the sample attributes have changed and also data held in the sample row in the database (as opposed to data held in the sample_attributes table)
if ($fieldInPostFormat == 'sample:entered_sref' || $fieldInPostFormat == 'sample:date' || $fieldInPostFormat == 'sample:comment' || $fieldInPostFormat == 'sample:location_name' || substr($fieldInPostFormat, 0, 8) === "smpAttr:") {
if (!empty($values[$fieldInPostFormat]) && $values[$fieldInPostFormat] != $data[$postCounter]) {
$newSampleRequired = true;
}
}
//For the Site we submit an id rather than the raw name.
if ($fieldName == 'Site') {
//If there is no main location, this is still a valid scenerio as there can be an "Other Site"
if (empty($data[$postCounter])) {
$values['sample:location_id'] = '';
} else {
$readAuth = data_entry_helper::get_read_auth($args['website_id'], $args['password']);
$locationRecord = data_entry_helper::get_population_data(array('table' => 'location', 'extraParams' => $readAuth + array('name' => $data[$postCounter])));
//If we can't find an id for the location name in the database, then warn the user.
if (!empty($locationRecord[0]['id'])) {
//Still need to do the same check for location_id to see if it has changed from the previous row.
if (!empty($values['sample:location_id']) && $values['sample:location_id'] != $locationRecord[0]['id']) {
$newSampleRequired = true;
}
$values['sample:location_id'] = $locationRecord[0]['id'];
} else {
drupal_set_message('<B>Warning: The location ' . $data[$postCounter] . ' is not currently present in the database. .</B>');
if ($args['keep_going_after_error']) {
drupal_set_message('<i>I will attempt to continue with the import but errors may occur or there might be inconsistent data entered into the database.</i>');
} else {
drupal_set_message('<i>The import has been stopped.</i>');
}
return array($occurrenceNumber, true);
}
}
}
//Move onto the next column.
$postCounter++;
}
if ($newSampleRequired === true) {
$submission = self::get_submission($values, $args, true);
$authentication = import_helper::get_read_write_auth($args['website_id'], $args['password']);
$response = data_entry_helper::forward_post_to('save', $submission, $authentication['write_tokens']);
//Once we know we need a new sample, we start building the values array again.
$occurrenceNumber = 0;
$values = array();
self::get_initial_values_array_values($values, $args);
}
return array($occurrenceNumber, false);
}
示例12: testCreateUser
public function testCreateUser()
{
$array = array('person:first_name' => 'Test', 'person:surname' => 'Person', 'person:email_address' => 'test123abc@example.com');
$s = submission_builder::build_submission($array, array('model' => 'person'));
$r = data_entry_helper::forward_post_to('person', $s, $this->auth['write_tokens']);
$this->assertTrue(isset($r['success']), 'Submitting a new person did not work');
$personId = $r['success'];
$array = array('user:person_id' => $personId, 'user:email_visible' => 'f', 'user:core_role_id' => 1, 'user:username' => 'testUser');
$s = submission_builder::build_submission($array, array('model' => 'user'));
$r = data_entry_helper::forward_post_to('user', $s, $this->auth['write_tokens']);
$this->assertTrue(isset($r['success']), 'Submitting a new user did not work');
$userId = $r['success'];
ORM::Factory('user', $userId)->delete();
ORM::Factory('person', $personId)->delete();
}
示例13:
padding: 1%;
font-size: 9pt;
}
.comment-comment {
float: right;
width: 60%;
padding: 1%;
}
</style>
</head>
<body>
<div id="wrap">
<h1>Record details</h1>
<?php
if ($_POST) {
$response = data_entry_helper::forward_post_to('occurrence_comment');
echo data_entry_helper::dump_errors($response);
}
if (empty($_GET['id'])) {
echo 'This form requires an occurrence_id parameter in the URL.';
return;
}
data_entry_helper::link_default_stylesheet();
// Get authorisation tokens to update and read from the Warehouse.
$auth = data_entry_helper::get_read_write_auth($config['website_id'], $config['password']);
data_entry_helper::load_existing_record($auth['read'], 'occurrence', $_GET['id']);
data_entry_helper::load_existing_record($auth['read'], 'sample', data_entry_helper::$entity_to_load['occurrence:sample_id']);
$r .= "<div id=\"controls\">\n";
$r .= "<table>\n";
$r .= "<tr><td><strong>" . lang::get('Species') . "</strong></td><td>" . data_entry_helper::$entity_to_load['occurrence:taxon'] . "</td></tr>\n";
$r .= "<tr><td><strong>Date</strong></td><td>" . data_entry_helper::$entity_to_load['sample:date'] . "</td></tr>\n";