streams/Zotlabs/Module/Expire.php

54 lines
1.6 KiB
PHP
Raw Normal View History

<?php
namespace Zotlabs\Module;
use Zotlabs\Lib\Apps;
use Zotlabs\Lib\Libsync;
use Zotlabs\Web\Controller;
class Expire extends Controller {
2019-05-29 23:29:55 +00:00
function post() {
2019-09-30 00:17:40 +00:00
if (! ( local_channel() && Apps::system_app_installed(local_channel(),'Expire Posts'))) {
2019-05-29 23:29:55 +00:00
return;
}
2019-09-30 00:17:40 +00:00
if ($_POST['expire-submit']) {
2019-05-29 23:29:55 +00:00
$expire = intval($_POST['selfexpiredays']);
2019-09-30 00:17:40 +00:00
if ($expire < 0) {
2019-05-29 23:29:55 +00:00
$expire = 0;
2019-09-30 00:17:40 +00:00
}
2019-05-29 23:29:55 +00:00
set_pconfig(local_channel(),'system','selfexpiredays',$expire);
info( t('Expiration settings updated.') . EOL);
}
Libsync::build_sync_packet();
}
function get() {
2019-05-29 23:29:55 +00:00
$desc = t('This app allows you to set an optional expiration date/time for posts, after which they will be deleted. This must be at least fifteen minutes into the future. You may also choose to automatically delete all your posts after a set number of days');
$text = '<div class="section-content-info-wrapper">' . $desc . '</div>';
2019-09-30 00:17:40 +00:00
if (! ( local_channel() && Apps::system_app_installed(local_channel(),'Expire Posts'))) {
return $text;
}
2019-09-30 00:17:40 +00:00
$setting_fields .= replace_macros(get_markup_template('field_input.tpl'), [
2019-05-29 23:29:55 +00:00
'$field' => array('selfexpiredays', t('Expire and delete all my posts after this many days'), intval(get_pconfig(local_channel(),'system','selfexpiredays',0)), t('Leave at 0 if you wish to manually control expiration of specific posts.'))
2019-09-30 00:17:40 +00:00
]);
2019-05-29 23:29:55 +00:00
2019-09-30 00:17:40 +00:00
return replace_macros(get_markup_template('generic_app_settings.tpl'), [
2019-05-29 23:29:55 +00:00
'$addon' => array('expire', t('Automatic Expiration Settings'), '', t('Submit')),
'$content' => $setting_fields
2019-09-30 00:17:40 +00:00
]);
2019-05-29 23:29:55 +00:00
}
}