Ejemplo n.º 1
0
}
$csv = new CsvIn();
/** FIXME: 
 * - set fields that should not be part of import
 * - set fields that must be part of import, and visually disable them in the list
 */
$fields = $model->getFields();
$defaults = $csv->getDefaultFields();
$defaults_loaded = false;
if ($fields === null) {
    $fields = $defaults;
    $defaults_loaded = true;
}
if (isset($_GET['generate'])) {
    $ocsv = new CsvOut();
    $res = $ocsv->export($fields, Csv::DEFAULT_SEPARATOR, Csv::DEFAULT_QUOTE, $fields);
    $filename = _T("galette_import_model.csv");
    header('Content-Type: text/csv');
    header('Content-Disposition: attachment; filename="' . $filename . '";');
    header('Pragma: no-cache');
    echo $res;
} else {
    $tpl->assign('success_detected', $success_detected);
    $tpl->assign('error_detected', $error_detected);
    $tpl->assign('fields', $fields);
    $tpl->assign('model', $model);
    $tpl->assign('defaults', $defaults);
    $import_fields = $members_fields;
    //we do not want to import id_adh. Never.
    unset($import_fields['id_adh']);
    $tpl->assign('members_fields', $import_fields);
Ejemplo n.º 2
0
        }
        if (isset($member->bool_admin_adh)) {
            $member->bool_admin_adh = $member->bool_admin_adh ? _T("Yes") : _T("No");
        }
        if (isset($member->bool_exempt_adh)) {
            $member->bool_exempt_adh = $member->bool_exempt_adh ? _T("Yes") : _T("No");
        }
        if (isset($member->bool_display_info)) {
            $member->bool_display_info = $member->bool_display_info ? _T("Yes") : _T("No");
        }
    }
    $filename = 'filtered_memberslist.csv';
    $filepath = CsvOut::DEFAULT_DIRECTORY . $filename;
    $fp = fopen($filepath, 'w');
    if ($fp) {
        $res = $csv->export($members_list, Csv::DEFAULT_SEPARATOR, Csv::DEFAULT_QUOTE, $labels, $fp);
        fclose($fp);
        $written[] = array('name' => $filename, 'file' => $filepath);
    }
    if (file_exists(CsvOut::DEFAULT_DIRECTORY . $filename)) {
        header('Content-Type: text/csv');
        header('Content-Disposition: attachment; filename="' . $filename . '";');
        header('Pragma: no-cache');
        readfile(CsvOut::DEFAULT_DIRECTORY . $filename);
    } else {
        Analog::log('A request has been made to get an exported file named `' . $filename . '` that does not exists.', Analog::WARNING);
        header('HTTP/1.0 404 Not Found');
    }
} else {
    Analog::log('A non authorized person asked to retrieve exported file named `' . $filename . '`. Access ha not been granted.', Analog::WARNING);
    header('HTTP/1.0 403 Forbidden');
Ejemplo n.º 3
0
    if ($res === true) {
        $success_detected[] = str_replace('%export', $_GET['sup'], _T("'%export' file has been removed from disk."));
    } else {
        $error_detected[] = str_replace('%export', $_GET['sup'], _T("Cannot remove '%export' from disk :/"));
    }
}
if (isset($_POST['export_tables']) && $_POST['export_tables'] != '') {
    foreach ($_POST['export_tables'] as $table) {
        $select = $zdb->sql->select($table);
        $results = $zdb->execute($select);
        if ($results->count() > 0) {
            $filename = $table . '_full.csv';
            $filepath = CsvOut::DEFAULT_DIRECTORY . $filename;
            $fp = fopen($filepath, 'w');
            if ($fp) {
                $res = $csv->export($results, Csv::DEFAULT_SEPARATOR, Csv::DEFAULT_QUOTE, true, $fp);
                fclose($fp);
                $written[] = array('name' => $filename, 'file' => $filepath);
            }
        } else {
            $warning_detected[] = str_replace('%table', $table, _T("Table %table is empty, and has not been exported."));
        }
    }
}
if (isset($_POST['export_parameted']) && $_POST['export_parameted'] != '') {
    foreach ($_POST['export_parameted'] as $p) {
        $res = $csv->runParametedExport($p);
        $pn = $csv->getParamedtedExportName($p);
        switch ($res) {
            case Csv::FILE_NOT_WRITABLE:
                $error_detected[] = str_replace('%export', $pn, _T("Export file could not be write on disk for '%export'. Make sure web server can write in the exports directory."));