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 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) (limited to 'lib/class') 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 -- cgit