event integration improvements
This commit is contained in:
parent
4e3d295c90
commit
a4caaefd32
@ -850,6 +850,17 @@ function event_store_item($arr, $event) {
|
||||
$item_arr['item_origin'] = $item_origin;
|
||||
$item_arr['item_thread_top'] = $item_thread_top;;
|
||||
|
||||
$attach = array(array(
|
||||
'href' => z_root() . '/events/ical/' . urlencode($event['event_hash']),
|
||||
'length' => 0,
|
||||
'type' => 'text/calendar',
|
||||
'title' => t('event') . '-' . $event['event_hash'],
|
||||
'revision' => ''
|
||||
));
|
||||
|
||||
$item_arr['attach'] = $attach;
|
||||
|
||||
|
||||
if(array_key_exists('term', $arr))
|
||||
$item_arr['term'] = $arr['term'];
|
||||
|
||||
|
@ -1688,7 +1688,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $
|
||||
$result[] = array($d['hash'],'update ignored',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
}
|
||||
else {
|
||||
update_imported_item($sender,$arr,$channel['channel_id']);
|
||||
update_imported_item($sender,$arr,$r[0],$channel['channel_id']);
|
||||
$result[] = array($d['hash'],'updated',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']);
|
||||
if(! $relay)
|
||||
add_source_route($item_id,$sender['hash']);
|
||||
@ -1825,9 +1825,20 @@ function remove_community_tag($sender, $arr, $uid) {
|
||||
* @param array $item
|
||||
* @param int $uid (unused)
|
||||
*/
|
||||
function update_imported_item($sender, $item, $uid) {
|
||||
function update_imported_item($sender, $item, $orig, $uid) {
|
||||
|
||||
|
||||
$x = item_store_update($item);
|
||||
|
||||
// If we're updating an event that we've saved locally, we store the item info first
|
||||
// because event_addtocal will parse the body to get the 'new' event details
|
||||
|
||||
if($orig['resource_type'] === 'event') {
|
||||
$res = event_addtocal($orig['id'],$uid);
|
||||
if(! $res)
|
||||
logger('update event: failed');
|
||||
}
|
||||
|
||||
if(! $x['item_id'])
|
||||
logger('update_imported_item: failed: ' . $x['message']);
|
||||
else
|
||||
|
@ -32,6 +32,12 @@ function editpost_content(&$a) {
|
||||
return;
|
||||
}
|
||||
|
||||
if($itm[0]['resource_type'] === 'event' && $itm[0]['resource_id']) {
|
||||
goaway(z_root() . '/events/event/' . $itm[0]['resource_id']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
$plaintext = true;
|
||||
// if(feature_enabled(local_channel(),'richtext'))
|
||||
// $plaintext = false;
|
||||
|
@ -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') {
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user