} else { if ($crumb_ok && post_str("data")) { $GLOBALS['smarty']->assign('step', 'process'); $fingerprint = post_str('fingerprint'); $mime_type = post_str('mime_type'); $simplified = post_str('simplified'); $raw_data = post_str("data"); $data = json_decode($raw_data, "as hash"); $ok = 1; if (!$data) { $GLOBALS['error']['missing_data'] = 1; $ok = 0; } if ($ok) { $more = array('dots_index_on' => $dots_index_on); $pre_process = import_ensure_valid_data($data); if (!$pre_process['ok']) { # Don't get $GLOBALS['error'] because that will prevent # the data from being displayed/corrected. $ok = 0; $pre_process['data'] = $data; if (count($pre_process['errors'])) { $_errors = array(); foreach ($pre_process['errors'] as $e) { $_errors[$e['record']] = $e; } $pre_process['errors'] = $_errors; } $GLOBALS['smarty']->assign_by_ref("pre_process", $pre_process); } }
function import_process_data(&$user, &$data, $more = array()) { # # First do some sanity-checking on the data before # we bother to create a sheet. # $rsp = import_ensure_valid_data($data); if (!$rsp['ok']) { return $rsp; } # # CAN I HAS MAH SHEET? # $sheet_rsp = sheets_create_sheet($user, $more); if (!$sheet_rsp['ok']) { return $sheet_rsp; } $sheet = $sheet_rsp['sheet']; # # OMG!!! IT'S FULL OF DOTS!!!! # $more['skip_validation'] = 1; # see above $dots_rsp = dots_import_dots($user, $sheet_rsp['sheet'], $data, $more); # No soup for sheet! Or is it the other way around... if (!$dots_rsp['ok']) { sheets_delete_sheet($sheet); } else { $dots_rsp['sheet'] = $sheet; $count_rsp = sheets_update_dot_count_for_sheet($sheet); $dots_rsp['update_sheet_count'] = $count_rsp['ok']; if ($more['return_dots']) { $dots_rsp['dots'] = dots_get_dots_for_sheet($sheet, $sheet['user_id']); } } return $dots_rsp; }