From a5aff7d0c969adb78338e35a1d736ad80462b34b Mon Sep 17 00:00:00 2001 From: Andrew Manning Date: Wed, 4 Apr 2018 15:22:38 -0400 Subject: Post body and title are auto-saved --- Zotlabs/Module/Autosavetext.php | 37 +++++++++++++++++++++++++++++++++++++ Zotlabs/Module/Item.php | 4 ++++ 2 files changed, 41 insertions(+) create mode 100644 Zotlabs/Module/Autosavetext.php (limited to 'Zotlabs/Module') diff --git a/Zotlabs/Module/Autosavetext.php b/Zotlabs/Module/Autosavetext.php new file mode 100644 index 000000000..f6bffd2a2 --- /dev/null +++ b/Zotlabs/Module/Autosavetext.php @@ -0,0 +1,37 @@ + true); + if(array_key_exists('body',$_REQUEST) && array_key_exists('type',$_REQUEST)) { + $body = escape_tags($_REQUEST['body']); + $title = (array_key_exists('title',$_REQUEST) ? escape_tags($_REQUEST['title']) : ''); + $type = $_REQUEST['type']; + + if($body && $type === 'post') { + set_pconfig(local_channel(),'autosavetext_post','body',$body); + set_pconfig(local_channel(),'autosavetext_post','title',$title); + } + + logger('post saved.', LOGGER_DEBUG); + } + + // // push updates to channel clones + // + // if((argc() > 1) && (argv(1) === 'sync')) { + // require_once('include/zot.php'); + // build_sync_packet(); + // } + + json_return_and_die($ret); + + } + +} diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index fba2ef7a4..ed35fc20d 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -1050,6 +1050,10 @@ class Item extends \Zotlabs\Web\Controller { logger('post_complete'); + // Remove auto-saved post text if the post was successfully posted + del_pconfig(local_channel(),'autosavetext_post','body'); + del_pconfig(local_channel(),'autosavetext_post','title'); + if($moderated) { info(t('Your comment is awaiting approval.') . EOL); } -- cgit v1.2.3