aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to 'include')
-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
5 files changed, 118 insertions, 29 deletions
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)) {