summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/class/radio.class.php47
-rw-r--r--radio.php6
-rw-r--r--server/ajax.server.php12
-rw-r--r--templates/show_add_live_stream.inc.php8
-rw-r--r--templates/show_edit_live_stream_row.inc.php61
-rw-r--r--templates/show_live_streams.inc.php2
6 files changed, 129 insertions, 7 deletions
diff --git a/lib/class/radio.class.php b/lib/class/radio.class.php
index 108f0c16..97bde2f6 100644
--- a/lib/class/radio.class.php
+++ b/lib/class/radio.class.php
@@ -96,6 +96,53 @@ class Radio {
} // format
/**
+ * update
+ * This is a static function that takes a key'd array for input
+ * it depends on a ID element to determine which radio element it
+ * should be updating
+ */
+ public static function update($data) {
+
+ // Verify the incoming data
+ if (!$data['id']) {
+ Error::add('general','Missing ID');
+ }
+
+ if (!$data['name']) {
+ Error::add('general','Name Required');
+ }
+
+ if (!preg_match("/^https?:\/\/.+/",$data['url'])) {
+ Error::add('general','Invalid URL must be https:// or http://');
+ }
+
+ $genre = new Genre($data['genre']);
+ if (!$genre->name) {
+ Error::add('general','Invalid Genre Selected');
+ }
+
+ if (Error::$state) {
+ return false;
+ }
+
+ // Setup the data
+ $name = Dba::escape($data['name']);
+ $site_url = Dba::escape($data['site_url']);
+ $url = Dba::escape($data['url']);
+ $frequency = Dba::escape($data['frequency']);
+ $call_sign = Dba::escape($data['call_sign']);
+ $genre = Dba::escape($data['genre']);
+ $id = Dba::escape($data['id']);
+
+ $sql = "UPDATE `live_stream` SET `name`='$name',`site_url`='$site_url',`url`='$url',`genre`='$genre'" .
+ ",`frequency`='$frequency',`call_sign`='$call_sign' WHERE `id`='$id'";
+ $db_results = Dba::query($sql);
+
+ return $db_results;
+
+ } // update
+
+ /**
* create
* This is a static function that takes a key'd array for input
* and if everything is good creates the object.
diff --git a/radio.php b/radio.php
index bec97565..80361866 100644
--- a/radio.php
+++ b/radio.php
@@ -47,7 +47,11 @@ switch ($_REQUEST['action']) {
if (!$results) {
require_once Config::get('prefix') . '/templates/show_add_live_stream.inc.php';
}
-
+ else {
+ $body = _('Radio Station Added');
+ $title = '';
+ show_confirmation($title,$body,Config::get('web_path') . '/index.php');
+ }
break;
} // end data collection
diff --git a/server/ajax.server.php b/server/ajax.server.php
index 15ba8588..9021065a 100644
--- a/server/ajax.server.php
+++ b/server/ajax.server.php
@@ -59,6 +59,11 @@ switch ($action) {
$song = new Song($_GET['id']);
$song->format();
break;
+ case 'live_stream':
+ $key = 'live_stream_' . $_GET['id'];
+ $radio = new Radio($_GET['id']);
+ $radio->format();
+ break;
default:
$key = 'rfc3514';
echo xml_from_array(array($key=>'0x1'));
@@ -73,7 +78,6 @@ switch ($action) {
echo xml_from_array($results);
break;
case 'edit_object':
-
// Make sure we've got them rights
if (!$GLOBALS['user']->has_access('50')) {
exit;
@@ -90,6 +94,12 @@ switch ($action) {
$song = new Song($_POST['id']);
$song->format();
break;
+ case 'live_stream':
+ $key = 'live_stream_' . $_POST['id'];
+ Radio::update($_POST);
+ $radio = new Radio($_POST['id']);
+ $radio->format();
+ break;
default:
$key = 'rfc3514';
echo xml_from_array(array($key=>'0x1'));
diff --git a/templates/show_add_live_stream.inc.php b/templates/show_add_live_stream.inc.php
index 2533e777..059e852a 100644
--- a/templates/show_add_live_stream.inc.php
+++ b/templates/show_add_live_stream.inc.php
@@ -32,27 +32,27 @@
</td>
</tr>
<tr>
- <td><?php echo _('Station Homepage'); ?></td>
+ <td><?php echo _('Homepage'); ?></td>
<td>
<input type="text" name="site_url" value="<?php echo scrub_out($_REQUEST['site_url']); ?>" />
<?php Error::display('site_url'); ?>
</td>
</tr>
<tr>
- <td><?php echo _('Station URL'); ?></td>
+ <td><?php echo _('Stream URL'); ?></td>
<td>
<input type="text" name="url" value="<?php echo scrub_out($_REQUEST['url']); ?>" />
<?php Error::display('url'); ?>
</td>
</tr>
<tr>
- <td><?php echo _('Station Frequency'); ?></td>
+ <td><?php echo _('Frequency'); ?></td>
<td>
<input type="text" name="frequency" value="<?php echo scrub_out($_REQUEST['frequency']); ?>" />
</td>
</tr>
<tr>
- <td><?php echo _('Station call-sign'); ?></td>
+ <td><?php echo _('Callsign'); ?></td>
<td>
<input type="text" name="call_sign" value="<?Php echo scrub_out($_REQUEST['call_sign']); ?>" />
</td>
diff --git a/templates/show_edit_live_stream_row.inc.php b/templates/show_edit_live_stream_row.inc.php
new file mode 100644
index 00000000..d32aaebf
--- /dev/null
+++ b/templates/show_edit_live_stream_row.inc.php
@@ -0,0 +1,61 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 Ampache.org
+ All rights reserved.
+
+ This program is free software; you can redistribute it and/or
+ modify it under the terms of the GNU General Public License v2
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+*/
+?>
+<td colspan="6">
+<form method="post" id="edit_live_stream_<?php echo $radio->id; ?>">
+<table border="0" cellpadding="3" cellspacing="0">
+<tr>
+ <th><?php echo _('Name'); ?></th>
+ <th><?php echo _('Stream URL'); ?></th>
+ <th><?php echo _('Homepage'); ?></th>
+ <th><?php echo _('Callsign'); ?></th>
+ <th><?php echo _('Frequency'); ?></th>
+ <th><?php echo _('Genre'); ?></th>
+ <th>&nbsp;</th>
+</tr>
+<tr>
+<td>
+ <input type="textbox" name="name" value="<?php echo scrub_out($radio->name); ?>" size="9" />
+</td>
+<td>
+ <input type="textbox" name="url" value="<?php echo scrub_out($radio->url); ?>" size ="12" />
+</td>
+<td>
+ <input type="textbox" name="site_url" value="<?php echo scrub_out($radio->site_url); ?>" size="9" />
+</td>
+<td>
+ <input type="textbox" name="call_sign" value="<?php echo scrub_out($radio->call_sign); ?>" size="6" />
+</td>
+<td>
+ <input type="textbox" name="frequency" value="<?php echo scrub_out($radio->frequency); ?>" size="6" />
+</td>
+<td>
+ <?php show_genre_select('genre',$radio->genre); ?>
+</td>
+<td>
+ <input type="hidden" name="id" value="<?php echo $radio->id; ?>" />
+ <input type="hidden" name="type" value="live_stream" />
+ <?php echo Ajax::button('?action=edit_object&id=' . $radio->id . '&type=live_stream','download',_('Save Changes'),'save_live_stream_' . $radio->id,'edit_live_stream_' . $radio->id); ?>
+</td>
+</tr>
+</table>
+</form>
+</td>
diff --git a/templates/show_live_streams.inc.php b/templates/show_live_streams.inc.php
index 5aa5be5e..bd03bab6 100644
--- a/templates/show_live_streams.inc.php
+++ b/templates/show_live_streams.inc.php
@@ -40,7 +40,7 @@ foreach ($object_ids as $radio_id) {
$radio = new Radio($radio_id);
$radio->format();
?>
-<tr id="radio_<?php echo $radio->id; ?>" class="<?php echo flip_class(); ?>">
+<tr id="live_stream_<?php echo $radio->id; ?>" class="<?php echo flip_class(); ?>">
<?php require Config::get('prefix') . '/templates/show_live_stream_row.inc.php'; ?>
</tr>
<?php } //end foreach ($artists as $artist) ?>