diff options
author | friendica <info@friendica.com> | 2014-05-29 21:25:19 -0700 |
---|---|---|
committer | friendica <info@friendica.com> | 2014-05-29 21:25:19 -0700 |
commit | 832cbbec15ae2abbd04d775e4cfb056e797722f1 (patch) | |
tree | 157792443a0eb07be3cbeb4e805d0e18ba17df53 | |
parent | 22ed5b1d03314d2bc7ff41b4724526fe00472904 (diff) | |
download | volse-hubzilla-832cbbec15ae2abbd04d775e4cfb056e797722f1.tar.gz volse-hubzilla-832cbbec15ae2abbd04d775e4cfb056e797722f1.tar.bz2 volse-hubzilla-832cbbec15ae2abbd04d775e4cfb056e797722f1.zip |
testing new event code
-rw-r--r-- | include/ItemObject.php | 2 | ||||
-rw-r--r-- | include/event.php | 18 | ||||
-rw-r--r-- | mod/addtocal.php | 56 | ||||
-rwxr-xr-x | view/tpl/jot-header.tpl | 2 |
4 files changed, 14 insertions, 64 deletions
diff --git a/include/ItemObject.php b/include/ItemObject.php index ad2692624..b6a9a2897 100644 --- a/include/ItemObject.php +++ b/include/ItemObject.php @@ -201,7 +201,7 @@ class Item extends BaseObject { } $has_event = false; - if(activity_compare($item['obj_type'],ACTIVITY_OBJ_EVENT) && $conv->get_profile_owner() == local_user()) + if(($item['obj_type'] === ACTIVITY_OBJ_EVENT) && $conv->get_profile_owner() == local_user()) $has_event = true; if($this->is_commentable()) { diff --git a/include/event.php b/include/event.php index 498d2ab99..0f337867c 100644 --- a/include/event.php +++ b/include/event.php @@ -135,6 +135,8 @@ function event_store_event($arr) { $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : ''); + + // Existing event being modified if($arr['id'] || $arr['event_hash']) { @@ -154,6 +156,7 @@ function event_store_event($arr) { ); } + if(! $r) return false; @@ -205,9 +208,6 @@ function event_store_event($arr) { $hash = random_string(); - if(! $arr['mid']) - $arr['mid'] = item_message_id(); - $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) @@ -261,13 +261,14 @@ function event_addtocal($item_id, $uid) { intval($channel['channel_id']) ); - if((! $r) || (! activity_match($r[0]['obj_type'],ACTIVITY_OBJ_EVENT))) + if((! $r) || ($r[0]['obj_type'] !== ACTIVITY_OBJ_EVENT)) return false; $item = $r[0]; $ev = bbtoevent($r[0]['body']); - if(x($ev,'description') && x($ev,'start')) { + + if(x($ev,'summary') && x($ev,'start')) { $ev['event_xchan'] = $item['author_xchan']; $ev['uid'] = $channel['channel_id']; $ev['account'] = $channel['channel_account_id']; @@ -284,6 +285,7 @@ function event_addtocal($item_id, $uid) { $event = event_store_event($ev); if($event) { $r = q("update item set resource_id = '%s', resource_type = 'event' where id = %d and uid = %d limit 1", + dbesc($event['event_hash']), intval($item['id']), intval($channel['channel_id']) ); @@ -317,7 +319,7 @@ function event_store_item($arr,$event) { } $r = q("SELECT * FROM item left join xchan on author_xchan = xchan_hash WHERE resource_id = '%s' AND resource_type = 'event' and uid = %d LIMIT 1", - dbesc($event['hash']), + dbesc($event['event_hash']), intval($arr['uid']) ); @@ -386,6 +388,10 @@ function event_store_item($arr,$event) { $item_arr['item_flags'] = $item_flags; } + if(! $arr['mid']) + $arr['mid'] = item_message_id(); + + $item_arr['uid'] = $arr['uid']; $item_arr['author_xchan'] = $arr['event_xchan']; $item_arr['mid'] = $arr['mid']; diff --git a/mod/addtocal.php b/mod/addtocal.php deleted file mode 100644 index 7789e0ede..000000000 --- a/mod/addtocal.php +++ /dev/null @@ -1,56 +0,0 @@ -<?php /** @file */ - - -function addtocal_init(&$a) { - - if(! local_user()) - return; - - if(argc() > 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 diff --git a/view/tpl/jot-header.tpl b/view/tpl/jot-header.tpl index 9af786741..abf446ba9 100755 --- a/view/tpl/jot-header.tpl +++ b/view/tpl/jot-header.tpl @@ -301,7 +301,7 @@ function enableOnUser(){ } function itemAddToCal(id) { - $.get('{{$baseurl}}/event/add/' + id); + $.get('{{$baseurl}}/events/add/' + id); if(timer) clearTimeout(timer); timer = setTimeout(NavUpdate,1000); } |