diff --git a/Zotlabs/Lib/Apps.php b/Zotlabs/Lib/Apps.php index ae06a0c4b..dcdcecfb3 100644 --- a/Zotlabs/Lib/Apps.php +++ b/Zotlabs/Lib/Apps.php @@ -308,82 +308,81 @@ class Apps { static public function translate_system_apps(&$arr) { $apps = array( + 'Admin' => t('Site Admin'), 'Apps' => t('Apps'), - 'Friend Zoom' => t('Friend Zoom'), - 'Virtual Lists' => t('Virtual Lists'), - 'Markup' => t('Markup'), 'Articles' => t('Articles'), + 'CalDAV' => t('CalDAV'), + 'CardDAV' => t('CardDAV'), 'Cards' => t('Cards'), 'Calendar' => t('Calendar'), 'Categories' => t('Categories'), + 'Channel Home' => t('Channel Home'), + 'Channel Manager' => t('Channel Manager'), + 'Channel Sources' => t('Channel Sources'), + 'Chat' => t('Chat'), + 'Chatrooms' => t('Chatrooms'), 'Clients' => t('Clients'), - 'Admin' => t('Site Admin'), + 'Comment Control' => t('Comment Control'), + 'Connections' => t('Connections'), 'Content Filter' => t('Content Filter'), 'Content Import' => t('Content Import'), - 'Report Bug' => t('Report Bug'), - 'View Bookmarks' => t('View Bookmarks'), - 'Chatrooms' => t('Chatrooms'), - 'Followlist' => t('Followlist'), - 'Content Import' => t('Content Import'), - 'Connections' => t('Connections'), + 'Directory' => t('Directory'), + 'Drafts' => t('Drafts'), + 'Events' => t('Events'), 'Expire Posts' => t('Expire Posts'), + 'Features' => t('Features'), + 'Files' => t('Files'), + 'Followlist' => t('Followlist'), + 'Friend Zoom' => t('Friend Zoom'), 'Future Posting' => t('Future Posting'), - 'Remote Diagnostics' => t('Remote Diagnostics'), - 'Suggest Channels' => t('Suggest Channels'), + 'Gallery' => t('Gallery'), + 'Guest Access' => t('Guest Access'), + 'Help' => t('Help'), + 'Invite' => t('Invite'), + 'Language' => t('Language'), + 'Lists' => t('Lists'), 'Login' => t('Login'), - 'Channel Manager' => t('Channel Manager'), + 'Mail' => t('Mail'), + 'Markup' => t('Markup'), + 'Mood' => t('Mood'), + 'My Chatrooms' => t('My Chatrooms') + 'No Comment' => t('No Comment'), 'Notes' => t('Notes'), - 'Stream' => t('Stream'), + 'Notifications' => t('Notifications'), + 'OAuth Apps Manager' => t('OAuth Apps Manager'), + 'OAuth2 Apps Manager' => t('OAuth2 Apps Manager'), + 'Order Apps' => t('Order Apps'), + 'PDL Editor' => t('PDL Editor'), + 'Permission Categories' => t('Permission Categories'), + 'Photos' => t('Photos'), + 'Photomap' => t('Photomap'), + 'Poke' => t('Poke'), + 'Post' => t('Post'), + 'Premium Channel' => t('Premium Channel'), + 'Probe' => t('Probe'), + 'Profile' => t('Profile'), + 'Profile Photo' => t('Profile Photo'), + 'Profiles' => t('Profiles'), + 'Public Stream' => t('Public Stream'), + 'Random Channel' => t('Random Channel'), + 'Remote Diagnostics' => t('Remote Diagnostics'), + 'Report Bug' => t('Report Bug'), + 'Search' => t('Search'), 'Secrets' => t('Secrets'), 'Settings' => t('Settings'), 'Sites' => t('Sites'), - 'Files' => t('Files'), + 'Stream' => t('Stream'), + 'Stream Order' => t('Stream Order'), + 'Suggest' => t('Suggest'), + 'Suggest Channels' => t('Suggest Channels'), + 'Tagadelic' => t('Tagadelic'), + 'Tasks' => t('Tasks'), + 'View Bookmarks' => t('View Bookmarks'), + 'View Profile' => t('View Profile'), + 'Virtual Lists' => t('Virtual Lists'), 'Webpages' => t('Webpages'), 'Wiki' => t('Wiki'), - 'Channel Home' => t('Channel Home'), - 'View Profile' => t('View Profile'), - 'Photos' => t('Photos'), - 'Photomap' => t('Photomap'), - 'Events' => t('Events'), - 'Tasks' => t('Tasks'), - 'Tagadelic' => t('Tagadelic'), - 'No Comment' => t('No Comment'), - 'Comment Control' => t('Comment Control'), - 'Directory' => t('Directory'), - 'Help' => t('Help'), - 'Mail' => t('Mail'), - 'Mood' => t('Mood'), - 'Poke' => t('Poke'), - 'Chat' => t('Chat'), - 'Search' => t('Search'), - 'Stream Order' => t('Stream Order'), - 'Probe' => t('Probe'), - 'Suggest' => t('Suggest'), - 'Random Channel' => t('Random Channel'), - 'Invite' => t('Invite'), - 'Features' => t('Features'), - 'Language' => t('Language'), - 'Post' => t('Post'), 'ZotPost' => t('ZotPost'), - 'Profile Photo' => t('Profile Photo'), - 'Profile' => t('Profile'), - 'Profiles' => t('Profiles'), - 'Lists' => t('Lists'), - 'Notifications' => t('Notifications'), - 'Order Apps' => t('Order Apps'), - 'CalDAV' => t('CalDAV'), - 'CardDAV' => t('CardDAV'), - 'Channel Sources' => t('Channel Sources'), - 'Gallery' => t('Gallery'), - 'Guest Access' => t('Guest Access'), - 'Notes' => t('Notes'), - 'OAuth Apps Manager' => t('OAuth Apps Manager'), - 'OAuth2 Apps Manager' => t('OAuth2 Apps Manager'), - 'PDL Editor' => t('PDL Editor'), - 'Permission Categories' => t('Permission Categories'), - 'Premium Channel' => t('Premium Channel'), - 'Public Stream' => t('Public Stream'), - 'My Chatrooms' => t('My Chatrooms') ); if (array_key_exists('name',$arr)) { diff --git a/Zotlabs/Module/Drafts.php b/Zotlabs/Module/Drafts.php new file mode 100644 index 000000000..37afb6900 --- /dev/null +++ b/Zotlabs/Module/Drafts.php @@ -0,0 +1,29 @@ +' . $desc . ''; + + if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Drafts'))) { + return $text; + } + + } +} diff --git a/Zotlabs/Module/Editpost.php b/Zotlabs/Module/Editpost.php index 21a64384f..2e0ca6756 100644 --- a/Zotlabs/Module/Editpost.php +++ b/Zotlabs/Module/Editpost.php @@ -85,6 +85,11 @@ class Editpost extends \Zotlabs\Web\Controller { } } + if (intval($itm[0]['item_unpublished'])) { + // clear the old creation date if editing a saved draft. These will always show as just created. + unset($itm[0]['created']); + } + $x = array( 'nickname' => $channel['channel_address'], 'item' => $itm[0], @@ -95,6 +100,7 @@ class Editpost extends \Zotlabs\Web\Controller { 'hide_voting' => true, 'hide_future' => true, 'hide_location' => true, + 'is_draft' => ((intval($itm[0]['item_unpublished'])) ? true : false), 'parent' => (($itm[0]['mid'] === $itm[0]['parent_mid']) ? 0 : $itm[0]['parent']), 'mimetype' => $itm[0]['mimetype'], 'ptyp' => $itm[0]['obj_type'], diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php index b7e0be29c..9acdfa574 100644 --- a/Zotlabs/Module/Item.php +++ b/Zotlabs/Module/Item.php @@ -374,8 +374,9 @@ class Item extends Controller { if ($created <= NULL_DATE) { $created = datetime_convert(); } - + $post_id = ((x($_REQUEST,'post_id')) ? intval($_REQUEST['post_id']) : 0); + $app = ((x($_REQUEST,'source')) ? strip_tags($_REQUEST['source']) : ''); $return_path = ((x($_REQUEST,'return')) ? $_REQUEST['return'] : ''); $preview = ((x($_REQUEST,'preview')) ? intval($_REQUEST['preview']) : 0); @@ -666,6 +667,7 @@ class Item extends Controller { $private = 1; if($orig_post) { + $private = 0; // webpages are allowed to change ACLs after the fact. Normal conversation items aren't. if($webpage) { @@ -715,12 +717,12 @@ class Item extends Controller { $postopts = $orig_post['postopts']; - $created = $orig_post['created']; - $expires = $orig_post['expires']; + $created = ((intval($orig_post['item_unpublished'])) ? $created : $orig_post['created']); + $expires = ((intval($orig_post['item_unpublished'])) ? NULL_DATE : $orig_post['expires']); $mid = $orig_post['mid']; $parent_mid = $orig_post['parent_mid']; $plink = $orig_post['plink']; - + } else { if(! $walltowall) { @@ -1238,11 +1240,11 @@ class Item extends Controller { $datarray['owner_xchan'] = (($owner_hash) ? $owner_hash : $owner_xchan['xchan_hash']); $datarray['author_xchan'] = $observer['xchan_hash']; $datarray['created'] = $created; - $datarray['edited'] = (($orig_post) ? datetime_convert() : $created); + $datarray['edited'] = (($orig_post && (! intval($orig_post['item_unpublished']))) ? datetime_convert() : $created); $datarray['expires'] = $expires; - $datarray['commented'] = (($orig_post) ? datetime_convert() : $created); - $datarray['received'] = (($orig_post) ? datetime_convert() : $created); - $datarray['changed'] = (($orig_post) ? datetime_convert() : $created); + $datarray['commented'] = (($orig_post && (! intval($orig_post['item_unpublished']))) ? datetime_convert() : $created); + $datarray['received'] = (($orig_post && (! intval($orig_post['item_unpublished']))) ? datetime_convert() : $created); + $datarray['changed'] = (($orig_post && (! intval($orig_post['item_unpublished']))) ? datetime_convert() : $created); $datarray['comments_closed'] = $comments_closed; $datarray['mid'] = $mid; $datarray['parent_mid'] = $parent_mid; @@ -1378,6 +1380,9 @@ class Item extends Controller { (($remote_id) ? $remote_id : basename($datarray['mid'])), true); } + if (intval($datarray['item_unpublished'])) { + $draft_msg = t('Draft saved. Use Drafts app to continue editing.'); + } if($orig_post) { $datarray['id'] = $post_id; @@ -1400,6 +1405,13 @@ class Item extends Controller { if($api_source) return($x); + + if (intval($datarray['item_unpublished'])) { + info($draft_msg); + } + + + if((x($_REQUEST,'return')) && strlen($return_path)) { logger('return: ' . $return_path); goaway(z_root() . "/" . $return_path ); @@ -1412,7 +1424,6 @@ class Item extends Controller { $post = item_store($datarray,$execflag); $post_id = $post['item_id']; - $datarray = $post['item']; if($post_id) { @@ -1525,7 +1536,11 @@ class Item extends Controller { if($api_source) return $post; - + + if (intval($datarray['item_unpublished'])) { + info($draft_msg); + } + if($return_path) { goaway(z_root() . "/" . $return_path); } diff --git a/Zotlabs/Module/Stream.php b/Zotlabs/Module/Stream.php index 4768ce8cd..403e3b92b 100644 --- a/Zotlabs/Module/Stream.php +++ b/Zotlabs/Module/Stream.php @@ -156,6 +156,7 @@ class Stream extends Controller { $default_cmax = ((Apps::system_app_installed(local_channel(),'Friend Zoom')) ? get_pconfig(local_channel(),'affinity','cmax',99) : (-1)); $cid = ((x($_GET,'cid')) ? intval($_GET['cid']) : 0); + $draft = ((x($_GET,'draft')) ? intval($_GET['draft']) : 0); $star = ((x($_GET,'star')) ? intval($_GET['star']) : 0); $liked = ((x($_GET,'liked')) ? intval($_GET['liked']) : 0); $conv = ((x($_GET,'conv')) ? intval($_GET['conv']) : 0); @@ -170,6 +171,10 @@ class Stream extends Controller { $deftag = ''; + if ($draft) { + $item_normal = item_normal_draft(); + } + if (x($_GET,'search') || $file || (!$pf && $cid)) { $nouveau = true; } @@ -380,6 +385,7 @@ class Stream extends Controller { '$dm' => (($dm) ? $dm : '0'), '$nouveau' => (($nouveau) ? $nouveau : '0'), '$wall' => '0', + '$draft' => (($draft) ? $draft : '0'), '$static' => $static, '$list' => ((x($_REQUEST,'list')) ? intval($_REQUEST['list']) : 0), '$page' => ((App::$pager['page'] != 1) ? App::$pager['page'] : 1), diff --git a/app/drafts.apd b/app/drafts.apd new file mode 100644 index 000000000..84d4c6020 --- /dev/null +++ b/app/drafts.apd @@ -0,0 +1,6 @@ +version: 1 +url: $baseurl/stream?draft=1 +requires: local_channel +name: Drafts +photo: icon:floppy-o +categories: Productivity diff --git a/include/conversation.php b/include/conversation.php index ed8a7a3ff..e26ffab78 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1426,6 +1426,8 @@ function z_status_editor($a, $x, $popup = false) { call_hooks('jot_networks', $jotnets); } + $permanent_draft = ((intval($x['profile_uid']) && intval($x['profile_uid']) === local_channel() && Apps::system_app_installed($x['profile_uid'],'Drafts')) ? ('Save draft') : EMPTY_STR); + $sharebutton = (x($x,'button') ? $x['button'] : t('Share')); $placeholdtext = (x($x,'content_label') ? $x['content_label'] : $sharebutton); @@ -1507,6 +1509,8 @@ function z_status_editor($a, $x, $popup = false) { '$defexpire' => $defexpire, '$feature_expire' => $feature_expire, '$expires' => t('Set expiration date'), + '$save' => $permanent_draft, + '$is_draft' => ((array_key_exists('is_draft',$x) && intval($x['is_draft'])) ? true : false), '$defpublish' => $defpublish, '$feature_future' => $feature_future, '$future_txt' => t('Set publish date'), diff --git a/include/items.php b/include/items.php index 4bb81dacc..ed50e607d 100644 --- a/include/items.php +++ b/include/items.php @@ -210,6 +210,12 @@ function item_normal() { and item.item_blocked = 0 and item.obj_type != '" . ACTIVITY_OBJ_FILE . "' "; } +function item_normal_draft() { + return " and item.item_hidden = 0 and item.item_type = 0 and item.item_deleted = 0 + and item.item_unpublished = 1 and item.item_pending_remove = 0 + and item.item_blocked = 0 and item.obj_type != '" . ACTIVITY_OBJ_FILE . "' "; +} + function item_normal_search() { return " and item.item_hidden = 0 and item.item_type in (0,3,6,7) and item.item_deleted = 0 and item.item_unpublished = 0 and item.item_delayed = 0 and item.item_pending_remove = 0 @@ -2107,28 +2113,47 @@ function item_store_update($arr, $allow_exec = false, $deliver = true, $linkid = unset($arr['mid']); unset($arr['parent']); unset($arr['parent_mid']); - unset($arr['created']); unset($arr['author_xchan']); unset($arr['owner_xchan']); unset($arr['source_xchan']); unset($arr['thr_parent']); unset($arr['llink']); + if (intval($orig[0]['item_unpublished'])) { + + $arr['created'] = ((x($arr,'created') !== false) ? datetime_convert('UTC','UTC',$arr['created']) : datetime_convert()); + $arr['edited'] = $arr['created']; + $arr['expires'] = ((x($arr,'expires') !== false) ? datetime_convert('UTC','UTC',$arr['expires']) : NULL_DATE); + + if(array_key_exists('comments_closed',$arr) && $arr['comments_closed'] > NULL_DATE) + $arr['comments_closed'] = datetime_convert('UTC','UTC',$arr['comments_closed']); + else + $arr['comments_closed'] = NULL_DATE; + + $arr['commented'] = $arr['created']; + + $arr['received'] = $arr['created']; + $arr['changed'] = $arr['created']; + } + + else { + unset($arr['created']); + + $arr['expires'] = ((x($arr,'expires') !== false) ? datetime_convert('UTC','UTC',$arr['expires']) : $orig[0]['expires']); + + + if(array_key_exists('comments_closed',$arr) && $arr['comments_closed'] > NULL_DATE) + $arr['comments_closed'] = datetime_convert('UTC','UTC',$arr['comments_closed']); + else + $arr['comments_closed'] = $orig[0]['comments_closed']; + + $arr['commented'] = $orig[0]['commented']; + $arr['received'] = $orig[0]['received']; + $arr['changed'] = $orig[0]['changed']; + } + $arr['edited'] = ((x($arr,'edited') !== false) ? datetime_convert('UTC','UTC',$arr['edited']) : datetime_convert()); - $arr['expires'] = ((x($arr,'expires') !== false) ? datetime_convert('UTC','UTC',$arr['expires']) : $orig[0]['expires']); - $arr['revision'] = ((x($arr,'revision') && $arr['revision'] > 0) ? intval($arr['revision']) : 0); - - if(array_key_exists('comments_closed',$arr) && $arr['comments_closed'] > NULL_DATE) - $arr['comments_closed'] = datetime_convert('UTC','UTC',$arr['comments_closed']); - else - $arr['comments_closed'] = $orig[0]['comments_closed']; - - $arr['commented'] = $orig[0]['commented']; - - $arr['received'] = $orig[0]['received']; - $arr['changed'] = $orig[0]['changed']; - $arr['route'] = ((array_key_exists('route',$arr)) ? trim($arr['route']) : $orig[0]['route']); $arr['location'] = ((x($arr,'location')) ? notags(trim($arr['location'])) : $orig[0]['location']); diff --git a/view/js/main.js b/view/js/main.js index 152a89866..d325e9673 100644 --- a/view/js/main.js +++ b/view/js/main.js @@ -1412,6 +1412,20 @@ function preview_post() { return true; } +function save_draft() { + $("#jot-draft").val("1"); + $.post( + "item", + $("#profile-jot-form").serialize(), + function() { + itemCancel(); + document.location.href=document.location.href; + }, + ); + return true; +} + + function preview_mail() { $("#mail-preview").val("1"); $("#mail-preview-content").show(); diff --git a/view/tpl/build_query.tpl b/view/tpl/build_query.tpl index 87bed9716..3e07b8086 100755 --- a/view/tpl/build_query.tpl +++ b/view/tpl/build_query.tpl @@ -16,6 +16,7 @@ var bParam_new = {{$nouveau}}; var bParam_page = {{$page}}; var bParam_wall = {{$wall}}; + var bParam_draft = {{$draft}}; var bParam_list = {{$list}}; var bParam_fh = {{$fh}}; var bParam_dm = {{$dm}}; @@ -49,6 +50,7 @@ if(bParam_spam != 0) bCmd = bCmd + "&spam=" + bParam_spam; if(bParam_new != 0) bCmd = bCmd + "&new=" + bParam_new; if(bParam_wall != 0) bCmd = bCmd + "&wall=" + bParam_wall; + if(bParam_draft != 0) bCmd = bCmd + "&draft=" + bParam_draft; if(bParam_list != 0) bCmd = bCmd + "&list=" + bParam_list; if(bParam_fh != 0) bCmd = bCmd + "&fh=" + bParam_fh; if(bParam_dm != 0) bCmd = bCmd + "&dm=" + bParam_dm; diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl index a04d9a9d7..bee738547 100755 --- a/view/tpl/jot.tpl +++ b/view/tpl/jot.tpl @@ -27,6 +27,7 @@ + {{if $webpage}} @@ -215,6 +216,11 @@ {{/if}} + {{if $save}} + + {{/if}} {{if $jotnets}}