diff --git a/install/INSTALL.md b/install/INSTALL.md index 2b3ca7f..f9a5be2 100644 --- a/install/INSTALL.md +++ b/install/INSTALL.md @@ -96,6 +96,7 @@ apt-get install libmime-tools-perl libsession-token-perl libtext-multimarkdown-perl + libtext-unidecode libtext-wikicreole-perl liburi-escape-xs-perl perlmagick diff --git a/install/create.sql b/install/create.sql index 803dfa0..ca93986 100644 --- a/install/create.sql +++ b/install/create.sql @@ -1816,3 +1816,5 @@ CHANGE COLUMN `email` `email` VARCHAR(100) NULL DEFAULT NULL ; ALTER TABLE `calcms`.`calcms_user_selected_events` CHANGE COLUMN `user` `user` VARCHAR(100) NOT NULL ; + +CREATE INDEX idx_covering ON calcms_events (start, end, id); \ No newline at end of file diff --git a/install/migrate.sql b/install/migrate.sql index d788558..11dc0c3 100644 --- a/install/migrate.sql +++ b/install/migrate.sql @@ -361,4 +361,6 @@ ADD COLUMN `week_of_month` INT UNSIGNED NULL AFTER `weekday`, ADD COLUMN `month` INT UNSIGNED NULL AFTER `week_of_month`, CHANGE COLUMN `frequency` `frequency` INT UNSIGNED NULL ; -update `calcms_studio_timeslot_schedule` set period_type = 'days' where period_type = ''; \ No newline at end of file +update `calcms_studio_timeslot_schedule` set period_type = 'days' where period_type = ''; + +CREATE INDEX idx_covering ON calcms_events (start, end, id); \ No newline at end of file diff --git a/lib/calcms/events.pm b/lib/calcms/events.pm index 198030d..f6e8121 100644 --- a/lib/calcms/events.pm +++ b/lib/calcms/events.pm @@ -533,7 +533,7 @@ sub get_listen_key($$){ my $archive_dir = $config->{locations}->{local_archive_dir}; my $archive_url = $config->{locations}->{listen_url}; return $event->{listen_url} = $archive_url . '/' . $event->{listen_key} if - defined $event->{listen_key} and -l $archive_dir .'/'. $event->{listen_key}; + defined $event->{listen_key} && -l $archive_dir .'/'. $event->{listen_key}; set_listen_key($config, $event) unless $event->{listen_key}; } diff --git a/lib/calcms/mail.pm b/lib/calcms/mail.pm index 0ae856d..fb09583 100644 --- a/lib/calcms/mail.pm +++ b/lib/calcms/mail.pm @@ -3,11 +3,27 @@ package mail; use strict; use warnings; no warnings 'redefine'; +use utf8; use Email::Sender::Simple(); use Email::Simple(); -use MIME::Words qw(encode_mimeword); -use MIME::QuotedPrint qw(encode_qp); +use Text::Unidecode qw(unidecode); + +sub to_ascii { + my ($s) = @_; + my %translate = qw( + Ä Ae + ä ae + Ö Oe + ö oe + Ü Ue + ü ue + ß ss + ); + $s =~ s/([ÄäÖöÜüß])/$translate{$1}/g; + $s = unidecode $s; + return $s; +} sub send($) { my ($mail) = @_; @@ -15,14 +31,13 @@ sub send($) { my $email = Email::Simple->create( header => [ 'Content-Type' => 'text/plain;', - 'Content-Transfer-Encoding' => 'quoted-printable', 'From' => $mail->{'From'}, 'To' => $mail->{'To'}, 'Cc' => $mail->{'Cc'}, 'Reply-To' => $mail->{'Reply-To'}, - 'Subject' => encode_mimeword($mail->{'Subject'}, 'b', 'UTF-8') + 'Subject' => to_ascii($mail->{'Subject'}) ], - body => encode_qp($mail->{'Data'}), + body => to_ascii($mail->{'Data'}) ); Email::Sender::Simple->send($email); } diff --git a/lib/calcms/series_dates.pm b/lib/calcms/series_dates.pm index d7be3de..feceb95 100644 --- a/lib/calcms/series_dates.pm +++ b/lib/calcms/series_dates.pm @@ -521,7 +521,7 @@ sub delete ($$) { sub getDatesWithoutEvent ($$) { my ($config, $options) = @_; - for ('project_id', 'studio_id', 'form', 'till') { + for ('project_id', 'studio_id', 'from', 'till') { return unless defined $options->{$_} }; diff --git a/lib/calcms/user_sessions.pm b/lib/calcms/user_sessions.pm index 965d2da..fd3f053 100644 --- a/lib/calcms/user_sessions.pm +++ b/lib/calcms/user_sessions.pm @@ -86,9 +86,11 @@ sub insert ($$) { $entry->{pid} = $$; $entry->{expires_at} = time::time_to_datetime( time() + $entry->{timeout} ); - + $config->{access}->{write} = 1; my $dbh = db::connect($config); - return db::insert( $dbh, 'calcms_user_sessions', $entry ); + my $result = db::insert( $dbh, 'calcms_user_sessions', $entry ); + $config->{access}->{write} = 0; + return $result; } # start session and return generated session id @@ -176,6 +178,7 @@ sub update ($$) { return undef unless defined $entry->{session_id}; + $config->{access}->{write} = 1; my $dbh = db::connect($config); my @keys = sort keys %$entry; my $values = join( ",", map { $_ . '=?' } @keys ); @@ -187,7 +190,9 @@ sub update ($$) { set $values where session_id=? }; - return db::put( $dbh, $query, \@bind_values ); + my $result = db::put( $dbh, $query, \@bind_values ); + $config->{access}->{write} = 0; + return $result; } #map schedule id to id diff --git a/website/agenda/css/calcms.css b/website/agenda/css/calcms.css index d38cf85..bfb85d8 100644 --- a/website/agenda/css/calcms.css +++ b/website/agenda/css/calcms.css @@ -1,7 +1,49 @@ -/* -include in your web page: - -*/ +* { + border-radius:4px; +} + +@font-face { + font-family: 'Roboto'; + font-style: normal; + font-weight: 400; + src: local('Roboto'), local('Roboto-Regular'), + url('../fonts/roboto-v18-latin_latin-ext-regular.woff2') format('woff2'), +} + +@font-face { + font-family: 'Open Sans'; + font-style: normal; + font-weight: 400; + src: local('Open Sans Regular'), local('OpenSans-Regular'), + url('../fonts/open-sans-v15-latin_latin-ext-regular.woff2') format('woff2'), +} + +@media (prefers-color-scheme: dark) { + html, + *, + .entry-title a, + #calcms_calendar table thead a:hover, + #calcms_calendar table thead a:link, + .main-navigation a:hover, + .main-navigation a:focus + { + color:white !important; + background:black !important; + } + + #calcms_list h1.summary{ + background: none !important; + } + + a.load-prev, a.load-next{ + color:#999 !important; + background:#333 !important; + } + + img.custom-logo{ + filter: invert(1); + } +} /* fix drupal */ input{ @@ -676,23 +718,3 @@ ul.mobileMenu li a:hover{ line-height:2em; } -/* -pre{ - text-align:left; - font-family:Courier; - padding:1em; - margin:1em; - border:1px solid black; -} - -div.update{ - position:absolute; - bottom:0px; -} - -div.update, div.update a{ - text-align:left; - font-size:6px; - color:#bbb; -} -*/ diff --git a/website/agenda/planung/create-events.cgi b/website/agenda/planung/create-events.cgi index bd3e5a0..259c7fb 100755 --- a/website/agenda/planung/create-events.cgi +++ b/website/agenda/planung/create-events.cgi @@ -29,7 +29,6 @@ my $config = config::get('../config/config.cgi'); my ( $user, $expires ) = auth::get_user( $config, $params, $cgi ); return if ( ( !defined $user ) || ( $user eq '' ) ); -#print STDERR $params->{project_id}."\n"; my $user_presets = uac::get_user_presets( $config, { @@ -42,7 +41,6 @@ $params->{default_studio_id} = $user_presets->{studio_id}; $params = uac::setDefaultStudio( $params, $user_presets ); $params = uac::setDefaultProject( $params, $user_presets ); -#print STDERR $params->{project_id}."\n"; my $request = { url => $ENV{QUERY_STRING} || '', params => { @@ -80,7 +78,6 @@ sub show_events { uac::permissions_denied('read_events'); return; } - my $events = getDates( $config, $request ); $params->{events} = $events; $params->{total} = scalar(@$events); @@ -107,8 +104,6 @@ sub create_events { print STDERR "
found " . ( scalar @$dates ) . " dates\n";
     my $events = [];
     for my $date (@$dates) {
-
-        #print STDERR $date->{start}."\n";
         push @$events, createEvent( $config, $request, $date );
     }
     $params->{events} = $events;
diff --git a/website/agenda/planung/css/notify-events.css b/website/agenda/planung/css/notify-events.css
index bbc21ec..68046a3 100644
--- a/website/agenda/planung/css/notify-events.css
+++ b/website/agenda/planung/css/notify-events.css
@@ -2,8 +2,19 @@ table#events{
     transition:all 2s;
 }
 
-table#events.done{
-    background:#cfc;
+table#events div.error{
+    background: #f33;
+    color:white;
+    padding:1rem;
+    width: 30rem;
+}
+
+
+table#events div.done{
+    background: #3f3;
+    color:white;
+    padding:1rem;
+    width: 30rem;
 }
 
 table#events td:nth-of-type(1){
diff --git a/website/agenda/planung/js/notify-events.js b/website/agenda/planung/js/notify-events.js
index 98d0cf1..7d430cc 100644
--- a/website/agenda/planung/js/notify-events.js
+++ b/website/agenda/planung/js/notify-events.js
@@ -1,13 +1,20 @@
 function register_buttons() {
     $("#forms form").on('click', 'button', function( event ) {
         event.preventDefault();
-        var form = $(this).closest('form');
+        let form = $(this).closest('form');
+        let formId = form.attr('id');
+        let table = $('#' + formId+" table");
+        let  status = table.find("td.result div");
+        status.text('').removeClass("error").removeClass("done");
+
         $.post("notify-events.cgi", form.serialize())
-        .done( function(data) {
-            var content = $(data).find("#content");
-            $('#result').html(content);
-            var formId = form.attr('id');
-            $('#' + formId+" table").addClass("done");
+        .always( function(data) {
+            if (data.includes("done")){
+                status.text("ok").removeClass("error").addClass("done");
+            } else {
+                status.text(data).removeClass("ok").addClass("error");
+            }
+            table.find("tr.result").show();
         });
     });
 }
diff --git a/website/agenda/planung/notify-events.cgi b/website/agenda/planung/notify-events.cgi
index 4e01d02..b72b163 100755
--- a/website/agenda/planung/notify-events.cgi
+++ b/website/agenda/planung/notify-events.cgi
@@ -6,6 +6,7 @@ no warnings 'redefine';
 use utf8;
 
 use Data::Dumper;
+use Try::Tiny;
 
 use params();
 use config();
@@ -53,11 +54,10 @@ my $request = {
 
 #set user at params->presets->user
 $request = uac::prepare_request( $request, $user_presets );
-
 $params = $request->{params}->{checked};
 
 #show header
-unless ( params::isJson() || ( $params->{template} =~ /\.txt/ ) ) {
+unless ( params::isJson() || ( $params->{template} =~ /\.txt/ ) || $params->{action}eq'send' ) {
     my $headerParams = uac::set_template_permissions( $request->{permissions}, $params );
     $headerParams->{loc} = localization::get( $config, { user => $user, file => 'menu' } );
     template::process( $config, 'print', template::check( $config, 'default.html' ), $headerParams );
@@ -162,8 +162,13 @@ sub sendMail {
     $mail->{Cc}      = $params->{cc}      if defined $params->{cc};
     $mail->{Subject} = $params->{subject} if defined $params->{subject};
     $mail->{Data}    = $params->{content} if defined $params->{content};
-    my $result = mail::send($mail);
-    print "Content-type:text/plain\n\nresult:".Dumper($result);
+
+    try {
+        my $result = mail::send($mail);
+        print "Content-type:text/plain\n\ndone:$result\n";
+    } catch {
+        printf "Content-type:text/plain\n\nresult:%s\n", $_->{message} // $_;
+    }
 }
 
 sub getMail {
@@ -214,8 +219,6 @@ sub eventToText {
     $s .= $event->{user_excerpt} . "\n";
     $s .= $event->{topic} . "\n";
     $s .= $event->{content} . "\n";
-
-    #print STDERR "DUMP\n$s";
     return $s;
 
 }
diff --git a/website/agenda/planung/pot/de/notify-events.po b/website/agenda/planung/pot/de/notify-events.po
index dc8c301..38e5eb0 100644
--- a/website/agenda/planung/pot/de/notify-events.po
+++ b/website/agenda/planung/pot/de/notify-events.po
@@ -28,3 +28,5 @@ msgstr "Inhalt"
 msgid "show_details"
 msgstr "Zeige Details"
 
+msgid "result"
+msgstr "Ergebnis"
diff --git a/website/agenda/planung/pot/en/notify-events.po b/website/agenda/planung/pot/en/notify-events.po
index a25913e..6435d03 100644
--- a/website/agenda/planung/pot/en/notify-events.po
+++ b/website/agenda/planung/pot/en/notify-events.po
@@ -28,3 +28,5 @@ msgstr "Content"
 msgid "show_details"
 msgstr "Show Details"
 
+msgid "result"
+msgstr "Result"
diff --git a/website/agenda/planung/templates/notify-events.html b/website/agenda/planung/templates/notify-events.html
index 667894b..f86d7f8 100644
--- a/website/agenda/planung/templates/notify-events.html
+++ b/website/agenda/planung/templates/notify-events.html
@@ -43,15 +43,15 @@
             
         
 
-    
+
         
-        
+    
 
-        
-            Warning
-            
no recipient configured at series!
- - + + Warning +
no recipient configured at series!
+ + @@ -63,12 +63,18 @@
+ + +
+ + + @@ -97,7 +103,7 @@ -
+ diff --git a/website/agenda/planung/templates/studios.html b/website/agenda/planung/templates/studios.html index 4dd5e4b..8a4b1e4 100644 --- a/website/agenda/planung/templates/studios.html +++ b/website/agenda/planung/templates/studios.html @@ -66,7 +66,7 @@