diff --git a/install/create.sql b/install/create.sql index 66d39ef..4404da0 100644 --- a/install/create.sql +++ b/install/create.sql @@ -31,12 +31,12 @@ CREATE TABLE `calcms_audio_recordings` ( `path` varchar(300) NOT NULL, `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, `size` bigint(20) unsigned NOT NULL DEFAULT '0', - `audioDuration` float DEFAULT '0', - `eventDuration` int(11) DEFAULT '0', - `rmsLeft` float DEFAULT NULL, - `rmsRight` float DEFAULT NULL, - `mastered` tinyint(1) DEFAULT '0', - `processed` tinyint(1) DEFAULT '0', + `audioDuration` float NOT NULL DEFAULT '0', + `eventDuration` int(11) NOT NULL DEFAULT '0', + `rmsLeft` float NOT NULL, + `rmsRight` float NOT NULL, + `mastered` tinyint(1) NOT NULL DEFAULT '0', + `processed` tinyint(1) NOT NULL DEFAULT '0', `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `project_index` (`project_id`), @@ -178,6 +178,7 @@ CREATE TABLE `calcms_event_history` ( `series_id` int(10) unsigned DEFAULT NULL, `deleted` tinyint(1) unsigned DEFAULT '0', `project_id` int(10) unsigned NOT NULL, + `draft` tinyint(3) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `end` (`end`), KEY `start` (`start`), @@ -262,6 +263,7 @@ CREATE TABLE `calcms_events` ( `modified_by` varchar(20) DEFAULT NULL, `archive_url` varchar(300) DEFAULT NULL, `recurrence_count` int(10) unsigned NOT NULL DEFAULT '0', + `draft` tinyint(1) unsigned NOT NULL DEFAULT '0', PRIMARY KEY (`id`), KEY `end` (`end`), KEY `start` (`start`), @@ -281,7 +283,8 @@ CREATE TABLE `calcms_events` ( KEY `location` (`location`), KEY `published` (`published`), KEY `preproduced` (`playout`), - KEY `archived` (`archived`) + KEY `archived` (`archived`), + KEY `draft` (`draft`) ) ENGINE=MyISAM AUTO_INCREMENT=23271 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; @@ -391,8 +394,8 @@ CREATE TABLE `calcms_playout` ( `rms_right` float DEFAULT NULL, `rms_image` varchar(300) DEFAULT NULL, `replay_gain` float DEFAULT NULL, - `updated_at` datetime DEFAULT CURRENT_TIMESTAMP, - `modified_at` datetime DEFAULT NULL, + `updated_at` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP, + `modified_at` datetime NOT NULL, PRIMARY KEY (`project_id`,`studio_id`,`start`), KEY `project_id` (`project_id`), KEY `studio_id` (`studio_id`), @@ -586,6 +589,7 @@ CREATE TABLE `calcms_roles` ( `upload_audio_recordings` tinyint(1) unsigned NOT NULL, `delete_audio_recordings` tinyint(1) unsigned NOT NULL, `read_playout` tinyint(1) unsigned NOT NULL, + `update_event_status_draft` tinyint(1) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `role_2` (`role`), KEY `studio_id` (`studio_id`), @@ -600,7 +604,7 @@ CREATE TABLE `calcms_roles` ( LOCK TABLES `calcms_roles` WRITE; /*!40000 ALTER TABLE `calcms_roles` DISABLE KEYS */; -INSERT INTO `calcms_roles` VALUES (7,'Admin',1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,'0000-00-00 00:00:00','2017-07-30 14:32:32',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);/*!40000 ALTER TABLE `calcms_roles` ENABLE KEYS */; +INSERT INTO `calcms_roles` VALUES (7,'Admin',1,1,1,1,1,1,1,1,1,1,1,1,1,1,7,1,1,1,'0000-00-00 00:00:00','2017-07-30 14:32:32',1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1);/*!40000 ALTER TABLE `calcms_roles` ENABLE KEYS */; UNLOCK TABLES; -- @@ -1068,7 +1072,7 @@ CREATE TABLE `calcms_users` ( `full_name` varchar(30) DEFAULT NULL, `salt` varchar(32) NOT NULL, `pass` varchar(100) NOT NULL, - `email` varchar(300) DEFAULT NULL, + `email` varchar(300) NOT NULL, `modified_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `created_at` timestamp NULL DEFAULT CURRENT_TIMESTAMP, `disabled` int(10) unsigned DEFAULT '0', diff --git a/install/migrate.sql b/install/migrate.sql index 3d6565e..a03e086 100644 --- a/install/migrate.sql +++ b/install/migrate.sql @@ -80,4 +80,18 @@ ALTER TABLE `calcms_users` CHANGE COLUMN created_at created_at timestamp NULL DEFAULT CURRENT_TIMESTAMP, CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP; +ALTER TABLE `calcms_audio_recordings` + CHANGE COLUMN processed processed tinyint(1) NOT NULL DEFAULT '0', + CHANGE COLUMN modified_at modified_at timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP, + CHANGE COLUMN mastered mastered tinyint(1) NOT NULL DEFAULT '0', + CHANGE COLUMN eventDuration eventDuration int(11) NOT NULL DEFAULT '0', + CHANGE COLUMN rmsLeft rmsLeft float NOT NULL, + CHANGE COLUMN rmsRight rmsRight float NOT NULL, + CHANGE COLUMN audioDuration audioDuration float NOT NULL DEFAULT '0'; + +ALTER TABLE `calcms_events` + ADD COLUMN draft tinyint(1) unsigned NOT NULL DEFAULT '0' AFTER recurrence_count; + +ALTER TABLE `calcms_users` + CHANGE COLUMN email email varchar(300) NOT NULL; diff --git a/lib/calcms/events.pm b/lib/calcms/events.pm index 1c6b39c..575e10d 100644 --- a/lib/calcms/events.pm +++ b/lib/calcms/events.pm @@ -630,6 +630,12 @@ sub get_query { push @$bind_values, $published; } + my $draft = $params->{draft} || '0'; + if ( ( $draft eq '0' ) || ( $draft eq '1' ) ) { + push @$where_cond, 'draft=?'; + push @$bind_values, $draft; + } + } else { # conditions by date @@ -937,6 +943,14 @@ sub get_query { push @$bind_values, $published; } + #filter by draft, default =1, set to 'all' to see all + my $draft_cond = ''; + my $draft = $params->{draft} || '0'; + if ( ( $draft eq '0' ) || ( $draft eq '1' ) ) { + $draft_cond = 'draft=?'; + push @$bind_values, $draft; + } + my $disable_event_sync_cond = ''; my $disable_event_sync = $params->{disable_event_sync} || ''; if ( ( $disable_event_sync eq '0' ) || ( $disable_event_sync eq '1' ) ) { @@ -960,6 +974,7 @@ sub get_query { push @$where_cond, $search_cond if ( $search_cond =~ /\S/ ); push @$where_cond, $project_cond if ( $project_cond =~ /\S/ ); push @$where_cond, $published_cond if ( $published_cond =~ /\S/ ); + push @$where_cond, $draft_cond if ( $draft_cond =~ /\S/ ); push @$where_cond, $disable_event_sync_cond if ( $disable_event_sync_cond ne '' ); @@ -1016,6 +1031,7 @@ sub get_query { ,e.user_title ,e.user_excerpt ,e.published + ,e.draft ,e.playout ,e.archived ,e.rerun diff --git a/lib/calcms/series.pm b/lib/calcms/series.pm index bb9d289..97275c4 100644 --- a/lib/calcms/series.pm +++ b/lib/calcms/series.pm @@ -486,10 +486,17 @@ sub get_events{ push @conditions, 'e.location = ?'; push @bind_values, $options->{location}; } + + if(defined $options->{draft}){ + push @conditions, 'e.draft = ?'; + push @bind_values, $options->{draft}; + } + my $conditions=''; if (@conditions>0){ $conditions=' and '.join(' and ', @conditions); } + my $limit=''; if( (defined $options->{limit}) && ($limit=~/(\d+)/) ){ $limit='limit '.$1; @@ -542,7 +549,8 @@ sub get_event{ my $project_id = $options->{project_id}||''; my $studio_id = $options->{studio_id}||''; my $series_id = $options->{series_id}||''; - my $event_id = $options->{event_id} ||''; + my $event_id = $options->{event_id} ||''; + my $draft = $options->{draft} ||''; unless(defined($options->{allow_any})){ if ($project_id eq''){ @@ -569,6 +577,7 @@ sub get_event{ $queryOptions->{studio_id} = $studio_id if $studio_id ne ''; $queryOptions->{series_id} = $series_id if $series_id ne ''; $queryOptions->{event_id} = $event_id if $event_id ne ''; + $queryOptions->{draft} = $draft if $draft ne ''; my $events=series::get_events($config, $queryOptions); @@ -1113,6 +1122,7 @@ sub update_recurring_events{ project_id => $options->{project_id}, studio_id => $options->{studio_id}, series_id => $options->{series_id}, + draft => 0 } ); @$events=sort { $a->{start} cmp $b->{start}} @$events; diff --git a/lib/calcms/series_events.pm b/lib/calcms/series_events.pm index cdadf25..d083290 100644 --- a/lib/calcms/series_events.pm +++ b/lib/calcms/series_events.pm @@ -72,12 +72,13 @@ sub save_content{ for my $key ('series_name', 'title', 'excerpt', 'content', 'html_content', 'user_title', 'user_excerpt', 'topic', 'html_topic', 'episode', 'image', 'podcast_url', 'archive_url', - 'live', 'published', 'playout', 'archived', 'rerun', 'disable_event_sync', + 'live', 'published', 'playout', 'archived', 'rerun', 'draft', 'disable_event_sync', 'modified_by' ){ push @keys, $key if defined $entry->{$key}; } - $entry->{episode}=undef if((defined $entry->{episode}) && ($entry->{episode}eq'0')); + $entry->{episode} = undef if (defined $entry->{episode}) && ($entry->{episode} eq '0'); + $entry->{published} = 0 if (defined $entry->{draft}) && ($entry->{draft} eq '1'); my $values =join(",", map {$_.'=?'} (@keys)); my @bind_values =map {$entry->{$_}} (@keys); @@ -89,7 +90,7 @@ sub save_content{ where id=? }; - #print STDERR $query.Dumper(\@bind_values); + print STDERR $query.Dumper(\@bind_values); db::put($dbh, $query, \@bind_values); return $entry; } @@ -307,6 +308,9 @@ sub check_permission{ my $series_name=$series->[0]->{series_name}||''; $series_name.=' - '.$series->[0]->{title} if $series->[0]->{series_name} ne ''; + my $draft = 0; + $draft = 1 if (defined $options->{draft}) && ($options->{draft} == 1 ); + #check all items from checklist if((defined $check->{user})&&(uac::is_user_assigned_to_studio($request, $options)==0)){ return "User '$request->{user}' is not assigned to studio $studio_name ($options->{studio_id})"; @@ -328,7 +332,7 @@ sub check_permission{ return "User $request->{user} cannot create events for series '$series_name' ($options->{series_id})"; } - if((defined $check->{studio_timeslots})&&(studio_timeslot_dates::can_studio_edit_events($config, $options)==0)){ + if( ($draft==0) && (defined $check->{studio_timeslots}) && (studio_timeslot_dates::can_studio_edit_events($config, $options)==0) ){ return "requested time is not assigned to studio '$studio_name' ($options->{studio_id})"; } @@ -340,7 +344,7 @@ sub check_permission{ } # prevent editing events that are over for more than 14 days - if(defined $check->{event_age}){ + if( ($draft==0) && (defined $check->{event_age}) ){ if (series::is_event_older_than_days($config, { project_id => $options->{project_id}, studio_id => $options->{studio_id}, @@ -356,7 +360,7 @@ sub check_permission{ } #check if schedule event exists for given date - if(defined $check->{schedule}){ + if( ($draft == 0) && (defined $check->{schedule}) ){ return "unknown series" unless defined $series; return "missing start_at at check_permission" unless defined $options->{start_date}; #TODO: check "is_event_scheduled" if start_at could be moved to start_date @@ -414,7 +418,7 @@ sub insert_event{ $event->{'html_topic'} = markup::creole_to_html($event->{'topic'}) if defined $event->{'topic'}; #add event status - for my $attr ('live', 'published', 'playout', 'archived', 'rerun', 'disable_event_sync'){ + for my $attr ('live', 'published', 'playout', 'archived', 'rerun', 'draft', 'disable_event_sync'){ $event->{$attr}=$params->{$attr}||0; } diff --git a/lib/calcms/user_settings.pm b/lib/calcms/user_settings.pm index 08db559..a142885 100644 --- a/lib/calcms/user_settings.pm +++ b/lib/calcms/user_settings.pm @@ -18,6 +18,10 @@ our $defaultColors=[ name => 'color_event', css => '#content .event', color => '#c5e1a5' + },{ + name => 'color_draft', + css => '#content .draft', + color => '#eeeeee', },{ name => 'color_schedule', css => '#content .schedule', diff --git a/website/agenda/comments.cgi b/website/agenda/comments.cgi index f1f7e00..df32af9 100755 --- a/website/agenda/comments.cgi +++ b/website/agenda/comments.cgi @@ -40,6 +40,5 @@ if ($0=~/comments.*?\.cgi$/){ print $output; } - #do not delete last line 1; diff --git a/website/agenda/planung/calendar.cgi b/website/agenda/planung/calendar.cgi index 2edda78..2b9a700 100755 --- a/website/agenda/planung/calendar.cgi +++ b/website/agenda/planung/calendar.cgi @@ -245,6 +245,8 @@ sub showCalendar { delete $options->{till_date} if ( $params->{list} == 1 ); delete $options->{date_range_include} if ( $params->{list} == 1 ); } + + $options->{draft}=0 unless $params->{list}==1; #get events sorted by date $events = getSeriesEvents( $config, $request, $options, $params ); @@ -723,6 +725,7 @@ sub showEventList { $params->{loc}->{label_episode} + @@ -754,7 +757,7 @@ sub showEventList { $class .= ' error' if defined $event->{error}; $class .= ' no_series' if ( ( $class eq 'event' ) && ( $event->{series_id} eq '-1' ) ); - for my $filter ( 'rerun', 'archived', 'playout', 'published', 'live', 'disable_event_sync' ) { + for my $filter ( 'rerun', 'archived', 'playout', 'published', 'live', 'disable_event_sync', 'draft' ) { $class .= ' ' . $filter if ( ( defined $event->{$filter} ) && ( $event->{$filter} eq '1' ) ); } $class .= ' preproduced' unless ( ( defined $event->{'live'} ) && ( $event->{'live'} eq '1' ) ); @@ -772,7 +775,8 @@ sub showEventList { $event->{user_title} ||= ''; $event->{episode} ||= ''; $event->{rerun} ||= ''; - $id ||= ''; + $event->{draft} ||= ''; + $id ||= ''; $class ||= ''; my $archived = $event->{archived} || '-'; @@ -790,6 +794,11 @@ sub showEventList { $rerun = " [" . markup::base26( $event->{recurrence_count} + 1 ) . "]" if ( defined $event->{recurrence_count} ) && ( $event->{recurrence_count} ne '' ) && ( $event->{recurrence_count} > 0 ); + + my $draft = $event->{draft} || '0'; + $draft='-' if $draft eq '0'; + $draft='x' if $draft eq '1'; + my $title = $event->{title}; $title .= ': ' . $event->{user_title} if $event->{user_title} ne ''; @@ -804,6 +813,7 @@ sub showEventList { . qq!$title! . qq!$event->{episode}! . qq!$rerun! + . qq!$draft! . qq!$live! . qq!$archived! . qq!! . "\n"; @@ -1358,7 +1368,7 @@ sub print_event { $class .= ' no_series' if ( ( $class eq 'event' ) && ( $event->{series_id} eq '-1' ) ); $class .= " error x$event->{error}" if defined $event->{error}; - for my $filter ( 'rerun', 'archived', 'playout', 'published', 'live', 'disable_event_sync' ) { + for my $filter ( 'rerun', 'archived', 'playout', 'published', 'live', 'disable_event_sync', 'draft' ) { $class .= ' ' . $filter if ( ( defined $event->{$filter} ) && ( $event->{$filter} eq '1' ) ); } $class .= ' preproduced' unless ( ( defined $event->{'live'} ) && ( $event->{'live'} eq '1' ) ); @@ -1455,6 +1465,7 @@ sub find_errors { next if defined $event->{grid}; next if defined $event->{work}; next if defined $event->{play}; + next if (defined $event->{draft}) && ($event->{draft} == 1); next unless defined $event->{ystart}; next unless defined $event->{yend}; $event->{check_errors} = 1; @@ -1583,7 +1594,7 @@ sub printToolbar {