diff options
author | friendica <info@friendica.com> | 2013-01-15 20:13:25 -0800 |
---|---|---|
committer | friendica <info@friendica.com> | 2013-01-15 20:13:25 -0800 |
commit | ddd8a0e062964cc18a7ef54828019ee28e63175b (patch) | |
tree | c86901191690ddddaa861c0d5cce4d8f845030cb | |
parent | 275fa6e1d26b4ce3090719c9b9d913ef1f2091a1 (diff) | |
download | volse-hubzilla-ddd8a0e062964cc18a7ef54828019ee28e63175b.tar.gz volse-hubzilla-ddd8a0e062964cc18a7ef54828019ee28e63175b.tar.bz2 volse-hubzilla-ddd8a0e062964cc18a7ef54828019ee28e63175b.zip |
still some bugs but events are happening again.
-rw-r--r-- | include/event.php | 10 | ||||
-rwxr-xr-x | mod/events.php | 77 | ||||
-rw-r--r-- | mod/ping.php | 6 |
3 files changed, 43 insertions, 50 deletions
diff --git a/include/event.php b/include/event.php index 3630fb462..88efe2517 100644 --- a/include/event.php +++ b/include/event.php @@ -209,7 +209,7 @@ function event_store($arr) { $arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert()); $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : ''); - $arr['message_id'] = (x($arr,'message_id') ? $arr['message_id'] : get_message_id()); + $arr['message_id'] = (x($arr,'message_id') ? $arr['message_id'] : item_message_id()); $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0); @@ -327,12 +327,12 @@ function event_store($arr) { $hash = random_string(); - $r = q("INSERT INTO `event` ( `uid`,`account`,`event_xchan`,`event_hash`, `message_id`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`location`,`type`, + $r = q("INSERT INTO `event` ( `uid`,`aid`,`event_xchan`,`event_hash`, `message_id`,`created`,`edited`,`start`,`finish`,`summary`, `desc`,`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', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ", - intval($arr['account']), intval($arr['uid']), - intval($arr['event_xchan']), + intval($arr['account']), + dbesc($arr['event_xchan']), dbesc($hash), dbesc($arr['uri']), dbesc($arr['created']), @@ -397,7 +397,7 @@ function event_store($arr) { $item_arr['resource_id'] = $hash; $item_arr['obj_type'] = ACTIVITY_OBJ_EVENT; - $item_arr['body'] = format_event_bbcode($event); + $item_arr['body'] = format_event_bbcode($arr); $x = q("select * from xchan where xchan_hash = '%s' limit 1", dbesc($arr['event_xchan']) diff --git a/mod/events.php b/mod/events.php index 0002bf11c..9bcad1f87 100755 --- a/mod/events.php +++ b/mod/events.php @@ -69,14 +69,7 @@ function events_post(&$a) { $share = ((intval($_POST['share'])) ? intval($_POST['share']) : 0); - $c = q("select id from contact where uid = %d and self = 1 limit 1", - intval(local_user()) - ); - if(count($c)) - $self = $c[0]['id']; - else - $self = 0; - + $channel = $a->get_channel(); if($share) { $str_group_allow = perms2str($_POST['group_allow']); @@ -85,9 +78,9 @@ function events_post(&$a) { $str_contact_deny = perms2str($_POST['contact_deny']); // Undo the pseudo-contact of self, since there are real contacts now - if( strpos($str_contact_allow, '<' . $self . '>') !== false ) + if( strpos($str_contact_allow, '<' . $channel['channel_hash'] . '>') !== false ) { - $str_contact_allow = str_replace('<' . $self . '>', '', $str_contact_allow); + $str_contact_allow = str_replace('<' . $channel['channel_hash'] . '>', '', $str_contact_allow); } // Make sure to set the `private` field as true. This is necessary to // have the posts show up correctly in Diaspora if an event is created @@ -100,13 +93,12 @@ function events_post(&$a) { else { // Note: do not set `private` field for self-only events. It will // keep even you from seeing them! - $str_contact_allow = '<' . $self . '>'; + $str_contact_allow = '<' . $channel['channel_hash'] . '>'; $str_group_allow = $str_contact_deny = $str_group_deny = ''; } $datarray = array(); - $datarray['hash'] = random_string(); $datarray['start'] = $start; $datarray['finish'] = $finish; $datarray['summary'] = $summary; @@ -115,8 +107,9 @@ function events_post(&$a) { $datarray['type'] = $type; $datarray['adjust'] = $adjust; $datarray['nofinish'] = $nofinish; - $datarray['uid'] = $uid; - $datarray['cid'] = $cid; + $datarray['uid'] = local_user(); + $datarray['account'] = get_account_id(); + $datarray['event_xchan'] = $channel['channel_hash']; $datarray['allow_cid'] = $str_contact_allow; $datarray['allow_gid'] = $str_group_allow; $datarray['deny_cid'] = $str_contact_deny; @@ -142,16 +135,16 @@ function events_content(&$a) { return; } - if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) { + if((argc() > 2) && (argv(1) === 'ignore') && intval(argv(2))) { $r = q("update event set ignore = 1 where id = %d and uid = %d limit 1", - intval($a->argv[2]), + intval(argv(2)), intval(local_user()) ); } - if(($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) { + if((argc() > 2) && (argv(1) === 'unignore') && intval(argv(2))) { $r = q("update event set ignore = 0 where id = %d and uid = %d limit 1", - intval($a->argv[2]), + intval(argv(2)), intval(local_user()) ); } @@ -171,19 +164,19 @@ function events_content(&$a) { $m = 0; $ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0); - if($a->argc > 1) { - if($a->argc > 2 && $a->argv[1] == 'event') { + if(argc() > 1) { + if(argc() > 2 && argv(1) == 'event') { $mode = 'edit'; - $event_id = intval($a->argv[2]); + $event_id = argv(2); } - if($a->argv[1] === 'new') { + if(argv(1) === 'new') { $mode = 'new'; - $event_id = 0; + $event_id = ''; } - if($a->argc > 2 && intval($a->argv[1]) && intval($a->argv[2])) { + if(argc() > 2 && intval(argv(1)) && intval(argv(2))) { $mode = 'view'; - $y = intval($a->argv[1]); - $m = intval($a->argv[2]); + $y = intval(argv(1)); + $m = intval(argv(2)); } } @@ -225,7 +218,7 @@ function events_content(&$a) { $finish = sprintf('%d-%d-%d %d:%d:%d',$y,$m,$dim,23,59,59); - if ($a->argv[1] === 'json'){ + if (argv(1) === 'json'){ if (x($_GET,'start')) $start = date("Y-m-d h:i:s", $_GET['start']); if (x($_GET,'end')) $finish = date("Y-m-d h:i:s", $_GET['end']); } @@ -238,12 +231,12 @@ function events_content(&$a) { if (x($_GET,'id')){ - $r = q("SELECT event.*, item.* from event left join item on event.id = item.resource_id where resource_type = 'event' and event.uid = %d and event.id = %d limit 1", + $r = q("SELECT * from event left join item on resource_id = event_hash where resource_type = 'event' and event.uid = %d and event.id = %d limit 1", intval(local_user()), intval($_GET['id']) ); } else { - $r = q("SELECT event.*, item.* from event left join item on event.id = item.resource_id + $r = q("SELECT * from event left join item on event_hash = resource_id where resource_type = 'event' and event.uid = %d and event.ignore = %d AND (( `adjust` = 0 AND `finish` >= '%s' AND `start` <= '%s' ) OR ( `adjust` = 1 AND `finish` >= '%s' AND `start` <= '%s' )) ", @@ -297,7 +290,7 @@ function events_content(&$a) { $last_date = $d; // FIXME - $edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null); + $edit = (($rr['item_flags'] & ITEM_WALL) ? array($a->get_baseurl().'/events/event/'.$rr['event_hash'],t('Edit event'),'','') : null); $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8')); if(! $title) { list($title, $_trash) = explode("<br",bbcode($rr['desc']),2); @@ -308,6 +301,7 @@ function events_content(&$a) { $rr['location'] = bbcode($rr['location']); $events[] = array( 'id'=>$rr['id'], + 'hash' => $rr['event_hash'], 'start'=> $start, 'end' => $end, 'allDay' => false, @@ -333,12 +327,9 @@ function events_content(&$a) { // links: array('href', 'text', 'extra css classes', 'title') if (x($_GET,'id')){ $tpl = get_markup_template("event.tpl"); - } else { -// if (get_config('experimentals','new_calendar')==1){ - $tpl = get_markup_template("events-js.tpl"); -// } else { -// $tpl = get_markup_template("events.tpl"); -// } + } + else { + $tpl = get_markup_template("events-js.tpl"); } $o = replace_macros($tpl, array( '$baseurl' => $a->get_baseurl(), @@ -361,14 +352,16 @@ function events_content(&$a) { } if($mode === 'edit' && $event_id) { - $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($event_id), + $r = q("SELECT * FROM `event` WHERE event_hash = '%s' AND `uid` = %d LIMIT 1", + dbesc($event_id), intval(local_user()) ); if(count($r)) $orig_event = $r[0]; } + $channel = $a->get_channel(); + if($mode === 'edit' || $mode === 'new') { $n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : ''); @@ -377,14 +370,13 @@ function events_content(&$a) { $d_orig = ((x($orig_event)) ? $orig_event['desc'] : ''); $l_orig = ((x($orig_event)) ? $orig_event['location'] : ''); $eid = ((x($orig_event)) ? $orig_event['id'] : 0); - $cid = ((x($orig_event)) ? $orig_event['cid'] : 0); + $event_xchan = ((x($orig_event)) ? $orig_event['event_xchan'] : $channel['channel_hash']); $uri = ((x($orig_event)) ? $orig_event['uri'] : ''); - if(! x($orig_event)) $sh_checked = ''; else - $sh_checked = (($orig_event['allow_cid'] === '<' . local_user() . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' ); + $sh_checked = (($orig_event['allow_cid'] === '<' . $channel['channel_hash'] . '>' && (! $orig_event['allow_gid']) && (! $orig_event['deny_cid']) && (! $orig_event['deny_gid'])) ? '' : ' checked="checked" ' ); if($cid) $sh_checked .= ' disabled="disabled" '; @@ -426,7 +418,7 @@ function events_content(&$a) { $o .= replace_macros($tpl,array( '$post' => $a->get_baseurl() . '/events', '$eid' => $eid, - '$cid' => $cid, + '$xchan' => $event_xchan, '$uri' => $uri, '$title' => t('Event details'), @@ -450,6 +442,7 @@ function events_content(&$a) { '$t_orig' => $t_orig, '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, +// FIXME '$acl' => (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user),false)), '$submit' => t('Submit') diff --git a/mod/ping.php b/mod/ping.php index 6f41c80a7..34de31340 100644 --- a/mod/ping.php +++ b/mod/ping.php @@ -247,11 +247,11 @@ function ping_init(&$a) { $t5 = dba_timer(); $events = q("SELECT type, start, adjust FROM `event` - WHERE `event`.`uid` = %d AND `start` < '%s' AND `finish` > '%s' and `ignore` = 0 + WHERE `event`.`uid` = %d AND start < '%s' AND start > '%s' and `ignore` = 0 ORDER BY `start` ASC ", intval(local_user()), - dbesc(datetime_convert('UTC','UTC','now + 7 days')), - dbesc(datetime_convert('UTC','UTC','now')) + dbesc(datetime_convert('UTC',date_default_timezone_get(),'now + 7 days')), + dbesc(datetime_convert('UTC',date_default_timezone_get(),'now - 1 days')) ); if($events) { |