aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMario <mario@mariovavti.com>2019-04-10 13:25:57 +0200
committerMario <mario@mariovavti.com>2019-04-10 13:25:57 +0200
commite96fa64625447aed6c2ee83f8bb53007a3b8f8ec (patch)
treec7ed6f6889cc48a2f217acd76057e887912e2346
parent8dc495c9bcd4e2e59b74913d20b12fada93c5004 (diff)
parent999ae6eb494dbe7c700d40a2e7557ebee7157d80 (diff)
downloadvolse-hubzilla-e96fa64625447aed6c2ee83f8bb53007a3b8f8ec.tar.gz
volse-hubzilla-e96fa64625447aed6c2ee83f8bb53007a3b8f8ec.tar.bz2
volse-hubzilla-e96fa64625447aed6c2ee83f8bb53007a3b8f8ec.zip
Merge branch 'dev' into 'dev'
Dev See merge request hubzilla/core!1586
-rw-r--r--Zotlabs/Lib/Activity.php46
-rw-r--r--Zotlabs/Module/Embedphotos.php48
-rw-r--r--include/permissions.php16
3 files changed, 72 insertions, 38 deletions
diff --git a/Zotlabs/Lib/Activity.php b/Zotlabs/Lib/Activity.php
index 5b9d356bb..5c3002837 100644
--- a/Zotlabs/Lib/Activity.php
+++ b/Zotlabs/Lib/Activity.php
@@ -14,27 +14,30 @@ class Activity {
$x = json_decode($x,true);
}
- if(is_array($x) && array_key_exists('asld',$x)) {
- $x = $x['asld'];
- }
+ if(is_array($x)) {
- if($x['type'] === ACTIVITY_OBJ_PERSON) {
- return self::fetch_person($x);
- }
- if($x['type'] === ACTIVITY_OBJ_PROFILE) {
- return self::fetch_profile($x);
- }
- if(in_array($x['type'], [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_ARTICLE ] )) {
- return self::fetch_item($x);
- }
- if($x['type'] === ACTIVITY_OBJ_THING) {
- return self::fetch_thing($x);
- }
- if($x['type'] === ACTIVITY_OBJ_EVENT) {
- return self::fetch_event($x);
- }
- if($x['type'] === ACTIVITY_OBJ_PHOTO) {
- return self::fetch_image($x);
+ if(array_key_exists('asld',$x)) {
+ return $x['asld'];
+ }
+
+ if($x['type'] === ACTIVITY_OBJ_PERSON) {
+ return self::fetch_person($x);
+ }
+ if($x['type'] === ACTIVITY_OBJ_PROFILE) {
+ return self::fetch_profile($x);
+ }
+ if(in_array($x['type'], [ ACTIVITY_OBJ_NOTE, ACTIVITY_OBJ_ARTICLE ] )) {
+ return self::fetch_item($x);
+ }
+ if($x['type'] === ACTIVITY_OBJ_THING) {
+ return self::fetch_thing($x);
+ }
+ if($x['type'] === ACTIVITY_OBJ_EVENT) {
+ return self::fetch_event($x);
+ }
+ if($x['type'] === ACTIVITY_OBJ_PHOTO) {
+ return self::fetch_image($x);
+ }
}
return $x;
@@ -189,6 +192,9 @@ class Activity {
'source' => [ 'content' => format_event_bbcode($ev), 'mediaType' => 'text/bbcode' ],
'actor' => $actor,
];
+ if(! $ev['nofinish']) {
+ $y['endTime'] = (($ev['adjust']) ? datetime_convert('UTC','UTC',$ev['dtend'], ATOM_TIME) : datetime_convert('UTC','UTC',$ev['dtend'],'Y-m-d\\TH:i:s-00:00'));
+ }
if($actor) {
return $y;
}
diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.php
index 2df14c239..8b0421457 100644
--- a/Zotlabs/Module/Embedphotos.php
+++ b/Zotlabs/Module/Embedphotos.php
@@ -41,24 +41,44 @@ class Embedphotos extends \Zotlabs\Web\Controller {
json_return_and_die(array('errormsg' => 'Error retrieving link ' . $href, 'status' => false));
}
$resource_id = array_pop(explode('/', $href));
- $r = q("SELECT obj from item where resource_type = 'photo' and resource_id = '%s' limit 1",
- dbesc($resource_id)
+ $x = self::photolink($resource_id);
+ if($x)
+ json_return_and_die(array('status' => true, 'photolink' => $x, 'resource_id' => $resource_id));
+ json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
+ }
+ }
+
+
+ protected static function photolink($resource) {
+ $channel = \App::get_channel();
+ $output = EMPTY_STR;
+ if($channel) {
+ $resolution = ((feature_enabled($channel['channel_id'],'large_photos')) ? 2 : 3);
+ $r = q("select mimetype, height, width from photo where resource_id = '%s' and $resolution = %d and uid = %d limit 1",
+ dbesc($resource),
+ intval($resolution),
+ intval($channel['channel_id'])
);
- if (!$r) {
- json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
- }
- $obj = json_decode($r[0]['obj'], true);
- if (x($obj, 'body')) {
- $photolink = $obj['body'];
- } elseif (x($obj, 'bbcode')) {
- $photolink = $obj['bbcode'];
- } else {
- json_return_and_die(array('errormsg' => 'Error retrieving resource ' . $resource_id, 'status' => false));
- }
- json_return_and_die(array('status' => true, 'photolink' => $photolink, 'resource_id' => $resource_id));
+ if(! $r)
+ return $output;
+
+ if($r[0]['mimetype'] === 'image/jpeg')
+ $ext = '.jpg';
+ elseif($r[0]['mimetype'] === 'image/png')
+ $ext = '.png';
+ elseif($r[0]['mimetype'] === 'image/gif')
+ $ext = '.gif';
+ else
+ $ext = EMPTY_STR;
+
+ $output = '[zrl=' . z_root() . '/photos/' . $channel['channel_address'] . '/image/' . $resource . ']' .
+ '[zmg=' . $r[0]['width'] . 'x' . $r[0]['height'] . ']' . z_root() . '/photo/' . $resource . '-' . $resolution . $ext . '[/zmg][/zrl]';
+
+ return $output;
}
}
+
/**
* @brief Get photos from an album.
*
diff --git a/include/permissions.php b/include/permissions.php
index 1dcd6accb..501b2cc77 100644
--- a/include/permissions.php
+++ b/include/permissions.php
@@ -157,7 +157,7 @@ function get_all_perms($uid, $observer_xchan, $check_siteblock = true, $default_
// If we're still here, we have an observer, check the network.
if($channel_perm & PERMS_NETWORK) {
- if($x && $x[0]['xchan_network'] === 'zot') {
+ if($x && in_array($x[0]['xchan_network'],[ 'zot','zot6'])) {
$ret[$perm_name] = true;
continue;
}
@@ -321,6 +321,14 @@ function perm_is_allowed($uid, $observer_xchan, $permission, $check_siteblock =
dbesc($observer_xchan)
);
if($y) {
+
+ // This requires an explanation and the effects are subtle.
+ // The following line creates a fake connection, and this allows
+ // access tokens to have specific permissions even though they are
+ // not actual connections.
+ // The existence of this fake entry must be checked when dealing
+ // with connection related permissions.
+
$x = array(pseudo_abook($y[0]));
}
}
@@ -349,6 +357,7 @@ function perm_is_allowed($uid, $observer_xchan, $permission, $check_siteblock =
return true;
// If it's an unauthenticated observer, we only need to see if PERMS_PUBLIC is set
+ // We just did that.
if(! $observer_xchan) {
return false;
@@ -357,7 +366,7 @@ function perm_is_allowed($uid, $observer_xchan, $permission, $check_siteblock =
// If we're still here, we have an observer, check the network.
if($channel_perm & PERMS_NETWORK) {
- if (($x && $x[0]['xchan_network'] === 'zot') || ($y && $y[0]['xchan_network'] === 'zot'))
+ if ($x && in_array($x[0]['xchan_network'], ['zot','zot6']))
return true;
}
@@ -373,8 +382,7 @@ function perm_is_allowed($uid, $observer_xchan, $permission, $check_siteblock =
return false;
}
- // From here on we require that the observer be a connection and
- // handle whether we're allowing any, approved or specific ones
+ // From here on we require that the observer be a connection or pseudo connection
if(! $x) {
return false;