diff --git a/modules/tv/classes/Schedule.php b/modules/tv/classes/Schedule.php index 412a39e76..d2eb555f4 100644 --- a/modules/tv/classes/Schedule.php +++ b/modules/tv/classes/Schedule.php @@ -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 /**/ diff --git a/modules/tv/detail.php b/modules/tv/detail.php index c4a96b532..cffd75cd3 100644 --- a/modules/tv/detail.php +++ b/modules/tv/detail.php @@ -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) diff --git a/modules/tv/schedules_custom.php b/modules/tv/schedules_custom.php index de2614074..0aa289e39 100644 --- a/modules/tv/schedules_custom.php +++ b/modules/tv/schedules_custom.php @@ -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 diff --git a/modules/tv/schedules_manual.php b/modules/tv/schedules_manual.php index ac157cfa9..6a2937a44 100644 --- a/modules/tv/schedules_manual.php +++ b/modules/tv/schedules_manual.php @@ -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