Commit fa111d36 authored by Francois Marier's avatar Francois Marier Committed by Gerrit Code Review
Browse files

Merge "Html export: add files not owned by exporting user to special directory (bug #688304)"

parents d9146680 431f85f5
......@@ -36,13 +36,21 @@ class HtmlExportFile extends HtmlExportArtefactPlugin {
private $artefactdata = array();
private $owner;
// Keep track of files not owned by the exporting user. These should be included in the
// export tarball, but should not appear in the browseable folder structure.
private $otherfiles = array();
public function dump_export_data() {
$this->owner = $this->exporter->get('user')->get('id');
foreach ($this->exporter->get('artefacts') as $artefact) {
if (in_array($artefact->get('artefacttype'), PluginArtefactFile::get_artefact_types())) {
$this->artefactdata[$artefact->get('id')] = $artefact;
$id = $artefact->get('id');
$this->artefactdata[$id] = $artefact;
if ($artefact->get('owner') != $this->owner) {
$this->otherfiles[$id] = $id;
}
}
}
......@@ -51,7 +59,7 @@ class HtmlExportFile extends HtmlExportArtefactPlugin {
if ($this->exporter->get('artefactexportmode') != PluginExport::EXPORT_ALL_ARTEFACTS && $this->artefactdata) {
$folderids = array();
foreach (array_keys($this->artefactdata) as $artefactid) {
if ($this->artefactdata[$artefactid]->get('owner') == $this->owner) {
if (!isset($this->otherfiles[$artefactid])) {
$folderids = array_merge($folderids, array_keys(artefact_get_parents_for_cache($artefactid)));
}
}
......@@ -74,6 +82,16 @@ class HtmlExportFile extends HtmlExportArtefactPlugin {
$this->create_index_for_directory($this->fileroot, 0, null);
$this->populate_filedir($this->fileroot, 0, null);
// Copy other users' files into the extrafileroot directory
foreach ($this->otherfiles as $id) {
if (!$this->artefactdata[$id] instanceof ArtefactTypeFile) {
continue;
}
$dest = $this->extrafileroot . $id . '-' . PluginExportHtml::sanitise_path($this->artefactdata[$id]->get('title'));
if (!copy($this->artefactdata[$id]->get_path(), $dest)) {
throw new SystemException("Unable to copy artefact $id's file");
}
}
}
public function get_summary() {
......
......@@ -495,6 +495,10 @@ abstract class HtmlExportArtefactPlugin {
if (!check_dir_exists($this->fileroot)) {
throw new SystemException("Could not create the temporary export directory $this->fileroot");
}
$this->extrafileroot = $this->exporter->get('exportdir') . '/' . $this->exporter->get('rootdir') . '/files/extra/';
if (!check_dir_exists($this->extrafileroot)) {
throw new SystemException("Could not create the temporary export directory $this->extrafileroot");
}
}
abstract public function dump_export_data();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment