Merge branch 'dev'

This commit is contained in:
zotlabs 2020-02-24 17:47:08 -08:00
commit 4b77ee67f8
12 changed files with 189 additions and 51 deletions

View file

@ -401,11 +401,49 @@ class Activity {
}
}
}
if ($item['iconfig']) {
foreach ($item['iconfig'] as $att) {
if ($att['sharing']) {
$ret[] = [ 'type' => 'PropertyValue', 'name' => 'zot.' . $att['cat'] . '.' . $att['k'], 'value' => unserialise($att['v']) ];
}
}
}
return $ret;
}
static function decode_iconfig($item) {
$ret = [];
if (is_array($item['attachment']) && $item['attachment']) {
$ptr = $item['attachment'];
if (! array_key_exists(0,$ptr)) {
$ptr = [ $ptr ];
}
foreach ($ptr as $att) {
$entry = [];
if ($att['type'] === 'PropertyValue') {
if (array_key_exists('name',$att) && $att['name']) {
$key = explode('.',$att['name']);
if (count($key) === 3 && $key[0] === 'zot') {
$entry['cat'] = $key[1];
$entry['k'] = $key[2];
$entry['v'] = $att['value'];
$entry['sharing'] = '1';
$ret[] = $entry;
}
}
}
}
}
return $ret;
}
static function decode_attachment($item) {
$ret = [];
@ -2038,14 +2076,13 @@ class Activity {
$s['app'] = escape_tags($generator['name']);
}
if (! $response_activity) {
$a = self::decode_taxonomy($act->obj);
if ($a) {
$s['term'] = $a;
foreach ($a as $b) {
if ($b['ttype'] === TERM_EMOJI) {
$s['title'] = str_replace($b['term'],'[img=16x16]' . $b['url'] . '[/img]',$s['title']);
// $s['title'] = str_replace($b['term'],'[img=16x16]' . $b['url'] . '[/img]',$s['title']);
$s['summary'] = str_replace($b['term'],'[img=16x16]' . $b['url'] . '[/img]',$s['summary']);
$s['body'] = str_replace($b['term'],'[img=16x16]' . $b['url'] . '[/img]',$s['body']);
}
@ -2056,8 +2093,14 @@ class Activity {
if ($a) {
$s['attach'] = $a;
}
$a = self::decode_iconfig($act->obj);
if ($a) {
$s['iconfig'] = $a;
}
}
if ($act->obj['type'] === 'Note' && $s['attach']) {
$s['body'] .= self::bb_attach($s['attach'],$s['body']);
}

View file

@ -29,8 +29,9 @@ class Apschema extends \Zotlabs\Web\Controller {
'expires' => 'zot:expires',
'directMessage' => 'zot:directMessage',
'replyTo' => 'zot:replyTo',
'meta' => 'zot:meta',
'value' => 'zot:value',
'schema' => 'http://schema.org#',
'PropertyValue' => 'schema:PropertyValue',
'value' => 'schema:value',
]
];

View file

@ -498,7 +498,7 @@ class Channel extends Controller {
}
}
if ($is_owner && $update_unseen) {
if ($is_owner && $update_unseen && (! $_SESSION['sudo'])) {
$x = [ 'channel_id' => local_channel(), 'update' => 'unset' ];
call_hooks('update_unseen',$x);
if ($x['update'] === 'unset' || intval($x['update'])) {

View file

@ -1,23 +1,25 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Web\Controller;
class Notify extends \Zotlabs\Web\Controller {
class Notify extends Controller {
function init() {
if(! local_channel())
if (! local_channel()) {
return;
}
if(argc() > 2 && argv(1) === 'view' && intval(argv(2))) {
if (argc() > 2 && argv(1) === 'view' && intval(argv(2))) {
$r = q("select * from notify where id = %d and uid = %d limit 1",
intval(argv(2)),
intval(local_channel())
);
if($r) {
if ($r) {
$x = [ 'channel_id' => local_channel(), 'update' => 'unset' ];
call_hooks('update_unseen',$x);
if($x['update'] === 'unset' || intval($x['update'])) {
if ((! $_SESSION['sudo']) && ($x['update'] === 'unset' || intval($x['update']))) {
q("update notify set seen = 1 where (( parent != '' and parent = '%s' and otype = '%s' ) or link = '%s' ) and uid = %d",
dbesc($r[0]['parent']),
dbesc($r[0]['otype']),
@ -35,19 +37,19 @@ class Notify extends \Zotlabs\Web\Controller {
function get() {
if(! local_channel())
if (! local_channel()) {
return login();
}
$notif_tpl = get_markup_template('notifications.tpl');
$not_tpl = get_markup_template('notify.tpl');
require_once('include/bbcode.php');
$r = q("SELECT * from notify where uid = %d and seen = 0 order by created desc",
intval(local_channel())
);
if($r) {
if ($r) {
foreach ($r as $it) {
$notif_content .= replace_macros($not_tpl,array(
'$item_link' => z_root().'/notify/view/'. $it['id'],

View file

@ -232,7 +232,7 @@ class Ping extends Controller {
*/
// mark all items read
if (x($_REQUEST, 'markRead') && local_channel()) {
if (x($_REQUEST, 'markRead') && local_channel() && (! $_SESSION['sudo'])) {
switch ($_REQUEST['markRead']) {
case 'stream':
$r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND item_unseen = 1",
@ -269,7 +269,7 @@ class Ping extends Controller {
}
}
if (x($_REQUEST, 'markItemRead') && local_channel()) {
if (x($_REQUEST, 'markItemRead') && local_channel() && (! $_SESSION['sudo'])) {
$r = q("UPDATE item SET item_unseen = 0 WHERE uid = %d AND parent = %d",
intval(local_channel()),
intval($_REQUEST['markItemRead'])

View file

@ -589,7 +589,7 @@ class Stream extends Controller {
}
}
if ($update_unseen) {
if ($update_unseen && (! $_SESSION['sudo'])) {
$x = [ 'channel_id' => local_channel(), 'update' => 'unset' ];
call_hooks('update_unseen',$x);
if ($x['update'] === 'unset' || intval($x['update'])) {

34
Zotlabs/Module/Sudo.php Normal file
View file

@ -0,0 +1,34 @@
<?php
namespace Zotlabs\Module;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Config;
class Sudo extends Controller {
function init() {
if ((argc() < 2) || (! intval(Config::Get('system','allow_sudo')))) {
http_status_exit(404,'Not found');
}
if (! is_site_admin()) {
http_status_exit(403,'Permission denied');
}
$c = channelx_by_nick(argv(1));
if ($c) {
$tmp = $_SESSION;
$_SESSION['delegate_push'] = $tmp;
$_SESSION['delegate_channel'] = $c['channel_id'];
$_SESSION['delegate'] = get_observer_hash();
$_SESSION['account_id'] = intval($c['channel_account_id']);
$_SESSION['sudo'] = 1;
change_channel($c['channel_id']);
goaway(z_root());
}
}
}

View file

@ -48,7 +48,7 @@ require_once('include/items.php');
define ( 'STD_VERSION', '20.02.21' );
define ( 'STD_VERSION', '20.02.25' );
define ( 'ZOT_REVISION', '6.0' );
define ( 'DB_UPDATE_VERSION', 1237 );
@ -472,7 +472,7 @@ define ( 'NAMESPACE_YMEDIA', 'http://search.yahoo.com/mrss/' );
define ( 'ACTIVITYSTREAMS_JSONLD_REV', 'https://www.w3.org/ns/activitystreams' );
define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.15' );
define ( 'ZOT_APSCHEMA_REV', '/apschema/v1.16' );
/**
* activity stream defines

View file

@ -209,7 +209,7 @@ if((isset($_SESSION)) && (x($_SESSION, 'authenticated')) &&
// if our authenticated guest is allowed to take control of the admin channel, make it so.
$admins = get_config('system', 'remote_admin');
if($admins && is_array($admins) && in_array($_SESSION['visitor_id'], $admins)) {
$x = q("select * from account where account_email = '%s' and account_email != '' and ( account_flags & %d )>0 limit 1",
$x = q("select * from account where account_email = '%s' and account_email != '' and ( account_flags & %d ) > 0 limit 1",
dbesc(get_config('system', 'admin_email')),
intval(ACCOUNT_ROLE_ADMIN)
);

View file

@ -38,7 +38,7 @@ function authenticate_success($user_record, $channel = null, $login_initial = fa
change_channel($uid_to_load);
}
if($login_initial || $update_lastlog) {
if(($login_initial || $update_lastlog) && (! $_SESSION['sudo'])) {
q("update account set account_lastlog = '%s' where account_id = %d",
dbesc(datetime_convert()),
intval($_SESSION['account_id'])
@ -67,7 +67,7 @@ function authenticate_success($user_record, $channel = null, $login_initial = fa
// don't let members get redirected to a raw ajax page update - this can happen
// if DHCP changes the IP address at an unfortunate time and paranoia is turned on
if(strstr($return_url,'update_'))
if(strstr($return_url,'update'))
$return_url = '';
unset($_SESSION['login_return_url']);
@ -95,7 +95,7 @@ function atoken_login($atoken) {
$_SESSION['visitor_id'] = $atoken['xchan_hash'];
$_SESSION['atoken'] = $atoken['atoken_id'];
\App::set_observer($atoken);
App::set_observer($atoken);
return true;
}
@ -269,7 +269,7 @@ function change_channel($change_channel) {
// Update the active timestamp at most once a day
if(substr($r[0]['channel_active'],0,10) !== substr(datetime_convert(),0,10)) {
if(substr($r[0]['channel_active'],0,10) !== substr(datetime_convert(),0,10) && (! $_SESSION['sudo'])) {
$z = q("UPDATE channel SET channel_active = '%s' WHERE channel_id = %d",
dbesc(datetime_convert()),
intval($r[0]['channel_id'])

View file

@ -1332,37 +1332,50 @@ function theme_attachments(&$item) {
$arr = json_decode($item['attach'],true);
if(is_array($arr) && count($arr)) {
if (is_array($arr) && count($arr)) {
$attaches = array();
foreach($arr as $r) {
foreach ($arr as $r) {
$label = EMPTY_STR;
$icon = getIconFromType($r['type']);
if($r['title'])
if ($r['title']) {
$label = urldecode(htmlspecialchars($r['title'], ENT_COMPAT, 'UTF-8'));
}
if(! $label && $r['href'])
$label = basename($r['href']);
if (! $label) {
if ($r['href']) {
$m = parse_url($r['href']);
if ($m && $m['path']) {
$label = basename($m['path']);
}
}
}
//some feeds provide an attachment where title an empty space
if(! $label || $label == ' ')
// some feeds provide an attachment where title is an empty space
if (! trim($label)) {
$label = t('Unknown Attachment');
}
$title = t('Size') . ' ' . (($r['length']) ? userReadableSize($r['length']) : t('unknown'));
require_once('include/channel.php');
if(is_foreigner($item['author_xchan']))
if (is_foreigner($item['author_xchan'])) {
$url = $r['href'];
else
}
else {
$url = z_root() . '/magic?f=&owa=1&hash=' . $item['author_xchan'] . '&bdest=' . bin2hex($r['href'] . '/' . $r['revision']);
//$s .= '<a href="' . $url . '" title="' . $title . '" class="attachlink" >' . $icon . '</a>';
$attaches[] = array('label' => $label, 'url' => $url, 'icon' => $icon, 'title' => $title);
}
$attaches[] = [
'label' => $label,
'url' => $url,
'icon' => $icon,
'title' => $title
];
}
$s = replace_macros(get_markup_template('item_attach.tpl'), array(
'$attaches' => $attaches
));
$s = replace_macros(get_markup_template('item_attach.tpl'), [
'$attaches' => $attaches
]);
}
return $s;

View file

@ -42,22 +42,67 @@ if(cache_uid !== localUser.toString()) {
$.ajaxSetup({cache: false});
var region = 0;
$(document).ready(function() {
$(document).on('click focus', '.comment-edit-form', handle_comment_form);
// $(document).swipe( {
// swipeRight:function(event,direction,distance,duration,fingerCount,fingerData,currentDirection) {
// $('#region_1').show();
// $('#region_2').show();
// $('#region_3').hide();
// },
// swipeLeft:function(event,direction,distance,duration,fingerCount,fingerData,currentDirection) {
// $('#region_1').hide();
// $('#region_2').show();
// $('#region_3').show();
// }
// });
$(document).swipe( {
preventDefaultEvents: false,
swipeLeft:function(event,direction,distance,duration,fingerCount,fingerData,currentDirection) {
// if (region == 0) {
// $('#region_1').show();
// $('#region_2').show();
// $('#region_3').show();
// region = 1;
// }
// else if (region == 1) {
// $('#region_1').show();
// $('#region_2').hide();
// $('#region_3').hide();
// region = 2;
// }
// else if (region == 2) {
// $('#region_1').hide();
// $('#region_2').show();
// $('#region_3').hide();
// region = 3;
// }
// else if (region == 3) {
// $('#region_1').hide();
// $('#region_2').hide();
// $('#region_3').show();
// region = 0;
// }
},
swipeRight:function(event,direction,distance,duration,fingerCount,fingerData,currentDirection) {
// if (region == 0) {
// $('#region_1').show();
// $('#region_2').show();
// $('#region_3').show();
// region = 3;
// }
// else if (region == 1) {
// $('#region_1').show();
// $('#region_2').hide();
// $('#region_3').hide();
// region = 0;
// }
// else if (region == 2) {
// $('#region_1').hide();
// $('#region_2').show();
// $('#region_3').hide();
// region = 1;
// }
// else if (region == 3) {
// $('#region_1').hide();
// $('#region_2').hide();
// $('#region_3').show();
// region = 2;
// }
}
});