Example #1
0
/**
 * Prints a <select> of the available channels
/**/
function channel_select($params = '', $selected = '', $id = 00)
{
    $channels = Channel::getChannelList();
    echo "\n<select name=\"chan_{$id}\" {$params}>";
    foreach ($channels as $chanid) {
        $channel =& Channel::find($chanid);
        // Not visible?
        if (empty($channel->visible) || $channel->chanid == 91010) {
            continue;
        }
        // Print the option
        echo '
                <option value="', $channel->chanid, '"', ' title="', html_entities($channel->name), '"';
        // Selected?
        if ($channel->chanid == $selected || $channel->chanid == $_GET['chanid']) {
            echo ' SELECTED';
        }
        // Print the rest of the content
        echo '>';
        if ($_SESSION["prefer_channum"]) {
            echo $channel->channum . '&nbsp;&nbsp;(' . html_entities($channel->callsign) . ')';
        } else {
            echo html_entities($channel->callsign) . '&nbsp;&nbsp;(' . $channel->channum . ')';
        }
        echo '</option>';
    }
    echo '</select>';
}
/**
 * prints a <select> of the available channels
/**/
function channel_select($chanid)
{
    $Channel_list = Channel::getChannelList();
    echo '<select name="channel"><option value=""';
    if (empty($chanid)) {
        echo ' SELECTED';
    }
    echo '>(' . t('Any Channel') . ')</option>';
    foreach ($Channel_list as $chanid) {
        $channel =& Channel::find($chanid);
        // Print the option
        echo '<option value="', $channel->chanid, '"', ' title="', html_entities($channel->name), '"';
        // Selected?
        if ($channel->chanid == $chanid) {
            echo ' SELECTED';
        }
        // Print the rest of the content
        echo '>';
        if ($_SESSION["prefer_channum"]) {
            echo $channel->channum . '&nbsp;&nbsp;(' . html_entities($channel->callsign) . ')';
        } else {
            echo html_entities($channel->callsign) . '&nbsp;&nbsp;(' . $channel->channum . ')';
        }
        echo '</option>';
    }
    echo '</select>';
}
Example #3
0
    if (!isset($schedule->autoexpire)) {
        $schedule->autoexpire = setting('AutoExpireDefault');
    }
    // start early / end late
    if (!isset($schedule->startoffset)) {
        $schedule->startoffset = setting('DefaultStartOffset');
    }
    if (!isset($schedule->endoffset)) {
        $schedule->endoffset = setting('DefaultEndOffset');
    }
}
// Load the channel
if ($program) {
    $channel =& $program->channel;
} else {
    $channel =& Channel::find($schedule->chanid);
}
// Parse the list of scheduled recordings for possible conflicts
$conflicting_shows = array();
foreach (Schedule::findScheduled() as $callsign => $shows) {
    // Now the shows in this channel
    foreach ($shows as $starttime => &$show_group) {
        // Clearly not a match
        if ($starttime > $program->endtime) {
            continue;
        }
        // Parse each show group
        foreach ($show_group as $key => &$show) {
            // Ignore this show
            if ($show->chanid == $program->chanid && $show->starttime == $program->starttime) {
                continue;
Example #4
0
function cmd_mode($client, $argv)
{
    $name = $argv[0];
    $set = isset($argv[1]) ? implode(' ', array_slice($argv, 1)) : false;
    if (Channel::is_valid($name)) {
        // Valid channel name
        if (($channel = Channel::find($name)) === false) {
            // Channel doesn't exist.
            $client->write(IRC::sprintf(IRC::NoSuchNickChannel, &$client, $name));
            return;
        }
        if ($set === false) {
            // Not setting anything.
            // Modes
            $client->write(IRC::sprintf(IRC::ChannelModes, &$client, $name, $channel->modes->make_string()));
            // Creation time
            $client->write(IRC::sprintf(IRC::ChannelCreated, &$client, $name, $channel->created));
        } else {
            // TODO: Check for mode +o, etc, before allowing this.
            $channel->modes->mode($set);
        }
        return;
    }
    // Treat as a PM
    if (($user = Client::find_by_nick($name)) === false) {
        // Couldn't find a channel or user under this name
        $client->write(IRC::sprintf(IRC::NoSuchNickChannel, &$client, $name));
    } else {
        // Found a user
        // TODO: User modes (oper only?)
    }
}
Example #5
0
 public function __construct($data)
 {
     global $db;
     // This is a mythbackend-formatted program - info about this data structure is stored in libs/libmyth/programinfo.cpp
     if (!isset($data['chanid']) && isset($data[0])) {
         // Load the remaining info we got from mythbackend
         $this->title = trim($data[0]);
         # program name/title
         $this->subtitle = $data[1];
         # episode name
         $this->description = $data[2];
         # episode description
         $this->season = $data[3];
         $this->episode = $data[4];
         $this->total_episodes = $data[5];
         $this->syndicatedepisodenumber = $data[6];
         $this->category = $data[7];
         $this->chanid = $data[8];
         # mysql chanid
         $this->channum = $data[9];
         $this->callsign = $data[10];
         $this->channame = $data[11];
         $this->filename = $data[12];
         $this->filesize = $data[13];
         $this->starttime = $data[14];
         # show start-time
         $this->endtime = $data[15];
         # show end-time
         $this->findid = $data[16];
         $this->hostname = $data[17];
         $this->sourceid = $data[18];
         $this->cardid = $data[19];
         $this->inputid = $data[20];
         $this->recpriority = $data[21];
         $this->recstatus = $data[22];
         $this->recordid = $data[23];
         $this->rectype = $data[24];
         $this->dupin = $data[25];
         $this->dupmethod = $data[26];
         $this->recstartts = $data[27];
         # ACTUAL start time (also maps to recorded.starttime)
         $this->recendts = $data[28];
         # ACTUAL end time
         $this->progflags = $data[29];
         $this->recgroup = $data[30];
         $this->outputfilters = $data[31];
         $this->seriesid = $data[32];
         $this->programid = $data[33];
         $this->inetref = $data[34];
         $this->lastmodified = $data[35];
         $this->stars = $data[36];
         $this->airdate = $data[37];
         $this->playgroup = $data[38];
         $this->recpriority2 = $data[39];
         $this->parentid = $data[40];
         $this->storagegroup = $data[41];
         $this->audioproperties = $data[42];
         $this->videoproperties = $data[43];
         $this->subtitletype = $data[44];
         $this->year = $data[45];
         $this->partnumber = $data[46];
         $this->parttotal = $data[47];
         $this->category_type = $data[48];
         $this->recordedid = $data[49];
         // Is this a previously-recorded program?
         if (!empty($this->filename)) {
             $this->url = video_url($this);
             // get download info
         }
         // Assign the program flags
         $this->has_commflag = $this->progflags & 0x1 ? true : false;
         // FL_COMMFLAG       = 0x00000001
         $this->has_cutlist = $this->progflags & 0x2 ? true : false;
         // FL_CUTLIST        = 0x00000002
         $this->auto_expire = $this->progflags & 0x4 ? true : false;
         // FL_AUTOEXP        = 0x00000004
         $this->is_editing = $this->progflags & 0x8 ? true : false;
         // FL_EDITING        = 0x00000008
         $this->bookmark = $this->progflags & 0x10 ? true : false;
         // FL_BOOKMARK       = 0x00000010
         $this->is_recording = $this->progflags & 0x100000 ? true : false;
         // FL_INUSERECORDING = 0x00100000
         $this->is_playing = $this->progflags & 0x200000 ? true : false;
         // FL_INUSEPLAYING   = 0x00200000
         $this->is_transcoded = $this->progflags & 0x100 ? true : false;
         // FL_TRANSCODED     = 0x00000100
         $this->is_watched = $this->progflags & 0x200 ? true : false;
         // FL_WATCHED        = 0x00000200
         // Can be deleted?
         $this->can_delete = !$this->is_recording && !$this->is_playing || $this->recgroup != 'LiveTV';
         // Add a generic "will record" variable, too
         $this->will_record = $this->rectype && $this->rectype != rectype_dontrec ? true : false;
     } else {
         if (in_array($data['airdate'], array('0000-00-00', '0000', '1900-01-01'))) {
             $this->airdate = $data['originalairdate'];
         } else {
             $this->airdate = $data['airdate'];
         }
         $this->category = _or($data['category'], t('Unknown'));
         $this->category_type = _or($data['category_type'], t('Unknown'));
         $this->chanid = $data['chanid'];
         $this->description = $data['description'];
         $this->endtime = $data['endtime_unix'];
         $this->previouslyshown = $data['previouslyshown'];
         $this->programid = $data['programid'];
         $this->rater = $data['rater'];
         $this->rating = $data['rating'];
         $this->seriesid = $data['seriesid'];
         $this->showtype = $data['showtype'];
         $this->stars = $data['stars'];
         $this->starttime = $data['starttime_unix'];
         $this->subtitle = $data['subtitle'];
         $this->subtitled = $data['subtitled'];
         $this->title = $data['title'];
         $this->partnumber = $data['partnumber'];
         $this->parttotal = $data['parttotal'];
         $this->colorcode = $data['colorcode'];
         $this->syndicatedepisodenumber = $data['syndicatedepisodenumber'];
         $this->title_pronounce = $data['title_pronounce'];
         $this->recstatus = $data['recstatus'];
         $this->recordedid = $data['recordedid'];
         // These db fields should really get renamed...
         $this->audioproperties = $data['stereo'];
         $this->videoproperties = $data['hdtv'];
         $this->subtitletype = $data['closecaptioned'];
     }
     // Assign shortcut names to the new audio/video/subtitle property flags
     $this->stereo = $this->audioproperties & 0x1;
     $this->mono = $this->audioproperties & 0x2;
     $this->surround = $this->audioproperties & 0x4;
     $this->dolby = $this->audioproperties & 0x8;
     $this->audiohardhear = $this->audioproperties & 0x10;
     $this->audiovisimpair = $this->audioproperties & 0x20;
     $this->hdtv = $this->videoproperties & 0x1;
     $this->widescreen = $this->videoproperties & 0x2;
     $this->avc = $this->videoproperties & 0x4;
     $this->hd_ready = $this->videoproperties & 0x8;
     $this->fullhd = $this->videoproperties & 0x10;
     $this->damaged = $this->videoproperties & 0x20;
     $this->closecaptioned = $this->subtitletype & 0x1;
     $this->has_subtitles = $this->subtitletype & 0x2;
     $this->subtitled = $this->subtitletype & 0x4;
     $this->deaf_signed = $this->subtitletype & 0x8;
     // Generate the star string, since mysql has issues with REPEAT() and
     // decimals, and the backend doesn't do it for us, anyway.
     $this->starstring = @str_repeat(star_character, intVal($this->stars * max_stars));
     $frac = $this->stars * max_stars - intVal($this->stars * max_stars);
     if ($frac >= 0.75) {
         $this->starstring .= '&frac34;';
     } elseif ($frac >= 0.5) {
         $this->starstring .= '&frac12;';
     } elseif ($frac >= 0.25) {
         $this->starstring .= '&frac14;';
     }
     // Get the name of the input
     if ($this->inputid) {
         $this->inputname = $db->query_col('SELECT displayname
                                              FROM capturecard
                                             WHERE cardid=?', $this->inputid);
     } else {
         $this->inputname = $db->query_col('SELECT inputname
                                              FROM recorded
                                             WHERE recordedid=?', $this->recordedid);
     }
     // Turn recstatus into a word
     if (isset($this->recstatus) && $GLOBALS['RecStatus_Types'][$this->recstatus]) {
         $this->recstatus_orig = $this->recstatus;
         $this->recstatus = $GLOBALS['RecStatus_Types'][$this->recstatus];
         $this->conflicting = $this->recstatus == 'Conflict';
         # conflicts with another scheduled recording?
         $this->recording = $this->recstatus == 'WillRecord';
         # scheduled to record?
     }
     // No longer a null column, so check for blank entries
     if (in_array($this->airdate, array('0000-00-00', '0000', '1900-01-01'))) {
         $this->airdate = NULL;
     }
     // Do we have a chanid?  Load some info about it
     if ($this->chanid && !isset($this->channel)) {
         $this->channel =& Channel::find($this->chanid);
     }
     // Calculate the duration
     if ($this->recendts) {
         $this->length = $this->recendts - $this->recstartts;
     } else {
         $this->length = $this->endtime - $this->starttime;
     }
     // A special recstatus for shows that this was manually set to record
     if ($this->rectype == rectype_override) {
         $this->recstatus = 'ForceRecord';
     }
     // Find out which css category this program falls into
     if ($this->chanid != '') {
         $this->css_class = category_class($this);
     }
     // Create the fancy description
     $this->update_fancy_desc();
 }
Example #6
0
    break;
}
// Warning?
if (!empty($warning)) {
    add_warning(t('No matching programs found.') . "\n" . $warning);
}
// Now that we've selected only certain shows, load them into objects
$All_Shows = array();
foreach ($Programs as $title => $shows) {
    foreach ($shows as $key => $record) {
        // Create a new program object
        $show =& new Program($record);
        // Assign a reference to this show to the various arrays
        $All_Shows[] =& $show;
        $Programs[$title][$key] =& $show;
        $channel =& Channel::find($show->chanid);
        $channel->programs[] =& $show;
        unset($show);
    }
}
// Sort the program titles
uksort($Program_Titles, 'by_no_articles');
ksort($Groups);
// Keep track of the program/title the user wants to view
if (isset($_REQUEST['title'])) {
    $_SESSION['recorded_title'] = $_REQUEST['title'];
}
if (isset($_REQUEST['recgroup'])) {
    $_SESSION['recorded_recgroup'] = $_REQUEST['recgroup'];
}
// The default sorting choice isn't so good for recorded programs, so we'll set our own default
Example #7
0
</td>
    <td width="5%"><?php 
echo t('commfree');
?>
</td>
    <td width="5%"><?php 
echo t('visible');
?>
</td>
    <td width="5%"><?php 
echo t('useonairguide');
?>
</td>
</tr><?php 
foreach ($channels as $chanid) {
    $channel =& Channel::find($chanid);
    ?>
<tr class="settings" align="center">
    <td><input type="checkbox" name="channel[<?php 
    echo $channel->chanid;
    ?>
][delete]" id="delete_<?php 
    echo $channel->chanid;
    ?>
" value="true" /></td>
    <td><?php 
    echo html_entities($channel->sourceid);
    ?>
</td>
    <td><input type="text" size="5"  name="channel[<?php 
    echo $channel->chanid;
Example #8
0
				<td class="x-description"><?php 
    echo $show->description;
    ?>
</td>
				<td class="x-channum"><?php 
    echo $show->channel->channum . ' - ' . $show->channel->name;
    ?>
</td>
				<td class="x-airdate"><?php 
    echo '<a href="' . root_url . 'tv/detail/' . $show->chanid . '/' . $show->starttime . '">' . strftime($_SESSION['date_search'], $show->starttime) . '</a>';
    if ($show->extra_showings) {
        foreach ($show->extra_showings as $pair) {
            list($chanid, $showtime) = $pair;
            echo '<br><a href="', root_url, 'tv/detail/', $chanid, '/', $showtime, '" class="italic">', strftime($_SESSION['date_search'], $showtime);
            if ($chanid != $show->chanid) {
                echo ' (', Channel::find($chanid)->callsign, ')';
            }
            echo '</a>';
        }
    }
    ?>
</td>
				<td class="x-length"><?php 
    echo nice_length($show->length);
    ?>
</td>
				</tr>
	<?php 
}
?>
</table>
Example #9
0
$displayed_channels = array();
$channels = Channel::getChannelList();
foreach ($channels as $key) {
    // Ignore channels with no number
    if (strlen(Channel::find($key)->channum) < 1) {
        continue;
    }
    // Skip already-displayed channels
    if ($displayed_channels[Channel::find($key)->channum]) {
        continue;
    }
    $displayed_channels[Channel::find($key)->channum] = 1;
    // Count this channel
    $channel_count++;
    // Grab the reference
    $channel =& Channel::find($key);
    // Print the data
    print_channel(&$channel, $list_starttime, $list_endtime);
    // Cleanup is a good thing
    unset($channel);
    // Display the timeslot bar?
    //          if ($channel_count % timeslotbar_skip == 0)
    //              $this->print_timeslots($Timeslots, $list_starttime, $list_endtime, $channel_count);
}
// Display the listing page footer
require_once 'modules/_shared/tmpl/' . tmpl . '/footer.php';
/*
        print_channel:
*/
function print_channel($channel, $start_time, $end_time)
{
Example #10
0
 function Recording($recording_data)
 {
     // SQL data
     if (is_array($recording_data) && isset($recording_data['recordid'])) {
         $this->recordid = $recording_data['recordid'];
         $this->type = $recording_data['type'];
         $this->chanid = $recording_data['chanid'];
         $this->starttime = $recording_data['starttime_unix'];
         $this->endtime = $recording_data['endtime_unix'];
         $this->title = $recording_data['title'];
         $this->subtitle = $recording_data['subtitle'];
         $this->description = $recording_data['description'];
         $this->season = $recording_data['season'];
         $this->episode = $recording_data['episode'];
         $this->category = $recording_data['category'];
         $this->profile = $recording_data['profile'];
         $this->recgroup = $recording_data['recgroup'];
         $this->storagegroup = $recording_data['storagegroup'];
         $this->recpriority = $recording_data['recpriority'];
         $this->autoexpire = $recording_data['autoexpire'];
         $this->maxepisodes = $recording_data['maxepisodes'];
         $this->maxnewest = $recording_data['maxnewest'];
         $this->dupin = $recording_data['dupin'];
         $this->dupmethod = $recording_data['dupmethod'];
         $this->startoffset = $recording_data['startoffset'];
         $this->endoffset = $recording_data['endoffset'];
         $this->seriesid = $recording_data['seriesid'];
         $this->programid = $recording_data['programid'];
         $this->inetref = $recording_data['inetref'];
         $this->progstart = $recording_data['progstart'];
         $this->progend = $recording_data['progend'];
         $this->basename = $recording_data['basename'];
     } else {
         $tmp = @get_object_vars($recording_data);
         if (count($tmp) > 0) {
             foreach ($tmp as $key => $value) {
                 $this->{$key} = $value;
             }
         }
     }
     // We get various recording-related information, too
     switch ($this->type) {
         case 1:
             $this->record_once = true;
             break;
         case 2:
             $this->record_daily = true;
             break;
         case 3:
             $this->record_channel = true;
             break;
         case 4:
             $this->record_always = true;
             break;
         case 5:
             $this->record_weekly = true;
             break;
         case 6:
             $this->record_findone = true;
             break;
     }
     // Add a generic "will record" variable, too
     $this->will_record = $this->record_daily || $this->record_weekly || $this->record_once || $this->record_findone || $this->record_channel || $this->record_always ? true : false;
     // Turn type int a word
     $this->texttype = $GLOBALS['RecTypes'][$this->type];
     // Do we have a chanid?  Load some info about it
     if ($this->chanid && !isset($this->channel)) {
         $this->channel =& Channel::find($this->chanid);
     }
     // Find out which css category this recording falls into
     if ($this->chanid != '') {
         $this->css_class = category_class($this);
     }
 }
 /**
  * Show the form for editing the specified propertieschannel.
  *
  * @param  int $channelId
  * @return Response
  */
 public function getEdit($channelId)
 {
     $propertieschannel = PropertiesChannel::firstOrNew(['channel_id' => $channelId, 'property_id' => Property::getLoggedId()]);
     $channel = Channel::find($propertieschannel->channel_id);
     return View::make('properties_channels.edit', compact('propertieschannel', 'channel'));
 }
Example #12
0
 /**
  * constructor
 /**/
 public function __construct($data)
 {
     global $db;
     $this->dupmethod = _or(setting('prefDupMethod'), 0);
     // Schedule object data -- just copy it into place
     if (is_object($data)) {
         // Not the right type of object?
         if (strcasecmp(get_class($data), 'schedule')) {
             trigger_error("Incorrect object of class " . get_class($data) . " passed to new Schedule()", FATAL);
         }
         // Copy its variables into place
         $a = @get_object_vars($data);
         if (is_array($a) && count($a) > 0) {
             foreach ($a as $key => $val) {
                 $this->{$key} = $val;
             }
         }
     } elseif (is_null($data)) {
         return;
     } else {
         // Are we passing in a set of chanid, starttime?
         if (func_num_args() == 2) {
             $chanid = func_get_arg(0);
             $start = func_get_arg(1);
             $data = $db->query_col('
                 SELECT recordid
                 FROM   record
                 WHERE  record.chanid = ?
                    AND record.starttime = FROM_UNIXTIME(?)', $chanid, $start);
         }
         // Data is a recordid -- load its contents
         if (!is_array($data) && $data > 0) {
             $data = $db->query_assoc('SELECT *, 
                                              UNIX_TIMESTAMP(startdate)+TIME_TO_SEC(starttime) AS starttime,
                                              UNIX_TIMESTAMP(enddate)+TIME_TO_SEC(endtime)     AS endtime
                                         FROM record
                                        WHERE recordid=?', $data);
         }
         // Array?
         if (is_array($data) && isset($data['recordid'])) {
             foreach ($data as $key => $val) {
                 $this->{$key} = $val;
             }
         }
     }
     // Custom power search needs to have fields split out
     if ($this->search == searchtype_power) {
         #########
         /** @todo actually split out the fields! */
     }
     // Add a generic "will record" variable, too
     $this->will_record = $this->type && $this->type != rectype_dontrec ? true : false;
     // Turn type into a word
     $this->texttype = $GLOBALS['RecTypes'][$this->type];
     // Do we have a chanid?  Load some info about it
     if ($this->chanid > 0 && !isset($this->channel)) {
         $this->channel =& Channel::find($this->chanid);
     }
     // Find out which css category this recording falls into
     if ($this->chanid != '') {
         $this->css_class = category_class($this);
     }
 }
Example #13
0
    $schedule =& Schedule::find($key);
    // Ignore overrides
    #    if ($schedule->type == rectype_override)
    #        continue;
    #    if ($schedule->type == rectype_dontrec)
    #        continue;
    // Ignore manual schedules
    #    if ($schedule->category == 'Manual recording')
    #        continue;
    // Couple of modifications
    if ($schedule->type == rectype_dontrec) {
        $schedule->profile = '';
        $schedule->recgroup = '';
    }
    // Add a blank channel, to suppress warnings
    if (!$schedule->channel) {
        $schedule->channel = Channel::find(null);
    }
    // Add this show
    $the_schedules[] =& $schedule;
}
// Remove the reference. This prevents duplicate entries showing up in the list
unset($schedule);
// Sort the recordings
if (count($the_schedules)) {
    sort_programs($the_schedules, 'schedules_sortby');
}
// Load the class for this page
require_once tmpl_dir . 'schedules.php';
// Exit
exit;
Example #14
0
 /**
  * The "details list" for recording schedules.  Very similar to that for
  * programs, but with a few extra checks, and some information arranged
  * differently.
 /**/
 public function details_list()
 {
     // Start the list, and print the title and schedule type
     $str = "<dl class=\"details_list\">\n" . "\t<dt>" . t('Title') . ":</dt>\n" . "\t<dd>" . html_entities($this->title) . "</dd>\n" . "\t<dt>" . t('Type') . ":</dt>\n" . "\t<dd>" . html_entities($this->texttype) . "</dd>\n";
     // Only show these fields for recording types where they're relevant
     if (in_array($this->type, array(rectype_once, rectype_daily, rectype_weekly, rectype_override, rectype_dontrec))) {
         // Airtime
         $str .= "\t<dt>" . t('Airtime') . ":</dt>\n" . "\t<dd>" . strftime($_SESSION['date_scheduled_popup'] . ', ' . $_SESSION['time_format'], $this->starttime) . ' to ' . strftime($_SESSION['time_format'], $this->endtime) . "</dd>\n";
         // Subtitle
         if (preg_match('/\\S/', $this->subtitle)) {
             $str .= "\t<dt>" . t('Subtitle') . ":</dt>\n" . "\t<dd>" . html_entities($this->subtitle) . "</dd>\n";
         }
         // Description
         if (preg_match('/\\S/', $this->description)) {
             $str .= "\t<dt>" . t('Description') . ":</dt>\n" . "\t<dd>" . nl2br(html_entities($this->description)) . "</dd>\n";
         }
         // Rating
         if (preg_match('/\\S/', $this->rating)) {
             $str .= "\t<dt>" . t('Rating') . ":</dt>\n" . "\t<dd>" . html_entities($this->rating) . "</dd>\n";
         }
     }
     // Category
     if (preg_match('/\\S/', $this->category)) {
         $str .= "\t<dt>" . t('Category') . ":</dt>\n" . "\t<dd>" . html_entities($this->category) . "</dd>\n";
     }
     // Rerun?
     if (!empty($this->previouslyshown)) {
         $str .= "\t<dt>" . t('Repeat') . ":</dt>\n" . "\t<dd>" . t('Yes') . "</dd>\n";
     }
     // Will be recorded at some point in the future?
     if (!empty($this->will_record)) {
         $str .= "\t<dt>" . t('Schedule') . ":</dt>\n" . "\t<dd>";
         switch ($this->type) {
             case rectype_once:
                 $str .= t('rectype-long: once');
                 break;
             case rectype_daily:
                 $str .= t('rectype-long: daily');
                 break;
             case rectype_channel:
                 $channel =& Channel::find($this->chanid);
                 $str .= t('rectype-long: channel', $_SESSION["prefer_channum"] ? $channel->channum : $channel->callsign);
                 break;
             case rectype_always:
                 $str .= t('rectype-long: always');
                 break;
             case rectype_weekly:
                 $str .= t('rectype-long: weekly');
                 break;
             case rectype_findone:
                 $str .= t('rectype-long: findone');
                 break;
             case rectype_override:
                 $str .= t('rectype-long: override');
                 break;
             case rectype_dontrec:
                 $str .= t('rectype-long: dontrec');
                 break;
             case rectype_finddaily:
                 $str .= t('rectype-long: finddaily');
                 break;
             case rectype_findweekly:
                 $str .= t('rectype-long: findweekly');
                 break;
             default:
                 $str .= t('Unknown');
         }
         $str .= "</dd>\n";
     }
     // Which duplicate-checking method will be used
     if ($this->dupmethod > 0) {
         $str .= "\t<dt>" . t('Dup Method') . ":</dt>\n" . "\t<dd>";
         switch ($this->dupmethod) {
             case 1:
                 $str .= t('None');
                 break;
             case 2:
                 $str .= t('Subtitle');
                 break;
             case 4:
                 $str .= t('Description');
                 break;
             case 6:
                 $str .= t('Subtitle and Description');
                 break;
             case 8:
                 $str .= t('Subtitle then Description');
                 break;
             case 22:
                 $str .= t('Sub and Desc (Empty matches)');
                 break;
         }
         $str .= "</dd>\n";
     }
     // Recording Priority
     if (preg_match('/\\S/', $this->recpriority)) {
         $str .= "\t<dt>" . t('Recording Priority') . ":</dt>\n" . "\t<dd>" . html_entities($this->recpriority) . "</dd>\n";
     }
     // Profile
     if (preg_match('/\\S/', $this->profile)) {
         $str .= "\t<dt>" . t('Profile') . ":</dt>\n" . "\t<dd>" . html_entities($this->profile) . "</dd>\n";
     }
     // Transcoder
     if (preg_match('/\\S/', $this->transcoder)) {
         global $Transcoders;
         $str .= "\t<dt>" . t('Transcoder') . ":</dt>\n" . "\t<dd>" . html_entities(_or($Transcoders[$this->transcoder], '&nbsp;')) . "</dd>\n";
     }
     // Recording Group
     if (!empty($this->recgroup)) {
         $str .= "\t<dt>" . t('Recording Group') . ":</dt>\n" . "\t<dd>" . html_entities($this->recgroup) . "</dd>\n";
     }
     // Storage Group
     if (!empty($this->storagegroup)) {
         $str .= "\t<dt>" . t('Storage Group') . ":</dt>\n" . "\t<dd>" . html_entities($this->storagegroup) . "</dd>\n";
     }
     // Finish off the table and return
     $str .= "\n</dl>";
     return $str;
 }
 /**
  * Show the form for editing the specified room.
  *
  * @param int $id
  * @param int $channelId
  * @return Response
  */
 public function getMap($id, $channelId)
 {
     $room = Room::find($id);
     $channelSettings = PropertiesChannel::getSettings($channelId, Property::getLoggedId());
     $channel = ChannelFactory::create($channelSettings);
     $result = $channel->getInventoryList();
     //todo temp
     //        file_put_contents('1.txt', serialize($result));
     //        $result = unserialize(file_get_contents('1.txt'));
     //add Inventories and Plans to DB//TODO move to another place
     //delete exist maps
     Inventory::where(['channel_id' => $channelId, 'property_id' => $channelSettings->property_id])->delete();
     //delete exist plan maps
     InventoryPlan::where(['channel_id' => $channelId, 'property_id' => $channelSettings->property_id])->delete();
     if ($result) {
         foreach ($result as $inventory) {
             Inventory::create(['code' => $inventory['code'], 'name' => $inventory['name'], 'channel_id' => $channelId, 'property_id' => $channelSettings->property_id]);
             if ($inventory['plans']) {
                 foreach ($inventory['plans'] as $plan) {
                     InventoryPlan::create(['code' => $plan['code'], 'name' => $plan['name'], 'channel_id' => $channelId, 'inventory_code' => $inventory['code'], 'property_id' => $channelSettings->property_id]);
                 }
             }
         }
     }
     $existMapping = [];
     //        $mapCollection = InventoryMap::where(
     //            [
     //                'channel_id' => $channelId,
     //                'property_id' => $channelSettings->property_id
     //            ]
     //        )
     ////            ->where('room_id', '<>', $id)
     //            ->lists('inventory_code', 'room_id');
     //        if ($mapCollection) {
     //            foreach ($mapCollection as $map) {
     //                $existMapping[] = $map;
     //            }
     //        }>F
     $inventories = Channel::find($channelId)->inventory()->where('property_id', Property::getLoggedId());
     $inventoryList = [];
     $inventoryPlans = [];
     foreach ($inventories->get() as $inventory) {
         //            if (in_array($inventory->code, $existMapping)) {
         //                continue;
         //            }
         $inventoryList[$inventory->code] = $inventory->name;
         $plans = $inventory->plans()->get(['name', 'code']);
         for ($i = 0; $i < count($plans); $i++) {
             //TODO rewrite to ONE query
             $plans[$i]->selected = InventoryMap::getByKeys($channelId, $channelSettings->property_id, $id, $plans[$i]['code'])->first() ? true : false;
         }
         $inventoryPlans[$inventory->code] = $plans;
     }
     $inventoryPlans = json_encode($inventoryPlans);
     $mapping = InventoryMap::getByKeys($channelId, $channelSettings->property_id, $id)->first();
     return View::make('rooms.map', compact('room', 'channel', 'inventoryList', 'inventoryPlans', 'channelId', 'mapping'));
 }