X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fevents.php;h=c448dc0f2e459a38d6d3ef4769476712437b5da7;hb=386b6d081b41850908adf7b5670db41a344170e6;hp=e66a2dc4423953a80b9fd2dbb1fdf1d4d81f3871;hpb=8a80ea24d1d8039be6dc532c9db23c60e71eb467;p=friendica.git diff --git a/mod/events.php b/mod/events.php old mode 100644 new mode 100755 index e66a2dc442..c448dc0f2e --- a/mod/events.php +++ b/mod/events.php @@ -28,6 +28,9 @@ function events_post(&$a) { $adjust = intval($_POST['adjust']); $nofinish = intval($_POST['nofinish']); + // The default setting for the `private` field in event_store() is false, so mirror that + $private_event = false; + $start = sprintf('%d-%d-%d %d:%d:0',$startyear,$startmonth,$startday,$starthour,$startminute); if($nofinish) @@ -54,25 +57,50 @@ function events_post(&$a) { if(strcmp($finish,$start) < 0) $finish = $start; + $summary = escape_tags(trim($_POST['summary'])); $desc = escape_tags(trim($_POST['desc'])); $location = escape_tags(trim($_POST['location'])); $type = 'event'; - if((! $desc) || (! $start)) { - notice( t('Event description and start time are required.') . EOL); + if((! $summary) || (! $start)) { + notice( t('Event title and start time are required.') . EOL); goaway($a->get_baseurl() . '/events/new'); } $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; + + 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, '<' . $self . '>') !== false ) + { + $str_contact_allow = str_replace('<' . $self . '>', '', $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 + // 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 { - $str_contact_allow = '<' . local_user() . '>'; + // Note: do not set `private` field for self-only events. It will + // keep even you from seeing them! + $str_contact_allow = '<' . $self . '>'; $str_group_allow = $str_contact_deny = $str_group_deny = ''; } @@ -80,6 +108,7 @@ function events_post(&$a) { $datarray = array(); $datarray['start'] = $start; $datarray['finish'] = $finish; + $datarray['summary'] = $summary; $datarray['desc'] = $desc; $datarray['location'] = $location; $datarray['type'] = $type; @@ -91,6 +120,7 @@ function events_post(&$a) { $datarray['allow_gid'] = $str_group_allow; $datarray['deny_cid'] = $str_contact_deny; $datarray['deny_gid'] = $str_group_deny; + $datarray['private'] = (($private_event) ? 1 : 0); $datarray['id'] = $event_id; $datarray['created'] = $created; $datarray['edited'] = $edited; @@ -115,6 +145,9 @@ function events_content(&$a) { $htpl = get_markup_template('event_head.tpl'); $a->page['htmlhead'] .= replace_macros($htpl,array('$baseurl' => $a->get_baseurl())); + $etpl = get_markup_template('event_end.tpl'); + $a->page['end'] .= replace_macros($etpl,array('$baseurl' => $a->get_baseurl())); + $o =""; // tabs $tabs = profile_tabs($a, True); @@ -202,8 +235,8 @@ function events_content(&$a) { $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` WHERE `event`.`uid` = %d - AND (( `adjust` = 0 AND `start` >= '%s' AND `start` <= '%s' ) - OR ( `adjust` = 1 AND `start` >= '%s' AND `start` <= '%s' )) ", + AND (( `adjust` = 0 AND `finish` >= '%s' AND `start` <= '%s' ) + OR ( `adjust` = 1 AND `finish` >= '%s' AND `start` <= '%s' )) ", intval(local_user()), dbesc($start), dbesc($finish), @@ -250,9 +283,11 @@ function events_content(&$a) { $last_date = $d; $edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null); - - list($title, $_trash) = explode(" $eid, '$cid' => $cid, '$uri' => $uri, + '$title' => t('Event details'), - '$desc' => sprintf( t('Format is %s %s. Starting date and Description are required.'),$dateformat,$timeformat), + '$desc' => sprintf( t('Format is %s %s. Starting date and Title are required.'),$dateformat,$timeformat), - '$s_text' => t('Event Starts:') . ' * ', + '$s_text' => t('Event Starts:') . ' *', '$s_dsel' => datesel($f,'start',$syear+5,$syear,false,$syear,$smonth,$sday), '$s_tsel' => timesel('start',$shour,$sminute), '$n_text' => t('Finish date/time is not known or not relevant'), @@ -390,10 +427,12 @@ function events_content(&$a) { '$f_tsel' => timesel('finish',$fhour,$fminute), '$a_text' => t('Adjust for viewer timezone'), '$a_checked' => $a_checked, - '$d_text' => t('Description:') . ' *', + '$d_text' => t('Description:'), '$d_orig' => $d_orig, '$l_text' => t('Location:'), '$l_orig' => $l_orig, + '$t_text' => t('Title:') . ' *', + '$t_orig' => $t_orig, '$sh_text' => t('Share this event'), '$sh_checked' => $sh_checked, '$acl' => (($cid) ? '' : populate_acl(((x($orig_event)) ? $orig_event : $a->user),false)),