diff options
Diffstat (limited to 'include/event.php')
-rw-r--r-- | include/event.php | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/include/event.php b/include/event.php index 8078a9a5e..aab195d24 100644 --- a/include/event.php +++ b/include/event.php @@ -8,7 +8,7 @@ function format_event_html($ev) { if(! ((is_array($ev)) && count($ev))) return ''; - $bd_format = t('l F d, Y \@ g A') ; // Friday January 18, 2011 @ 8 AM + $bd_format = t('l F d, Y \@ g:i A') ; // Friday January 18, 2011 @ 8 AM $o = '<div class="vevent">' . "\r\n"; @@ -212,7 +212,29 @@ function event_store($arr) { $contact = $c[0]; + // Existing event being modified + if($arr['id']) { + + // has the event actually changed? + + $r = q("SELECT * FROM `event` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($arr['id']), + intval($arr['uid']) + ); + if((! count($r)) || ($r[0]['edited'] === $arr['edited'])) { + + // Nothing has changed. Grab the item id to return. + + $r = q("SELECT * FROM `item` WHERE `event-id` = %d AND `uid` = %d LIMIT 1", + intval($arr['id']), + intval($arr['uid']) + ); + return((count($r)) ? $r[0]['id'] : 0); + } + + // The event changed. Update it. + $r = q("UPDATE `event` SET `edited` = '%s', `start` = '%s', @@ -260,7 +282,7 @@ function event_store($arr) { dbesc($arr['allow_gid']), dbesc($arr['deny_cid']), dbesc($arr['deny_gid']), - dbesc(datetime_convert()), + dbesc($arr['edited']), intval($r[0]['id']), intval($arr['uid']) ); @@ -272,6 +294,8 @@ function event_store($arr) { } else { + // New event. Store it. + $r = q("INSERT INTO `event` ( `uid`,`cid`,`uri`,`created`,`edited`,`start`,`finish`,`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' ) ", |