improve expiration +cleanup

This commit is contained in:
zotlabs 2019-05-29 16:29:55 -07:00
parent 5a1f198705
commit bb97dedcdd
6 changed files with 589 additions and 540 deletions

View file

@ -8,10 +8,30 @@ use Zotlabs\Web\Controller;
class Expire extends Controller { class Expire extends Controller {
function post() {
logger('expire: ' . print_r($_POST,true));
if(! ( local_channel() && Apps::system_app_installed(local_channel(),'Expire Posts'))) {
return;
}
if($_POST['expire-submit']) {
$expire = intval($_POST['selfexpiredays']);
if($expire < 0)
$expire = 0;
set_pconfig(local_channel(),'system','selfexpiredays',$expire);
info( t('Expiration settings updated.') . EOL);
}
Libsync::build_sync_packet();
}
function get() { function get() {
$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.'); $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>'; $text = '<div class="section-content-info-wrapper">' . $desc . '</div>';
@ -19,6 +39,27 @@ class Expire extends Controller {
return $text; return $text;
} }
$setting_fields .= replace_macros(get_markup_template('field_input.tpl'), array(
'$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.'))
));
$s .= replace_macros(get_markup_template('generic_app_settings.tpl'), array(
'$addon' => array('expire', t('Automatic Expiration Settings'), '', t('Submit')),
'$content' => $setting_fields
));
return $s;
} }

View file

@ -2,10 +2,14 @@
namespace Zotlabs\Module; namespace Zotlabs\Module;
use App;
use URLify;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Libzot; use Zotlabs\Lib\Libzot;
use Zotlabs\Daemon\Master;
require_once('include/channel.php');
require_once('include/import.php'); require_once('include/import.php');
require_once('include/photo_factory.php');
/** /**
@ -14,7 +18,8 @@ require_once('include/import.php');
* Import a channel, either by direct file upload or via * Import a channel, either by direct file upload or via
* connection to another server. * connection to another server.
*/ */
class Import extends \Zotlabs\Web\Controller {
class Import extends Controller {
/** /**
* @brief Import channel into account. * @brief Import channel into account.
@ -23,7 +28,7 @@ class Import extends \Zotlabs\Web\Controller {
*/ */
function import_account($account_id) { function import_account($account_id) {
if(! $account_id){ if (! $account_id) {
logger('No account ID supplied'); logger('No account ID supplied');
return; return;
} }
@ -41,30 +46,31 @@ class Import extends \Zotlabs\Web\Controller {
$newname = trim(strtolower($_REQUEST['newname'])); $newname = trim(strtolower($_REQUEST['newname']));
// import channel from file // import channel from file
if($src) { if ($src) {
// This is OS specific and could also fail if your tmpdir isn't very // This is OS specific and could also fail if your tmpdir isn't very
// large mostly used for Diaspora which exports gzipped files. // large mostly used for Diaspora which exports gzipped files.
if(strpos($filename,'.gz')){ if (strpos($filename,'.gz')){
@rename($src,$src . '.gz'); @rename($src,$src . '.gz');
@system('gunzip ' . escapeshellarg($src . '.gz')); @system('gunzip ' . escapeshellarg($src . '.gz'));
} }
if($filesize) { if ($filesize) {
$data = @file_get_contents($src); $data = @file_get_contents($src);
} }
unlink($src); unlink($src);
} }
// import channel from another server // import channel from another server
if(! $src) { if (! $src) {
$old_address = ((x($_REQUEST,'old_address')) ? $_REQUEST['old_address'] : ''); $old_address = ((x($_REQUEST,'old_address')) ? $_REQUEST['old_address'] : '');
if(! $old_address) { if (! $old_address) {
logger('Nothing to import.'); logger('Nothing to import.');
notice( t('Nothing to import.') . EOL); notice( t('Nothing to import.') . EOL);
return; return;
} else if(strpos($old_address, '')) { }
elseif (strpos($old_address, '')) {
// if you copy the identity address from your profile page, make it work for convenience - WARNING: this is a utf-8 variant and NOT an ASCII ampersand. Please do not edit. // if you copy the identity address from your profile page, make it work for convenience - WARNING: this is a utf-8 variant and NOT an ASCII ampersand. Please do not edit.
$old_address = str_replace('', '@', $old_address); $old_address = str_replace('', '@', $old_address);
} }
@ -76,20 +82,20 @@ class Import extends \Zotlabs\Web\Controller {
$servername = substr($old_address,strpos($old_address,'@')+1); $servername = substr($old_address,strpos($old_address,'@')+1);
$api_path = probe_api_path($servername); $api_path = probe_api_path($servername);
if(! $api_path) { if (! $api_path) {
notice( t('Unable to download data from old server') . EOL); notice( t('Unable to download data from old server') . EOL);
return; return;
} }
$api_path .= 'channel/export/basic?f=&channel=' . $channelname; $api_path .= 'channel/export/basic?f=&channel=' . $channelname;
if($import_posts) if ($import_posts) {
$api_path .= '&posts=1'; $api_path .= '&posts=1';
}
$binary = false; $binary = false;
$redirects = 0; $redirects = 0;
$opts = array('http_auth' => $email . ':' . $password); $opts = [ 'http_auth' => $email . ':' . $password ];
$ret = z_fetch_url($api_path, $binary, $redirects, $opts); $ret = z_fetch_url($api_path, $binary, $redirects, $opts);
if($ret['success']) { if ($ret['success']) {
$data = $ret['body']; $data = $ret['body'];
} }
else { else {
@ -109,49 +115,51 @@ class Import extends \Zotlabs\Web\Controller {
//logger('import: data: ' . print_r($data,true)); //logger('import: data: ' . print_r($data,true));
//print_r($data); //print_r($data);
if(! array_key_exists('compatibility',$data)) { if (! array_key_exists('compatibility',$data)) {
call_hooks('import_foreign_channel_data',$data); call_hooks('import_foreign_channel_data',$data);
if($data['handled']) if ($data['handled']) {
return; return;
}
} }
$codebase = ((defined('NOMADIC')) ? 'zap' : 'osada'); $codebase = ((defined('NOMADIC')) ? 'zap' : 'osada');
if((! array_path_exists('compatibility/codebase',$data)) || $data['compatibility']['codebase'] !== $codebase) { if ((! array_path_exists('compatibility/codebase',$data)) || $data['compatibility']['codebase'] !== $codebase) {
notice('Data export format is not compatible with this software'); notice('Data export format is not compatible with this software');
return; return;
} }
if($moving) if ($moving) {
$seize = 1; $seize = 1;
}
// import channel // import channel
$relocate = ((array_key_exists('relocate',$data)) ? $data['relocate'] : null); $relocate = ((array_key_exists('relocate',$data)) ? $data['relocate'] : null);
if(array_key_exists('channel',$data)) { if (array_key_exists('channel',$data)) {
$max_identities = account_service_class_fetch($account_id,'total_identities'); $max_identities = account_service_class_fetch($account_id,'total_identities');
if($max_identities !== false) { if ($max_identities !== false) {
$r = q("select channel_id from channel where channel_account_id = %d", $r = q("select channel_id from channel where channel_account_id = %d",
intval($account_id) intval($account_id)
); );
if($r && count($r) > $max_identities) { if ($r && count($r) > $max_identities) {
notice( sprintf( t('Your service plan only allows %d channels.'), $max_identities) . EOL); notice( sprintf( t('Your service plan only allows %d channels.'), $max_identities) . EOL);
return; return;
} }
} }
if($newname) { if ($newname) {
$x = false; $x = false;
if(get_config('system','unicode_usernames')) { if (get_config('system','unicode_usernames')) {
$x = punify(mb_strtolower($newname)); $x = punify(mb_strtolower($newname));
} }
if((! $x) || strlen($x) > 64) { if ((! $x) || strlen($x) > 64) {
$x = strtolower(\URLify::transliterate($newname)); $x = strtolower(URLify::transliterate($newname));
} }
$newname = $x; $newname = $x;
} }
@ -160,77 +168,37 @@ class Import extends \Zotlabs\Web\Controller {
} }
else { else {
$moving = false; $moving = false;
$channel = \App::get_channel(); $channel = App::get_channel();
} }
if(! $channel) { if (! $channel) {
logger('Channel not found. ', print_r($channel,true)); logger('Channel not found. ' . print_r($channel,true));
notice( t('No channel. Import failed.') . EOL); notice( t('No channel. Import failed.') . EOL);
return; return;
} }
if(is_array($data['config'])) { if (is_array($data['config'])) {
import_config($channel,$data['config']); import_config($channel,$data['config']);
} }
logger('import step 2'); logger('import step 2');
if(array_key_exists('channel',$data)) { if (array_key_exists('channel',$data)) {
if($data['photo']) { if ($data['photo']) {
require_once('include/photo_factory.php');
import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],$account_id,$channel['channel_id']); import_channel_photo(base64url_decode($data['photo']['data']),$data['photo']['type'],$account_id,$channel['channel_id']);
} }
if(is_array($data['profile'])) if (is_array($data['profile'])) {
import_profiles($channel,$data['profile']); import_profiles($channel,$data['profile']);
}
} }
logger('import step 3'); logger('import step 3');
if(is_array($data['hubloc'])) {
import_hublocs($channel,$data['hubloc'],$seize,$moving);
}
logger('import step 4');
// create new hubloc for the new channel at this site
if(array_key_exists('channel',$data)) {
$r = hubloc_store_lowlevel(
[
'hubloc_guid' => $channel['channel_guid'],
'hubloc_guid_sig' => $channel['channel_guid_sig'],
'hubloc_id_url' => channel_url($channel),
'hubloc_hash' => $channel['channel_hash'],
'hubloc_addr' => channel_reddress($channel),
'hubloc_network' => 'zot6',
'hubloc_primary' => (($seize) ? 1 : 0),
'hubloc_url' => z_root(),
'hubloc_url_sig' => Libzot::sign(z_root(),$channel['channel_prvkey']),
'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')),
'hubloc_host' => \App::get_hostname(),
'hubloc_callback' => z_root() . '/zot',
'hubloc_sitekey' => get_config('system','pubkey'),
'hubloc_updated' => datetime_convert()
]
);
// reset the original primary hubloc if it is being seized
if($seize) {
$r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ",
dbesc($channel['channel_hash']),
dbesc(z_root())
);
}
}
logger('import step 5');
// import xchans and contact photos // import xchans and contact photos
// This *must* be done before importing hublocs
if(array_key_exists('channel',$data) && $seize) { if (array_key_exists('channel',$data) && $seize) {
// replace any existing xchan we may have on this site if we're seizing control // replace any existing xchan we may have on this site if we're seizing control
@ -259,12 +227,12 @@ class Import extends \Zotlabs\Web\Controller {
); );
} }
logger('import step 6'); logger('import step 4');
// import xchans // import xchans
$xchans = $data['xchan']; $xchans = $data['xchan'];
if($xchans) { if ($xchans) {
foreach($xchans as $xchan) { foreach ($xchans as $xchan) {
$hash = Libzot::make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_pubkey']); $hash = Libzot::make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_pubkey']);
@ -276,14 +244,13 @@ class Import extends \Zotlabs\Web\Controller {
$r = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1", $r = q("select xchan_hash from xchan where xchan_hash = '%s' limit 1",
dbesc($xchan['xchan_hash']) dbesc($xchan['xchan_hash'])
); );
if($r) if ($r) {
continue; continue;
}
xchan_store_lowlevel($xchan); xchan_store_lowlevel($xchan);
require_once('include/photo_factory.php');
if($xchan['xchan_hash'] === $channel['channel_hash']) { if ($xchan['xchan_hash'] === $channel['channel_hash']) {
$r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s' where xchan_hash = '%s'", $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s' where xchan_hash = '%s'",
dbesc(z_root() . '/photo/profile/l/' . $channel['channel_id']), dbesc(z_root() . '/photo/profile/l/' . $channel['channel_id']),
dbesc(z_root() . '/photo/profile/m/' . $channel['channel_id']), dbesc(z_root() . '/photo/profile/m/' . $channel['channel_id']),
@ -293,10 +260,12 @@ class Import extends \Zotlabs\Web\Controller {
} }
else { else {
$photos = import_xchan_photo($xchan['xchan_photo_l'],$xchan['xchan_hash']); $photos = import_xchan_photo($xchan['xchan_photo_l'],$xchan['xchan_hash']);
if($photos[4]) if ($photos[4]) {
$photodate = NULL_DATE; $photodate = NULL_DATE;
else }
else {
$photodate = $xchan['xchan_photo_date']; $photodate = $xchan['xchan_photo_date'];
}
$r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s', xchan_photo_date = '%s' where xchan_hash = '%s'", $r = q("update xchan set xchan_photo_l = '%s', xchan_photo_m = '%s', xchan_photo_s = '%s', xchan_photo_mimetype = '%s', xchan_photo_date = '%s' where xchan_hash = '%s'",
dbesc($photos[0]), dbesc($photos[0]),
@ -309,22 +278,66 @@ class Import extends \Zotlabs\Web\Controller {
} }
} }
logger('import step 7'); logger('import step 5');
} }
logger('import step 6');
if (is_array($data['hubloc'])) {
import_hublocs($channel,$data['hubloc'],$seize,$moving);
}
logger('import step 7');
// create new hubloc for the new channel at this site
if (array_key_exists('channel',$data)) {
$r = hubloc_store_lowlevel(
[
'hubloc_guid' => $channel['channel_guid'],
'hubloc_guid_sig' => $channel['channel_guid_sig'],
'hubloc_id_url' => channel_url($channel),
'hubloc_hash' => $channel['channel_hash'],
'hubloc_addr' => channel_reddress($channel),
'hubloc_network' => 'zot6',
'hubloc_primary' => (($seize) ? 1 : 0),
'hubloc_url' => z_root(),
'hubloc_url_sig' => Libzot::sign(z_root(),$channel['channel_prvkey']),
'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey')),
'hubloc_host' => App::get_hostname(),
'hubloc_callback' => z_root() . '/zot',
'hubloc_sitekey' => get_config('system','pubkey'),
'hubloc_updated' => datetime_convert()
]
);
// reset the original primary hubloc if it is being seized
if ($seize) {
$r = q("update hubloc set hubloc_primary = 0 where hubloc_primary = 1 and hubloc_hash = '%s' and hubloc_url != '%s' ",
dbesc($channel['channel_hash']),
dbesc(z_root())
);
}
}
$friends = 0; $friends = 0;
$feeds = 0; $feeds = 0;
// import contacts // import contacts
$abooks = $data['abook']; $abooks = $data['abook'];
if($abooks) { if ($abooks) {
foreach($abooks as $abook) { foreach ($abooks as $abook) {
$abook_copy = $abook; $abook_copy = $abook;
$abconfig = null; $abconfig = null;
if(array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && count($abook['abconfig'])) if (array_key_exists('abconfig',$abook) && is_array($abook['abconfig']) && count($abook['abconfig'])) {
$abconfig = $abook['abconfig']; $abconfig = $abook['abconfig'];
}
unset($abook['abook_id']); unset($abook['abook_id']);
unset($abook['abook_rating']); unset($abook['abook_rating']);
@ -336,16 +349,6 @@ class Import extends \Zotlabs\Web\Controller {
$abook['abook_account'] = $account_id; $abook['abook_account'] = $account_id;
$abook['abook_channel'] = $channel['channel_id']; $abook['abook_channel'] = $channel['channel_id'];
if(! array_key_exists('abook_blocked',$abook)) {
$abook['abook_blocked'] = (($abook['abook_flags'] & 0x0001 ) ? 1 : 0);
$abook['abook_ignored'] = (($abook['abook_flags'] & 0x0002 ) ? 1 : 0);
$abook['abook_hidden'] = (($abook['abook_flags'] & 0x0004 ) ? 1 : 0);
$abook['abook_archived'] = (($abook['abook_flags'] & 0x0008 ) ? 1 : 0);
$abook['abook_pending'] = (($abook['abook_flags'] & 0x0010 ) ? 1 : 0);
$abook['abook_unconnected'] = (($abook['abook_flags'] & 0x0020 ) ? 1 : 0);
$abook['abook_self'] = (($abook['abook_flags'] & 0x0080 ) ? 1 : 0);
$abook['abook_feed'] = (($abook['abook_flags'] & 0x0100 ) ? 1 : 0);
}
if(array_key_exists('abook_instance',$abook) && $abook['abook_instance'] && strpos($abook['abook_instance'],z_root()) === false) { if(array_key_exists('abook_instance',$abook) && $abook['abook_instance'] && strpos($abook['abook_instance'],z_root()) === false) {
$abook['abook_not_here'] = 1; $abook['abook_not_here'] = 1;
@ -377,7 +380,12 @@ class Import extends \Zotlabs\Web\Controller {
intval($channel['channel_id']) intval($channel['channel_id'])
); );
if($r) { if($r) {
foreach($abook as $k => $v) { $columns = db_columns('abook');
foreach ($abook as $k => $v) {
if (! in_array($k,$columns)) {
continue;
}
$r = q("UPDATE abook SET " . TQUOT . "%s" . TQUOT . " = '%s' WHERE abook_xchan = '%s' AND abook_channel = %d", $r = q("UPDATE abook SET " . TQUOT . "%s" . TQUOT . " = '%s' WHERE abook_xchan = '%s' AND abook_channel = %d",
dbesc($k), dbesc($k),
dbesc($v), dbesc($v),
@ -390,13 +398,13 @@ class Import extends \Zotlabs\Web\Controller {
abook_store_lowlevel($abook); abook_store_lowlevel($abook);
$friends ++; $friends ++;
if(intval($abook['abook_feed'])) if (intval($abook['abook_feed'])) {
$feeds ++; $feeds ++;
}
} }
if($abconfig) { if ($abconfig) {
/// @FIXME does not handle sync of del_abconfig foreach ($abconfig as $abc) {
foreach($abconfig as $abc) {
set_abconfig($channel['channel_id'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']); set_abconfig($channel['channel_id'],$abc['xchan'],$abc['cat'],$abc['k'],$abc['v']);
} }
} }
@ -407,11 +415,11 @@ class Import extends \Zotlabs\Web\Controller {
// import groups // import groups
$groups = $data['group']; $groups = $data['group'];
if($groups) { if ($groups) {
$saved = array(); $saved = array();
foreach($groups as $group) { foreach ($groups as $group) {
$saved[$group['hash']] = array('old' => $group['id']); $saved[$group['hash']] = [ 'old' => $group['id'] ];
if(array_key_exists('name', $group)) { if (array_key_exists('name', $group)) {
$group['gname'] = $group['name']; $group['gname'] = $group['name'];
unset($group['name']); unset($group['name']);
} }
@ -432,11 +440,11 @@ class Import extends \Zotlabs\Web\Controller {
// import group members // import group members
$group_members = $data['group_member']; $group_members = $data['group_member'];
if($group_members) { if ($group_members) {
foreach($group_members as $group_member) { foreach ($group_members as $group_member) {
unset($group_member['id']); unset($group_member['id']);
$group_member['uid'] = $channel['channel_id']; $group_member['uid'] = $channel['channel_id'];
foreach($saved as $x) { foreach ($saved as $x) {
if($x['old'] == $group_member['gid']) if($x['old'] == $group_member['gid'])
$group_member['gid'] = $x['new']; $group_member['gid'] = $x['new'];
} }
@ -446,67 +454,63 @@ class Import extends \Zotlabs\Web\Controller {
logger('import step 9'); logger('import step 9');
if(is_array($data['xign'])) if (is_array($data['xign'])) {
import_xign($channel,$data['xign']); import_xign($channel,$data['xign']);
}
if(is_array($data['obj'])) if (is_array($data['obj'])) {
import_objs($channel,$data['obj']); import_objs($channel,$data['obj']);
}
if(is_array($data['likes'])) if (is_array($data['likes'])) {
import_likes($channel,$data['likes']); import_likes($channel,$data['likes']);
}
if(is_array($data['app'])) if (is_array($data['app'])) {
import_apps($channel,$data['app']); import_apps($channel,$data['app']);
}
if(is_array($data['sysapp'])) if (is_array($data['sysapp'])) {
import_sysapps($channel,$data['sysapp']); import_sysapps($channel,$data['sysapp']);
}
if(is_array($data['chatroom'])) if (is_array($data['chatroom'])) {
import_chatrooms($channel,$data['chatroom']); import_chatrooms($channel,$data['chatroom']);
}
if(is_array($data['conv'])) if (is_array($data['conv'])) {
import_conv($channel,$data['conv']); import_conv($channel,$data['conv']);
}
if(is_array($data['mail'])) if (is_array($data['mail'])) {
import_mail($channel,$data['mail']); import_mail($channel,$data['mail']);
}
if(is_array($data['event'])) if (is_array($data['event'])) {
import_events($channel,$data['event']); import_events($channel,$data['event']);
}
if(is_array($data['event_item'])) if (is_array($data['event_item'])) {
import_items($channel,$data['event_item'],false,$relocate); import_items($channel,$data['event_item'],false,$relocate);
}
if(is_array($data['menu'])) if (is_array($data['menu'])) {
import_menus($channel,$data['menu']); import_menus($channel,$data['menu']);
}
if(is_array($data['wiki'])) if (is_array($data['wiki'])) {
import_items($channel,$data['wiki'],false,$relocate); import_items($channel,$data['wiki'],false,$relocate);
}
if(is_array($data['webpages'])) if (is_array($data['webpages'])) {
import_items($channel,$data['webpages'],false,$relocate); import_items($channel,$data['webpages'],false,$relocate);
}
$addon = array('channel' => $channel,'data' => $data); $addon = array('channel' => $channel,'data' => $data);
call_hooks('import_channel',$addon); call_hooks('import_channel',$addon);
$saved_notification_flags = notifications_off($channel['channel_id']); $saved_notification_flags = notifications_off($channel['channel_id']);
if ($import_posts && array_key_exists('item',$data) && $data['item']) {
if($import_posts && array_key_exists('item',$data) && $data['item'])
import_items($channel,$data['item'],false,$relocate); import_items($channel,$data['item'],false,$relocate);
}
notifications_on($channel['channel_id'],$saved_notification_flags); notifications_on($channel['channel_id'],$saved_notification_flags);
if(array_key_exists('item_id',$data) && $data['item_id'])
import_item_ids($channel,$data['item_id']);
// send out refresh requests // send out refresh requests
// notify old server that it may no longer be primary. // notify old server that it may no longer be primary.
\Zotlabs\Daemon\Master::Summon(array('Notifier','refresh_all',$channel['channel_id'])); Master::Summon( [ 'Notifier','refresh_all',$channel['channel_id'] ] );
// This will indirectly perform a refresh_all *and* update the directory // This will indirectly perform a refresh_all *and* update the directory
\Zotlabs\Daemon\Master::Summon(array('Directory', $channel['channel_id'])); Master::Summon( [ 'Directory', $channel['channel_id'] ] );
notice( t('Import completed.') . EOL); notice( t('Import completed.') . EOL);
@ -518,13 +522,14 @@ class Import extends \Zotlabs\Web\Controller {
/** /**
* @brief Handle POST action on channel import page. * @brief Handle POST action on channel import page.
*/ */
function post() { function post() {
$account_id = get_account_id(); $account_id = get_account_id();
if(! $account_id) if (! $account_id) {
return; return;
}
check_form_security_token_redirectOnErr('/import', 'channel_import'); check_form_security_token_redirectOnErr('/import', 'channel_import');
$this->import_account($account_id); $this->import_account($account_id);
} }
@ -533,37 +538,35 @@ class Import extends \Zotlabs\Web\Controller {
* *
* @return string with parsed HTML. * @return string with parsed HTML.
*/ */
function get() { function get() {
if(! get_account_id()) { if (! get_account_id()) {
notice( t('You must be logged in to use this feature.') . EOL); notice( t('You must be logged in to use this feature.') . EOL);
return ''; return EMPTY_STR;
} }
$o = replace_macros(get_markup_template('channel_import.tpl'),array( return replace_macros(get_markup_template('channel_import.tpl'), [
'$title' => t('Import Channel'), '$title' => t('Import Channel'),
'$desc' => t('Use this form to import an existing channel from a different server/hub. You may retrieve the channel identity from the old server/hub via the network or provide an export file.'), '$desc' => t('Use this form to import an existing channel from a different server. You may retrieve the channel identity from the old server via the network or provide an export file.'),
'$label_filename' => t('File to Upload'), '$label_filename' => t('File to Upload'),
'$choice' => t('Or provide the old server/hub details'), '$choice' => t('Or provide the old server details'),
'$old_address' => [ 'old_address', t('Your old identity address (xyz@example.com)'), '', ''],
'$old_address' => [ 'old_address', t('Your old identity address (xyz@example.com)'), '', ''], '$email' => [ 'email', t('Your old login email address'), '', '' ],
'$email' => [ 'email', t('Your old login email address'), '', '' ], '$password' => [ 'password', t('Your old login password'), '', '' ],
'$password' => [ 'password', t('Your old login password'), '', '' ], '$import_posts' => [ 'import_posts', t('Import a few months of posts if possible (limited by available memory'), false, '', [ t('No'), t('Yes') ]],
'$import_posts' => [ 'import_posts', t('Import a few months of posts if possible (limited by available memory'), false, '', [ t('No'), t('Yes') ]],
'$common' => t('For either option, please choose whether to make this hub your new primary address, or whether your old location should continue this role. You will be able to post from either location, but only one can be marked as the primary location for files, photos, and media.'), '$common' => t('For either option, please choose whether to make this hub your new primary address, or whether your old location should continue this role. You will be able to post from either location, but only one can be marked as the primary location for files, photos, and media.'),
'$make_primary' => [ 'make_primary', t('Make this hub my primary location'), false, '', [ t('No'), t('Yes') ] ], '$make_primary' => [ 'make_primary', t('Make this hub my primary location'), false, '', [ t('No'), t('Yes') ] ],
'$moving' => [ 'moving', t('Move this channel (disable all previous locations)'), false, '', [ t('No'), t('Yes') ] ], '$moving' => [ 'moving', t('Move this channel (disable all previous locations)'), false, '', [ t('No'), t('Yes') ] ],
'$newname' => [ 'newname', t('Use this channel nickname instead of the one provided'), '', t('Leave blank to keep your existing channel nickname. You will be randomly assigned a similar nickname if either name is already allocated on this site.')], '$newname' => [ 'newname', t('Use this channel nickname instead of the one provided'), '', t('Leave blank to keep your existing channel nickname. You will be randomly assigned a similar nickname if either name is already allocated on this site.')],
'$pleasewait' => t('This process may take several minutes to complete. Please submit the form only once and leave this page open until finished.'), '$pleasewait' => t('This process may take several minutes to complete. Please submit the form only once and leave this page open until finished.'),
'$form_security_token' => get_form_security_token('channel_import'), '$form_security_token' => get_form_security_token('channel_import'),
'$submit' => t('Submit') '$submit' => t('Submit')
)); ]);
return $o;
} }
} }

View file

@ -101,10 +101,6 @@ class Import_items extends \Zotlabs\Web\Controller {
import_items($channel,$data['item'],false,((array_key_exists('relocate',$data)) ? $data['relocate'] : null)); import_items($channel,$data['item'],false,((array_key_exists('relocate',$data)) ? $data['relocate'] : null));
} }
if(array_key_exists('item_id',$data) && $data['item_id']) {
import_item_ids($channel,$data['item_id']);
}
info( t('Import completed') . EOL); info( t('Import completed') . EOL);
} }

View file

@ -1314,6 +1314,12 @@ function z_status_editor($a, $x, $popup = false) {
$defexpire = ((($z = get_pconfig($x['profile_uid'], 'system', 'default_post_expire')) && (! $webpage)) ? $z : ''); $defexpire = ((($z = get_pconfig($x['profile_uid'], 'system', 'default_post_expire')) && (! $webpage)) ? $z : '');
if($defexpire) if($defexpire)
$defexpire = datetime_convert('UTC',date_default_timezone_get(),$defexpire,'Y-m-d H:i'); $defexpire = datetime_convert('UTC',date_default_timezone_get(),$defexpire,'Y-m-d H:i');
else {
$defexpire = ((($z = intval(get_pconfig($x['profile_uid'], 'system', 'selfexpiredays'))) && (! $webpage)) ? $z : '');
if($defexpire)
$defexpire = datetime_convert('UTC',date_default_timezone_get(),"now + $defexpire days",'Y-m-d H:i');
}
$defpublish = ((($z = get_pconfig($x['profile_uid'], 'system', 'default_post_publish')) && (! $webpage)) ? $z : ''); $defpublish = ((($z = get_pconfig($x['profile_uid'], 'system', 'default_post_publish')) && (! $webpage)) ? $z : '');
if($defpublish) if($defpublish)

File diff suppressed because it is too large Load diff

View file

@ -264,7 +264,7 @@
</div> </div>
<div class="modal-body form-group" style="width:90%"> <div class="modal-body form-group" style="width:90%">
<div class="date"> <div class="date">
<input type="text" placeholder="yyyy-mm-dd HH:MM" name="start_text" id="expiration-date" class="form-control" /> <input type="text" placeholder="yyyy-mm-dd HH:MM" name="start_text" value="{{$defexpire}}" id="expiration-date" class="form-control" />
</div> </div>
<script> <script>
$(function () { $(function () {