Ejemplo n.º 1
0
function import_import_file(&$user, &$file, $more = array())
{
    if (!import_is_valid_mimetype($file, $more)) {
        return array('error' => 'invalid_mimetype', 'ok' => 0);
    }
    # Parse the file
    $process_rsp = import_process_file($file);
    if (!$process_rsp['ok']) {
        return $process_rsp;
    }
    #
    # store the data
    #
    $fingerprint = md5_file($file['path']);
    $label = $more['label'] ? $more['label'] : $process_rsp['label'];
    $import_more = array('return_dots' => $more['return_dots'], 'dots_index_on' => $more['dots_index_on'], 'label' => $label, 'mark_all_private' => $more['mark_all_private'], 'mime_type' => $file['type'], 'fingerprint' => $fingerprint, 'simplified' => $process_rsp['simplified'] ? 1 : 0);
    $import_rsp = import_process_data($user, $process_rsp['data'], $import_more);
    if (!$import_rsp['ok']) {
        return $import_rsp;
    }
    #
    # Hello new thing
    #
    $cache_key = "sheets_lookup_fingerprint_{$fingerprint}";
    cache_unset($cache_key);
    #
    # store the actual file?
    #
    if ($GLOBALS['cfg']['enable_feature_import_archive']) {
        loadlib("archive");
        $archive_rsp = archive_store_file($file, $import_rsp['sheet']);
        # throw an error if archiving fails?
    }
    #
    # happy happy
    #
    return $import_rsp;
}
Ejemplo n.º 2
0
                    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);
                }
            }
            #
            # Everything looks good, so let's try to talk to the database.
            # Note the part where we're also re-assign $step (below).
            #
            if ($ok) {
                $GLOBALS['smarty']->assign('step', 'import');
                $more = array('return_dots' => 0, 'dots_index_on' => $dots_index_on, 'label' => $label, 'mark_all_private' => $private, 'mime_type' => $mime_type, 'fingerprint' => $fingerprint, 'simplified' => $simplified);
                $import = import_process_data($GLOBALS['cfg']['user'], $data, $more);
                $GLOBALS['smarty']->assign_by_ref("import", $import);
            }
        } else {
            # nuthin'
        }
    }
}
$import_formats = formats_valid_import_map('key by extension');
$GLOBALS['smarty']->assign_by_ref("import_formats", $import_formats);
$import_formats_pretty = formats_pretty_import_names_map();
$GLOBALS['smarty']->assign_by_ref("import_formats_pretty", $import_formats_pretty);
$smarty->display("page_upload3.txt");
exit;