From 7381326b7a7a271da52464d15774a1309adb2bd5 Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 7 Nov 2013 00:47:50 -0800 Subject: provide expire feature on post and comments as well as private messages. This requires a feature setting and is currently unmaskable - if the author says it's gone, there's not a lot you can do to stop it or try and save it. It's gone. --- include/conversation.php | 6 +++++- include/features.php | 4 ++-- include/poller.php | 8 +++++++- mod/editblock.php | 3 +++ mod/editlayout.php | 3 +++ mod/editpost.php | 6 +++++- mod/editwebpage.php | 4 ++++ mod/item.php | 8 +++----- mod/message.php | 6 ++++-- version.inc | 2 +- view/theme/redbasic/css/style.css | 7 ++++++- view/tpl/jot-header.tpl | 7 +++++++ view/tpl/jot.tpl | 6 ++++++ view/tpl/prv_message.tpl | 2 ++ 14 files changed, 58 insertions(+), 14 deletions(-) diff --git a/include/conversation.php b/include/conversation.php index e8b41e775..fc0ae98e6 100644 --- a/include/conversation.php +++ b/include/conversation.php @@ -1064,7 +1064,8 @@ function status_editor($a,$x,$popup=false) { '$audurl' => t("Please enter an audio link/URL:"), '$term' => t('Tag term:'), '$fileas' => t('Save to Folder:'), - '$whereareu' => t('Where are you right now?') + '$whereareu' => t('Where are you right now?'), + '$expireswhen' => t('Expires YYYY-MM-DD HH:MM') )); @@ -1130,6 +1131,9 @@ function status_editor($a,$x,$popup=false) { '$preview' => $preview, '$sourceapp' => t($a->sourcename), '$jotplugins' => $jotplugins, + '$defexpire' => '', + '$feature_expire' => ((feature_enabled($x['profile_uid'],'content_expire') && (! $webpage)) ? 'block' : 'none'), + '$expires' => t('Set expiration date'), )); diff --git a/include/features.php b/include/features.php index 9950039c0..bf3323b56 100644 --- a/include/features.php +++ b/include/features.php @@ -19,8 +19,8 @@ function get_features() { // General 'general' => array( t('General Features'), -// uncomment when expire is fixed -// array('expire', t('Content Expiration'), t('Remove old posts/comments after a period of time')), +// This is per post, and different from fixed expiration 'expire' which isn't working yet + array('content_expire', t('Content Expiration'), t('Remove posts/comments and/or private messages at a future time')), array('multi_profiles', t('Multiple Profiles'), t('Ability to create multiple profiles')), array('webpages', t('Web Pages'), t('Provide managed web pages on your channel')), array('prettyphoto', t('Enhanced Photo Albums'), t('Enable photo album with enhanced features')), diff --git a/include/poller.php b/include/poller.php index b1f89955c..e5a274758 100644 --- a/include/poller.php +++ b/include/poller.php @@ -46,7 +46,13 @@ function poller_run($argv, $argc){ // expire any expired mail q("delete from mail where expires != '0000-00-00 00:00:00' and expires < UTC_TIMESTAMP() "); - + + $r = q("select id from item where expires != '0000-00-00 00:00:00' and expires < UTC_TIMESTAMP() "); + if($r) { + require_once('include/items.php'); + foreach($r as $rr) + drop_item($rr['id'],false); + } // Ensure that every channel pings a directory server once a month. This way we can discover // channels and sites that quietly vanished and prevent the directory from accumulating stale diff --git a/mod/editblock.php b/mod/editblock.php index a111f6666..9c691640b 100644 --- a/mod/editblock.php +++ b/mod/editblock.php @@ -144,6 +144,9 @@ function editblock_content(&$a) { '$preview' => ((feature_enabled(local_user(),'preview')) ? t('Preview') : ''), '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), + '$defexpire' => '', + '$feature_expire' => 'none', + '$expires' => t('Set expiration date'), )); diff --git a/mod/editlayout.php b/mod/editlayout.php index 7bcd02512..f8906d981 100644 --- a/mod/editlayout.php +++ b/mod/editlayout.php @@ -129,6 +129,9 @@ function editlayout_content(&$a) { '$preview' => ((feature_enabled(local_user(),'preview')) ? t('Preview') : ''), '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), + '$defexpire' => '', + '$feature_expire' => 'none', + '$expires' => t('Set expiration date'), )); $ob = get_observer_hash(); diff --git a/mod/editpost.php b/mod/editpost.php index 161e8f301..81eef2782 100644 --- a/mod/editpost.php +++ b/mod/editpost.php @@ -48,7 +48,8 @@ function editpost_content(&$a) { '$editselect' => (($plaintext) ? 'none' : '/(profile-jot-text|prvmail-text)/'), '$ispublic' => ' ', // t('Visible to everybody'), '$geotag' => $geotag, - '$nickname' => $channel['channel_address'] + '$nickname' => $channel['channel_address'], + '$expireswhen' => t('Expires YYYY-MM-DD HH:MM'), )); @@ -126,6 +127,9 @@ function editpost_content(&$a) { '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), '$catsenabled' => $catsenabled, + '$defexpire' => $itm[0]['expires'], + '$feature_expire' => 'none', + '$expires' => t('Set expiration date'), )); return $o; diff --git a/mod/editwebpage.php b/mod/editwebpage.php index 44ac0bc85..5a21aa78d 100644 --- a/mod/editwebpage.php +++ b/mod/editwebpage.php @@ -150,6 +150,10 @@ function editwebpage_content(&$a) { '$preview' => ((feature_enabled(local_user(),'preview')) ? t('Preview') : ''), '$jotplugins' => $jotplugins, '$sourceapp' => t($a->sourcename), + '$defexpire' => '', + '$feature_expire' => 'none', + '$expires' => t('Set expiration date'), + )); $ob = get_observer_hash(); diff --git a/mod/item.php b/mod/item.php index 2b8de1247..be24d242c 100644 --- a/mod/item.php +++ b/mod/item.php @@ -327,11 +327,9 @@ function item_post(&$a) { $expires = '0000-00-00 00:00:00'; - if(feature_enabled($profile_uid,'expire')) { - // expire_quantity, e.g. '3' - // expire_units, e.g. days, weeks, months - if(x($_REQUEST,'expire_quantity') && (x($_REQUEST,'expire_units'))) { - $expire = datetime_convert('UTC','UTC', 'now + ' . $_REQUEST['expire_quantity'] . ' ' . $_REQUEST['expire_units']); + if(feature_enabled($profile_uid,'content_expire')) { + if(x($_REQUEST,'expire')) { + $expires = datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expire']); if($expires <= datetime_convert()) $expires = '0000-00-00 00:00:00'; } diff --git a/mod/message.php b/mod/message.php index e31d903a7..dbbe8836b 100644 --- a/mod/message.php +++ b/mod/message.php @@ -324,7 +324,8 @@ function message_content(&$a) { '$insert' => t('Insert web link'), '$wait' => t('Please wait'), '$submit' => t('Submit'), - '$expires' => t('Expires: (leave blank for never)') + '$expires' => t('Expires: (leave blank for never)'), + '$feature_expire' => ((feature_enabled(local_user(),'content_expire')) ? '1' : ''), )); return $o; @@ -499,7 +500,8 @@ function message_content(&$a) { '$insert' => t('Insert web link'), '$submit' => t('Submit'), '$wait' => t('Please wait'), - '$expires' => t('Expires: (leave blank for never)') + '$expires' => t('Expires: (leave blank for never)'), + '$feature_expire' => ((feature_enabled(local_user(),'content_expire')) ? '1' : ''), )); return $o; diff --git a/version.inc b/version.inc index 0cbb9a0a6..259a60c9a 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2013-11-06.489 +2013-11-07.490 diff --git a/view/theme/redbasic/css/style.css b/view/theme/redbasic/css/style.css index c5d41d7ba..1a556df06 100644 --- a/view/theme/redbasic/css/style.css +++ b/view/theme/redbasic/css/style.css @@ -319,7 +319,8 @@ footer { #profile-video, #profile-audio, #profile-link, -#profile-title, +#profile-title, +#profile-expires, #wall-image-upload, #wall-file-upload, #profile-upload-wrapper, @@ -1137,6 +1138,10 @@ footer { float: left; margin-left: 15px; } +#profile-expire-wrapper { + float: left; + margin-left: 15px; +} #jot-preview-link { float: left; margin-left: 45px; diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 527db4e4f..05928bc32 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -191,6 +191,13 @@ function enableOnUser(){ } } + function jotGetExpiry() { + reply = prompt("{{$expirewhen}}", $('#jot-expire').val()); + if(reply && reply.length) { + $('#jot-expire').val(reply); + } + } + function jotShare(id) { if ($('#jot-popup').length != 0) $('#jot-popup').show(); diff --git a/view/tpl/jot.tpl b/view/tpl/jot.tpl index 12978038c..f7dd12758 100755 --- a/view/tpl/jot.tpl +++ b/view/tpl/jot.tpl @@ -5,6 +5,7 @@ + @@ -50,6 +51,11 @@ +
+ +
+ +
diff --git a/view/tpl/prv_message.tpl b/view/tpl/prv_message.tpl index 494eec48c..35f50da00 100755 --- a/view/tpl/prv_message.tpl +++ b/view/tpl/prv_message.tpl @@ -17,8 +17,10 @@
{{$subject}}
+{{if $feature_expire}}
{{$expires}}
+{{/if}}
{{$yourmessage}}
-- cgit v1.2.3