1 | <?php
|
---|
2 | /**
|
---|
3 | * Configure MythTV Channels
|
---|
4 | *
|
---|
5 | * @url $URL: http://svn.mythtv.org/svn/tags/release-0-23-rc2/mythplugins/mythweb/modules/tv/set_channels.php $
|
---|
6 | * @date $Date: 2009-09-11 22:15:43 -0700 (Fri, 11 Sep 2009) $
|
---|
7 | * @version $Revision: 21798 $
|
---|
8 | * @author $Author: kormoc $
|
---|
9 | * @license GPL
|
---|
10 | *
|
---|
11 | * @package MythWeb
|
---|
12 | * @subpackage Settings
|
---|
13 | *
|
---|
14 | /**/
|
---|
15 |
|
---|
16 | // Save?
|
---|
17 | if ($_POST['save']) {
|
---|
18 | // Parse the post variables and save each group of channel info
|
---|
19 | foreach (array_keys($_POST) as $key) {
|
---|
20 | $query_params = array();
|
---|
21 | // First, delete any unwanted channels
|
---|
22 |
|
---|
23 | if (preg_match('/^delete_(\\d+)$/', $key, $match)) {
|
---|
24 | list($match, $chanid) = $match;
|
---|
25 | $query = 'DELETE FROM channel';
|
---|
26 | }
|
---|
27 |
|
---|
28 | // Figure out the chanid, or leave
|
---|
29 | elseif (!preg_match('/^channum_(\\d+)$/', $key, $match)) continue; // leave
|
---|
30 |
|
---|
31 | else {
|
---|
32 | list($match, $chanid) = $match;
|
---|
33 |
|
---|
34 | // Not deleting so grab values that can be empty
|
---|
35 | $query = 'UPDATE channel SET xmltvid = ?,
|
---|
36 | freqid = ?,
|
---|
37 | finetune = ?,
|
---|
38 | videofilters = ?,
|
---|
39 | brightness = ?,
|
---|
40 | contrast = ?,
|
---|
41 | colour = ?,
|
---|
42 | hue = ?,
|
---|
43 | recpriority = ?,
|
---|
44 | commmethod = ?,
|
---|
45 | useonairguide = ?,
|
---|
46 | visible = ?';
|
---|
47 | $query_params[] = $_POST['xmltvid_'.$chanid];
|
---|
48 | $query_params[] = $_POST['freqid_'.$chanid];
|
---|
49 | $query_params[] = $_POST['finetune_'.$chanid];
|
---|
50 | $query_params[] = $_POST['videofilters_'.$chanid];
|
---|
51 | $query_params[] = $_POST['brightness_'.$chanid];
|
---|
52 | $query_params[] = $_POST['contrast_'.$chanid];
|
---|
53 | $query_params[] = $_POST['colour_'.$chanid];
|
---|
54 | $query_params[] = $_POST['hue_'.$chanid];
|
---|
55 | $query_params[] = $_POST['recpriority_'.$chanid];
|
---|
56 | $query_params[] = empty($_POST['commfree_'.$chanid]) ? -1 : -2;
|
---|
57 | $query_params[] = empty($_POST['useonairguide_'.$chanid]) ? 0 : 1;
|
---|
58 | $query_params[] = empty($_POST['visible_'.$chanid]) ? 0 : 1;
|
---|
59 | // next, the fields that need to have a value, so we won't change them if they were emptied
|
---|
60 | if ($_POST['channum_'.$chanid]) {
|
---|
61 | $query .= ',channum=?';
|
---|
62 | $query_params[] = $_POST['channum_'.$chanid];
|
---|
63 | }
|
---|
64 | if ($_POST['callsign_'.$chanid]) {
|
---|
65 | $query .= ',callsign=?';
|
---|
66 | $query_params[] = $_POST['callsign_'.$chanid];
|
---|
67 | }
|
---|
68 | if ($_POST['name_'.$chanid]) {
|
---|
69 | $query .= ',name=?';
|
---|
70 | $query_params[] = $_POST['name_'.$chanid];
|
---|
71 | }
|
---|
72 | }
|
---|
73 | // Submit the query
|
---|
74 | $db->query($query.' WHERE chanid=?',
|
---|
75 | $query_params,
|
---|
76 | $chanid
|
---|
77 | );
|
---|
78 | }
|
---|
79 | // Do a reschedule to refresh scheduled recordings;
|
---|
80 | MythBackend::find()->rescheduleRecording();
|
---|
81 | }
|
---|
82 |
|
---|
83 | // Sortby
|
---|
84 | if ($_GET['sortby'])
|
---|
85 | $_SESSION['tv']['set']['chan_sort'] = $_GET['sortby'];
|
---|
86 | switch ($_SESSION['tv']['set']['chan_sort']) {
|
---|
87 | case 'callsign':
|
---|
88 | case 'name':
|
---|
89 | $sortby = $_SESSION['tv']['set']['chan_sort'];
|
---|
90 | break;
|
---|
91 | case 'channum':
|
---|
92 | case 'xmltvid':
|
---|
93 | case 'freqid':
|
---|
94 | $sortby = $_SESSION['tv']['set']['chan_sort'].' + 0, '.$_SESSION['tv']['set']['chan_sort'];
|
---|
95 | break;
|
---|
96 | case 'sourceid':
|
---|
97 | $sortby = $_SESSION['tv']['set']['chan_sort'].', channum';
|
---|
98 | break;
|
---|
99 | default:
|
---|
100 | $sortby = 'channum + 0, channum';
|
---|
101 | }
|
---|
102 |
|
---|
103 | // Load all of the channel data from the database
|
---|
104 | $Channels = array();
|
---|
105 | $sh = $db->query('SELECT * FROM channel ORDER BY '.$sortby);
|
---|
106 | while ($row = $sh->fetch_assoc()) {
|
---|
107 | $Channels[] = $row;
|
---|
108 | }
|
---|
109 | $sh->finish();
|
---|
110 |
|
---|
111 | // These settings affect all of mythtv
|
---|
112 | $Settings_Hosts = t('All Hosts');
|
---|