select event by event_hash instead of item_id

This commit is contained in:
Mario Vavti 2019-04-30 10:47:48 +02:00
parent 9cc1eff15c
commit 0b062d0b8a
5 changed files with 23 additions and 12 deletions

View File

@ -905,19 +905,18 @@ class Cdav extends Controller {
head_add_js('/library/fullcalendar/packages/list/main.min.js');
$sources = '';
$iid = '';
$resource_id = '';
$resource = null;
if(argc() == 3 && intval(argv(2)))
$iid = argv(2);
if(argc() == 3)
$resource_id = argv(2);
if($iid) {
$r = q("SELECT event.*, item.author_xchan, item.owner_xchan, item.id as item_id FROM item LEFT JOIN event ON item.resource_id = event.event_hash
WHERE item.id = %d AND item.uid = %d LIMIT 1",
dbesc($iid),
intval(local_channel())
if($resource_id) {
$r = q("SELECT event.*, item.author_xchan, item.owner_xchan, item.plink, item.id as item_id FROM event LEFT JOIN item ON event.event_hash = item.resource_id
WHERE event.uid = %d AND event.event_hash = '%s' LIMIT 1",
intval(local_channel()),
dbesc($resource_id)
);
if($r) {
xchan_query($r);
$r = fetch_post_tags($r,true);
@ -925,6 +924,8 @@ class Cdav extends Controller {
$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')];
$resource = $r[0];
$catsenabled = feature_enabled(local_channel(),'categories');
@ -940,6 +941,12 @@ class Cdav extends Controller {
}
}
if($r[0]['dismissed'] == 0) {
q("UPDATE event SET dismissed = 1 WHERE event.uid = %d AND event.event_hash = '%s'",
intval(local_channel()),
dbesc($resource_id)
);
}
}
}

View File

@ -570,7 +570,7 @@ class Channel_calendar extends \Zotlabs\Web\Controller {
'is_first'=>$is_first,
'item'=>$rr,
'html'=>$html,
'plink' => array($rr['plink'],t('Link to Source'),'',''),
'plink' => [$rr['plink'], t('Link to source')],
'description' => $rr['description'],
'location' => $rr['location'],

View File

@ -45,7 +45,7 @@ class Editpost extends \Zotlabs\Web\Controller {
}
if($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) {
goaway(z_root() . '/cdav/calendar/' . $itm[0]['id']);
goaway(z_root() . '/cdav/calendar/' . $itm[0]['resource_id']);
//goaway(z_root() . '/events/' . $itm[0]['resource_id'] . '?expandform=1');
}

View File

@ -447,7 +447,7 @@ class Ping extends \Zotlabs\Web\Controller {
$when = day_translate(datetime_convert('UTC', (($rr['adjust']) ? date_default_timezone_get() : 'UTC'), $rr['dtstart'], $bd_format)) . (($today) ? ' ' . t('[today]') : '');
$result[] = array(
'notify_link' => z_root() . '/cdav/calendar', /// @FIXME this takes you to an edit page and it may not be yours, we really want to just view the single event --> '/events/event/' . $rr['event_hash'],
'notify_link' => z_root() . '/cdav/calendar/' . $rr['event_hash'],
'name' => $rr['xchan_name'],
'addr' => $rr['xchan_addr'],
'url' => $rr['xchan_url'],

View File

@ -309,6 +309,10 @@ $(document).ready(function() {
if(resource !== null) {
$('.section-content-tools-wrapper, #event_form_wrapper').show();
$('#id_title_wrapper').prepend('<span id="l2s" class="float-right"></span>');
$('#l2s').html('<a href="' + resource.plink[0] + '" target="_blank"><i class="fa fa-external-link"></i> ' + resource.plink[1] + '</a>');
event_id = resource.id;
event_uri = resource.event_hash;
$('#calendar_select').val('channel_calendar').attr('disabled', true);