aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Zotlabs/Daemon/Cron_daily.php2
-rw-r--r--Zotlabs/Daemon/Notifier.php14
-rw-r--r--Zotlabs/Lib/Activity.php7
-rw-r--r--Zotlabs/Module/Channel_calendar.php32
-rw-r--r--Zotlabs/Module/Connections.php2
-rw-r--r--Zotlabs/Module/Import.php119
-rw-r--r--Zotlabs/Module/Owa.php6
-rw-r--r--Zotlabs/Module/Sse_bs.php2
-rw-r--r--Zotlabs/Update/_1236.php8
-rwxr-xr-xboot.php18
-rw-r--r--include/connections.php64
-rw-r--r--include/event.php70
-rw-r--r--include/import.php3
-rw-r--r--include/photos.php8
-rw-r--r--include/zot.php2
-rwxr-xr-xview/tpl/event_item_header.tpl5
16 files changed, 247 insertions, 115 deletions
diff --git a/Zotlabs/Daemon/Cron_daily.php b/Zotlabs/Daemon/Cron_daily.php
index 452ef45f1..2cf0c9119 100644
--- a/Zotlabs/Daemon/Cron_daily.php
+++ b/Zotlabs/Daemon/Cron_daily.php
@@ -96,7 +96,9 @@ class Cron_daily {
Master::Summon(array('Cli_suggest'));
remove_obsolete_hublocs();
+
z6_discover();
+ z6trans_connections();
call_hooks('cron_daily',datetime_convert());
diff --git a/Zotlabs/Daemon/Notifier.php b/Zotlabs/Daemon/Notifier.php
index fdf0148a6..d66079216 100644
--- a/Zotlabs/Daemon/Notifier.php
+++ b/Zotlabs/Daemon/Notifier.php
@@ -737,10 +737,16 @@ class Notifier {
}
if(stripos($hub['site_project'], 'hubzilla') !== false && version_compare($hub['site_version'], '4.7.3', '<=')) {
- $encoded_item['owner']['network'] = 'zot';
- $encoded_item['owner']['guid_sig'] = str_replace('sha256.', '', $encoded_item['owner']['guid_sig']);
- $encoded_item['author']['network'] = 'zot';
- $encoded_item['author']['guid_sig'] = str_replace('sha256.', '', $encoded_item['author']['guid_sig']);
+ if($encoded_item['type'] === 'mail') {
+ $encoded_item['from']['network'] = 'zot';
+ $encoded_item['from']['guid_sig'] = str_replace('sha256.', '', $encoded_item['from']['guid_sig']);
+ }
+ else {
+ $encoded_item['owner']['network'] = 'zot';
+ $encoded_item['owner']['guid_sig'] = str_replace('sha256.', '', $encoded_item['owner']['guid_sig']);
+ $encoded_item['author']['network'] = 'zot';
+ $encoded_item['author']['guid_sig'] = str_replace('sha256.', '', $encoded_item['author']['guid_sig']);
+ }
}
queue_insert(
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 02ec7614e..3c16a5367 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -323,6 +323,11 @@ class Activity {
return $ret;
}
+
+ if ($i['obj']) {
+ $ret = Activity::encode_object($i['obj']);
+ }
+
$ret['type'] = $objtype;
if ($objtype === 'Question') {
@@ -507,7 +512,7 @@ class Activity {
if ($item['iconfig']) {
foreach ($item['iconfig'] as $att) {
if ($att['sharing']) {
- $value = ((preg_match('|^a:[0-9]+:{.*}$|s', $att['v'])) ? unserialize($att['v']) : $att['v']);
+ $value = ((is_string($att['v']) && preg_match('|^a:[0-9]+:{.*}$|s', $att['v'])) ? unserialize($att['v']) : $att['v']);
$ret[] = [ 'type' => 'PropertyValue', 'name' => 'zot.' . $att['cat'] . '.' . $att['k'], 'value' => $value ];
}
}
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index 7d75a7e41..5d5fe300a 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -16,7 +16,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if(! local_channel())
return;
-
+
$event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0);
$event_hash = ((x($_POST,'event_hash')) ? $_POST['event_hash'] : '');
@@ -27,15 +27,19 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
if(($xchan) && ($xchan !== get_observer_hash()))
return;
- $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
- $tz = (($timezone) ? $timezone : date_default_timezone_get());
-
$categories = escape_tags(trim($_POST['categories']));
+ // allday events have adjust = 0, normal events have adjust = 1
$adjust = intval($_POST['adjust']);
- $start = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtstart']));
- $finish = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtend']));
+ $start = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtstart']));
+ $finish = datetime_convert((($adjust) ? $tz : 'UTC'), 'UTC', escape_tags($_REQUEST['dtend']));
+
+ $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
+ $tz = (($timezone) ? $timezone : date_default_timezone_get());
+
+ if(! $adjust)
+ $tz = 'UTC';
$summary = escape_tags(trim($_POST['summary']));
$desc = escape_tags(trim($_POST['desc']));
@@ -337,21 +341,16 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
}
$events = [];
-
+
if($r) {
foreach($r as $rr) {
- $tz = get_iconfig($rr, 'event', 'timezone');
-
- if(! $tz)
- $tz = 'UTC';
-
- $start = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c'));
+ $start = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtstart'], 'c'));
if ($rr['nofinish']){
$end = null;
} else {
- $end = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c'));
+ $end = (($rr['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c'));
}
$catsenabled = feature_enabled(local_channel(),'categories');
@@ -371,6 +370,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');
+ $tz = get_iconfig($rr, 'event', 'timezone');
+
+ if(! $tz)
+ $tz = 'UTC';
+
$events[] = array(
'calendar_id' => 'channel_calendar',
'rw' => true,
diff --git a/Zotlabs/Module/Connections.php b/Zotlabs/Module/Connections.php
index 029601867..7dc301623 100644
--- a/Zotlabs/Module/Connections.php
+++ b/Zotlabs/Module/Connections.php
@@ -34,7 +34,7 @@ class Connections extends \Zotlabs\Web\Controller {
}
nav_set_selected('Connections');
-
+
$active = false;
$blocked = false;
$hidden = false;
diff --git a/Zotlabs/Module/Import.php b/Zotlabs/Module/Import.php
index 18cb5560e..2c6e09fa7 100644
--- a/Zotlabs/Module/Import.php
+++ b/Zotlabs/Module/Import.php
@@ -137,6 +137,11 @@ class Import extends \Zotlabs\Web\Controller {
return;
}
+ if(version_compare($data['compatibility']['version'], '4.7.3', '<=')) {
+ // zot6 transition: cloning is not compatible with older versions
+ notice('Data export format is not compatible with this software (not a zot6 channel)');
+ return;
+ }
if($moving)
$seize = 1;
@@ -212,50 +217,21 @@ class Import extends \Zotlabs\Web\Controller {
// 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_hash' => $channel['channel_hash'],
- 'hubloc_addr' => channel_reddress($channel),
- 'hubloc_network' => 'zot',
- 'hubloc_primary' => (($seize) ? 1 : 0),
- 'hubloc_url' => z_root(),
- 'hubloc_url_sig' => base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])),
- 'hubloc_host' => \App::get_hostname(),
- 'hubloc_callback' => z_root() . '/post',
- '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())
- );
- }
-
- // create a new zot6 hubloc if we have got a channel_portable_id
if($channel['channel_portable_id']) {
$r = hubloc_store_lowlevel(
[
'hubloc_guid' => $channel['channel_guid'],
- 'hubloc_guid_sig' => 'sha256.' . $channel['channel_guid_sig'],
+ 'hubloc_guid_sig' => $channel['channel_guid_sig'],
'hubloc_hash' => $channel['channel_portable_id'],
'hubloc_addr' => channel_reddress($channel),
- 'hubloc_network' => 'zot6',
+ 'hubloc_network' => 'zot',
'hubloc_primary' => (($seize) ? 1 : 0),
'hubloc_url' => z_root(),
- 'hubloc_url_sig' => 'sha256.' . base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])),
+ 'hubloc_url_sig' => base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])),
'hubloc_host' => \App::get_hostname(),
- 'hubloc_callback' => z_root() . '/zot',
+ 'hubloc_callback' => z_root() . '/post',
'hubloc_sitekey' => get_config('system','pubkey'),
- 'hubloc_updated' => datetime_convert(),
- 'hubloc_id_url' => channel_url($channel),
- 'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey'))
-
+ 'hubloc_updated' => datetime_convert()
]
);
@@ -266,7 +242,35 @@ class Import extends \Zotlabs\Web\Controller {
dbesc(z_root())
);
}
+ }
+ // create a new zot6 hubloc if we have got a channel_portable_id
+
+ $r = hubloc_store_lowlevel(
+ [
+ 'hubloc_guid' => $channel['channel_guid'],
+ 'hubloc_guid_sig' => $channel['channel_guid_sig'],
+ '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' => 'sha256.' . base64url_encode(rsa_sign(z_root(),$channel['channel_prvkey'])),
+ 'hubloc_host' => \App::get_hostname(),
+ 'hubloc_callback' => z_root() . '/zot',
+ 'hubloc_sitekey' => get_config('system','pubkey'),
+ 'hubloc_updated' => datetime_convert(),
+ 'hubloc_id_url' => channel_url($channel),
+ 'hubloc_site_id' => Libzot::make_xchan_hash(z_root(),get_config('system','pubkey'))
+ ]
+ );
+
+ // 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())
+ );
}
}
@@ -285,32 +289,12 @@ class Import extends \Zotlabs\Web\Controller {
dbesc($channel['channel_portable_id'])
);
- $r = xchan_store_lowlevel(
- [
- 'xchan_hash' => $channel['channel_hash'],
- 'xchan_guid' => $channel['channel_guid'],
- 'xchan_guid_sig' => $channel['channel_guid_sig'],
- 'xchan_pubkey' => $channel['channel_pubkey'],
- 'xchan_photo_l' => z_root() . "/photo/profile/l/" . $channel['channel_id'],
- 'xchan_photo_m' => z_root() . "/photo/profile/m/" . $channel['channel_id'],
- 'xchan_photo_s' => z_root() . "/photo/profile/s/" . $channel['channel_id'],
- 'xchan_addr' => channel_reddress($channel),
- 'xchan_url' => z_root() . '/channel/' . $channel['channel_address'],
- 'xchan_connurl' => z_root() . '/poco/' . $channel['channel_address'],
- 'xchan_follow' => z_root() . '/follow?f=&url=%s',
- 'xchan_name' => $channel['channel_name'],
- 'xchan_network' => 'zot',
- 'xchan_photo_date' => datetime_convert(),
- 'xchan_name_date' => datetime_convert()
- ]
- );
-
if($channel['channel_portable_id']) {
$r = xchan_store_lowlevel(
[
- 'xchan_hash' => \Zotlabs\Lib\Libzot::make_xchan_hash($channel['channel_guid'],$channel['channel_pubkey']),
+ 'xchan_hash' => $channel['channel_portable_id'],
'xchan_guid' => $channel['channel_guid'],
- 'xchan_guid_sig' => 'sha256.' . $channel['channel_guid_sig'],
+ 'xchan_guid_sig' => $channel['channel_guid_sig'],
'xchan_pubkey' => $channel['channel_pubkey'],
'xchan_photo_l' => z_root() . "/photo/profile/l/" . $channel['channel_id'],
'xchan_photo_m' => z_root() . "/photo/profile/m/" . $channel['channel_id'],
@@ -320,13 +304,32 @@ class Import extends \Zotlabs\Web\Controller {
'xchan_connurl' => z_root() . '/poco/' . $channel['channel_address'],
'xchan_follow' => z_root() . '/follow?f=&url=%s',
'xchan_name' => $channel['channel_name'],
- 'xchan_network' => 'zot6',
+ 'xchan_network' => 'zot',
'xchan_photo_date' => datetime_convert(),
'xchan_name_date' => datetime_convert()
]
);
}
+ $r = xchan_store_lowlevel(
+ [
+ 'xchan_hash' => $channel['channel_hash'],
+ 'xchan_guid' => $channel['channel_guid'],
+ 'xchan_guid_sig' => $channel['channel_guid_sig'],
+ 'xchan_pubkey' => $channel['channel_pubkey'],
+ 'xchan_photo_l' => z_root() . "/photo/profile/l/" . $channel['channel_id'],
+ 'xchan_photo_m' => z_root() . "/photo/profile/m/" . $channel['channel_id'],
+ 'xchan_photo_s' => z_root() . "/photo/profile/s/" . $channel['channel_id'],
+ 'xchan_addr' => channel_reddress($channel),
+ 'xchan_url' => z_root() . '/channel/' . $channel['channel_address'],
+ 'xchan_connurl' => z_root() . '/poco/' . $channel['channel_address'],
+ 'xchan_follow' => z_root() . '/follow?f=&url=%s',
+ 'xchan_name' => $channel['channel_name'],
+ 'xchan_network' => 'zot6',
+ 'xchan_photo_date' => datetime_convert(),
+ 'xchan_name_date' => datetime_convert()
+ ]
+ );
}
@@ -346,7 +349,7 @@ class Import extends \Zotlabs\Web\Controller {
}
if($xchan['xchan_network'] === 'zot6') {
- $zhash = \Zotlabs\Lib\Libzot::make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_pubkey']);
+ $zhash = Libzot::make_xchan_hash($xchan['xchan_guid'],$xchan['xchan_pubkey']);
if($zhash !== $xchan['xchan_hash']) {
logger('forged xchan: ' . print_r($xchan,true));
continue;
diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php
index 89f83bf8f..4c6fd6216 100644
--- a/Zotlabs/Module/Owa.php
+++ b/Zotlabs/Module/Owa.php
@@ -33,11 +33,11 @@ class Owa extends \Zotlabs\Web\Controller {
if($keyId) {
- // Hubzilla connections can have both zot and zot6 hublocs
- // The connections will usually be zot so match those first
+ // Hubzilla connections can have both zot6 and zot hublocs
+ // The connections will usually be zot6 so match those first
$r = q("select * from hubloc left join xchan on hubloc_hash = xchan_hash
- where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) and hubloc_network = 'zot' ",
+ where ( hubloc_addr = '%s' or hubloc_id_url = '%s' ) and hubloc_network = 'zot6' ",
dbesc(str_replace('acct:','',$keyId)),
dbesc($keyId)
);
diff --git a/Zotlabs/Module/Sse_bs.php b/Zotlabs/Module/Sse_bs.php
index 90e870330..89e852120 100644
--- a/Zotlabs/Module/Sse_bs.php
+++ b/Zotlabs/Module/Sse_bs.php
@@ -399,7 +399,7 @@ class Sse_bs extends Controller {
if($r) {
$mids = flatten_array_recursive($r);
-
+ $b64mids = [];
foreach($mids as $mid)
$b64mids[] = 'b64.' . base64url_encode($mid);
diff --git a/Zotlabs/Update/_1236.php b/Zotlabs/Update/_1236.php
index d40cc9e25..6b4e7b299 100644
--- a/Zotlabs/Update/_1236.php
+++ b/Zotlabs/Update/_1236.php
@@ -105,10 +105,12 @@ class _1236 {
}
- if(count($r) == $i)
+ if(count($r) == $i) {
+ z6trans_connections();
return UPDATE_SUCCESS;
- else
- return UPDATE_FAILED;
+ }
+
+ return UPDATE_FAILED;
}
diff --git a/boot.php b/boot.php
index 4bd51f09c..4d641baf0 100755
--- a/boot.php
+++ b/boot.php
@@ -50,7 +50,7 @@ require_once('include/attach.php');
require_once('include/bbcode.php');
define ( 'PLATFORM_NAME', 'hubzilla' );
-define ( 'STD_VERSION', '4.7.4' );
+define ( 'STD_VERSION', '4.7.5' );
define ( 'ZOT_REVISION', '6.0a' );
define ( 'DB_UPDATE_VERSION', 1236 );
@@ -1593,6 +1593,22 @@ function fix_system_urls($oldurl, $newurl) {
}
}
+ // fix links in apps
+
+ $a = q("select id, app_url, app_photo from app where app_url like '%s' OR app_photo like '%s'",
+ dbesc('%' . $oldurl . '%'),
+ dbesc('%' . $oldurl . '%')
+ );
+ if($a) {
+ foreach($a as $aa) {
+ q("update app set app_url = '%s', app_photo = '%s' where id = %d",
+ dbesc(str_replace($oldurl,$newurl,$aa['app_url'])),
+ dbesc(str_replace($oldurl,$newurl,$aa['app_photo'])),
+ intval($aa['id'])
+ );
+ }
+ }
+
// now replace any remote xchans whose photos are stored locally (which will be most if not all remote xchans)
$r = q("select * from xchan where xchan_photo_l like '%s'",
diff --git a/include/connections.php b/include/connections.php
index 51df18b70..c7ec163c8 100644
--- a/include/connections.php
+++ b/include/connections.php
@@ -772,3 +772,67 @@ function vcard_query(&$r) {
}
}
}
+
+function z6trans_connections() {
+
+ $r = q("SELECT DISTINCT abook.abook_xchan, hubloc.hubloc_addr, hubloc.hubloc_url, hubloc.hubloc_guid, site.site_project, site.site_version FROM abook
+ LEFT JOIN hubloc ON abook_xchan = hubloc_hash
+ LEFT JOIN site ON hubloc_url = site_url
+ WHERE abook.abook_self = 0 AND hubloc.hubloc_network = 'zot'
+ AND hubloc.hubloc_deleted = 0 AND site.site_dead = 0"
+ );
+
+ foreach($r as $rr) {
+ if(stripos($rr['site_project'], 'hubzilla') !== false && version_compare($rr['site_version'], '4.7.4', '>=')) {
+
+ $zot_xchan = $rr['abook_xchan'];
+ $guid = $rr['hubloc_guid'];
+ $hub_url = $rr['hubloc_url'];
+ $addr = $rr['hubloc_addr'];
+
+ $x = q("SELECT hubloc_hash FROM hubloc
+ WHERE hubloc_guid = '%s' AND hubloc_url = '%s' AND hubloc_network = 'zot6' AND hubloc_deleted = 0",
+ dbesc($guid),
+ dbesc($hub_url)
+ );
+
+ if(!$x) {
+ logger("z6trans_connections: zot6 hubloc for $addr not found");
+ discover_by_webbie($addr,'zot6');
+ continue;
+ }
+
+ $zot6_xchan = $x[0]['hubloc_hash'];
+
+ logger("z6trans_connections: transition $zot_xchan to $zot6_xchan");
+
+ q("START TRANSACTION");
+
+ $q1 = q("UPDATE abook set abook_xchan = '%s' WHERE abook_xchan = '%s'",
+ dbesc($zot6_xchan),
+ dbesc($zot_xchan)
+ );
+
+ $q2 = q("UPDATE abconfig set xchan = '%s' WHERE xchan = '%s'",
+ dbesc($zot6_xchan),
+ dbesc($zot_xchan)
+ );
+
+ $q3 = q("UPDATE pgrp_member set xchan = '%s' WHERE xchan = '%s'",
+ dbesc($zot6_xchan),
+ dbesc($zot_xchan)
+ );
+
+ if($q1 && $q2 && $q3) {
+ q("COMMIT");
+ logger("z6trans_connections: completed");
+ continue;
+ }
+
+ logger("z6trans_connections: failed - performing rollback");
+ q("ROLLBACK");
+
+ }
+ }
+
+}
diff --git a/include/event.php b/include/event.php
index 64e63074c..69ca64e0f 100644
--- a/include/event.php
+++ b/include/event.php
@@ -40,7 +40,7 @@ function format_event_html($ev) {
$o .= '<div class="event-start"><span class="event-label">' . t('Starts:') . '</span>&nbsp;<span class="dtstart" title="'
. datetime_convert('UTC', 'UTC', $ev['dtstart'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
- . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(),
+ . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['dtstart'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['dtstart'] , $bd_format)))
@@ -50,7 +50,7 @@ function format_event_html($ev) {
$o .= '<div class="event-end" ><span class="event-label">' . t('Finishes:') . '</span>&nbsp;<span class="dtend" title="'
. datetime_convert('UTC','UTC',$ev['dtend'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' ))
. '" >'
- . (($ev['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(),
+ . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(),
$ev['dtend'] , $bd_format ))
: day_translate(datetime_convert('UTC', 'UTC',
$ev['dtend'] , $bd_format )))
@@ -76,7 +76,25 @@ function format_event_obj($jobject) {
//ensure compatibility with older items - this check can be removed at a later point
if(array_key_exists('description', $object)) {
- $tz = (($object['timezone']) ? $object['timezone'] : 'UTC');
+ $event_tz = '';
+ if($object['adjust'] && is_array($object['asld']) && is_array($object['asld']['attachment'])) {
+ foreach($object['asld']['attachment'] as $attachment) {
+ if($attachment['type'] === 'PropertyValue' && $attachment['name'] == 'zot.event.timezone' ) {
+ // check if the offset of the timezones is different and only set event_tz if offset is not the same
+ $local_tz = new DateTimeZone(date_default_timezone_get());
+ $local_dt = new DateTime('now', $local_tz);
+
+ $ev_tz = new DateTimeZone($attachment['value']);
+ $ev_dt = new DateTime('now', $ev_tz);
+
+ if($local_dt->getOffset() !== $ev_dt->getOffset())
+ $event_tz = $attachment['value'];
+
+ break;
+ }
+ }
+ }
+
$allday = (($object['adjust']) ? false : true);
$dtstart = new DateTime($object['dtstart']);
@@ -97,14 +115,15 @@ function format_event_obj($jobject) {
$event['header'] = replace_macros(get_markup_template('event_item_header.tpl'),array(
'$title' => zidify_links(smilies(bbcode($object['title']))),
'$dtstart_label' => t('Start:'),
- '$dtstart_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
- '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))),
+ '$dtstart_title' => datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
+ '$dtstart_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtstart'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtstart'] , $bd_format))),
'$finish' => (($object['nofinish']) ? false : true),
'$dtend_label' => t('End:'),
- '$dtend_title' => datetime_convert($tz, date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
- '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert($tz, date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))),
+ '$dtend_title' => datetime_convert('UTC', date_default_timezone_get(), $object['dtend'], (($object['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )),
+ '$dtend_dt' => (($object['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), $object['dtend'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $object['dtend'] , $bd_format ))),
'$allday' => $allday,
- '$oneday' => $oneday
+ '$oneday' => $oneday,
+ '$event_tz' => ['label' => t('Timezone'), 'value' => (($event_tz === date_default_timezone_get()) ? '' : $event_tz)]
));
$event['content'] = replace_macros(get_markup_template('event_item_content.tpl'),array(
@@ -257,15 +276,15 @@ function format_event_bbcode($ev, $utc = false) {
if($ev['event_vdata']) {
$o .= '[event]' . $ev['event_vdata'] . '[/event]';
}
-
+/*
if ($utc && $ev['event-timezone'] !== 'UTC') {
- $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart'],ATOM_TIME);
+ $ev['dtstart'] = datetime_convert($ev['timezone'],'UTC',$ev['dtstart']);
if ($ev['dtend'] && ! $ev['nofinish']) {
- $ev['dtend'] = datetime_convert($ev['timezone'],'UTC',$ev['dtend'],ATOM_TIME);
+ $ev['dtend'] = datetime_convert($ev['timezone'],'UTC',$ev['dtend']);
}
$ev['timezone'] = 'UTC';
}
-
+*/
if($ev['summary'])
$o .= '[event-summary]' . $ev['summary'] . '[/event-summary]';
@@ -284,8 +303,8 @@ function format_event_bbcode($ev, $utc = false) {
if($ev['event_hash'])
$o .= '[event-id]' . $ev['event_hash'] . '[/event-id]';
- if($ev['timezone'])
- $o .= '[event-timezone]' . $ev['timezone'] . '[/event-timezone]';
+// if($ev['timezone'])
+// $o .= '[event-timezone]' . $ev['timezone'] . '[/event-timezone]';
if($ev['adjust'])
$o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]';
@@ -1091,12 +1110,17 @@ function event_store_item($arr, $event) {
$item_arr['comment_policy'] = 'none';
}
- $r = q("SELECT * FROM item left join xchan on author_xchan = xchan_hash WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1",
+ $r = q("SELECT * FROM item WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1",
dbesc($event['event_hash']),
intval($arr['uid'])
);
if($r) {
+
+ set_iconfig($r[0]['id'], 'event', 'timezone', $arr['timezone'], true);
+ xchan_query($r);
+ $r = fetch_post_tags($r,true);
+
$object = json_encode(array(
'type' => ACTIVITY_OBJ_EVENT,
'id' => z_root() . '/event/' . $r[0]['resource_id'],
@@ -1111,13 +1135,13 @@ function event_store_item($arr, $event) {
'content' => format_event_bbcode($arr),
'attachment' => Activity::encode_attachment($r[0]),
'author' => array(
- 'name' => $r[0]['xchan_name'],
- 'address' => $r[0]['xchan_addr'],
- 'guid' => $r[0]['xchan_guid'],
- 'guid_sig' => $r[0]['xchan_guid_sig'],
+ 'name' => $r[0]['author']['xchan_name'],
+ 'address' => $r[0]['author']['xchan_addr'],
+ 'guid' => $r[0]['author']['xchan_guid'],
+ 'guid_sig' => $r[0]['author']['xchan_guid_sig'],
'link' => array(
- array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['xchan_url']),
- array('rel' => 'photo', 'type' => $r[0]['xchan_photo_mimetype'], 'href' => $r[0]['xchan_photo_m'])
+ array('rel' => 'alternate', 'type' => 'text/html', 'href' => $r[0]['author']['xchan_url']),
+ array('rel' => 'photo', 'type' => $r[0]['author']['xchan_photo_mimetype'], 'href' => $r[0]['author']['xchan_photo_m'])
),
),
));
@@ -1167,7 +1191,6 @@ function event_store_item($arr, $event) {
}
$item_id = $r[0]['id'];
- set_iconfig($item_id, 'event', 'timezone', $arr['timezone'], true);
/**
* @hooks event_updated
@@ -1251,6 +1274,8 @@ function event_store_item($arr, $event) {
else
$item_arr['plink'] = z_root() . '/display/' . gen_link_id($item_arr['mid']);
+ set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true);
+
$x = q("select * from xchan where xchan_hash = '%s' limit 1",
dbesc($arr['event_xchan'])
);
@@ -1286,7 +1311,6 @@ function event_store_item($arr, $event) {
// activities refer to the item message_id as the parent.
set_iconfig($item_arr, 'system','event_id',$event['event_hash'],true);
- set_iconfig($item_arr, 'event','timezone',$arr['timezone'],true);
$res = item_store($item_arr);
diff --git a/include/import.php b/include/import.php
index bfe71963f..910cb8be7 100644
--- a/include/import.php
+++ b/include/import.php
@@ -1,6 +1,7 @@
<?php
use Zotlabs\Lib\IConfig;
+use Zotlabs\Lib\Libzot;
use Zotlabs\Web\HTTPSig;
@@ -31,7 +32,7 @@ function import_channel($channel, $account_id, $seize, $newname = '') {
// Ignore the hash provided and re-calculate
- $channel['channel_hash'] = make_xchan_hash($channel['channel_guid'],$channel['channel_guid_sig']);
+ $channel['channel_hash'] = Libzot::make_xchan_hash($channel['channel_guid'],$channel['channel_pubkey']);
if($newname) {
$channel['channel_address'] = $newname;
diff --git a/include/photos.php b/include/photos.php
index ee662f707..631660d7a 100644
--- a/include/photos.php
+++ b/include/photos.php
@@ -388,7 +388,7 @@ function photo_upload($channel, $observer, $args) {
'title' => $title,
'created' => $p['created'],
'edited' => $p['edited'],
- 'id' => z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $photo_hash,
+ 'id' => z_root() . '/item/' . $photo_hash,
'link' => $link,
'body' => $summary
);
@@ -438,13 +438,13 @@ function photo_upload($channel, $observer, $args) {
}
}
else {
- $uuid = item_message_id();
- $mid = z_root() . '/item/' . $uuid;
+ // $uuid = item_message_id();
+ $mid = z_root() . '/item/' . $photo_hash;
$arr = [
'aid' => $account_id,
'uid' => $channel_id,
- 'uuid' => $uuid,
+ 'uuid' => $photo_hash,
'mid' => $mid,
'parent_mid' => $mid,
'item_hidden' => $item_hidden,
diff --git a/include/zot.php b/include/zot.php
index 5cf357d40..8b9cb0767 100644
--- a/include/zot.php
+++ b/include/zot.php
@@ -4355,7 +4355,7 @@ function zotinfo($arr) {
$r = q("select channel.*, xchan.* from channel left join xchan on channel_portable_id = xchan_hash
where channel_guid = '%s' and channel_guid_sig = '%s' limit 1",
dbesc($zguid),
- dbesc($zguid_sig)
+ dbesc('sha256.' . $zguid_sig)
);
}
elseif(strlen($zaddr)) {
diff --git a/view/tpl/event_item_header.tpl b/view/tpl/event_item_header.tpl
index ed46c304f..e81db48a1 100755
--- a/view/tpl/event_item_header.tpl
+++ b/view/tpl/event_item_header.tpl
@@ -15,3 +15,8 @@
</div>
{{/if}}
{{/if}}
+{{if $event_tz.value}}
+<div class="event-item-start">
+ <span class="event-item-label">{{$event_tz.label}}:</span>&nbsp;<span class="timezone" title="{{$event_tz.value}}">{{$event_tz.value}}</span>
+</div>
+{{/if}}