aboutsummaryrefslogtreecommitdiffstats
path: root/include/import.php
diff options
context:
space:
mode:
authorMario Vavti <mario@mariovavti.com>2019-06-04 10:19:04 +0200
committerMario Vavti <mario@mariovavti.com>2019-06-04 10:19:04 +0200
commite4ca3609d90bb437061e4b8db95ed0424b25eb76 (patch)
treeaa070e40ab01cb1354cbf879a0fb8b2f570631d5 /include/import.php
parent071fba2f7121aeb9690a21398935a53deac09af8 (diff)
parentbc092d8d7815195d62299c0ea54caa4759e6f2e7 (diff)
downloadvolse-hubzilla-e4ca3609d90bb437061e4b8db95ed0424b25eb76.tar.gz
volse-hubzilla-e4ca3609d90bb437061e4b8db95ed0424b25eb76.tar.bz2
volse-hubzilla-e4ca3609d90bb437061e4b8db95ed0424b25eb76.zip
Merge branch '4.2RC'4.2
Diffstat (limited to 'include/import.php')
-rw-r--r--include/import.php52
1 files changed, 37 insertions, 15 deletions
diff --git a/include/import.php b/include/import.php
index 7a1e9aa55..4da0d1a0b 100644
--- a/include/import.php
+++ b/include/import.php
@@ -94,7 +94,8 @@ function import_channel($channel, $account_id, $seize, $newname = '') {
'channel_w_comment', 'channel_w_mail', 'channel_w_like', 'channel_w_tagwall',
'channel_w_chat', 'channel_w_storage', 'channel_w_pages', 'channel_a_republish',
'channel_a_delegate', 'perm_limits', 'channel_password', 'channel_salt',
- 'channel_moved', 'channel_removed', 'channel_deleted', 'channel_system'
+ 'channel_moved', 'channel_removed', 'channel_deleted', 'channel_system',
+ 'channel_r_photos', 'channel_w_photos'
];
$clean = array();
@@ -896,9 +897,9 @@ function import_menus($channel, $menus) {
$m['menu_name'] = $menu['pagetitle'];
$m['menu_desc'] = $menu['desc'];
if($menu['created'])
- $m['menu_created'] = datetime_convert($menu['created']);
+ $m['menu_created'] = datetime_convert('UTC','UTC',$menu['created']);
if($menu['edited'])
- $m['menu_edited'] = datetime_convert($menu['edited']);
+ $m['menu_edited'] = datetime_convert('UTC','UTC',$menu['edited']);
$m['menu_flags'] = 0;
if($menu['flags']) {
@@ -954,9 +955,9 @@ function sync_menus($channel, $menus) {
$m['menu_name'] = $menu['pagetitle'];
$m['menu_desc'] = $menu['desc'];
if($menu['created'])
- $m['menu_created'] = datetime_convert($menu['created']);
+ $m['menu_created'] = datetime_convert('UTC','UTC',$menu['created']);
if($menu['edited'])
- $m['menu_edited'] = datetime_convert($menu['edited']);
+ $m['menu_edited'] = datetime_convert('UTC','UTC',$menu['edited']);
$m['menu_flags'] = 0;
if($menu['flags']) {
@@ -1345,6 +1346,7 @@ function sync_files($channel, $files) {
logger('attachment store failed',LOGGER_NORMAL,LOG_ERR);
}
if($f['photo']) {
+
foreach($f['photo'] as $p) {
unset($p['id']);
$p['aid'] = $channel['channel_account_id'];
@@ -1366,6 +1368,7 @@ function sync_files($channel, $files) {
dbesc($p['resource_id']),
intval($channel['channel_id'])
);
+ $update_xchan = $p['edited'];
}
// same for cover photos
@@ -1385,19 +1388,20 @@ function sync_files($channel, $files) {
else
$p['content'] = (($p['content'])? base64_decode($p['content']) : '');
- if(intval($p['imgscale']) && (! $p['content'])) {
+ if(intval($p['imgscale']) && (! empty($p['content']))) {
$time = datetime_convert();
- $parr = array('hash' => $channel['channel_hash'],
+ $parr = array(
+ 'hash' => $channel['channel_hash'],
'time' => $time,
- 'resource' => $att['hash'],
+ 'resource' => $p['resource_id'],
'revision' => 0,
'signature' => base64url_encode(rsa_sign($channel['channel_hash'] . '.' . $time, $channel['channel_prvkey'])),
- 'resolution' => $p['imgscale']
+ 'resolution' => intval($p['imgscale'])
);
- $stored_image = $newfname . '-' . intval($p['imgscale']);
+ $stored_image = $newfname . '-' . $p['imgscale'];
$fp = fopen($stored_image,'w');
if(! $fp) {
@@ -1406,7 +1410,6 @@ function sync_files($channel, $files) {
}
$redirects = 0;
-
$headers = [];
$headers['Accept'] = 'application/x-zot+json' ;
$headers['Sigtoken'] = random_string();
@@ -1414,8 +1417,17 @@ function sync_files($channel, $files) {
$x = z_post_url($fetch_url,$parr,$redirects,[ 'filep' => $fp, 'headers' => $headers]);
fclose($fp);
- $p['content'] = file_get_contents($stored_image);
- unlink($stored_image);
+
+ // Override remote hub thumbnails storage settings
+ if(! boolval(get_config('system','filesystem_storage_thumbnails', 0))) {
+ $p['os_storage'] = 0;
+ $p['content'] = file_get_contents($stored_image);
+ @unlink($stored_image);
+ }
+ else {
+ $p['os_storage'] = 1;
+ $p['content'] = $stored_image;
+ }
}
if(!isset($p['display_path']))
@@ -1447,6 +1459,16 @@ function sync_files($channel, $files) {
create_table_from_array('photo',$p, [ 'content' ] );
}
}
+
+ }
+
+ // Set xchan photo date to prevent thumbnails fetch for clones on profile update packet recieve
+ if(isset($update_xchan)) {
+
+ $x = q("UPDATE xchan SET xchan_photo_date = '%s' WHERE xchan_hash = '%s'",
+ dbescdate($update_xchan),
+ dbesc($channel['channel_hash'])
+ );
}
\Zotlabs\Daemon\Master::Summon([ 'Thumbnail' , $att['hash'] ]);
@@ -1621,12 +1643,12 @@ function import_webpage_element($element, $channel, $type) {
$arr['created'] = $iteminfo[0]['created'];
}
else { // otherwise, generate the creation times and unique id
- $arr['created'] = datetime_convert('UTC', 'UTC');
+ $arr['created'] = datetime_convert();
$arr['uuid'] = item_message_id();
$arr['mid'] = $arr['parent_mid'] = z_root() . '/item/' . $arr['uuid'];
}
// Update the edited time whether or not the element already exists
- $arr['edited'] = datetime_convert('UTC', 'UTC');
+ $arr['edited'] = datetime_convert();
// Import the actual element content
$arr['body'] = file_get_contents($element['path']);
// The element owner is the channel importing the elements