do ical export before checking logged in channel

This commit is contained in:
redmatrix 2015-08-20 04:51:03 -07:00
parent fd7b668a16
commit a322254f2a
2 changed files with 22 additions and 24 deletions

View File

@ -146,7 +146,7 @@ function format_ical_text($s) {
require_once('include/bbcode.php');
require_once('include/html2plain.php');
return(wordwrap(str_replace(',','\\,',html2plain(bbcode($s))),72,"\r\n ",true));
return(wordwrap(str_replace(array(',',';','\\'),array('\\,','\\;','\\\\'),html2plain(bbcode($s))),72,"\r\n ",true));
}

View File

@ -228,6 +228,27 @@ function events_post(&$a) {
function events_content(&$a) {
if(argc() > 2 && argv(1) == 'ical') {
$event_id = argv(2);
require_once('include/security.php');
$sql_extra = permissions_sql(local_channel());
$r = q("select * from event where event_hash = '%s' $sql_extra limit 1",
dbesc($event_id)
);
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(! local_channel()) {
notice( t('Permission denied.') . EOL);
return;
@ -282,10 +303,6 @@ 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));
@ -311,25 +328,6 @@ function events_content(&$a) {
}
if($mode === 'ical') {
require_once('include/security.php');
$sql_extra = permissions_sql(local_channel());
$r = q("select * from event where event_hash = '%s' $sql_extra limit 1",
dbesc($event_id)
);
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;
}
}