%if ($debug) { RC: <% $rc %>
MSG: <%$msg %>
RC2: <% $rc2 %>
MSG2: <%$msg2 %>
EVENT_NAME: <%$eventname%>
DEFAULT_PLAYLIST: <% $default[0]->{'PLAYLIST_NAME'} %>

DATA:
% foreach my $k (@data) { <%$k%>
% }
DEFAULT DATA:
% foreach my $k (@data2) { <%$k%>
% }
START_TIME:<%$current_event->{'START_TIME'}%>
DURATION: <%$current_event->{'DURATION'}%>

SUBMITTING EVENT:
PLAYLIST: <%$new_playlist %>
EVENTNAME: <%$new_name %>
DESCRIPTION: <%$new_description %>
%} Live365 - Broadcast Schedule - Add or Edit Events
Broadcast Schedule for <% $stationname %> - Add or Edit Events
% if ($error_title ne '') { <& /mc/messaging/message-box.mh, severity=>$error_severity, title=>$error_title, message=>$error_message &>
% }
Add Events to Your Schedule Back
%if ($mode eq 'default' || $default[0]->{'EVENT_NAME'} eq '') {
Default Event Help
This playlist will play in between your other scheduled playlists.
Default Playlist: <& .playlistselect, dbh=>$dbh, stationname=> $stationname, current_playlist=>$default[0]->{'PLAYLIST_NAME'}, fieldname=>"new_playlist" &> Select a playlist that you have created.
<% $playlists_link %>.
Event Name: Appears as the bold title of the event on the schedule.
Description: Appears as the description of this specific event on the schedule. Upon activation, this new description will also become your default Station description in the Listen Directory.
Save Default EventDo not save changes on this form and return to Scheduler
 
 
%}
New/Edit Event Help %if ($mode ne 'default' && $default[0]->{'EVENT_NAME'} ne '') { Default Event: <% CGI::unescape($default[0]->{'EVENT_NAME'} ) %> (edit) %}
Station Title: <% $station_title %>  
Event Name: %if ($mode eq 'edit') { <% CGI::unescape($current_event->{'EVENT_NAME'} ) %> %}else{ %} Appears as the bold title of the event on the schedule.
Event Type: Is this event a Basic, Live, or Relay Broadcast?
Playlist Name: <& .playlistselect, dbh=>$dbh, stationname=> $stationname, current_playlist=>$current_event->{'PLAYLIST_NAME'}, fieldname=>"new_playlist" &> Select a playlist that you have created.
<% $playlists_link %>.
Description: Appears as the description of this specific event on the schedule. This event description will also become your station description in the Listen Directory while playing.
Recurrence: Once, daily, or weekly.
Tip: If you're scheduling a one-time event, we recommend including the date of the event within your event title or description.
Day: Select the day. (One-time or Weekly event only)
Start Time: Select a start time.
End Time: Select an end time.
Save Scheduled EventDo not save changes on this form and return to Scheduler

 
%######################################### %# arguments passed to this page %######################################### <%args> $stationname => '' $eventname =>'' $mode => '' $check => 1 #ON SUBMIT $new_name =>'' $new_type =>'' $new_playlist =>'' $new_description =>'' $new_recurrence =>'' $new_day =>'' $new_start =>'' $new_end =>'' $new_timezone =>'' $debug =>0 %############################################## %# initialization routine %############################################## <%init> use LiveConf; use LiveLib; use LiveSched; use CGI ':standard'; use CGI::Cookie; use LivePlaylist; use LiveACL; use Broadcast; my $ecast_server; my $playlists_link; my $station_title; my @playlists; my @default; my @events; my $current_event; ## pointer to an @event element (HASH) my @data; my $response; my @data2; my ($rc2, $msg2, $response2); my $error_severity; my $error_title; my $error_message; my $nodata; my $nodefaultdata; my $do_dup_check = 1; ## CLEANUP INPUT FOR DB INPUT $new_description = &LiveLib::cleanup_data_field('desc', $new_description); $new_name = &LiveLib::cleanup_data_field('desc', $new_name); my $dbh = &LiveLib::open_database(); # # Figure out who is logged in and which station she's editing. # my ($rc, $msg, $member_name, $stn, $session_key) = &LiveACL::get_member_and_station($dbh, 2, 'schedule_event'); if (!$stationname) { $stationname = $stn; } if ($rc || !$member_name || !$stn || $stn ne $stationname) { my $q = new CGI(''); print $q->redirect("/members/login.live?action=exp"); exit; } # # Get broadcaster data # my $b_info = &Broadcast::init_broadcast_info($dbh, $stationname, 'STA|STR'); my %station = &Broadcast::get_broadcast_info($b_info, 'STA'); my %stream = &Broadcast::get_broadcast_info($b_info, 'STR'); $station_title = $station{'TITLE'}; my $pool = $stream{'ASSIGNED_SERVER_POOL'}; $ecast_server = $LIVECONF{"Easycast::server_$pool"}; # # "manage playlists" link appearing twice on page # $playlists_link = "Manage playlists"; # # Create or edit an event # if ($mode eq 'submitevent') { # # Calc the duration # my $new_duration = 0; if ($new_end ne 'cont' ) { ## CONTINUOUS PLAY IS TAGGED WITH DURATION OF ZERO IN DB $new_duration = $new_end - $new_start; if ($new_duration < 0) { $new_duration += 86400; ##ADD 24HRS IF IT GOES PAST MIDNIGHT } } # # This is to re-populate the form if errors # $current_event -> {'STATION_NAME'} = $stationname; $current_event -> {'STATUS'} = 1; $current_event -> {'START_TIME'} = $new_start; $current_event -> {'TIME_ZONE'} = $new_timezone; $current_event -> {'RECURRENCE'} = $new_recurrence; $current_event -> {'DESCRIPTION'} = $new_description; $current_event -> {'PRIORITY'} = '-1'; $current_event -> {'DURATION'} = $new_duration; $current_event -> {'EVENT_NAME'} = $new_name; $current_event -> {'EVENT_TYPE'} = $new_type; $current_event -> {'PLAYLIST_NAME'} = $new_playlist; $current_event -> {'RECURRENCE_INFO'} = $new_day; # # Check for conflicting existing record # my $record_exists = 0; if ($check) { $record_exists = &LiveSched::does_record_exist($dbh, $new_name, $stationname); } if (!$record_exists) { ($rc, $msg) = &LiveSched::set_broadcaster_event($stationname, $new_type, $new_name, $new_playlist, $new_description, $new_recurrence, $new_day, '-1', $new_timezone, $new_duration, $new_start); } else { ($rc, $msg) = (1, "An event with named $new_name already exists. Please choose a different name for your new event."); } if ($rc != 0) { $error_severity = 'error'; $error_title = 'Error Submitting Scheduler Data'; $error_message = "There was an error submitting your data to the scheduler:

". CGI::unescape($msg); } else { # # Bounce to main scheduler page with success confirmation # my $q = new CGI; print $q->redirect("/broadcast/scheduler/index.live?stationname=$stationname&edit=1&confirm=1"); exit; } } elsif ($mode eq 'edit') { $do_dup_check = 0; # # Get scheduler event data for broadcaster's edit mode # ($rc, $msg, $response) = &LiveSched::get_broadcaster_events('NOHEADER', $stationname); if ($response =~/Generic error/) { $nodata = 1; } elsif($rc != 0) { $error_severity = 'error'; $error_title = 'Error Getting Scheduler Data'; $error_message = "There was an error getting data from the scheduler. Please return to the Scheduler, and try again. ($msg)"; } else { $response=~ s/'/'/g; @data = split(/<\/EVENT>/, $response); ## split up into individual events pop @data; my $count = 0; ### PARSE CONTENT OUT OF EACH DATA ELEMENT foreach my $data_chunk (@data) { my $station_name; my $status; my $start_time; my $time_zone; my $recurrence; my $description; my $priority; my $duration; my $event_name; my $event_type; my $playlist_name; my $recurrence_info; if ($data_chunk=~ /<\/STATION_NAME>/) { $station_name = $1; } if ($data_chunk=~/(.*)<\/STATUS>/) { $status = $1; } if ($data_chunk=~/(.*)<\/START_TIME>/) { $start_time = $1; } if ($data_chunk=~/(.*)<\/TIME_ZONE>/) { $time_zone = $1; ##$start_time += $time_zone; ##add time zone offset to get us to GMT } if ($data_chunk=~/(.*)<\/RECURRENCE>/) { $recurrence = $1; } if ($data_chunk=~/<\/DESCRIPTION>/) { $description = $1; } if ($data_chunk=~/(.*)<\/PRIORITY>/) { $priority = $1; } if ($data_chunk=~/(.*)<\/DURATION>/) { $duration = $1; } if ($data_chunk=~/<\/EVENT_NAME>/) { $event_name = $1; } if ($data_chunk=~/(.*)<\/EVENT_TYPE>/) { $event_type = $1; } if ($data_chunk=~/<\/PLAYLIST_NAME>/) { $playlist_name = $1; } if ($data_chunk=~/(.*)<\/RECURRENCE_INFO>/) { $recurrence_info = $1; } my $key = $count++; $events[$key] = { 'STATION_NAME' => $station_name, 'STATUS' => $status, 'START_TIME' => $start_time, 'TIME_ZONE' => $time_zone, 'RECURRENCE' => $recurrence, 'DESCRIPTION' => $description, 'PRIORITY' => $priority, 'DURATION' => $duration, 'EVENT_NAME' => $event_name, 'EVENT_TYPE' => $event_type, 'PLAYLIST_NAME' => $playlist_name, 'RECURRENCE_INFO' => $recurrence_info }; ##GRAB DESIRED SCHEDULER EVENT DATA INTO ONE ARRAY FOR LOCAL HANDLING ON THIS PAGE if ($events[$key]{'EVENT_NAME'} eq $eventname) { $current_event = $events[$key]; } }#end of foreach loop }#end of response elsif block }#end of edit-mode if block ##CREATE OR EDIT THE DEFAULT EVENT if ($mode eq 'submitdefault') { # # This is to re-populate the form if errors # $default[0] = { 'STATION_NAME' => $stationname, 'DESCRIPTION' => $new_description, 'PLAYLIST_NAME' => $new_playlist, 'EVENT_NAME' => $new_name }; ## SUBMIT TO DATABASE ($rc2, $msg2) = &LiveSched::set_default($stationname, $new_playlist, $new_description, $new_name); if ($rc2 != 0) { $error_severity = 'error'; $error_title = 'Error Submitting Scheduler Data'; $error_message = "There was an error submitting your data to the scheduler. (". CGI::unescape($msg2) .")"; } else { # # Bounce to main scheduler page with success confirmation # my $q = new CGI; print $q->redirect("/broadcast/scheduler/index.live?stationname=$stationname&edit=1&confirm=1"); exit; } } else { # # Get scheduler default data # ($rc2, $msg2, $response2) = &LiveSched::get_default('NOHEADER', $stationname, 0); if ($response2 =~/Generic error/) { $nodefaultdata = 1; } elsif ($rc2 != 0) { $error_severity = 'error'; $error_title = 'Error Getting Scheduler Data'; $error_message = "There was an error getting data from the scheduler. Please return to the Scheduler, and try again. ($msg2)"; } else { $response2=~ s/'/'/g; $data2[0] = $response2; my $count = 0; # # Parse content out of each data element # foreach my $data_chunk (@data2) { $data_chunk=~ /<\/STATION_NAME>/; my $station_name = $1; $data_chunk =~/<\/DESCRIPTION>/; my $description = $1; $data_chunk=~/<\/EVENT_NAME>/; my $event_name = $1; $data_chunk=~/(.+)<\/EVENT_TYPE>/; my $event_type = $1; $data_chunk=~/(.+)<\/PLAYLIST_NAME>/; my $playlist_name = $1; my $key = $count++; $default[$key] = { 'STATION_NAME' => $station_name, 'DESCRIPTION' => $description, 'EVENT_NAME' => $event_name, 'EVENT_TYPE' => $event_type, 'PLAYLIST_NAME' => $playlist_name, }; } } } <%cleanup> { if ($dbh) { &LiveLib::close_database($dbh); } } <%def .playlistselect> <%args> $dbh $stationname $current_playlist => '' $fieldname <%init> # Fetch playlist names from PLAYLIST_META. my ($rc, $msg, @names) = &LivePlaylist::get_playlist_meta($dbh, $stationname); my $optlist = "