Ticket #9850: filters.2.diff

File filters.2.diff, 9.1 KB (added by Doug Haber <doug@…>, 14 years ago)
  • modules/_shared/lang/English.lang

    diff --git a/modules/_shared/lang/English.lang b/modules/_shared/lang/English.lang
    index b7b2f2c..d0bfd6d 100644
    a b  
     1"New episode"
     2"Identifiable episode"
     3"First showing"
     4"Primetime"
     5"Commercial free"
     6"High definition"
     7"This Episode"
     8"Post Processing"
     9"Schedule Options"
    110""
    211"# Tracks"
    312"$1 B"
  • modules/tv/classes/Schedule.php

    diff --git a/modules/tv/classes/Schedule.php b/modules/tv/classes/Schedule.php
    index 7129da5..f3454c4 100644
    a b class Schedule extends MythBase {  
    5151    public $findid;
    5252    public $transcoder;
    5353    public $parentid;
     54    public $filter;
    5455
    5556    public $playgroup;
    5657    public $prefinput;
    class Schedule extends MythBase {  
    6364    public $will_record = false;
    6465    public $css_class;         // css class, based on category and/or category_type
    6566
     67
     68        /**
     69         * Intended to be called as Schedule::availableRecordFilters()
     70         *
     71         * @return array sorted list of record filters available to the system keyed by filterid
     72        /**/
     73    public static function availableRecordFilters() {
     74        static $cache = array();
     75        if (empty($cache)) {
     76            global $db;
     77            $cache = $db->query_keyed_list_assoc('filterid',
     78                                'SELECT filterid,description,newruledefault
     79                                        FROM recordfilter
     80                                    ORDER BY filterid');
     81        }
     82        return $cache;
     83    }
     84
     85        /**
     86         *
     87         * @return an array of the filters for this Schedule.  Array includes
     88         * a property called "enabled" to indicate if the filter is enabled.
     89         * If this is not a real schedule "enabled" is from the newruledefault
     90         * property
     91         *
     92        /**/
     93   public function recordFilters() {
     94        $filters = array();
     95        foreach (Schedule::availableRecordFilters() as $id => $filter) {
     96                $filters[$id] = $filter;
     97                // if this is a real schedule, use the filter property
     98                if ($this->recordid) {
     99                        $mask = 1 << $id;
     100                        $filters[$id]['enabled'] = ($this->filter & $mask) == $mask;
     101
     102                // otherwise it's not a real schedule, so use the default value
     103                } else {
     104                        $filters[$id]['enabled'] = $filter['newruledefault'];
     105                }
     106        }
     107
     108        return $filters;
     109    }
     110
    66111    public static function findAll($sort = true) {
    67112        global $db;
    68113        $orderby = '';
    class Schedule extends MythBase {  
    236281                                               findday,findtime,findid,autotranscode,parentid,transcoder,
    237282                                               autouserjob1,autouserjob2,autouserjob3,autouserjob4,autometadata,
    238283                                               playgroup,storagegroup,prefinput,
    239                                                next_record,last_record,last_delete,inetref,season,episode)
     284                                               next_record,last_record,last_delete,inetref,season,episode,filter)
    240285                                       VALUES (?,?,?,
    241286                                               FROM_UNIXTIME(?),FROM_UNIXTIME(?),FROM_UNIXTIME(?),FROM_UNIXTIME(?),
    242                                                ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
     287                                               ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)',
    243288                         _or($this->recordid,      0,          true),
    244289                         _or($this->type,          0,          true),
    245290                         $this->chanid,
    class Schedule extends MythBase {  
    286331                         _or($this->last_delete,   '00:00:00'      ),
    287332                         _or($this->inetref,       ''              ),
    288333                         _or($this->season,        0              ),
    289                          _or($this->episode,       0              )
     334                         _or($this->episode,       0              ),
     335                         _or($this->filter,        0              )
    290336                        );
    291337    // Get the id that was returned
    292338        $recordid = $sh->insert_id();
  • modules/tv/detail.php

    diff --git a/modules/tv/detail.php b/modules/tv/detail.php
    index 5b444d9..a63d818 100644
    a b  
    162162        redirect_browser(root_url.'tv/detail/'.$program->chanid.'/'.$program->recstartts);
    163163    }
    164164
     165// Load the utility/display functions for scheduling
     166    require_once 'includes/schedule_utils.php';
     167
    165168// The user tried to update the recording settings - update the database and the variable in memory
    166169    if (isset($_POST['save'])) {
    167170        if ($schedule) {
     
    234237                $schedule->inetref       = $_POST['inetref'];
    235238                $schedule->season        = intval($_POST['season']);
    236239                $schedule->episode       = intval($_POST['episode']);
     240                $schedule->filter        = generateFilter();
    237241
    238242            // Keep track of the parent recording for overrides
    239243                if ($_POST['record'] == rectype_override) {
     
    348352        $program->load_jobs();
    349353    }
    350354
    351 // Load the utility/display functions for scheduling
    352     require_once 'includes/schedule_utils.php';
    353 
    354355// Setup some vars for the ipod template
    355356    $Page_Previous_Location = root_url.'tv/list_shows_in_title_and_group?group='.urlencode($program->recgroup).'&title='.urlencode($program->title);
    356357    $Page_Previous_Location_Name = $program->title;
  • modules/tv/includes/schedule_utils.php

    diff --git a/modules/tv/includes/schedule_utils.php b/modules/tv/includes/schedule_utils.php
    index eb1ec4f..d5f3af3 100644
    a b  
    1111/**/
    1212
    1313/**
     14 *  Generates a schedule filter paramater from the POST parameters
     15/**/
     16   function generateFilter() {
     17        $total = 0;
     18        foreach (Schedule::availableRecordFilters() as $id => $filter) {
     19                $enabled = intval($_POST["recordfilter_$id"]);
     20                $total |= $enabled << $id;
     21        }
     22        return $total;
     23}
     24
     25/**
    1426 * Prints a <select> of the available recording inputs
    1527/**/
    1628    function input_select($selected, $ename='prefinput') {
  • modules/tv/tmpl/default/_advanced_options.php

    diff --git a/modules/tv/tmpl/default/_advanced_options.php b/modules/tv/tmpl/default/_advanced_options.php
    index 6054165..4754c6b 100644
    a b  
    351351                <dd><input type="text" id="season" class="quantity" name="season" value="<?php echo html_entities($schedule->season) ?>"></dd>
    352352                <dt><?php echo t('Episode') ?>:</dt>
    353353                <dd><input type="text" id="episode" class="quantity" name="episode" value="<?php echo html_entities($schedule->episode) ?>"></dd>
     354                <fieldset>
     355                <legend><?php echo t('Filters') ?></legend>
     356                <?php
     357                foreach ($schedule->recordFilters() as $id => $filter) {
     358                ?>
     359                        <dt><label for="recordfilter_$id"><?php echo t($filter['description']) ?>:</label></dt>
     360                        <dd><input type="checkbox" class="radio" id="recordfilter_<?php echo $id ?>" name="recordfilter_<?php echo $id ?>"<?php if ($filter['enabled']) echo ' CHECKED' ?> value="1"></dd>
     361                <?php } ?>
     362                </fieldset>
     363                <fieldset>
     364                <legend><?php echo t('Post Processing') ?></legend>
    354365                <dt><label for="autometadata"><?php echo t('Look up Metadata') ?>:</label></dt>
    355366                <dd><input type="checkbox" class="radio" id="autometadata" name="autometadata"<?php if ($schedule->autometadata) echo ' CHECKED' ?> value="1"></dd>
    356367                <dt><label for="autocommflag"><?php echo t('Auto-flag commercials') ?>:</label></dt>
     
    365376                <dd><input type="checkbox" class="radio" id="autouserjob3" name="autouserjob3"<?php if ($schedule->autouserjob3) echo ' CHECKED' ?> value="1"></dd>
    366377                <dt><label for="autouserjob4"><?php echo setting('UserJobDesc4') ?>:</label></dt>
    367378                <dd><input type="checkbox" class="radio" id="autouserjob4" name="autouserjob4"<?php if ($schedule->autouserjob4) echo ' CHECKED' ?> value="1"></dd>
     379                </fieldset>
     380                <fieldset>
     381                <legend><?php echo t('Schedule Options') ?></legend>
    368382                <dt><label for="inactive"><?php echo t('Inactive') ?>:</label></dt>
    369383                <dd><input type="checkbox" class="radio" id="inactive" name="inactive"<?php if ($schedule->inactive) echo ' CHECKED' ?> value="1"></dd>
    370384                <dt><label for="autoexpire"><?php echo t('Auto-expire recordings') ?>:</label></dt>
     
    379393                <dt><?php echo t('End Late') ?>:</dt>
    380394                <dd><input type="text" class="quantity" name="endoffset" value="<?php echo html_entities($schedule->endoffset) ?>">
    381395                    <?php echo t('minutes') ?></dd>
     396                </fieldset>
    382397            </dl>
    383398
    384399<div style="display: none;" id="message-dialog">
  • modules/tv/tmpl/default/schedules.php

    diff --git a/modules/tv/tmpl/default/schedules.php b/modules/tv/tmpl/default/schedules.php
    index eafd188..9c7f273 100644
    a b  
    1818// Print the page header
    1919    require 'modules/_shared/tmpl/'.tmpl.'/header.php';
    2020
    21 
    2221// No schedules defined?
    2322    if (!is_array($the_schedules) || !count($the_schedules)) {
    2423        echo '<div id="no_schedules">',