diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/acl_selectors.php | 1 | ||||
-rw-r--r-- | include/bbcode.php | 3 | ||||
-rw-r--r-- | include/cli_startup.php | 4 | ||||
-rw-r--r-- | include/event.php | 59 |
4 files changed, 41 insertions, 26 deletions
diff --git a/include/acl_selectors.php b/include/acl_selectors.php index 1f97a7a7b..54ea0304b 100644 --- a/include/acl_selectors.php +++ b/include/acl_selectors.php @@ -266,7 +266,6 @@ function populate_acl($defaults = null,$show_jotnets = true, $emptyACL_descripti $o = replace_macros($tpl, array( '$showall' => $showall_caption, '$onlyme' => t('Only me'), - '$add_others' => t('Add others'), '$showallOrigin' => $showall_origin, '$showallIcon' => $showall_icon, '$select_label' => t('Who can see this?'), diff --git a/include/bbcode.php b/include/bbcode.php index 1001a4938..f47dc6f2e 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -168,7 +168,7 @@ function bb_parse_app($match) { $app = Zotlabs\Lib\Apps::app_decode($match[1]); if ($app) - return Zotlab\Lib\Apps::app_render($app); + return Zotlabs\Lib\Apps::app_render($app); } function bb_parse_element($match) { @@ -981,6 +981,7 @@ function bbcode($Text, $preserve_nl = false, $tryoembed = true, $cache = false) $Text = preg_replace("/\[event\-summary\](.*?)\[\/event\-summary\]/ism",'',$Text); $Text = preg_replace("/\[event\-description\](.*?)\[\/event\-description\]/ism",'',$Text); $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism",'',$Text); + $Text = preg_replace("/\[event\-id\](.*?)\[\/event\-id\]/ism",'',$Text); $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism",'',$Text); $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text); diff --git a/include/cli_startup.php b/include/cli_startup.php index 1436fe1ef..792598c6c 100644 --- a/include/cli_startup.php +++ b/include/cli_startup.php @@ -8,9 +8,7 @@ function cli_startup() { global $default_timezone; - if(is_null($a)) { - $a = new miniApp; - } + $a = new miniApp; App::init(); diff --git a/include/event.php b/include/event.php index 29ca5bb79..db67dac64 100644 --- a/include/event.php +++ b/include/event.php @@ -175,6 +175,9 @@ function format_event_bbcode($ev) { if($ev['location']) $o .= '[event-location]' . $ev['location'] . '[/event-location]'; + if($ev['event_hash']) + $o .= '[event-id]' . $ev['event_hash'] . '[/event-id]'; + if($ev['adjust']) $o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]'; @@ -212,6 +215,9 @@ function bbtoevent($s) { if(preg_match("/\[event\-location\](.*?)\[\/event\-location\]/is",$s,$match)) $ev['location'] = $match[1]; $match = ''; + if(preg_match("/\[event\-id\](.*?)\[\/event\-id\]/is",$s,$match)) + $ev['event_hash'] = $match[1]; + $match = ''; if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match)) $ev['adjust'] = $match[1]; if(array_key_exists('start',$ev)) { @@ -278,34 +284,41 @@ function event_store_event($arr) { else $arr['event_status_date'] = NULL_DATE; - // Existing event being modified - if($arr['id'] || $arr['event_hash']) { + $existing_event = null; - // has the event actually changed? + if($arr['event_hash']) { + $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", + dbesc($arr['event_hash']), + intval($arr['uid']) + ); + if($r) { + $existing_event = $r[0]; + } + } - if($arr['event_hash']) { - $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", - dbesc($arr['event_hash']), - intval($arr['uid']) - ); + if($arr['id']) { + $r = q("SELECT * FROM event WHERE id = %d AND uid = %d LIMIT 1", + intval($arr['id']), + intval($arr['uid']) + ); + if($r) { + $existing_event = $r[0]; } else { - $r = q("SELECT * FROM event WHERE id = %d AND uid = %d LIMIT 1", - intval($arr['id']), - intval($arr['uid']) - ); + return false; } + } - if(! $r) - return false; - if($r[0]['edited'] === $arr['edited']) { - // Nothing has changed. Return the ID. - return $r[0]; + if($existing_event) { + + if($existing_event['edited'] >= $arr['edited']) { + // Nothing has changed. + return $existing_event; } - $hash = $r[0]['event_hash']; + $hash = $existing_event['event_hash']; // The event changed. Update it. @@ -350,7 +363,7 @@ function event_store_event($arr) { dbesc($arr['allow_gid']), dbesc($arr['deny_cid']), dbesc($arr['deny_gid']), - intval($r[0]['id']), + intval($existing_event['id']), intval($arr['uid']) ); } else { @@ -360,6 +373,8 @@ function event_store_event($arr) { if(array_key_exists('external_id',$arr)) $hash = $arr['external_id']; + elseif(array_key_exists('event_hash',$arr)) + $hash = $arr['event_hash']; else $hash = random_string() . '@' . App::get_hostname(); @@ -436,7 +451,7 @@ function event_addtocal($item_id, $uid) { // is this an edit? - if($item['resource_type'] === 'event') { + if($item['resource_type'] === 'event' && (! $ev['event_hash'])) { $ev['event_hash'] = $item['resource_id']; } @@ -472,7 +487,6 @@ function event_addtocal($item_id, $uid) { if($z) { build_sync_packet($channel['channel_id'],array('event_item' => array(encode_item($sync_item[0],true)),'event' => $z)); } - return true; } } @@ -764,6 +778,9 @@ function event_store_item($arr, $event) { $prefix = ''; // $birthday = false; + if(($event) && array_key_exists('event_hash',$event) && (! array_key_exists('event_hash',$arr))) + $arr['event_hash'] = $event['event_hash']; + if($event['type'] === 'birthday') { if(! is_sys_channel($arr['uid'])) $prefix = t('This event has been added to your calendar.'); |