From 4ad67656eb63a6c23b0e6caed619f463e0c14aec Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Mon, 23 Jul 2007 07:09:45 +0000 Subject: editing a live stream works now, added confirmation to live stream creation and also tweaked the create page to be slightly less wordy --- lib/class/radio.class.php | 47 ++++++++++++++++++++++ radio.php | 6 ++- server/ajax.server.php | 12 +++++- templates/show_add_live_stream.inc.php | 8 ++-- templates/show_edit_live_stream_row.inc.php | 61 +++++++++++++++++++++++++++++ templates/show_live_streams.inc.php | 2 +- 6 files changed, 129 insertions(+), 7 deletions(-) create mode 100644 templates/show_edit_live_stream_row.inc.php 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 @@ -95,6 +95,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 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 @@ - + - + - + - + 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 @@ + + +
+ + + + + + + + + + + + + + + + + + + +
 
+ + + + + + + + + + + genre); ?> + + + + id . '&type=live_stream','download',_('Save Changes'),'save_live_stream_' . $radio->id,'edit_live_stream_' . $radio->id); ?> +
+
+ 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(); ?> - + -- cgit