diff options
Diffstat (limited to 'include/event.php')
-rw-r--r-- | include/event.php | 50 |
1 files changed, 36 insertions, 14 deletions
diff --git a/include/event.php b/include/event.php index 2cfc52408..9d4a8df59 100644 --- a/include/event.php +++ b/include/event.php @@ -10,9 +10,9 @@ function format_event_html($ev) { $bd_format = t('l F d, Y \@ g A') ; // Friday January 18, 2011 @ 8 AM - $o = '<div class="vevent">'; + $o = '<div class="vevent">' . "\r\n"; - $o .= '<p class="description event-description">' . bbcode($ev['desc']) . '</p>'; + $o .= '<p class="description event-description">' . bbcode($ev['desc']) . '</p>' . "\r\n"; $o .= '<p class="event-start">' . t('Starts:') . ' <abbr class="dtstart" title="' . datetime_convert('UTC','UTC',$ev['start'], (($ev['adjust']) ? ATOM_TIME : 'Y-m-d\TH:i:s' )) @@ -21,7 +21,7 @@ function format_event_html($ev) { $ev['start'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['start'] , $bd_format))) - . '</abbr></p>'; + . '</abbr></p>' . "\r\n"; if(! $ev['nofinish']) $o .= '<p class="event-end" >' . t('Finishes:') . ' <abbr class="dtend" title="' @@ -31,14 +31,14 @@ function format_event_html($ev) { $ev['finish'] , $bd_format )) : day_translate(datetime_convert('UTC', 'UTC', $ev['finish'] , $bd_format ))) - . '</abbr></p>'; + . '</abbr></p>' . "\r\n"; if(strlen($ev['location'])) $o .= '<p class="event-location"> ' . t('Location:') . ' <span class="location">' . bbcode($ev['location']) - . '</span></p>'; + . '</span></p>' . "\r\n"; - $o .= '</div>'; + $o .= '</div>' . "\r\n"; return $o; } @@ -175,6 +175,9 @@ function ev_compare($a,$b) { $date_a = (($a['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$a['start']) : $a['start']); $date_b = (($b['adjust']) ? datetime_convert('UTC',date_default_timezone_get(),$b['start']) : $b['start']); + + if($date_a === $date_b) + return strcasecmp($a['desc'],$b['desc']); return strcmp($date_a,$date_b); } @@ -190,10 +193,10 @@ function event_store($arr) { $a = get_app(); $arr['created'] = (($arr['created']) ? $arr['created'] : datetime_convert()); - $arr['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert()); - $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['edited'] = (($arr['edited']) ? $arr['edited'] : datetime_convert()); + $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'])); if($arr['cid']) $c = q("SELECT * FROM `contact` WHERE `id` = %d AND `uid` = %d LIMIT 1", @@ -244,8 +247,26 @@ function event_store($arr) { intval($arr['id']), intval($arr['uid']) ); - if(count($r)) + if(count($r)) { + $object = '<object><type>' . xmlify(ACTIVITY_OBJ_EVENT) . '</type><title></title><id>' . xmlify($arr['uri']) . '</id>'; + $object .= '<content>' . xmlify(format_event_bbcode($arr)) . '</content>'; + $object .= '</object>' . "\n"; + + + q("UPDATE `item` SET `body` = '%s', `object` = '%s', `allow_cid` = '%s', `allow_gid` = '%s', `deny_cid` = '%s', `deny_gid` = '%s', `edited` = '%s' WHERE `id` = %d AND `uid` = %d LIMIT 1", + dbesc(format_event_bbcode($arr)), + dbesc($object), + dbesc($arr['allow_cid']), + dbesc($arr['allow_gid']), + dbesc($arr['deny_cid']), + dbesc($arr['deny_gid']), + dbesc(datetime_convert()), + intval($r[0]['id']), + intval($arr['uid']) + ); + return $r[0]['id']; + } else return 0; } @@ -274,7 +295,7 @@ function event_store($arr) { ); $r = q("SELECT * FROM `event` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", - dbesc($uri), + dbesc($arr['uri']), intval($arr['uid']) ); if(count($r)) @@ -284,8 +305,8 @@ function event_store($arr) { $item_arr['uid'] = $arr['uid']; $item_arr['contact-id'] = $arr['cid']; - $item_arr['uri'] = $uri; - $item_arr['parent-uri'] = $uri; + $item_arr['uri'] = $arr['uri']; + $item_arr['parent-uri'] = $arr['uri']; $item_arr['type'] = 'activity'; $item_arr['wall'] = 1; $item_arr['contact-id'] = $contact['id']; @@ -329,6 +350,7 @@ function event_store($arr) { intval($item_id) ); } + return $item_id; } } |