aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Module
diff options
context:
space:
mode:
authorManuel Jiménez Friaza <mjfriaza@openmailbox.org>2019-08-11 10:39:03 +0200
committerManuel Jiménez Friaza <mjfriaza@openmailbox.org>2019-08-11 10:39:03 +0200
commitb89d2d7580e40cd417defaffd2514b5eed38577d (patch)
tree78ba9004d87b994dd9a531b475fd51b940bf3dd8 /Zotlabs/Module
parent350e636e3d0a44323c69185555e89cc01a213aa2 (diff)
parent047dd31724f8da12c153b4a6f27dc5462f7b97e5 (diff)
downloadvolse-hubzilla-b89d2d7580e40cd417defaffd2514b5eed38577d.tar.gz
volse-hubzilla-b89d2d7580e40cd417defaffd2514b5eed38577d.tar.bz2
volse-hubzilla-b89d2d7580e40cd417defaffd2514b5eed38577d.zip
Merge remote-tracking branch 'upstream/dev' into dev
Diffstat (limited to 'Zotlabs/Module')
-rw-r--r--Zotlabs/Module/Apschema.php13
-rw-r--r--Zotlabs/Module/Cal.php431
-rw-r--r--Zotlabs/Module/Cdav.php116
-rw-r--r--Zotlabs/Module/Channel.php13
-rw-r--r--Zotlabs/Module/Channel_calendar.php157
-rw-r--r--Zotlabs/Module/Dav.php9
-rw-r--r--Zotlabs/Module/Dirsearch.php2
-rw-r--r--Zotlabs/Module/Embedphotos.php2
-rw-r--r--Zotlabs/Module/Events.php9
-rw-r--r--Zotlabs/Module/Getfile.php6
-rw-r--r--Zotlabs/Module/Group.php2
-rw-r--r--Zotlabs/Module/Id.php2
-rw-r--r--Zotlabs/Module/Item.php42
-rw-r--r--Zotlabs/Module/Linkinfo.php27
-rw-r--r--Zotlabs/Module/Lockview.php2
-rw-r--r--Zotlabs/Module/Magic.php7
-rw-r--r--Zotlabs/Module/Mail.php9
-rw-r--r--Zotlabs/Module/Owa.php6
-rw-r--r--Zotlabs/Module/Photo.php4
-rw-r--r--Zotlabs/Module/Ping.php3
-rw-r--r--Zotlabs/Module/Search.php4
-rw-r--r--Zotlabs/Module/Share.php2
-rw-r--r--Zotlabs/Module/Zfinger.php8
-rw-r--r--Zotlabs/Module/Zot_probe.php2
24 files changed, 438 insertions, 440 deletions
diff --git a/Zotlabs/Module/Apschema.php b/Zotlabs/Module/Apschema.php
index 5b249bfe8..756057a8a 100644
--- a/Zotlabs/Module/Apschema.php
+++ b/Zotlabs/Module/Apschema.php
@@ -27,7 +27,9 @@ class Apschema extends \Zotlabs\Web\Controller {
'nomadicLocation' => 'zot:nomadicLocation',
'nomadicHubs' => 'zot:nomadicHubs',
'emojiReaction' => 'zot:emojiReaction',
-
+ 'expires' => 'zot:expires',
+ 'directMessage' => 'zot:directMessage',
+
'magicEnv' => [
'@id' => 'zot:magicEnv',
'@type' => '@id'
@@ -39,8 +41,13 @@ class Apschema extends \Zotlabs\Web\Controller {
],
'ostatus' => 'http://ostatus.org#',
- 'conversation' => 'ostatus:conversation'
+ 'conversation' => 'ostatus:conversation',
+
+ 'diaspora' => 'https://diasporafoundation.org/ns/',
+ 'guid' => 'diaspora:guid',
+ 'Hashtag' => 'as:Hashtag'
+
]
];
@@ -53,4 +60,4 @@ class Apschema extends \Zotlabs\Web\Controller {
-} \ No newline at end of file
+}
diff --git a/Zotlabs/Module/Cal.php b/Zotlabs/Module/Cal.php
index 70098a2a1..07bee38bd 100644
--- a/Zotlabs/Module/Cal.php
+++ b/Zotlabs/Module/Cal.php
@@ -1,6 +1,10 @@
<?php
namespace Zotlabs\Module;
+
+use App;
+use Zotlabs\Web\Controller;
+
require_once('include/conversation.php');
require_once('include/bbcode.php');
require_once('include/datetime.php');
@@ -9,15 +13,13 @@ require_once('include/items.php');
require_once('include/html2plain.php');
-class Cal extends \Zotlabs\Web\Controller {
+class Cal extends Controller {
function init() {
if(observer_prohibited()) {
return;
}
- $o = '';
-
if(argc() > 1) {
$nick = argv(1);
@@ -25,19 +27,21 @@ class Cal extends \Zotlabs\Web\Controller {
$channelx = channelx_by_nick($nick);
- if(! $channelx)
+ if(! $channelx) {
+ notice( t('Channel not found.') . EOL);
return;
+ }
- \App::$data['channel'] = $channelx;
+ App::$data['channel'] = $channelx;
- $observer = \App::get_observer();
- \App::$data['observer'] = $observer;
+ $observer = App::get_observer();
+ App::$data['observer'] = $observer;
$observer_xchan = (($observer) ? $observer['xchan_hash'] : '');
- head_set_icon(\App::$data['channel']['xchan_photo_s']);
+ head_set_icon(App::$data['channel']['xchan_photo_s']);
- \App::$page['htmlhead'] .= "<script> var profile_uid = " . ((\App::$data['channel']) ? \App::$data['channel']['channel_id'] : 0) . "; </script>" ;
+ App::$page['htmlhead'] .= "<script> var profile_uid = " . ((App::$data['channel']) ? App::$data['channel']['channel_id'] : 0) . "; </script>" ;
}
@@ -52,18 +56,8 @@ class Cal extends \Zotlabs\Web\Controller {
return;
}
- $channel = null;
-
- if(argc() > 1) {
- $channel = channelx_by_nick(argv(1));
- }
-
-
- if(! $channel) {
- notice( t('Channel not found.') . EOL);
- return;
- }
-
+ $channel = App::$data['channel'];
+
// since we don't currently have an event permission - use the stream permission
if(! perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_stream')) {
@@ -72,287 +66,152 @@ class Cal extends \Zotlabs\Web\Controller {
}
nav_set_selected('Calendar');
+
+ head_add_css('/library/fullcalendar/packages/core/main.min.css');
+ head_add_css('/library/fullcalendar/packages/daygrid/main.min.css');
+ head_add_css('cdav_calendar.css');
+
+ head_add_js('/library/fullcalendar/packages/core/main.min.js');
+ head_add_js('/library/fullcalendar/packages/daygrid/main.min.js');
+
+ $sql_extra = permissions_sql($channel['channel_id'], get_observer_hash(), 'event');
+
+ if(! perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_contacts') || App::$profile['hide_friends'])
+ $sql_extra .= " and etype != 'birthday' ";
- $sql_extra = permissions_sql($channel['channel_id'],get_observer_hash(),'event');
-
- $first_day = feature_enabled($channel['channel_id'], 'events_cal_first_day');
+ $first_day = feature_enabled($channel['channel_id'], 'cal_first_day');
$first_day = (($first_day) ? $first_day : 0);
- $htpl = get_markup_template('event_head.tpl');
- \App::$page['htmlhead'] .= replace_macros($htpl,array(
- '$baseurl' => z_root(),
- '$module_url' => '/cal/' . $channel['channel_address'],
- '$modparams' => 2,
- '$lang' => \App::$language,
- '$first_day' => $first_day
- ));
-
- $o = '';
-
- $mode = 'view';
- $y = 0;
- $m = 0;
- $ignored = ((x($_REQUEST,'ignored')) ? " and dismissed = " . intval($_REQUEST['ignored']) . " " : '');
-
- // logger('args: ' . print_r(\App::$argv,true));
+ $start = '';
+ $finish = '';
+
+ if (argv(2) === 'json') {
+ if (x($_GET,'start')) $start = $_GET['start'];
+ if (x($_GET,'end')) $finish = $_GET['end'];
+ }
- if(argc() > 3 && intval(argv(2)) && intval(argv(3))) {
- $mode = 'view';
- $y = intval(argv(2));
- $m = intval(argv(3));
+ $start = datetime_convert('UTC','UTC',$start);
+ $finish = datetime_convert('UTC','UTC',$finish);
+ $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
+ $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
+
+ if (x($_GET, 'id')) {
+ $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id
+ from event left join item on item.resource_id = event.event_hash
+ where item.resource_type = 'event' and event.uid = %d and event.id = %d $sql_extra limit 1",
+ intval($channel['channel_id']),
+ intval($_GET['id'])
+ );
}
- if(argc() <= 3) {
- $mode = 'view';
- $event_id = argv(2);
+ else {
+ // fixed an issue with "nofinish" events not showing up in the calendar.
+ // There's still an issue if the finish date crosses the end of month.
+ // Noting this for now - it will need to be fixed here and in Friendica.
+ // Ultimately the finish date shouldn't be involved in the query.
+ $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id
+ from event left join item on event.event_hash = item.resource_id
+ where item.resource_type = 'event' and event.uid = %d and event.uid = item.uid
+ AND (( event.adjust = 0 AND ( event.dtend >= '%s' or event.nofinish = 1 ) AND event.dtstart <= '%s' )
+ OR ( event.adjust = 1 AND ( event.dtend >= '%s' or event.nofinish = 1 ) AND event.dtstart <= '%s' ))
+ $sql_extra",
+ intval($channel['channel_id']),
+ dbesc($start),
+ dbesc($finish),
+ dbesc($adjust_start),
+ dbesc($adjust_finish)
+ );
}
- if($mode == 'view') {
-
- /* edit/create form */
- if($event_id) {
- $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1",
- dbesc($event_id),
- intval($channel['channel_id'])
- );
- if(count($r))
- $orig_event = $r[0];
- }
-
-
- // Passed parameters overrides anything found in the DB
- if(!x($orig_event))
- $orig_event = array();
-
-
-
- $tz = date_default_timezone_get();
- if(x($orig_event))
- $tz = (($orig_event['adjust']) ? date_default_timezone_get() : 'UTC');
-
- $syear = datetime_convert('UTC', $tz, $sdt, 'Y');
- $smonth = datetime_convert('UTC', $tz, $sdt, 'm');
- $sday = datetime_convert('UTC', $tz, $sdt, 'd');
- $shour = datetime_convert('UTC', $tz, $sdt, 'H');
- $sminute = datetime_convert('UTC', $tz, $sdt, 'i');
-
- $stext = datetime_convert('UTC',$tz,$sdt);
- $stext = substr($stext,0,14) . "00:00";
-
- $fyear = datetime_convert('UTC', $tz, $fdt, 'Y');
- $fmonth = datetime_convert('UTC', $tz, $fdt, 'm');
- $fday = datetime_convert('UTC', $tz, $fdt, 'd');
- $fhour = datetime_convert('UTC', $tz, $fdt, 'H');
- $fminute = datetime_convert('UTC', $tz, $fdt, 'i');
-
- $ftext = datetime_convert('UTC',$tz,$fdt);
- $ftext = substr($ftext,0,14) . "00:00";
-
- $type = ((x($orig_event)) ? $orig_event['etype'] : 'event');
-
- $f = get_config('system','event_input_format');
- if(! $f)
- $f = 'ymd';
-
- $catsenabled = feature_enabled($channel['channel_id'],'categories');
-
-
- $show_bd = perm_is_allowed($channel['channel_id'], get_observer_hash(), 'view_contacts');
- if(! $show_bd) {
- $sql_extra .= " and event.etype != 'birthday' ";
- }
-
-
- $category = '';
-
- $thisyear = datetime_convert('UTC',date_default_timezone_get(),'now','Y');
- $thismonth = datetime_convert('UTC',date_default_timezone_get(),'now','m');
- if(! $y)
- $y = intval($thisyear);
- if(! $m)
- $m = intval($thismonth);
-
- // Put some limits on dates. The PHP date functions don't seem to do so well before 1900.
- // An upper limit was chosen to keep search engines from exploring links millions of years in the future.
-
- if($y < 1901)
- $y = 1900;
- if($y > 2099)
- $y = 2100;
-
- $nextyear = $y;
- $nextmonth = $m + 1;
- if($nextmonth > 12) {
- $nextmonth = 1;
- $nextyear ++;
- }
-
- $prevyear = $y;
- if($m > 1)
- $prevmonth = $m - 1;
- else {
- $prevmonth = 12;
- $prevyear --;
- }
-
- $dim = get_dim($y,$m);
- $start = sprintf('%d-%d-%d %d:%d:%d',$y,$m,1,0,0,0);
- $finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59);
-
-
- if (argv(2) === 'json'){
- if (x($_GET,'start')) $start = $_GET['start'];
- if (x($_GET,'end')) $finish = $_GET['end'];
- }
-
- $start = datetime_convert('UTC','UTC',$start);
- $finish = datetime_convert('UTC','UTC',$finish);
-
- $adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
- $adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
+ if($r) {
+ xchan_query($r);
+ $r = fetch_post_tags($r,true);
+ $r = sort_by_date($r);
+ }
+
+ $events = [];
+ if($r) {
- if(! perm_is_allowed(\App::$profile['uid'],get_observer_hash(),'view_contacts'))
- $sql_extra .= " and etype != 'birthday' ";
+ foreach($r as $rr) {
- if (x($_GET,'id')){
- $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan
- from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d $sql_extra limit 1",
- intval($channel['channel_id']),
- intval($_GET['id'])
- );
- }
- else {
- // fixed an issue with "nofinish" events not showing up in the calendar.
- // There's still an issue if the finish date crosses the end of month.
- // Noting this for now - it will need to be fixed here and in Friendica.
- // Ultimately the finish date shouldn't be involved in the query.
-
- $r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan
- from event left join item on event_hash = resource_id
- where resource_type = 'event' and event.uid = %d and event.uid = item.uid $ignored
- AND (( adjust = 0 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )
- OR ( adjust = 1 AND ( dtend >= '%s' or nofinish = 1 ) AND dtstart <= '%s' )) $sql_extra ",
- intval($channel['channel_id']),
- dbesc($start),
- dbesc($finish),
- dbesc($adjust_start),
- dbesc($adjust_finish)
- );
-
- }
-
- $links = array();
-
- if($r) {
- xchan_query($r);
- $r = fetch_post_tags($r,true);
-
- $r = sort_by_date($r);
- }
-
- if($r) {
- foreach($r as $rr) {
- $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j'));
- if(! x($links,$j))
- $links[$j] = z_root() . '/' . \App::$cmd . '#link-' . $j;
+ $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'));
+ 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'));
}
- }
-
- $events=array();
-
- $last_date = '';
- $fmt = t('l, F j');
-
- if($r) {
-
- foreach($r as $rr) {
-
- $j = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'j') : datetime_convert('UTC','UTC',$rr['dtstart'],'j'));
- $d = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], $fmt) : datetime_convert('UTC','UTC',$rr['dtstart'],$fmt));
- $d = day_translate($d);
-
- $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('UTC',date_default_timezone_get(),$rr['dtend'], 'c') : datetime_convert('UTC','UTC',$rr['dtend'],'c'));
- }
-
-
- $is_first = ($d !== $last_date);
-
- $last_date = $d;
-
- $edit = false;
-
- $drop = false;
-
- $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
- if(! $title) {
- list($title, $_trash) = explode("<br",bbcode($rr['desc']),2);
- $title = strip_tags(html_entity_decode($title,ENT_QUOTES,'UTF-8'));
- }
+
+ $html = '';
+ if (x($_GET,'id')) {
+ $rr['timezone'] = $tz;
$html = format_event_html($rr);
- $rr['desc'] = zidify_links(smilies(bbcode($rr['desc'])));
- $rr['description'] = htmlentities(html2plain(bbcode($rr['description'])),ENT_COMPAT,'UTF-8',false);
- $rr['location'] = zidify_links(smilies(bbcode($rr['location'])));
- $events[] = array(
- 'id'=>$rr['id'],
- 'hash' => $rr['event_hash'],
- 'start'=> $start,
- 'end' => $end,
- 'drop' => $drop,
- 'allDay' => false,
- 'title' => $title,
-
- 'j' => $j,
- 'd' => $d,
- 'edit' => $edit,
- 'is_first'=>$is_first,
- 'item'=>$rr,
- 'html'=>$html,
- 'plink' => array($rr['plink'],t('Link to Source'),'',''),
- );
-
-
}
+
+ $events[] = array(
+ 'calendar_id' => 'channel_calendar',
+ 'rw' => true,
+ 'id'=>$rr['id'],
+ 'uri' => $rr['event_hash'],
+ 'timezone' => $tz,
+ 'start'=> $start,
+ 'end' => $end,
+ 'drop' => $drop,
+ 'allDay' => (($rr['adjust']) ? 0 : 1),
+ 'title' => html_entity_decode($rr['summary'], ENT_COMPAT, 'UTF-8'),
+ 'editable' => $edit ? true : false,
+ 'item' => $rr,
+ 'plink' => [$rr['plink'], t('Link to source')],
+ 'description' => html_entity_decode($rr['description'], ENT_COMPAT, 'UTF-8'),
+ 'location' => html_entity_decode($rr['location'], ENT_COMPAT, 'UTF-8'),
+ 'allow_cid' => expand_acl($rr['allow_cid']),
+ 'allow_gid' => expand_acl($rr['allow_gid']),
+ 'deny_cid' => expand_acl($rr['deny_cid']),
+ 'deny_gid' => expand_acl($rr['deny_gid']),
+ 'html' => $html
+ );
}
+ }
+
+ if (argv(2) === 'json') {
+ echo json_encode($events);
+ killme();
+ }
- if (argv(2) === 'json'){
- echo json_encode($events); killme();
- }
-
- // links: array('href', 'text', 'extra css classes', 'title')
- if (x($_GET,'id')){
- $tpl = get_markup_template("event_cal.tpl");
- }
- else {
- $tpl = get_markup_template("events_cal-js.tpl");
- }
-
- $nick = $channel['channel_address'];
-
- $o = replace_macros($tpl, array(
- '$baseurl' => z_root(),
- '$new_event' => array(z_root().'/cal',(($event_id) ? t('Edit Event') : t('Create Event')),'',''),
- '$previus' => array(z_root()."/cal/$nick/$prevyear/$prevmonth",t('Previous'),'',''),
- '$next' => array(z_root()."/cal/$nick/$nextyear/$nextmonth",t('Next'),'',''),
- '$export' => array(z_root()."/cal/$nick/$y/$m/export",t('Export'),'',''),
- '$calendar' => cal($y,$m,$links, ' eventcal'),
- '$events' => $events,
- '$upload' => t('Import'),
- '$submit' => t('Submit'),
- '$prev' => t('Previous'),
- '$next' => t('Next'),
- '$today' => t('Today'),
- '$form' => $form,
- '$expandform' => ((x($_GET,'expandform')) ? true : false)
- ));
-
- if (x($_GET,'id')){ echo $o; killme(); }
-
- return $o;
+ if (x($_GET,'id')) {
+ $o = replace_macros(get_markup_template("cal_event.tpl"), [
+ '$events' => $events
+ ]);
+ echo $o;
+ killme();
}
+
+ $nick = $channel['channel_address'];
+
+ $sources = '{
+ id: \'channel_calendar\',
+ url: \'/cal/' . $nick . '/json/\',
+ color: \'#3a87ad\'
+ }';
+
+ $o = replace_macros(get_markup_template("cal_calendar.tpl"), [
+ '$sources' => $sources,
+ '$lang' => App::$language,
+ '$timezone' => date_default_timezone_get(),
+ '$first_day' => $first_day,
+ '$prev' => t('Previous'),
+ '$next' => t('Next'),
+ '$today' => t('Today'),
+ '$title' => $title,
+ '$dtstart' => $dtstart,
+ '$dtend' => $dtend,
+ '$nick' => $nick
+ ]);
+
+ return $o;
}
diff --git a/Zotlabs/Module/Cdav.php b/Zotlabs/Module/Cdav.php
index 6b4f57ea5..e2855d2b6 100644
--- a/Zotlabs/Module/Cdav.php
+++ b/Zotlabs/Module/Cdav.php
@@ -4,6 +4,7 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Lib\Apps;
use Zotlabs\Web\Controller;
+use Zotlabs\Web\HTTPSig;
require_once('include/event.php');
@@ -41,7 +42,7 @@ class Cdav extends Controller {
continue;
}
- $sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]);
+ $sigblock = HTTPSig::parse_sigheader($_SERVER[$head]);
if($sigblock) {
$keyId = str_replace('acct:','',$sigblock['keyId']);
if($keyId) {
@@ -64,7 +65,7 @@ class Cdav extends Controller {
continue;
if($record) {
- $verified = \Zotlabs\Web\HTTPSig::verify('',$record['channel']['channel_pubkey']);
+ $verified = HTTPSig::verify('',$record['channel']['channel_pubkey']);
if(! ($verified && $verified['header_signed'] && $verified['header_valid'])) {
$record = null;
}
@@ -271,11 +272,17 @@ class Cdav extends Controller {
if(!cdav_perms($id[0],$calendars,true))
return;
+ $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
+ $tz = (($timezone) ? $timezone : date_default_timezone_get());
+
+ $allday = $_REQUEST['allday'];
+
$title = $_REQUEST['title'];
- $start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']);
+ $start = datetime_convert('UTC', 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start);
+
if($_REQUEST['dtend']) {
- $end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']);
+ $end = datetime_convert('UTC', 'UTC', $_REQUEST['dtend']);
$dtend = new \DateTime($end);
}
$description = $_REQUEST['description'];
@@ -301,16 +308,23 @@ class Cdav extends Controller {
'DTSTART' => $dtstart
]
]);
+
if($dtend) {
$vcalendar->VEVENT->add('DTEND', $dtend);
- $vcalendar->VEVENT->DTEND['TZID'] = App::$timezone;
+ if($allday)
+ $vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTEND['TZID'] = $tz;
}
if($description)
$vcalendar->VEVENT->add('DESCRIPTION', $description);
if($location)
$vcalendar->VEVENT->add('LOCATION', $location);
- $vcalendar->VEVENT->DTSTART['TZID'] = App::$timezone;
+ if($allday)
+ $vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTSTART['TZID'] = $tz;
$calendarData = $vcalendar->serialize();
@@ -348,12 +362,17 @@ class Cdav extends Controller {
if(!cdav_perms($id[0],$calendars,true))
return;
+ $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
+ $tz = (($timezone) ? $timezone : date_default_timezone_get());
+
+ $allday = $_REQUEST['allday'];
+
$uri = $_REQUEST['uri'];
$title = $_REQUEST['title'];
- $start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']);
+ $start = datetime_convert('UTC', 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start);
if($_REQUEST['dtend']) {
- $end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']);
+ $end = datetime_convert('UTC', 'UTC', $_REQUEST['dtend']);
$dtend = new \DateTime($end);
}
$description = $_REQUEST['description'];
@@ -365,12 +384,23 @@ class Cdav extends Controller {
if($title)
$vcalendar->VEVENT->SUMMARY = $title;
- if($dtstart)
+ if($dtstart) {
$vcalendar->VEVENT->DTSTART = $dtstart;
- if($dtend)
+ if($allday)
+ $vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTSTART['TZID'] = $tz;
+ }
+ if($dtend) {
$vcalendar->VEVENT->DTEND = $dtend;
+ if($allday)
+ $vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTEND['TZID'] = $tz;
+ }
else
unset($vcalendar->VEVENT->DTEND);
+
if($description)
$vcalendar->VEVENT->DESCRIPTION = $description;
if($location)
@@ -406,11 +436,16 @@ class Cdav extends Controller {
if(!cdav_perms($id[0],$calendars,true))
return;
+ $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
+ $tz = (($timezone) ? $timezone : date_default_timezone_get());
+
+ $allday = $_REQUEST['allday'];
+
$uri = $_REQUEST['uri'];
- $start = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtstart']);
+ $start = datetime_convert('UTC', 'UTC', $_REQUEST['dtstart']);
$dtstart = new \DateTime($start);
if($_REQUEST['dtend']) {
- $end = datetime_convert(App::$timezone, 'UTC', $_REQUEST['dtend']);
+ $end = datetime_convert('UTC', 'UTC', $_REQUEST['dtend']);
$dtend = new \DateTime($end);
}
@@ -420,13 +455,20 @@ class Cdav extends Controller {
if($dtstart) {
$vcalendar->VEVENT->DTSTART = $dtstart;
+ if($allday)
+ $vcalendar->VEVENT->DTSTART['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTSTART['TZID'] = $tz;
}
if($dtend) {
$vcalendar->VEVENT->DTEND = $dtend;
+ if($allday)
+ $vcalendar->VEVENT->DTEND['VALUE'] = 'DATE';
+ else
+ $vcalendar->VEVENT->DTEND['TZID'] = $tz;
}
- else {
+ else
unset($vcalendar->VEVENT->DTEND);
- }
$calendarData = $vcalendar->serialize();
@@ -915,8 +957,13 @@ class Cdav extends Controller {
xchan_query($r);
$r = fetch_post_tags($r,true);
- $r[0]['dtstart'] = (($r[0]['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$r[0]['dtstart'], 'c') : datetime_convert('UTC','UTC',$r[0]['dtstart'],'c'));
- $r[0]['dtend'] = (($r[0]['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$r[0]['dtend'], 'c') : datetime_convert('UTC','UTC',$r[0]['dtend'],'c'));
+ $tz = get_iconfig($r[0], 'event', 'timezone');
+ if(! $tz)
+ $tz = 'UTC';
+
+ $r[0]['timezone'] = $tz;
+ $r[0]['dtstart'] = (($r[0]['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $r[0]['dtstart'], 'c') : datetime_convert('UTC', 'UTC', $r[0]['dtstart'], 'c'));
+ $r[0]['dtend'] = (($r[0]['adjust']) ? datetime_convert('UTC', date_default_timezone_get(), $r[0]['dtend'], 'c') : datetime_convert('UTC', 'UTC' ,$r[0]['dtend'], 'c'));
$r[0]['plink'] = [$r[0]['plink'], t('Link to source')];
@@ -984,9 +1031,11 @@ class Cdav extends Controller {
$first_day = feature_enabled(local_channel(), 'cal_first_day');
$first_day = (($first_day) ? $first_day : 0);
- $title = ['title', t('Event title')];
+ $title = ['title', t('Event title') ];
$dtstart = ['dtstart', t('Start date and time')];
$dtend = ['dtend', t('End date and time')];
+ $timezone_select = ['timezone_select' , t('Timezone:'), date_default_timezone_get(), '', get_timezones()];
+
$description = ['description', t('Description')];
$location = ['location', t('Location')];
@@ -1000,14 +1049,13 @@ class Cdav extends Controller {
//$acl = (($orig_event['event_xchan']) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $perm_defaults), false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream')));
$acl = populate_acl($perm_defaults, false, \Zotlabs\Lib\PermissionDescription::fromGlobalPermission('view_stream'));
- //$permissions = ((x($orig_event)) ? $orig_event : $perm_defaults);
- $permissions = $perm_defaults;
+ $permissions = (($resource_id) ? $resource : $perm_defaults);
$o .= replace_macros(get_markup_template('cdav_calendar.tpl'), [
'$sources' => $sources,
'$color' => $color,
'$lang' => App::$language,
- '$timezone' => App::$timezone,
+ '$timezone' => date_default_timezone_get(),
'$first_day' => $first_day,
'$prev' => t('Previous'),
'$next' => t('Next'),
@@ -1047,7 +1095,8 @@ class Cdav extends Controller {
'$categories_label' => t('Categories'),
'$resource' => json_encode($resource),
- '$categories' => $categories
+ '$categories' => $categories,
+ '$timezone_select' => ((feature_enabled(local_channel(),'event_tz_select')) ? $timezone_select : '')
]);
return $o;
@@ -1076,8 +1125,8 @@ class Cdav extends Controller {
$filters['comp-filters'][0]['time-range']['end'] = $end;
$uris = $caldavBackend->calendarQuery($id, $filters);
-
if($uris) {
+
$objects = $caldavBackend->getMultipleCalendarObjects($id, $uris);
foreach($objects as $object) {
@@ -1096,30 +1145,33 @@ class Cdav extends Controller {
$dtend = (string)$vevent->DTEND;
$description = (string)$vevent->DESCRIPTION;
$location = (string)$vevent->LOCATION;
- $timezone = (string)$vevent->DTSTART['TZID'];
+ $timezone_str = (string)$vevent->DTSTART['TZID'];
$rw = ((cdav_perms($id[0],$calendars,true)) ? true : false);
$editable = $rw ? true : false;
$recurrent = ((isset($vevent->{'RECURRENCE-ID'})) ? true : false);
if($recurrent) {
$editable = false;
- $timezone = $recurrent_timezone;
+ $timezone_str = $recurrent_timezone;
}
- $allDay = false;
+ // Try to get an usable olson format timezone
+ $timezone_obj = \Sabre\VObject\TimeZoneUtil::getTimeZone($timezone_str, $vcalendar);
+ $timezone = $timezone_obj->getName();
+
+ // If we got nothing fallback to UTC
+ if(! $timezone)
+ $timezone = 'UTC';
- // allDay event rules
- if(!strpos($dtstart, 'T') && !strpos($dtend, 'T'))
- $allDay = true;
- if(strpos($dtstart, 'T000000') && strpos($dtend, 'T000000'))
- $allDay = true;
+ $allDay = (((string)$vevent->DTSTART['VALUE'] == 'DATE') ? true : false);
$events[] = [
'calendar_id' => $id,
'uri' => $object['uri'],
'title' => $title,
- 'start' => datetime_convert($timezone, $timezone, $dtstart, 'c'),
- 'end' => (($dtend) ? datetime_convert($timezone, $timezone, $dtend, 'c') : ''),
+ 'timezone' => $timezone,
+ 'start' => datetime_convert($timezone, date_default_timezone_get(), $dtstart, 'c'),
+ 'end' => (($dtend) ? datetime_convert($timezone, date_default_timezone_get(), $dtend, 'c') : ''),
'description' => $description,
'location' => $location,
'allDay' => $allDay,
diff --git a/Zotlabs/Module/Channel.php b/Zotlabs/Module/Channel.php
index 144c2472a..b1639b213 100644
--- a/Zotlabs/Module/Channel.php
+++ b/Zotlabs/Module/Channel.php
@@ -6,7 +6,7 @@ namespace Zotlabs\Module;
use App;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\PermissionDescription;
-use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\HTTPSig;
use Zotlabs\Lib\Libzot;
require_once('include/items.php');
@@ -111,6 +111,17 @@ class Channel extends Controller {
// we start loading content
profile_load($which,$profile);
+
+ App::$page['htmlhead'] .= '<meta property="og:title" content="' . htmlspecialchars($channel['channel_name']) . '">' . "\r\n";
+ App::$page['htmlhead'] .= '<meta property="og:image" content="' . $channel['xchan_photo_l'] . '">' . "\r\n";
+
+ if(App::$profile['about'] && perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_profile')) {
+ App::$page['htmlhead'] .= '<meta property="og:description" content="' . htmlspecialchars(App::$profile['about']) . '">' . "\r\n";
+ }
+ else {
+ App::$page['htmlhead'] .= '<meta property="og:description" content="' . htmlspecialchars(sprintf( t('This is the home page of %s.'), $channel['channel_name'])) . '">' . "\r\n";
+ }
+
}
function get($update = 0, $load = false) {
diff --git a/Zotlabs/Module/Channel_calendar.php b/Zotlabs/Module/Channel_calendar.php
index 9229e6eb2..7d75a7e41 100644
--- a/Zotlabs/Module/Channel_calendar.php
+++ b/Zotlabs/Module/Channel_calendar.php
@@ -21,53 +21,21 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$event_hash = ((x($_POST,'event_hash')) ? $_POST['event_hash'] : '');
$xchan = ((x($_POST,'xchan')) ? dbesc($_POST['xchan']) : '');
- $uid = local_channel();
-
- $start_text = escape_tags($_REQUEST['dtstart']);
- $finish_text = escape_tags($_REQUEST['dtend']);
-
- $adjust = intval($_POST['adjust']);
- $nofinish = intval($_POST['nofinish']);
-
- $timezone = ((x($_POST,'timezone_select')) ? notags(trim($_POST['timezone_select'])) : '');
-
- $tz = (($timezone) ? $timezone : date_default_timezone_get());
+ $uid = local_channel();
- $categories = escape_tags(trim($_POST['categories']));
-
// only allow editing your own events.
-
if(($xchan) && ($xchan !== get_observer_hash()))
return;
-
- if($start_text) {
- $start = $start_text;
- }
- else {
- $start = sprintf('%d-%d-%d %d:%d:0',$startyear,$startmonth,$startday,$starthour,$startminute);
- }
- if($finish_text) {
- $finish = $finish_text;
- }
- else {
- $finish = sprintf('%d-%d-%d %d:%d:0',$finishyear,$finishmonth,$finishday,$finishhour,$finishminute);
- }
+ $timezone = ((x($_POST,'timezone_select')) ? escape_tags(trim($_POST['timezone_select'])) : '');
+ $tz = (($timezone) ? $timezone : date_default_timezone_get());
- if($nofinish) {
- $finish = NULL_DATE;
- }
+ $categories = escape_tags(trim($_POST['categories']));
+
+ $adjust = intval($_POST['adjust']);
- if($adjust) {
- $start = datetime_convert($tz,'UTC',$start);
- if(! $nofinish)
- $finish = datetime_convert($tz,'UTC',$finish);
- }
- else {
- $start = datetime_convert('UTC','UTC',$start);
- if(! $nofinish)
- $finish = datetime_convert('UTC','UTC',$finish);
- }
+ $start = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtstart']));
+ $finish = datetime_convert('UTC', 'UTC', escape_tags($_REQUEST['dtend']));
$summary = escape_tags(trim($_POST['summary']));
$desc = escape_tags(trim($_POST['desc']));
@@ -176,7 +144,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$datarray['location'] = $location;
$datarray['etype'] = $type;
$datarray['adjust'] = $adjust;
- $datarray['nofinish'] = $nofinish;
+ $datarray['nofinish'] = 0;
$datarray['uid'] = local_channel();
$datarray['account'] = get_account_id();
$datarray['event_xchan'] = $channel['channel_hash'];
@@ -188,6 +156,8 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$datarray['id'] = $event_id;
$datarray['created'] = $created;
$datarray['edited'] = $edited;
+ $datarray['timezone'] = $tz;
+
if(intval($_REQUEST['preview'])) {
$html = format_event_html($datarray);
@@ -322,10 +292,9 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
$start = datetime_convert('UTC','UTC',$start);
$finish = datetime_convert('UTC','UTC',$finish);
-
$adjust_start = datetime_convert('UTC', date_default_timezone_get(), $start);
$adjust_finish = datetime_convert('UTC', date_default_timezone_get(), $finish);
-
+
if (x($_GET,'id')){
$r = q("SELECT event.*, item.plink, item.item_flags, item.author_xchan, item.owner_xchan, item.id as item_id
from event left join item on item.resource_id = event.event_hash
@@ -335,7 +304,9 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
);
}
elseif($export) {
- $r = q("SELECT * from event where uid = %d and dtstart > '%s' and dtend > dtstart",
+ $r = q("SELECT event.*, item.id as item_id
+ from event left join item on item.resource_id = event.event_hash
+ where event.uid = %d and event.dtstart > '%s' and event.dtend > event.dtstart",
intval(local_channel()),
dbesc(NULL_DATE)
);
@@ -357,13 +328,11 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
dbesc($adjust_start),
dbesc($adjust_finish)
);
-
}
if($r && ! $export) {
xchan_query($r);
$r = fetch_post_tags($r,true);
-
$r = sort_by_date($r);
}
@@ -373,17 +342,16 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
foreach($r as $rr) {
- $start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtstart'], 'c') : datetime_convert('UTC','UTC',$rr['dtstart'],'c'));
+ $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'));
if ($rr['nofinish']){
$end = null;
} else {
- $end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['dtend'], 'c') : datetime_convert('UTC','UTC',$rr['dtend'],'c'));
-
- // give a fake end to birthdays so they get crammed into a
- // single day on the calendar
-
- if($rr['etype'] === 'birthday')
- $end = null;
+ $end = (($rr['adjust']) ? datetime_convert($tz, date_default_timezone_get(), $rr['dtend'], 'c') : datetime_convert('UTC', 'UTC', $rr['dtend'], 'c'));
}
$catsenabled = feature_enabled(local_channel(),'categories');
@@ -399,14 +367,6 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
}
}
- $allDay = false;
-
- // allDay event rules
- if(!strpos($start, 'T') && !strpos($end, 'T'))
- $allDay = true;
- if(strpos($start, 'T00:00:00') && strpos($end, 'T00:00:00'))
- $allDay = true;
-
$edit = ((local_channel() && $rr['author_xchan'] == get_observer_hash()) ? array(z_root().'/events/'.$rr['event_hash'].'?expandform=1',t('Edit event'),'','') : false);
$drop = array(z_root().'/events/drop/'.$rr['event_hash'],t('Delete event'),'','');
@@ -416,16 +376,17 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
'rw' => true,
'id'=>$rr['id'],
'uri' => $rr['event_hash'],
+ 'timezone' => $tz,
'start'=> $start,
'end' => $end,
'drop' => $drop,
- 'allDay' => $allDay,
- 'title' => htmlentities($rr['summary'], ENT_COMPAT, 'UTF-8', false),
+ 'allDay' => (($rr['adjust']) ? 0 : 1),
+ 'title' => html_entity_decode($rr['summary'], ENT_COMPAT, 'UTF-8'),
'editable' => $edit ? true : false,
- 'item'=>$rr,
+ 'item' => $rr,
'plink' => [$rr['plink'], t('Link to source')],
- 'description' => htmlentities($rr['description'], ENT_COMPAT, 'UTF-8', false),
- 'location' => htmlentities($rr['location'], ENT_COMPAT, 'UTF-8', false),
+ 'description' => html_entity_decode($rr['description'], ENT_COMPAT, 'UTF-8'),
+ 'location' => html_entity_decode($rr['location'], ENT_COMPAT, 'UTF-8'),
'allow_cid' => expand_acl($rr['allow_cid']),
'allow_gid' => expand_acl($rr['allow_gid']),
'deny_cid' => expand_acl($rr['deny_cid']),
@@ -441,7 +402,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
echo ical_wrapper($r);
killme();
}
-
+
if (\App::$argv[1] === 'json'){
json_return_and_die($events);
}
@@ -461,13 +422,67 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
dbesc($event_id),
intval(local_channel())
);
+
if($r) {
- $r = q("update item set resource_type = '', resource_id = '' where resource_type = 'event' and resource_id = '%s' and uid = %d",
+
+ $sync_event['event_deleted'] = 1;
+ build_sync_packet(0,array('event' => array($sync_event)));
+
+ $i = q("select * from item where resource_type = 'event' and resource_id = '%s' and uid = %d",
dbesc($event_id),
intval(local_channel())
);
- $sync_event['event_deleted'] = 1;
- build_sync_packet(0,array('event' => array($sync_event)));
+
+ if ($i) {
+
+ $can_delete = false;
+ $local_delete = true;
+
+ $ob_hash = get_observer_hash();
+ if($ob_hash && ($ob_hash === $i[0]['author_xchan'] || $ob_hash === $i[0]['owner_xchan'] || $ob_hash === $i[0]['source_xchan'])) {
+ $can_delete = true;
+ }
+
+ // The site admin can delete any post/item on the site.
+ // If the item originated on this site+channel the deletion will propagate downstream.
+ // Otherwise just the local copy is removed.
+
+ if(is_site_admin()) {
+ $local_delete = true;
+ if(intval($i[0]['item_origin']))
+ $can_delete = true;
+ }
+
+ if($can_delete || $local_delete) {
+
+ // if this is a different page type or it's just a local delete
+ // but not by the item author or owner, do a simple deletion
+
+ $complex = false;
+
+ if(intval($i[0]['item_type']) || ($local_delete && (! $can_delete))) {
+ drop_item($i[0]['id']);
+ }
+ else {
+ // complex deletion that needs to propagate and be performed in phases
+ drop_item($i[0]['id'],true,DROPITEM_PHASE1);
+ $complex = true;
+ }
+
+ $ii = q("select * from item where id = %d",
+ intval($i[0]['id'])
+ );
+ if($ii) {
+ xchan_query($ii);
+ $sync_item = fetch_post_tags($ii);
+ build_sync_packet($i[0]['uid'],array('item' => array(encode_item($sync_item[0],true))));
+ }
+
+ if($complex) {
+ tag_deliver($i[0]['uid'],$i[0]['id']);
+ }
+ }
+ }
killme();
}
notice( t('Failed to remove event' ) . EOL);
diff --git a/Zotlabs/Module/Dav.php b/Zotlabs/Module/Dav.php
index 9f64e2fea..866520461 100644
--- a/Zotlabs/Module/Dav.php
+++ b/Zotlabs/Module/Dav.php
@@ -8,8 +8,9 @@
namespace Zotlabs\Module;
-use \Sabre\DAV as SDAV;
-use \Zotlabs\Storage;
+use Sabre\DAV as SDAV;
+use Zotlabs\Storage;
+use Zotlabs\Web\HTTPSig;
require_once('include/attach.php');
require_once('include/auth.php');
@@ -46,7 +47,7 @@ class Dav extends \Zotlabs\Web\Controller {
continue;
}
- $sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]);
+ $sigblock = HTTPSig::parse_sigheader($_SERVER[$head]);
if($sigblock) {
$keyId = str_replace('acct:','',$sigblock['keyId']);
if($keyId) {
@@ -69,7 +70,7 @@ class Dav extends \Zotlabs\Web\Controller {
continue;
if($record) {
- $verified = \Zotlabs\Web\HTTPSig::verify('',$record['channel']['channel_pubkey']);
+ $verified = HTTPSig::verify('',$record['channel']['channel_pubkey']);
if(! ($verified && $verified['header_signed'] && $verified['header_valid'])) {
$record = null;
}
diff --git a/Zotlabs/Module/Dirsearch.php b/Zotlabs/Module/Dirsearch.php
index 26cb82044..92b33df0c 100644
--- a/Zotlabs/Module/Dirsearch.php
+++ b/Zotlabs/Module/Dirsearch.php
@@ -394,7 +394,7 @@ class Dirsearch extends \Zotlabs\Web\Controller {
$quoted_string = false;
}
else
- $curr['value'] .= ' ' . trim(q);
+ $curr['value'] .= ' ' . trim($q);
}
}
}
diff --git a/Zotlabs/Module/Embedphotos.php b/Zotlabs/Module/Embedphotos.php
index 8b0421457..6a88513dc 100644
--- a/Zotlabs/Module/Embedphotos.php
+++ b/Zotlabs/Module/Embedphotos.php
@@ -53,7 +53,7 @@ class Embedphotos extends \Zotlabs\Web\Controller {
$channel = \App::get_channel();
$output = EMPTY_STR;
if($channel) {
- $resolution = ((feature_enabled($channel['channel_id'],'large_photos')) ? 2 : 3);
+ $resolution = ((feature_enabled($channel['channel_id'],'large_photos')) ? 1 : 2);
$r = q("select mimetype, height, width from photo where resource_id = '%s' and $resolution = %d and uid = %d limit 1",
dbesc($resource),
intval($resolution),
diff --git a/Zotlabs/Module/Events.php b/Zotlabs/Module/Events.php
index e883db49f..681d6887d 100644
--- a/Zotlabs/Module/Events.php
+++ b/Zotlabs/Module/Events.php
@@ -11,6 +11,9 @@ require_once('include/html2plain.php');
class Events extends \Zotlabs\Web\Controller {
function post() {
+
+ // this module is deprecated
+ return;
logger('post: ' . print_r($_REQUEST,true), LOGGER_DATA);
@@ -245,6 +248,9 @@ class Events extends \Zotlabs\Web\Controller {
function get() {
+
+ // this module is deprecated
+ return;
if(argc() > 2 && argv(1) == 'ical') {
$event_id = argv(2);
@@ -662,9 +668,10 @@ class Events extends \Zotlabs\Web\Controller {
'html'=>$html,
'plink' => array($rr['plink'],t('Link to Source'),'',''),
);
+
}
}
-
+
if($export) {
header('Content-type: text/calendar');
header('content-disposition: attachment; filename="' . t('calendar') . '-' . $channel['channel_address'] . '.ics"' );
diff --git a/Zotlabs/Module/Getfile.php b/Zotlabs/Module/Getfile.php
index 583cf38f0..6d31d23fd 100644
--- a/Zotlabs/Module/Getfile.php
+++ b/Zotlabs/Module/Getfile.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Web\HTTPSig;
+
/**
* module: getfile
*
@@ -46,7 +48,7 @@ class Getfile extends \Zotlabs\Web\Controller {
continue;
}
- $sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]);
+ $sigblock = HTTPSig::parse_sigheader($_SERVER[$head]);
if($sigblock) {
$keyId = $sigblock['keyId'];
@@ -57,7 +59,7 @@ class Getfile extends \Zotlabs\Web\Controller {
);
if($r) {
$hubloc = $r[0];
- $verified = \Zotlabs\Web\HTTPSig::verify('',$hubloc['xchan_pubkey']);
+ $verified = HTTPSig::verify('',$hubloc['xchan_pubkey']);
if($verified && $verified['header_signed'] && $verified['header_valid'] && $hash == $hubloc['hubloc_hash']) {
$header_verified = true;
}
diff --git a/Zotlabs/Module/Group.php b/Zotlabs/Module/Group.php
index 12edf8428..f836978ee 100644
--- a/Zotlabs/Module/Group.php
+++ b/Zotlabs/Module/Group.php
@@ -177,7 +177,7 @@ class Group extends Controller {
if($r)
$result = group_rmv(local_channel(),$r[0]['gname']);
if($result) {
- $hookinfo = [ 'pgrp_extras' => '', 'group'=>$argv(2) ];
+ $hookinfo = [ 'pgrp_extras' => '', 'group' => argv(2) ];
call_hooks ('privacygroup_extras_drop',$hookinfo);
info( t('Privacy group removed.') . EOL);
}
diff --git a/Zotlabs/Module/Id.php b/Zotlabs/Module/Id.php
index 15abfa2a3..e08568d00 100644
--- a/Zotlabs/Module/Id.php
+++ b/Zotlabs/Module/Id.php
@@ -12,7 +12,7 @@ namespace Zotlabs\Module;
use Zotlabs\Lib\Activity;
use Zotlabs\Lib\ActivityStreams;
use Zotlabs\Lib\LDSignatures;
-use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\HTTPSig;
use Zotlabs\Web\Controller;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\ThreadListener;
diff --git a/Zotlabs/Module/Item.php b/Zotlabs/Module/Item.php
index 6bc8c645f..d03b6ee30 100644
--- a/Zotlabs/Module/Item.php
+++ b/Zotlabs/Module/Item.php
@@ -9,7 +9,7 @@ use Zotlabs\Daemon\Master;
use Zotlabs\Lib\Activity;
use Zotlabs\Lib\ActivityStreams;
use Zotlabs\Lib\LDSignatures;
-use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\HTTPSig;
use Zotlabs\Lib\Libzot;
use Zotlabs\Lib\ThreadListener;
use App;
@@ -96,11 +96,12 @@ class Item extends Controller {
}
// if we don't have a parent id belonging to the signer see if we can obtain one as a visitor that we have permission to access
+ // with a bias towards those items owned by channels on this site (item_wall = 1)
$sql_extra = item_permissions_sql(0);
if (! $i) {
- $i = q("select id as item_id from item where mid = '%s' $item_normal $sql_extra limit 1",
+ $i = q("select id as item_id from item where mid = '%s' $item_normal $sql_extra order by item_wall desc limit 1",
dbesc($r[0]['parent_mid'])
);
}
@@ -192,6 +193,25 @@ class Item extends Controller {
killme();
}
+
+ if(argc() > 1 && argv(1) !== 'drop') {
+ $x = q("select uid, item_wall, llink, mid from item where mid = '%s' ",
+ dbesc(z_root() . '/item/' . argv(1))
+ );
+ if($x) {
+ foreach($x as $xv) {
+ if (intval($xv['item_wall'])) {
+ $c = channelx_by_n($xv['uid']);
+ if ($c) {
+ goaway($c['xchan_url'] . '?mid=' . gen_link_id($xv['mid']));
+ }
+ }
+ }
+ goaway($x[0]['llink']);
+ }
+ http_status_exit(404, 'Not found');
+ }
+
}
@@ -550,10 +570,10 @@ class Item extends Controller {
$public_policy = $orig_post['public_policy'];
$private = $orig_post['item_private'];
}
-
- if($private || $public_policy || $acl->is_private())
- $private = 1;
-
+
+ if($public_policy || $acl->is_private()) {
+ $private = (($private) ? $private : 1);
+ }
$location = $orig_post['location'];
$coord = $orig_post['coord'];
@@ -630,12 +650,11 @@ class Item extends Controller {
$allow_empty = ((array_key_exists('allow_empty',$_REQUEST)) ? intval($_REQUEST['allow_empty']) : 0);
- $private = intval($acl->is_private() || ($public_policy));
+ $private = (($private) ? $private : intval($acl->is_private() || ($public_policy)));
// If this is a comment, set the permissions from the parent.
if($parent_item) {
- $private = 0;
$acl->set($parent_item);
$private = intval($acl->is_private() || $parent_item['item_private']);
$public_policy = $parent_item['public_policy'];
@@ -741,7 +760,12 @@ class Item extends Controller {
}
}
}
-
+
+ if(($str_contact_allow) && (! $str_group_allow)) {
+ // direct message - private between individual channels but not groups
+ $private = 2;
+ }
+
/**
*
diff --git a/Zotlabs/Module/Linkinfo.php b/Zotlabs/Module/Linkinfo.php
index b9f90deec..fcf8a6aa1 100644
--- a/Zotlabs/Module/Linkinfo.php
+++ b/Zotlabs/Module/Linkinfo.php
@@ -2,9 +2,6 @@
namespace Zotlabs\Module;
-
-
-
class Linkinfo extends \Zotlabs\Web\Controller {
function get() {
@@ -48,7 +45,22 @@ class Linkinfo extends \Zotlabs\Web\Controller {
}
logger('linkinfo: ' . $url);
-
+
+ // Replace plink URL with 'share' tag if possible
+ preg_match("/(mid=b64\.|display\/|posts\/)([\w\-]+)(&.+)?$/", $url, $mid);
+
+ if (!empty($mid) && $mid[1] == 'mid=b64.')
+ $mid[2] = base64_decode($mid[2]);
+
+ $r = q("SELECT id FROM item WHERE mid = '%s' AND uid = %d LIMIT 1",
+ dbesc((empty($mid) ? $url : $mid[2])),
+ intval(local_channel())
+ );
+ if ($r) {
+ echo "[share=" . $r[0]['id'] . "][/share]";
+ killme();
+ }
+
$result = z_fetch_url($url,false,0,array('novalidate' => true, 'nobody' => true));
if($result['success']) {
$hdrs=array();
@@ -275,7 +287,7 @@ class Linkinfo extends \Zotlabs\Web\Controller {
// Check codepage in HTTP headers or HTML if not exist
$cp = (preg_match('/Content-Type: text\/html; charset=(.+)\r\n/i', $header, $o) ? $o[1] : '');
if(empty($cp))
- $cp = (preg_match('/meta.+content=["|\']text\/html; charset=([^"|\']+)/i', $body, $o) ? $o[1] : 'AUTO');
+ $cp = (preg_match('/meta.+content=["\']text\/html; charset=([^"\']+)/i', $body, $o) ? $o[1] : 'AUTO');
$body = mb_convert_encoding($body, 'UTF-8', $cp);
$body = mb_convert_encoding($body, 'HTML-ENTITIES', "UTF-8");
@@ -444,8 +456,9 @@ class Linkinfo extends \Zotlabs\Web\Controller {
while (strpos($text, " "))
$text = trim(str_replace(" ", " ", $text));
-
- $siteinfo["text"] = html_entity_decode(substr($text,0,350), ENT_QUOTES, "UTF-8").'...';
+
+ $text = substr(html_entity_decode($text, ENT_QUOTES, "UTF-8"), 0, 350);
+ $siteinfo["text"] = rtrim(substr($text, 0, strrpos($text, " ")), "?.,:;!-") . '...';
}
}
diff --git a/Zotlabs/Module/Lockview.php b/Zotlabs/Module/Lockview.php
index d7ed07a53..8c8519c57 100644
--- a/Zotlabs/Module/Lockview.php
+++ b/Zotlabs/Module/Lockview.php
@@ -76,7 +76,7 @@ class Lockview extends \Zotlabs\Web\Controller {
killme();
}
- if(($item['item_private'] == 1) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid']))
+ if(intval($item['item_private']) && (! strlen($item['allow_cid'])) && (! strlen($item['allow_gid']))
&& (! strlen($item['deny_cid'])) && (! strlen($item['deny_gid']))) {
// if the post is private, but public_policy is blank ("visible to the internet"), and there aren't any
diff --git a/Zotlabs/Module/Magic.php b/Zotlabs/Module/Magic.php
index e8e960574..6ac656a04 100644
--- a/Zotlabs/Module/Magic.php
+++ b/Zotlabs/Module/Magic.php
@@ -1,6 +1,8 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Web\HTTPSig;
+
@require_once('include/zot.php');
@@ -152,10 +154,9 @@ class Magic extends \Zotlabs\Web\Controller {
$headers['Accept'] = 'application/x-zot+json' ;
$headers['X-Open-Web-Auth'] = random_string();
$headers['Host'] = $parsed['host'];
- $headers['Digest'] = 'SHA-256=' . \Zotlabs\Web\HTTPSig::generate_digest($data,false);
+ $headers['Digest'] = HTTPSig::generate_digest_header($data);
- $headers = \Zotlabs\Web\HTTPSig::create_sig('',$headers,$channel['channel_prvkey'],
- 'acct:' . $channel['channel_address'] . '@' . \App::get_hostname(),false,true,'sha512');
+ $headers = HTTPSig::create_sig($headers,$channel['channel_prvkey'], 'acct:' . channel_reddress($channel),true,'sha512');
$x = z_post_url($basepath . '/owa',$data,$redirects,[ 'headers' => $headers ]);
if($x['success']) {
diff --git a/Zotlabs/Module/Mail.php b/Zotlabs/Module/Mail.php
index 3202d38a5..7c344966b 100644
--- a/Zotlabs/Module/Mail.php
+++ b/Zotlabs/Module/Mail.php
@@ -25,6 +25,10 @@ class Mail extends \Zotlabs\Web\Controller {
$expires = ((x($_REQUEST,'expires')) ? datetime_convert(date_default_timezone_get(),'UTC', $_REQUEST['expires']) : NULL_DATE);
$raw = ((x($_REQUEST,'raw')) ? intval($_REQUEST['raw']) : 0);
$mimetype = ((x($_REQUEST,'mimetype')) ? notags(trim($_REQUEST['mimetype'])) : 'text/bbcode');
+
+ $sig = ((x($_REQUEST,'signature')) ? trim($_REQUEST['signature']) : '');
+ if(strpos($sig,'b64.') === 0)
+ $sig = base64_decode(str_replace('b64.', '', $sig));
if($preview) {
@@ -123,7 +127,7 @@ class Mail extends \Zotlabs\Web\Controller {
// We have a local_channel, let send_message use the session channel and save a lookup
- $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw);
+ $ret = send_message(0, $recipient, $body, $subject, $replyto, $expires, $mimetype, $raw, $sig);
if($ret['success']) {
xchan_mail_query($ret['mail']);
@@ -396,8 +400,9 @@ class Mail extends \Zotlabs\Web\Controller {
'can_recall' => ($channel['channel_hash'] == $message['from_xchan']),
'is_recalled' => (intval($message['mail_recalled']) ? t('Message has been recalled.') : ''),
'date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'], 'c'),
+ 'sig' => base64_encode($message['sig'])
);
-
+
$seen = $message['seen'];
}
diff --git a/Zotlabs/Module/Owa.php b/Zotlabs/Module/Owa.php
index cf116a96c..89f83bf8f 100644
--- a/Zotlabs/Module/Owa.php
+++ b/Zotlabs/Module/Owa.php
@@ -2,6 +2,8 @@
namespace Zotlabs\Module;
+use Zotlabs\Web\HTTPSig;
+
/**
* OpenWebAuth verifier and token generator
* See https://macgirvin.com/wiki/mike/OpenWebAuth/Home
@@ -25,7 +27,7 @@ class Owa extends \Zotlabs\Web\Controller {
continue;
}
- $sigblock = \Zotlabs\Web\HTTPSig::parse_sigheader($_SERVER[$head]);
+ $sigblock = HTTPSig::parse_sigheader($_SERVER[$head]);
if($sigblock) {
$keyId = $sigblock['keyId'];
@@ -65,7 +67,7 @@ class Owa extends \Zotlabs\Web\Controller {
if ($r) {
foreach($r as $hubloc) {
- $verified = \Zotlabs\Web\HTTPSig::verify(file_get_contents('php://input'),$hubloc['xchan_pubkey']);
+ $verified = HTTPSig::verify(file_get_contents('php://input'),$hubloc['xchan_pubkey']);
if($verified && $verified['header_signed'] && $verified['header_valid']) {
logger('OWA header: ' . print_r($verified,true),LOGGER_DATA);
logger('OWA success: ' . $hubloc['hubloc_addr'],LOGGER_DATA);
diff --git a/Zotlabs/Module/Photo.php b/Zotlabs/Module/Photo.php
index 0dc6d0194..59dc709e1 100644
--- a/Zotlabs/Module/Photo.php
+++ b/Zotlabs/Module/Photo.php
@@ -169,7 +169,7 @@ class Photo extends \Zotlabs\Web\Controller {
);
call_hooks('cache_url_hook', $cache);
if(! $cache['status']) {
- $url = htmlspecialchars_decode($r[0]['display_path']);
+ $url = html_entity_decode($r[0]['display_path'], ENT_QUOTES);
// SSLify if needed
if(strpos(z_root(),'https:') !== false && strpos($url,'https:') === false)
$url = z_root() . '/sslify/' . $filename . '?f=&url=' . urlencode($url);
@@ -222,7 +222,7 @@ class Photo extends \Zotlabs\Web\Controller {
if(! $data)
killme();
- $etag = md5($data . $modified);
+ $etag = '"' . md5($data . $modified) . '"';
if($modified == 0)
$modified = time();
diff --git a/Zotlabs/Module/Ping.php b/Zotlabs/Module/Ping.php
index 3dabe0f7b..6e8042eaf 100644
--- a/Zotlabs/Module/Ping.php
+++ b/Zotlabs/Module/Ping.php
@@ -282,8 +282,8 @@ class Ping extends \Zotlabs\Web\Controller {
if(strpos($message, $tt['xname']) === 0)
$message = substr($message, strlen($tt['xname']) + 1);
-
$mid = basename($tt['link']);
+ $mid = ((strpos($mid, 'b64.') === 0) ? @base64url_decode(substr($mid, 4)) : $mid);
if(in_array($tt['verb'], [ACTIVITY_LIKE, ACTIVITY_DISLIKE])) {
// we need the thread parent
@@ -291,7 +291,6 @@ class Ping extends \Zotlabs\Web\Controller {
dbesc($mid),
intval(local_channel())
);
-
$b64mid = ((strpos($r[0]['thr_parent'], 'b64.') === 0) ? $r[0]['thr_parent'] : 'b64.' . base64url_encode($r[0]['thr_parent']));
}
else {
diff --git a/Zotlabs/Module/Search.php b/Zotlabs/Module/Search.php
index 838f9d6b9..214ece9a3 100644
--- a/Zotlabs/Module/Search.php
+++ b/Zotlabs/Module/Search.php
@@ -38,8 +38,8 @@ class Search extends \Zotlabs\Web\Controller {
$observer_hash = (($observer) ? $observer['xchan_hash'] : '');
$o = '<div id="live-search"></div>' . "\r\n";
-
- $o = '<div class="generic-content-wrapper-styled">' . "\r\n";
+
+ $o .= '<div class="generic-content-wrapper-styled">' . "\r\n";
$o .= '<h3>' . t('Search') . '</h3>';
diff --git a/Zotlabs/Module/Share.php b/Zotlabs/Module/Share.php
index 53a06b072..a18a81937 100644
--- a/Zotlabs/Module/Share.php
+++ b/Zotlabs/Module/Share.php
@@ -106,7 +106,7 @@ class Share extends \Zotlabs\Web\Controller {
$arr['owner_xchan'] = $item['author_xchan'];
$arr['obj'] = Activity::encode_item($item);
$arr['obj_type'] = $item['obj_type'];
- $arr['verb'] = 'Announce';
+ $arr['verb'] = ACTIVITY_SHARE;
$post = item_store($arr);
diff --git a/Zotlabs/Module/Zfinger.php b/Zotlabs/Module/Zfinger.php
index 6ed001df5..3a20144a5 100644
--- a/Zotlabs/Module/Zfinger.php
+++ b/Zotlabs/Module/Zfinger.php
@@ -1,6 +1,7 @@
<?php
namespace Zotlabs\Module;
+use Zotlabs\Web\HTTPSig;
class Zfinger extends \Zotlabs\Web\Controller {
@@ -23,10 +24,9 @@ class Zfinger extends \Zotlabs\Web\Controller {
$ret = json_encode($x);
if($chan) {
- $hash = \Zotlabs\Web\HTTPSig::generate_digest($ret,false);
- $headers['Digest'] = 'SHA-256=' . $hash;
- \Zotlabs\Web\HTTPSig::create_sig('',$headers,$chan['channel_prvkey'],
- 'acct:' . $chan['channel_address'] . '@' . \App::get_hostname(),true);
+ $headers['Digest'] = HTTPSig::generate_digest_header($ret);
+ $h = HTTPSig::create_sig($headers,$chan['channel_prvkey'],'acct:' . channel_reddress($chan));
+ HTTPSig::set_headers($h);
}
else {
foreach($headers as $k => $v) {
diff --git a/Zotlabs/Module/Zot_probe.php b/Zotlabs/Module/Zot_probe.php
index d0c7e688f..648ed2175 100644
--- a/Zotlabs/Module/Zot_probe.php
+++ b/Zotlabs/Module/Zot_probe.php
@@ -3,7 +3,7 @@
namespace Zotlabs\Module;
use Zotlabs\Lib\Zotfinger;
-use Zotlabs\Zot6\HTTPSig;
+use Zotlabs\Web\HTTPSig;
class Zot_probe extends \Zotlabs\Web\Controller {