event integration improvements

This commit is contained in:
redmatrix
2015-08-19 16:50:32 -07:00
parent 4e3d295c90
commit a4caaefd32
4 changed files with 55 additions and 3 deletions

View File

@@ -8,7 +8,7 @@ require_once('include/items.php');
function events_post(&$a) {
logger('post: ' . print_r($_REQUEST,true));
logger('post: ' . print_r($_REQUEST,true), LOGGER_DATA);
if(! local_channel())
return;
@@ -282,6 +282,10 @@ function events_content(&$a) {
$mode = 'edit';
$event_id = argv(2);
}
if(argc() > 2 && argv(1) == 'ical') {
$mode = 'ical';
$event_id = argv(2);
}
if(argc() > 2 && argv(1) === 'add') {
$mode = 'add';
$item_id = intval(argv(2));
@@ -306,6 +310,26 @@ function events_content(&$a) {
killme();
}
if($mode === 'ical') {
$r = q("select * from event where event_hash = '%s' and uid = %d limit 1",
dbesc($event_id),
intval(local_channel())
);
if($r) {
header('Content-type: text/calendar');
header('content-disposition: attachment; filename="' . t('event') . '-' . $event_id . '.ics"' );
echo ical_wrapper($r);
killme();
}
else {
notice( t('Event not found.') . EOL );
return;
}
}
if($mode == 'view') {