From 4b96b76f5c6c76878e8b0d37214b798498eb0b29 Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 26 Jul 2015 16:42:36 -0700 Subject: revision and string update --- util/messages.po | 62 ++++++++++++++++++++++++++++++-------------------------- version.inc | 2 +- 2 files changed, 34 insertions(+), 30 deletions(-) diff --git a/util/messages.po b/util/messages.po index 3e4a7873c..6db106a2c 100644 --- a/util/messages.po +++ b/util/messages.po @@ -6,9 +6,9 @@ #, fuzzy msgid "" msgstr "" -"Project-Id-Version: 2015-07-17.1096\n" +"Project-Id-Version: 2015-07-24.1103\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2015-07-17 00:04-0700\n" +"POT-Creation-Date: 2015-07-24 00:04-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -40,42 +40,42 @@ msgstr "" msgid "Edit" msgstr "" -#: ../../include/diaspora.php:2115 ../../include/text.php:1888 +#: ../../include/diaspora.php:2114 ../../include/text.php:1888 #: ../../include/conversation.php:120 ../../mod/like.php:346 #: ../../mod/subthread.php:72 ../../mod/subthread.php:174 #: ../../mod/tagger.php:43 msgid "photo" msgstr "" -#: ../../include/diaspora.php:2115 ../../include/text.php:1894 +#: ../../include/diaspora.php:2114 ../../include/text.php:1894 #: ../../include/conversation.php:148 ../../mod/like.php:346 #: ../../mod/subthread.php:72 ../../mod/subthread.php:174 msgid "status" msgstr "" -#: ../../include/diaspora.php:2144 ../../include/conversation.php:164 +#: ../../include/diaspora.php:2143 ../../include/conversation.php:164 #: ../../mod/like.php:394 #, php-format msgid "%1$s likes %2$s's %3$s" msgstr "" -#: ../../include/diaspora.php:2490 +#: ../../include/diaspora.php:2489 msgid "Please choose" msgstr "" -#: ../../include/diaspora.php:2492 +#: ../../include/diaspora.php:2491 msgid "Agree" msgstr "" -#: ../../include/diaspora.php:2494 +#: ../../include/diaspora.php:2493 msgid "Disagree" msgstr "" -#: ../../include/diaspora.php:2496 +#: ../../include/diaspora.php:2495 msgid "Abstain" msgstr "" -#: ../../include/diaspora.php:2518 ../../include/diaspora.php:2529 +#: ../../include/diaspora.php:2517 ../../include/diaspora.php:2528 #: ../../include/network.php:1586 ../../include/enotify.php:59 #: ../../mod/p.php:46 msgid "$projectname" @@ -297,7 +297,7 @@ msgstr "" msgid "Required" msgstr "" -#: ../../include/datetime.php:262 ../../boot.php:2355 +#: ../../include/datetime.php:262 ../../boot.php:2354 msgid "never" msgstr "" @@ -942,7 +942,7 @@ msgstr "" msgid "Click to open/close" msgstr "" -#: ../../include/text.php:1665 ../../mod/events.php:444 +#: ../../include/text.php:1665 ../../mod/events.php:443 msgid "Link to Source" msgstr "" @@ -3036,14 +3036,14 @@ msgstr "" msgid "Visible to specific connections." msgstr "" -#: ../../include/items.php:4198 ../../mod/thing.php:74 +#: ../../include/items.php:4207 ../../mod/thing.php:74 #: ../../mod/filestorage.php:27 ../../mod/viewsrc.php:20 #: ../../mod/admin.php:167 ../../mod/admin.php:1025 ../../mod/admin.php:1225 #: ../../mod/display.php:36 msgid "Item not found." msgstr "" -#: ../../include/items.php:4271 ../../include/attach.php:137 +#: ../../include/items.php:4280 ../../include/attach.php:137 #: ../../include/attach.php:184 ../../include/attach.php:247 #: ../../include/attach.php:261 ../../include/attach.php:305 #: ../../include/attach.php:319 ../../include/attach.php:350 @@ -3055,7 +3055,7 @@ msgstr "" #: ../../mod/thing.php:256 ../../mod/thing.php:290 #: ../../mod/profile_photo.php:264 ../../mod/profile_photo.php:277 #: ../../mod/block.php:22 ../../mod/block.php:72 ../../mod/like.php:178 -#: ../../mod/events.php:219 ../../mod/group.php:9 ../../mod/item.php:206 +#: ../../mod/events.php:218 ../../mod/group.php:9 ../../mod/item.php:206 #: ../../mod/item.php:214 ../../mod/item.php:978 ../../mod/network.php:12 #: ../../mod/common.php:35 ../../mod/connections.php:169 #: ../../mod/blocks.php:69 ../../mod/blocks.php:76 ../../mod/editpost.php:13 @@ -3086,26 +3086,26 @@ msgstr "" msgid "Permission denied." msgstr "" -#: ../../include/items.php:4673 ../../mod/group.php:38 ../../mod/group.php:140 +#: ../../include/items.php:4682 ../../mod/group.php:38 ../../mod/group.php:140 #: ../../mod/bulksetclose.php:51 msgid "Collection not found." msgstr "" -#: ../../include/items.php:4689 +#: ../../include/items.php:4698 msgid "Collection is empty." msgstr "" -#: ../../include/items.php:4696 +#: ../../include/items.php:4705 #, php-format msgid "Collection: %s" msgstr "" -#: ../../include/items.php:4706 ../../mod/connedit.php:658 +#: ../../include/items.php:4715 ../../mod/connedit.php:658 #, php-format msgid "Connection: %s" msgstr "" -#: ../../include/items.php:4708 +#: ../../include/items.php:4717 msgid "Connection not found." msgstr "" @@ -3117,7 +3117,7 @@ msgstr "" msgid "Unable to verify channel signature" msgstr "" -#: ../../include/zot.php:2131 +#: ../../include/zot.php:2132 #, php-format msgid "Unable to verify site signature for %s" msgstr "" @@ -4388,18 +4388,22 @@ msgstr "" msgid "Event not found." msgstr "" -#: ../../mod/events.php:396 +#: ../../mod/events.php:395 msgid "l, F j" msgstr "" -#: ../../mod/events.php:418 +#: ../../mod/events.php:417 msgid "Edit event" msgstr "" -#: ../../mod/events.php:419 +#: ../../mod/events.php:418 msgid "Delete event" msgstr "" +#: ../../mod/events.php:452 +msgid "calendar" +msgstr "" + #: ../../mod/events.php:473 msgid "Create New Event" msgstr "" @@ -9046,24 +9050,24 @@ msgstr "" msgid "Forgot your password?" msgstr "" -#: ../../boot.php:2179 +#: ../../boot.php:2178 msgid "toggle mobile" msgstr "" -#: ../../boot.php:2314 +#: ../../boot.php:2313 msgid "Website SSL certificate is not valid. Please correct." msgstr "" -#: ../../boot.php:2317 +#: ../../boot.php:2316 #, php-format msgid "[red] Website SSL error for %s" msgstr "" -#: ../../boot.php:2354 +#: ../../boot.php:2353 msgid "Cron/Scheduled tasks not running." msgstr "" -#: ../../boot.php:2358 +#: ../../boot.php:2357 #, php-format msgid "[red] Cron tasks not running on %s" msgstr "" diff --git a/version.inc b/version.inc index 73b533b5e..35b7084c7 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-07-23.1102 +2015-07-26.1105 -- cgit v1.2.3 From 9e6aea73822741a742f4630e60629442dae5633b Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 26 Jul 2015 21:39:46 -0700 Subject: backend code for importing events from "simple" ics calendar files. --- include/event.php | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/include/event.php b/include/event.php index db604cc6a..8e9492690 100644 --- a/include/event.php +++ b/include/event.php @@ -90,6 +90,7 @@ function format_event_ical($ev) { $o .= "\nLOCATION:" . format_ical_text($ev['location']); if($ev['description']) $o .= "\nDESCRIPTION:" . format_ical_text($ev['description']); + $o .= "\nUID:" . $ev['event_hash'] ; $o .= "\nEND:VEVENT\n"; return $o; @@ -364,6 +365,70 @@ function event_addtocal($item_id, $uid) { } +function parse_ical_file($f,$uid) { + require_once('library/ical.php'); + $ical = new ICAL($f); + if($ical) { + $events = $ical->events(); + if($events) { + foreach($events as $ev) { + event_import_ical($ev,$uid); + } + } + return true; + } + return false; +} + + + +function event_import_ical($ical, $uid) { + + $c = q("select * from channel where channel_id = %d limit 1", + intval($uid) + ); + + if(! $c) + return false; + + $channel = $c[0]; + $ev = array(); + + if($ical['UID']) + $ev['event_hash'] = $ical['UID']; + if($ical['CREATED']) + $ev['created'] = $ical['CREATED']; + if($ical['LAST-MODIFIED']) + $ev['edited'] = $ical['LAST-MODIFIED']; + if($ical['LOCATION']) + $ev['location'] = $ical['LOCATION']; + if($ical['DESCRIPTION']) + $ev['description'] = $ical['DESCRIPTION']; + if($ical['DTEND']) + $ev['finish'] = datetime_convert('UTC','UTC', $ical['DTEND']); + else + $ev['nofinish'] = 1; + $ev['start'] = datetime_convert('UTC','UTC',$ical['DTSTART']); + if(substr($ical['DTSTART'],-1) === 'Z') + $ev['adjust'] = 1; + + if($ical['SUMMARY'] && $ical['DTSTART']) { + $ev['event_xchan'] = $channel['channel_hash']; + $ev['uid'] = $channel['channel_id']; + $ev['account'] = $channel['channel_account_id']; + $ev['private'] = 1; + + $event = event_store_event($ev); + if($event) { + return true; + } + } + + return false; + +} + + function event_store_item($arr, $event) { require_once('include/datetime.php'); -- cgit v1.2.3 From 85f546e691351efbab36da34be6e625c7198066a Mon Sep 17 00:00:00 2001 From: redmatrix Date: Sun, 26 Jul 2015 22:44:49 -0700 Subject: crude but more or less functional event import from thunderbird ics files --- include/event.php | 31 +++++++++++++++++++++++++------ mod/events.php | 18 ++++++++++++++++-- view/tpl/events-js.tpl | 13 +++++++++++++ 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/include/event.php b/include/event.php index 8e9492690..a5cd93215 100644 --- a/include/event.php +++ b/include/event.php @@ -209,6 +209,7 @@ function event_store_event($arr) { $arr['type'] = (($arr['type']) ? $arr['type'] : 'event' ); $arr['event_xchan'] = (($arr['event_xchan']) ? $arr['event_xchan'] : ''); + // Existing event being modified if($arr['id'] || $arr['event_hash']) { @@ -276,7 +277,11 @@ function event_store_event($arr) { // New event. Store it. - $hash = random_string(); + + if(array_key_exists('external_id',$arr)) + $hash = $arr['external_id']; + else + $hash = random_string(); $r = q("INSERT INTO event ( uid,aid,event_xchan,event_hash,created,edited,start,finish,summary,description,location,type, adjust,nofinish,allow_cid,allow_gid,deny_cid,deny_gid) @@ -367,11 +372,12 @@ function event_addtocal($item_id, $uid) { function parse_ical_file($f,$uid) { require_once('library/ical.php'); - $ical = new ICAL($f); + $ical = new ICal($f); if($ical) { $events = $ical->events(); if($events) { foreach($events as $ev) { + logger('event parsed: ' . print_r($ev,true), LOGGER_ALL); event_import_ical($ev,$uid); } } @@ -394,16 +400,16 @@ function event_import_ical($ical, $uid) { $channel = $c[0]; $ev = array(); - if($ical['UID']) - $ev['event_hash'] = $ical['UID']; if($ical['CREATED']) - $ev['created'] = $ical['CREATED']; + $ev['created'] = datetime_convert('UTC','UTC',$ical['CREATED']); if($ical['LAST-MODIFIED']) - $ev['edited'] = $ical['LAST-MODIFIED']; + $ev['edited'] = datetime_convert('UTC','UTC',$ical['LAST-MODIFIED']); if($ical['LOCATION']) $ev['location'] = $ical['LOCATION']; if($ical['DESCRIPTION']) $ev['description'] = $ical['DESCRIPTION']; + if($ical['SUMMARY']) + $ev['summary'] = $ical['SUMMARY']; if($ical['DTEND']) $ev['finish'] = datetime_convert('UTC','UTC', $ical['DTEND']); else @@ -411,6 +417,17 @@ function event_import_ical($ical, $uid) { $ev['start'] = datetime_convert('UTC','UTC',$ical['DTSTART']); if(substr($ical['DTSTART'],-1) === 'Z') $ev['adjust'] = 1; + + if($ical['UID']) { + $r = q("SELECT * FROM event WHERE event_hash = '%s' AND uid = %d LIMIT 1", + dbesc($ical['UID']), + intval($arr['uid']) + ); + if($r) + $ev['event_hash'] = $ical['UID']; + else + $ev['external_id'] = $ical['UID']; + } if($ical['SUMMARY'] && $ical['DTSTART']) { $ev['event_xchan'] = $channel['channel_hash']; @@ -418,8 +435,10 @@ function event_import_ical($ical, $uid) { $ev['account'] = $channel['channel_account_id']; $ev['private'] = 1; + logger('storing event: ' . print_r($ev,true), LOGGER_ALL); $event = event_store_event($ev); if($event) { + $item_id = event_store_item($ev,$event); return true; } } diff --git a/mod/events.php b/mod/events.php index a3540ab0a..7fc4b26f2 100755 --- a/mod/events.php +++ b/mod/events.php @@ -13,6 +13,20 @@ function events_post(&$a) { if(! local_channel()) return; + if(($_FILES) && array_key_exists('userfile',$_FILES) && intval($_FILES['userfile']['size'])) { + $src = $_FILES['userfile']['tmp_name']; + if($src) { + $result = parse_ical_file($src,local_channel()); + if($result) + info( t('Calendar entries imported.') . EOL); + else + notice( t('No calendar entries found.') . EOL); + @unlink($src); + } + goaway(z_root() . '/events'); + } + + $event_id = ((x($_POST,'event_id')) ? intval($_POST['event_id']) : 0); $event_hash = ((x($_POST,'event_hash')) ? $_POST['event_hash'] : ''); @@ -476,8 +490,8 @@ function events_content(&$a) { '$export' => array($a->get_baseurl()."/events/$y/$m/export",t('Export'),'',''), '$calendar' => cal($y,$m,$links, ' eventcal'), '$events' => $events, - - + '$upload' => t('Upload'), + '$submit' => t('Submit') )); if (x($_GET,'id')){ echo $o; killme(); } diff --git a/view/tpl/events-js.tpl b/view/tpl/events-js.tpl index 9812291bf..7ecf2e753 100755 --- a/view/tpl/events-js.tpl +++ b/view/tpl/events-js.tpl @@ -3,6 +3,19 @@

{{$title}}

+ + + + -- cgit v1.2.3 From 0b232a610cdcbb701dacf8dd661b86b64bb582fc Mon Sep 17 00:00:00 2001 From: redmatrix Date: Mon, 27 Jul 2015 13:48:41 -0700 Subject: logic issue in connection filter --- include/items.php | 7 +++---- version.inc | 2 +- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/items.php b/include/items.php index fdcae3a6c..f0b7d6a7f 100755 --- a/include/items.php +++ b/include/items.php @@ -3373,19 +3373,18 @@ function post_is_importable($item,$abook) { if(! $item) return false; - if((! $abook['abook_incl']) && (! $abook['abook_excl'])) + if(! ($abook['abook_incl'] || $abook['abook_excl'])) return true; - require_once('include/html2plain.php'); $text = prepare_text($item['body'],$item['mimetype']); $text = html2plain($text); $lang = null; - if((strpos($abook['abook_incl'],'lang=') !== false) || (strpos($abook['abook_excl'],'lang=') !== false)) + if((strpos($abook['abook_incl'],'lang=') !== false) || (strpos($abook['abook_excl'],'lang=') !== false)) { $lang = detect_language($text); - + } $tags = ((count($item['term'])) ? $item['term'] : false); // exclude always has priority diff --git a/version.inc b/version.inc index 35b7084c7..928fb3ee9 100644 --- a/version.inc +++ b/version.inc @@ -1 +1 @@ -2015-07-26.1105 +2015-07-27.1106 -- cgit v1.2.3