diff options
-rw-r--r-- | include/event.php | 2 | ||||
-rwxr-xr-x | mod/events.php | 63 |
2 files changed, 42 insertions, 23 deletions
diff --git a/include/event.php b/include/event.php index e198fe15c..0c29d26f6 100644 --- a/include/event.php +++ b/include/event.php @@ -165,7 +165,7 @@ function event_store_event($arr) { return $r[0]; } - $event_hash = $r[0]['event_hash']; + $hash = $r[0]['event_hash']; // The event changed. Update it. diff --git a/mod/events.php b/mod/events.php index 7c4d6c191..02a9d1ed9 100755 --- a/mod/events.php +++ b/mod/events.php @@ -77,33 +77,52 @@ function events_post(&$a) { $channel = $a->get_channel(); - if($share) { - $str_group_allow = perms2str($_POST['group_allow']); - $str_contact_allow = perms2str($_POST['contact_allow']); - $str_group_deny = perms2str($_POST['group_deny']); - $str_contact_deny = perms2str($_POST['contact_deny']); - - // Undo the pseudo-contact of self, since there are real contacts now - if( strpos($str_contact_allow, '<' . $channel['channel_hash'] . '>') !== false ) - { - $str_contact_allow = str_replace('<' . $channel['channel_hash'] . '>', '', $str_contact_allow); + if($event_id) { + $x = q("select * from event where id = %d and uid = %d limit 1", + intval($event_id), + intval(local_user()) + ); + if(! $x) { + notice( t('Event not found.') . EOL); + return; + } + if($x[0]['allow_cid'] === '<' . $channel['channel_hash'] . '>' + && $x[0]['allow_gid'] === '' && $x[0]['deny_cid'] === '' && $x[0]['deny_gid'] === '') { + $share = false; } - // 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 - // as visible only to self at first, but then edited to display to others. - if( strlen($str_group_allow) or strlen($str_contact_allow) or strlen($str_group_deny) or strlen($str_contact_deny) ) - { - $private_event = true; + else { + $share = true; + $str_group_allow = $x[0]['allow_gid']; + $str_contact_allow = $x[0]['allow_cid']; + $str_group_deny = $x[0]['deny_gid']; + $str_contact_deny = $x[0]['deny_cid']; + + if(strlen($str_group_allow) || strlen($str_contact_allow) + || strlen($str_group_deny) || strlen($str_contact_deny)) { + $private_event = true; + } } } else { - // Note: do not set `private` field for self-only events. It will - // keep even you from seeing them! - $str_contact_allow = '<' . $channel['channel_hash'] . '>'; - $str_group_allow = $str_contact_deny = $str_group_deny = ''; + if($share) { + $str_group_allow = perms2str($_POST['group_allow']); + $str_contact_allow = perms2str($_POST['contact_allow']); + $str_group_deny = perms2str($_POST['group_deny']); + $str_contact_deny = perms2str($_POST['contact_deny']); + + if(strlen($str_group_allow) || strlen($str_contact_allow) + || strlen($str_group_deny) || strlen($str_contact_deny)) { + $private_event = true; + } + } + else { + // Note: do not set `private` field for self-only events. It will + // keep even you from seeing them! + $str_contact_allow = '<' . $channel['channel_hash'] . '>'; + $str_group_allow = $str_contact_deny = $str_group_deny = ''; + } } - $datarray = array(); $datarray['start'] = $start; $datarray['finish'] = $finish; @@ -406,7 +425,7 @@ function events_content(&$a) { $n_checked = ((x($orig_event) && $orig_event['nofinish']) ? ' checked="checked" ' : ''); $a_checked = ((x($orig_event) && $orig_event['adjust']) ? ' checked="checked" ' : ''); $t_orig = ((x($orig_event)) ? $orig_event['summary'] : ''); - $d_orig = ((x($orig_event)) ? $orig_event['desc'] : ''); + $d_orig = ((x($orig_event)) ? $orig_event['description'] : ''); $l_orig = ((x($orig_event)) ? $orig_event['location'] : ''); $eid = ((x($orig_event)) ? $orig_event['id'] : 0); $event_xchan = ((x($orig_event)) ? $orig_event['event_xchan'] : $channel['channel_hash']); |