diff --git a/indefero/src/IDF/Views/Project.php b/indefero/src/IDF/Views/Project.php index 8029839..677ae3f 100644 --- a/indefero/src/IDF/Views/Project.php +++ b/indefero/src/IDF/Views/Project.php @@ -325,6 +325,53 @@ class IDF_Views_Project $request); } + public $backup_precond = array('IDF_Precondition::projectOwner'); + public function backup($request, $match) + { + $prj = $request->project; + + $to_json = array(); + $to_json["IDF_Project"] = Pluf_Test_Fixture::prepare(Pluf::factory("IDF_Project")->getOne(array("filter" => "id=" . $prj->id))); + + $to_json["IDF_Issue"] = array(); + $to_json["IDF_Upload"] = array(); + $to_json["IDF_Wiki_Page"] = array(); + + + foreach(Pluf::factory("IDF_Issue")->getList(array("filter"=>"project=".$prj->id)) as $item) + { + $tmp = array(); + $tmp = Pluf_Test_Fixture::dump($item, false); + $tmp = $tmp[0]; + $tmp["comments"] = array(); + foreach($item->get_comments_list() as $item2) + $tmp["comments"][] = Pluf_Test_Fixture::dump($item2, false)[0]; + $to_json["IDF_Issue"][] = $tmp; + } + foreach(Pluf::factory("IDF_Upload")->getList(array("filter"=>"project=".$prj->id)) as $item) + { + $path = $item->getFullPath(); + $file = file_get_contents($path); + + $tmp = Pluf_Test_Fixture::dump($item, false); + $tmp[0]["file_encoded"] = base64_encode($file); + $to_json["IDF_Upload"][] = $tmp[0]; + + } + + foreach(Pluf::factory("IDF_Wiki_Page")->getList(array("filter"=>"project=".$prj->id)) as $item) + { + $tmp = Pluf_Test_Fixture::dump($item, false)[0]; + $tmp["WikiPageRevs"] = array(); + foreach($item->get_revisions_list() as $item2) + $tmp["WikiPageRevs"][] = Pluf_Test_Fixture::dump($item2, false)[0]; + $to_json["IDF_Wiki_Page"][] = $tmp; + } + $render = new Pluf_HTTP_Response(json_encode($to_json), "application/json"); + $render->headers['Content-Disposition'] = 'attachment; filename="backup-' . $prj->name . '-' . date("YmdGis") . '.json"'; + return $render; + } + /** * Administrate the issue tracking of a project. */ diff --git a/indefero/src/IDF/templates/idf/admin/summary.html b/indefero/src/IDF/templates/idf/admin/summary.html index da344f3..ebb700b 100644 --- a/indefero/src/IDF/templates/idf/admin/summary.html +++ b/indefero/src/IDF/templates/idf/admin/summary.html @@ -100,4 +100,8 @@

The description of the project can be improved using the Markdown syntax.

{/blocktrans} +
+

Download Project

+

A copy of the project can be downloaded here: Download

+
{/block} diff --git a/indefero/src/IDF/templates/idf/project/home.html b/indefero/src/IDF/templates/idf/project/home.html index 7a6094a..35e78a7 100644 --- a/indefero/src/IDF/templates/idf/project/home.html +++ b/indefero/src/IDF/templates/idf/project/home.html @@ -3,7 +3,7 @@ {block tabhome} class="active"{/block} {block subtabs}
-{trans 'Welcome'} | {trans 'Latest Updates'}{superblock} +{trans 'Welcome'} | {trans 'RSS'} {trans 'Latest Updates'}{superblock}
{/block} {block body}