diff options
author | friendica <info@friendica.com> | 2014-05-07 22:23:43 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-05-07 22:23:43 -0700 |
commit | a00103b7dfa0b128cbe6ab03e6a43ccedb24f8c2 (patch) | |
tree | 22c095344073aa58d85abcb1b3ae916cb9a0cb7e /include | |
parent | e22e94cd9708406ef9a96c7ec4bb9216be630ec2 (diff) | |
download | volse-hubzilla-a00103b7dfa0b128cbe6ab03e6a43ccedb24f8c2.tar.gz volse-hubzilla-a00103b7dfa0b128cbe6ab03e6a43ccedb24f8c2.tar.bz2 volse-hubzilla-a00103b7dfa0b128cbe6ab03e6a43ccedb24f8c2.zip |
better event management
Diffstat (limited to 'include')
-rw-r--r-- | include/event.php | 55 | ||||
-rw-r--r-- | include/zot.php | 30 |
2 files changed, 40 insertions, 45 deletions
diff --git a/include/event.php b/include/event.php index 8e6a3fe71..968497a28 100644 --- a/include/event.php +++ b/include/event.php @@ -142,8 +142,21 @@ function event_store($arr) { $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : ''); - // Existing event being modified + $item = null; + + if($arr['mid'] && $arr['uid']) { + $i = q("select * from item where mid = '%s' and uid = %d limit 1", + dbesc($arr['mid']), + intval($arr['uid']) + ); + if($i) { + xchan_query($i); + $item = fetch_post_tags($i,true); + } + } + // Existing event being modified +dbg(1); if($arr['id'] || $arr['event_hash']) { // has the event actually changed? @@ -160,7 +173,7 @@ function event_store($arr) { intval($arr['uid']) ); } - +dbg(0); if(! $r) return 0; @@ -170,7 +183,7 @@ function event_store($arr) { } $event_hash = $r[0]['event_hash']; - +dbg(1); // The event changed. Update it. $r = q("UPDATE `event` SET @@ -253,7 +266,7 @@ function event_store($arr) { $item_id = 0; call_hooks('event_updated', $arr['id']); - +dbg(0); return $item_id; } else { @@ -265,7 +278,7 @@ function event_store($arr) { if(! $arr['mid']) $arr['mid'] = item_message_id(); - +dbg(1); $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type, adjust,nofinish,allow_cid,allow_gid,deny_cid,deny_gid) VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ", @@ -302,24 +315,32 @@ function event_store($arr) { intval($arr['uid']) ); - $wall = (($z) ? true : false); - - $item_flags = ITEM_THREAD_TOP; - if($wall) { - $item_flags |= ITEM_WALL; - $item_flags |= ITEM_ORIGIN; - } $private = (($arr['allow_cid'] || $arr['allow_gid'] || $arr['deny_cid'] || $arr['deny_gid']) ? 1 : 0); $item_arr = array(); + + + if($item) { + $item_arr['id'] = $item['id']; + } + else { + $wall = (($z) ? true : false); + + $item_flags = ITEM_THREAD_TOP; + if($wall) { + $item_flags |= ITEM_WALL; + $item_flags |= ITEM_ORIGIN; + } + $item_arr['item_flags'] = $item_flags; + } + $item_arr['uid'] = $arr['uid']; $item_arr['author_xchan'] = $arr['event_xchan']; $item_arr['mid'] = $arr['mid']; $item_arr['parent_mid'] = $arr['mid']; - $item_arr['item_flags'] = $item_flags; $item_arr['owner_xchan'] = (($wall) ? $z[0]['channel_hash'] : $arr['event_xchan']); $item_arr['author_xchan'] = $arr['event_xchan']; @@ -362,11 +383,15 @@ function event_store($arr) { } - $res = item_store($item_arr); + if($item) + $res = item_store_update($item_arr); + else + $res = item_store($item_arr); + $item_id = $res['item_id']; call_hooks("event_created", $event['id']); - +dbg(0); return $item_id; } } diff --git a/include/zot.php b/include/zot.php index ea439a603..7336c4290 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1452,36 +1452,6 @@ function process_delivery($sender,$arr,$deliveries,$relay,$public = false) { continue; } - // 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,'desc') && 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); - add_source_route($xyz,$sender['hash']); - - $result = array($d['hash'],'event processed',$channel['channel_name'] . ' <' . $channel['channel_address'] . '@' . get_app()->get_hostname() . '>',$arr['mid']); - continue; - } - } $r = q("select id, edited from item where mid = '%s' and uid = %d limit 1", dbesc($arr['mid']), |