Overview
Comment: | Implement export of user data as ZIP file |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk | stable |
Files: | files | file ages | folders |
SHA3-256: |
d483a6d1635fb3f7789e6c3948f246ca |
User & Date: | bohwaz on 2021-05-26 21:41:33 |
Other Links: | manifest | tags |
Context
2021-05-26
| ||
21:53 | Add alert message when category is empty check-in: bc619cd11c user: bohwaz tags: trunk, stable | |
21:41 | Implement export of user data as ZIP file check-in: d483a6d163 user: bohwaz tags: trunk, stable | |
21:41 | Move user info and services pages to admin/me/ tree check-in: 541af2ee19 user: bohwaz tags: trunk, stable | |
Changes
Added src/templates/me/export.tpl version [8a7de5d535].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | <!DOCTYPE html> <html> <head> <title>Données utilisateur</title> </head> <body> <h1>Données utilisateur</h1> <p>Ce document contient une copie de toutes les données détenues sur vous par {$config.nom_asso}, conformément à la réglementation.</p> <hr /> <h2>Profil</h2> {include file="admin/membres/_details.tpl" champs=$champs_list data=$data show_message_button=false mode="export"} <hr /> <h2>Inscriptions aux activités et cotisations</h2> <table> <thead> <tr> {foreach from=$services_list->getHeaderColumns() key="key" item="column"} <th>{$column.label}</th> {/foreach} </tr> </thead> <tbody> {foreach from=$services_list->iterate() item="row"} <tr> <th>{$row.label}</th> <td>{$row.date|date_short}</td> <td>{$row.expiry|date_short}</td> <td>{$row.fee}</td> <td>{if $row.paid}<b class="confirm">Oui</b>{else}<b class="error">Non</b>{/if}</td> <td>{$row.amount|raw|money_currency}</td> <td class="actions"> </td> </tr> {/foreach} </tbody> </table> </body> </html> |
Added src/www/admin/me/export.php version [0d8851baae].
> > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | <?php namespace Garradin; use Garradin\Services\Services_User; use Garradin\Files\Files; use Garradin\Entities\Files\File; use KD2\ZipWriter; require_once __DIR__ . '/../_inc.php'; $data = $session->getUser(); $champs = Config::getInstance()->get('champs_membres'); $champs_list = $champs->getList(); $services_list = Services_User::perUserList($user->id); $services_list->setPageSize(null); $export_data = [ 'user' => $data, 'services' => $services_list->asArray(), ]; $tpl->assign(compact('champs_list', 'data', 'services_list')); $name = sprintf('%s - Donnees - %s.zip', Config::getInstance()->get('nom_asso'), $data->identite); header('Content-type: application/zip'); header(sprintf('Content-Disposition: attachment; filename="%s"', $name)); $zip = new ZipWriter('php://output'); $zip->setCompression(0); $zip->add('info.html', $tpl->fetch('me/export.tpl')); $zip->add('info.json', json_encode($export_data)); foreach (Files::listForContext(File::CONTEXT_USER, $data->id) as $dir) { foreach (Files::list($dir->path) as $file) { $zip->add($file->path, null, $file->fullpath()); } } $zip->close(); |