Skip to content

Commit

Permalink
Use Default recording rule template in MythWeb
Browse files Browse the repository at this point in the history
when creating new recording rules.  This patch only uses values from the
Default recording rule template, but it's still better/more capable than
the old approach that pulled values for a few parameters from settings.

Patch by Paul Gardiner (thanks!) with minor changes by me.
Fixes #11512.

Signed-off-by: Michael T. Dean <mdean@mythtv.org>
  • Loading branch information
Paul Gardiner authored and sphery committed Jun 18, 2013
1 parent 71ee4dd commit f975296
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
41 changes: 41 additions & 0 deletions modules/tv/classes/Schedule.php
Expand Up @@ -241,6 +241,47 @@ public function __construct($data) {
$this->css_class = category_class($this);
}

/**
* Alternative constructor for returning recording templates
**/
static function recording_template($name) {
global $db;
$sched = new Schedule(NULL);
$data = $db->query_assoc('
SELECT *
FROM record
WHERE type = ?
AND title = ?',
rectype_template,
$name.' (Template)'
);

$template_params = array(
'recpriority', 'prefinput', 'startoffset', 'endoffset',
'dupmethod', 'dupin', 'filter', 'inactive',
'profile', 'recgroup', 'storagegroup', 'playgroup', 'autoexpire',
'maxepisodes', 'maxnewest',
'autocommflag', 'autotranscode', 'transcoder',
'autouserjob1', 'autouserjob2', 'autouserjob3', 'autouserjob4',
'autometadata');
foreach ($template_params as $param)
if (isset($data[$param]))
$sched->$param = $data[$param];

return $sched;
}

/**
* Merge values from another schedule
**/
public function merge($prog) {
foreach (get_object_vars($prog) as $name => $value) {
if ($value && !$this->$name) {
$this->$name = $value;
}
}
}

/**
* Save this schedule
/**/
Expand Down
4 changes: 4 additions & 0 deletions modules/tv/detail.php
Expand Up @@ -266,6 +266,10 @@
// Redirect back to the page again, but without the query string, so reloads are cleaner
redirect_browser(root_url.'tv/detail/'.$program->chanid.'/'.$program->starttime);
}
else {
// Load default values from Default recording rule template
$schedule->merge(Schedule::recording_template('Default'));
}

// Load the channel
if ($program)
Expand Down
2 changes: 2 additions & 0 deletions modules/tv/schedules_custom.php
Expand Up @@ -160,6 +160,8 @@
case searchtype_title:
default: $schedule->search_type = t('Title'); break;
}
// Load default values from Default recording rule template
$schedule->merge(Schedule::recording_template('Default'));
}

// Create an edit-friendly title
Expand Down
2 changes: 2 additions & 0 deletions modules/tv/schedules_manual.php
Expand Up @@ -120,6 +120,8 @@
// Date/time/etc
if (!$schedule->starttime)
$schedule->starttime = time();
// Load default values from Default recording rule template
$schedule->merge(Schedule::recording_template('Default'));
}

// Calculate the length
Expand Down

0 comments on commit f975296

Please sign in to comment.