X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fevents.php;h=c448dc0f2e459a38d6d3ef4769476712437b5da7;hb=386b6d081b41850908adf7b5670db41a344170e6;hp=731b824dec56b1411f8a89902b882ef21c5171d1;hpb=22cfb77173b1093028c1706f6c513a040ad89967;p=friendica.git
diff --git a/mod/events.php b/mod/events.php
index 731b824dec..c448dc0f2e 100755
--- 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),
@@ -241,10 +274,8 @@ function events_content(&$a) {
$start = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['start'], 'c') : datetime_convert('UTC','UTC',$rr['start'],'c'));
if ($rr['nofinish']){
$end = null;
- $allday=true;
} else {
$end = (($rr['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$rr['finish'], 'c') : datetime_convert('UTC','UTC',$rr['finish'],'c'));
- $allday=false;
}
@@ -252,27 +283,34 @@ function events_content(&$a) {
$last_date = $d;
$edit = ((! $rr['cid']) ? array($a->get_baseurl().'/events/event/'.$rr['id'],t('Edit event'),'','') : null);
-
+ $title = strip_tags(html_entity_decode(bbcode($rr['summary']),ENT_QUOTES,'UTF-8'));
+ if(! $title) {
+ list($title, $_trash) = explode("
$rr['id'],
'start'=> $start,
'end' => $end,
- 'allDay' => $allday,
- 'title' => strip_tags(bbcode($rr['desc'])),
+ 'allDay' => false,
+ 'title' => $title,
'j' => $j,
'd' => $d,
'edit' => $edit,
'is_first'=>$is_first,
'item'=>$rr,
- 'html'=>format_event_html($rr),
+ 'html'=>$html,
'plink' => array($rr['plink'],t('link to source'),'',''),
);
}
}
-
+
if ($a->argv[1] === 'json'){
echo json_encode($events); killme();
}
@@ -281,7 +319,11 @@ function events_content(&$a) {
if (x($_GET,'id')){
$tpl = get_markup_template("event.tpl");
} else {
- $tpl = get_markup_template("events.tpl");
+// if (get_config('experimentals','new_calendar')==1){
+ $tpl = get_markup_template("events-js.tpl");
+// } else {
+// $tpl = get_markup_template("events.tpl");
+// }
}
$o = replace_macros($tpl, array(
'$baseurl' => $a->get_baseurl(),
@@ -316,6 +358,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'] : '');
$l_orig = ((x($orig_event)) ? $orig_event['location'] : '');
$eid = ((x($orig_event)) ? $orig_event['id'] : 0);
@@ -370,10 +413,11 @@ function events_content(&$a) {
'$eid' => $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'),
@@ -383,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)),