From c6d0695edff770863ea08e521e5a9961af3b2ef6 Mon Sep 17 00:00:00 2001 From: Thomas Willingham Date: Mon, 15 Dec 2014 19:32:28 +0000 Subject: Issue #743 --- include/widgets.php | 7 +------ mod/uexport.php | 39 +++++++++++++++++++++++++++------------ view/tpl/uexport.tpl | 9 +++++++++ 3 files changed, 37 insertions(+), 18 deletions(-) create mode 100644 view/tpl/uexport.tpl diff --git a/include/widgets.php b/include/widgets.php index b13be4922..71284f6ad 100644 --- a/include/widgets.php +++ b/include/widgets.php @@ -496,15 +496,10 @@ function widget_settings_menu($arr) { array( 'label' => t('Export channel'), - 'url' => $a->get_baseurl(true) . '/uexport/basic', + 'url' => $a->get_baseurl(true) . '/uexport', 'selected' => '' ), - array( - 'label' => t('Export content'), - 'url' => $a->get_baseurl(true) . '/uexport/complete', - 'selected' => '' - ), ); if($role === false || $role === 'custom') { diff --git a/mod/uexport.php b/mod/uexport.php index 6304115c8..4c1f6bee2 100644 --- a/mod/uexport.php +++ b/mod/uexport.php @@ -4,22 +4,37 @@ function uexport_init(&$a) { if(! local_user()) killme(); - $channel = $a->get_channel(); + if(argc() > 1) { + $channel = $a->get_channel(); - require_once('include/identity.php'); + require_once('include/identity.php'); - header('content-type: application/octet_stream'); - header('content-disposition: attachment; filename="' . $channel['channel_address'] . '.json"' ); + header('content-type: application/octet_stream'); + header('content-disposition: attachment; filename="' . $channel['channel_address'] . '.json"' ); - if(argc() > 1 && argv(1) === 'basic') { - echo json_encode(identity_basic_export(local_user())); - killme(); - } + if(argc() > 1 && argv(1) === 'basic') { + echo json_encode(identity_basic_export(local_user())); + killme(); + } - if(argc() > 1 && argv(1) === 'complete') { - echo json_encode(identity_basic_export(local_user(),true)); - killme(); + // FIXME - this basically doesn't work in the wild with a channel more than a few months old due to memory and execution time limits. + // It probably needs to be built at the CLI and offered to download as a tarball. Maybe stored in the members dav. + + if(argc() > 1 && argv(1) === 'complete') { + echo json_encode(identity_basic_export(local_user(),true)); + killme(); + } } +} -} \ No newline at end of file +function uexport_content(&$a) { + $o = replace_macros(get_markup_template('uexport.tpl'), array( + '$title' => t('Export Channel'), + '$basictitle' => t('Export Channel'), + '$basic' => t('Export your basic channel information to a small file. This acts as a backup of your connections, permissions, profile and basic data, which can be used to import your data to a new hub, but does not contain your content.'), + '$fulltitle' => t('Export Content'), + '$full' => t('Export your channel information and all the content to a JSON backup. This backs up all of your connections, permissions, profile data and all of your content, but is generally not suitable for importing a channel to a new site as this file may be VERY large. Please be patient - it may take several minutes for this download to begin.') + )); +return $o; +} diff --git a/view/tpl/uexport.tpl b/view/tpl/uexport.tpl new file mode 100644 index 000000000..5de995ba0 --- /dev/null +++ b/view/tpl/uexport.tpl @@ -0,0 +1,9 @@ +
+

{{$title}}

+{{$basictitle}}

+

{{$basic}}

+ +

{{$fulltitle}}

+

{{$full}}

+ +
-- cgit v1.2.3