From a00103b7dfa0b128cbe6ab03e6a43ccedb24f8c2 Mon Sep 17 00:00:00 2001 From: friendica Date: Wed, 7 May 2014 22:23:43 -0700 Subject: better event management --- mod/addtocal.php | 56 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 mod/addtocal.php (limited to 'mod') diff --git a/mod/addtocal.php b/mod/addtocal.php new file mode 100644 index 000000000..7789e0ede --- /dev/null +++ b/mod/addtocal.php @@ -0,0 +1,56 @@ + 1) { + $post_id = intval(argv(1)); + + $r = q("select * from item where id = %d and uid = %d limit 1", + intval($post_id), + intval(local_user()) + ); + + if(! $r) + return; + } + + $arr = $r[0]; + $channel = $a->get_channel(); + + if(! $channel) + return; + + // for events, extract the event info and create an event linked to an item + + if((x($arr,'obj_type')) && (activity_match($arr['obj_type'],ACTIVITY_OBJ_EVENT))) { + + require_once('include/event.php'); + $ev = bbtoevent($arr['body']); + + if(x($ev,'description') && x($ev,'start')) { + $ev['event_xchan'] = $arr['author_xchan']; + $ev['uid'] = $channel['channel_id']; + $ev['account'] = $channel['channel_account_id']; + $ev['edited'] = $arr['edited']; + $ev['mid'] = $arr['mid']; + $ev['private'] = $arr['item_private']; + + // is this an edit? + + $r = q("SELECT resource_id FROM item where mid = '%s' and uid = %d and resource_type = 'event' limit 1", + dbesc($arr['mid']), + intval($channel['channel_id']) + ); + if($r) { + $ev['event_hash'] = $r[0]['resource_id']; + } + + $xyz = event_store($ev); + + } + } +} \ No newline at end of file -- cgit v1.2.3