X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=include%2Fevent.php;h=c4111dc0b174869be3fff15d6b58599a10d06bcd;hb=8a79e1afb34cf8098bc0e34180bb3b17b826c824;hp=866ae8c3f006370c7f0bae151995e47a5cad2934;hpb=39927e3dc5d0fc942ef9428b5c5c0d9b8cbb2f56;p=friendica.git diff --git a/include/event.php b/include/event.php index 866ae8c3f0..c4111dc0b1 100644 --- a/include/event.php +++ b/include/event.php @@ -1,43 +1,73 @@ ".bbcode($ev['summary']).""; + + $o .= "

".bbcode($ev['desc'])."

"; + + $o .= "

".t('Starts:')."

".$event_start."

"; + + if(! $ev['nofinish']) + $o .= "

".t('Finishes:')."

".$event_end."

"; + + if(strlen($ev['location'])) + $o .= "

".t('Location:')."

".$ev['location']."

"; + + return $o; + } + $o = '
' . "\r\n"; + + $o .= '

' . bbcode($ev['summary']) . '

' . "\r\n"; + $o .= '

' . bbcode($ev['desc']) . '

' . "\r\n"; $o .= '

' . t('Starts:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), - $ev['start'] , $bd_format )) - : day_translate(datetime_convert('UTC', 'UTC', - $ev['start'] , $bd_format))) + . '" >'.$event_start . '

' . "\r\n"; if(! $ev['nofinish']) $o .= '

' . t('Finishes:') . ' ' - . (($ev['adjust']) ? day_translate(datetime_convert('UTC', date_default_timezone_get(), - $ev['finish'] , $bd_format )) - : day_translate(datetime_convert('UTC', 'UTC', - $ev['finish'] , $bd_format ))) + . '" >'.$event_end . '

' . "\r\n"; - if(strlen($ev['location'])) - $o .= '

' . t('Location:') . ' ' - . bbcode($ev['location']) + if(strlen($ev['location'])){ + $o .= '

' . t('Location:') . ' ' + . bbcode($ev['location']) . '

' . "\r\n"; + if (strpos($ev['location'], "[map")===False) { + $map = generate_named_map($ev['location']); + if ($map!==$ev['location']) $o.=$map; + } + + } + $o .= '
' . "\r\n"; return $o; } @@ -114,6 +144,9 @@ function format_event_bbcode($ev) { $o = ''; + if($ev['summary']) + $o .= '[event-summary]' . $ev['summary'] . '[/event-summary]'; + if($ev['desc']) $o .= '[event-description]' . $ev['desc'] . '[/event-description]'; @@ -122,7 +155,7 @@ function format_event_bbcode($ev) { if(($ev['finish']) && (! $ev['nofinish'])) $o .= '[event-finish]' . $ev['finish'] . '[/event-finish]'; - + if($ev['location']) $o .= '[event-location]' . $ev['location'] . '[/event-location]'; @@ -147,6 +180,9 @@ function bbtoevent($s) { $ev = array(); + $match = ''; + if(preg_match("/\[event\-summary\](.*?)\[\/event\-summary\]/is",$s,$match)) + $ev['summary'] = $match[1]; $match = ''; if(preg_match("/\[event\-description\](.*?)\[\/event\-description\]/is",$s,$match)) $ev['desc'] = $match[1]; @@ -182,11 +218,17 @@ function ev_compare($a,$b) { if($date_a === $date_b) return strcasecmp($a['desc'],$b['desc']); - + return strcmp($date_a,$date_b); } +function event_delete($event_id) { + if ($event_id == 0) + return; + q("DELETE FROM `event` WHERE `id` = %d", intval($event_id)); + logger("Deleted event ".$event_id, LOGGER_DEBUG); +} function event_store($arr) { @@ -198,7 +240,7 @@ function event_store($arr) { $arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert()); $arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert()); - $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); + $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['cid'] = ((intval($arr['cid'])) ? intval($arr['cid']) : 0); $arr['uri'] = (x($arr,'uri') ? $arr['uri'] : item_new_uri($a->get_hostname(),$arr['uid'])); $arr['private'] = ((x($arr,'private')) ? intval($arr['private']) : 0); @@ -244,6 +286,7 @@ function event_store($arr) { `edited` = '%s', `start` = '%s', `finish` = '%s', + `summary` = '%s', `desc` = '%s', `location` = '%s', `type` = '%s', @@ -253,11 +296,12 @@ function event_store($arr) { `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s' - WHERE `id` = %d AND `uid` = %d LIMIT 1", + WHERE `id` = %d AND `uid` = %d", dbesc($arr['edited']), dbesc($arr['start']), dbesc($arr['finish']), + dbesc($arr['summary']), dbesc($arr['desc']), dbesc($arr['location']), dbesc($arr['type']), @@ -280,7 +324,7 @@ function event_store($arr) { $object .= '' . "\n"; - q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s', `private` = %d WHERE `id` = %d AND `uid` = %d LIMIT 1", + q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s', `private` = %d WHERE `id` = %d AND `uid` = %d", dbesc(format_event_bbcode($arr)), dbesc($object), dbesc($arr['allow_cid']), @@ -304,11 +348,11 @@ function event_store($arr) { } else { - // New event. Store it. + // New event. Store it. - $r = q("INSERT INTO `event` ( `uid`,`cid`,`uri`,`created`,`edited`,`start`,`finish`,`desc`,`location`,`type`, + $r = q("INSERT INTO `event` ( `uid`,`cid`,`uri`,`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', %d, %d, '%s', '%s', '%s', '%s' ) ", + VALUES ( %d, %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', %d, %d, '%s', '%s', '%s', '%s' ) ", intval($arr['uid']), intval($arr['cid']), dbesc($arr['uri']), @@ -316,6 +360,7 @@ function event_store($arr) { dbesc($arr['edited']), dbesc($arr['start']), dbesc($arr['finish']), + dbesc($arr['summary']), dbesc($arr['desc']), dbesc($arr['location']), dbesc($arr['type']), @@ -341,6 +386,7 @@ function event_store($arr) { $item_arr['contact-id'] = $arr['cid']; $item_arr['uri'] = $arr['uri']; $item_arr['parent-uri'] = $arr['uri']; + $item_arr['guid'] = $arr['guid']; $item_arr['type'] = 'activity'; $item_arr['wall'] = (($arr['cid']) ? 0 : 1); $item_arr['contact-id'] = $contact['id']; @@ -373,13 +419,18 @@ function event_store($arr) { $r = q("SELECT * FROM `user` WHERE `uid` = %d LIMIT 1", intval($arr['uid']) ); - if(count($r)) - $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id; + //if(count($r)) + // $plink = $a->get_baseurl() . '/display/' . $r[0]['nickname'] . '/' . $item_id; if($item_id) { - q("UPDATE `item` SET `plink` = '%s', `event-id` = %d WHERE `uid` = %d AND `id` = %d LIMIT 1", - dbesc($plink), + //q("UPDATE `item` SET `plink` = '%s', `event-id` = %d WHERE `uid` = %d AND `id` = %d", + // dbesc($plink), + // intval($event['id']), + // intval($arr['uid']), + // intval($item_id) + //); + q("UPDATE `item` SET `event-id` = %d WHERE `uid` = %d AND `id` = %d", intval($event['id']), intval($arr['uid']), intval($item_id)