123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <?php
- if (!defined('STATUSNET')) {
-
-
- exit(1);
- }
- class BackupaccountAction extends Action
- {
-
- function title()
- {
-
- return _('Backup account');
- }
-
- function prepare($argarray)
- {
- parent::prepare($argarray);
- $cur = common_current_user();
- if (empty($cur)) {
-
- throw new ClientException(_('Only logged-in users can backup their account.'), 403);
- }
- if (!$cur->hasRight(Right::BACKUPACCOUNT)) {
-
- throw new ClientException(_('You may not backup your account.'), 403);
- }
- return true;
- }
-
- function handle($argarray=null)
- {
- parent::handle($argarray);
- if ($this->isPost()) {
- $this->sendFeed();
- } else {
- $this->showPage();
- }
- return;
- }
-
- function sendFeed()
- {
- $cur = common_current_user();
- $stream = new UserActivityStream($cur, true, UserActivityStream::OUTPUT_RAW);
- header('Content-Disposition: attachment; filename='.$cur->nickname.'.atom');
- header('Content-Type: application/atom+xml; charset=utf-8');
-
-
- $this->raw($stream->getString());
- }
-
- function showContent()
- {
- $form = new BackupAccountForm($this);
- $form->show();
- }
-
- function isReadOnly($args)
- {
- return true;
- }
-
- function lastModified()
- {
-
-
- return null;
- }
-
- function etag()
- {
- return null;
- }
- }
- class BackupAccountForm extends Form
- {
-
- function formClass()
- {
- return 'form_profile_backup';
- }
-
- function action()
- {
- return common_local_url('backupaccount');
- }
-
- function formData()
- {
- $msg =
-
- _('You can backup your account data in '.
- '<a href="http://activitystrea.ms/">Activity Streams</a> '.
- 'format. This is an experimental feature and provides an '.
- 'incomplete backup; private account '.
- 'information like email and IM addresses is not backed up. '.
- 'Additionally, uploaded files and direct messages are not '.
- 'backed up.');
- $this->out->elementStart('p');
- $this->out->raw($msg);
- $this->out->elementEnd('p');
- }
-
- function formActions()
- {
- $this->out->submit('submit',
-
- _m('BUTTON', 'Backup'),
- 'submit',
- null,
-
- _('Backup your account.'));
- }
- }
|