add draft status to events
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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',
|
||||
|
||||
Reference in New Issue
Block a user