From bd270b02274b4e43a887e86805a44cf456f2da38 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Fri, 7 Mar 2008 06:51:52 +0000 Subject: fixed the acl issue... sigh --- lib/class/democratic.class.php | 69 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 68 insertions(+), 1 deletion(-) (limited to 'lib/class/democratic.class.php') diff --git a/lib/class/democratic.class.php b/lib/class/democratic.class.php index bc9429fb..32ecbee2 100644 --- a/lib/class/democratic.class.php +++ b/lib/class/democratic.class.php @@ -26,6 +26,51 @@ */ class Democratic extends tmpPlaylist { + /** + * constructor + * We need a constructor for this class. It does it's own thing now + */ + public function __construct($id='') { + + if (!$id) { return false; } + + $info = $this->get_info($id); + + foreach ($info as $key=>$value) { + $this->$key = $value; + } + + } // constructor + + + /** + * get_info + * This returns the data from the database + */ + private function get_info($id) { + + $id = Dba::escape($id); + + $sql = "SELECT * FROM `democratic` WHERE `id`='$id'"; + $db_results = Dba::query($sql); + + $row = Dba::fetch_assoc($db_results); + + return $row; + + } // get_info + + /** + * format + * This makes the objects variables all purrty so that they can be displayed + */ + public function format() { + + $this->f_cooldown = $this->cooldown . ' ' . _('minutes'); + $this->f_primary = $this->primary ? _('Primary') : ''; + + } // format + /** * get_playlists * This returns all of the current valid 'Democratic' Playlists @@ -36,7 +81,7 @@ class Democratic extends tmpPlaylist { // Pull all tmp playlsits with a session of < 0 (as those are fake) // This is kind of hackish, should really think about tweaking the db // and doing this right. - $sql = "SELECT `id` FROM `tmp_playlist` WHERE `session`< '0'"; + $sql = "SELECT `id` FROM `democratic` ORDER BY `name`"; $db_results = Dba::query($sql); $results = array(); @@ -328,6 +373,28 @@ class Democratic extends tmpPlaylist { } // delete_votes + /** + * create + * This is the democratic play create function it inserts this into the democratic table + */ + public static function create($data) { + + // Clean up the input + $name = Dba::escape($data['name']); + $base = Dba::escape($data['democratic']); + $cool = Dba::escape($data['cooldown']); + $level = Dba::escape($data['level']); + $default = Dba::escape($data['make_default']); + $user = Dba::escape($GLOBALS['user']->id); + + $sql = "INSERT INTO `democratic` (`name`,`cooldown`,`level`,`user`,`primary`) " . + "VALUES ('$name','$cool','$level','$user','$default')"; + $db_results = Dba::query($sql); + + return $db_results; + + } // create + /** * prune_tracks * This replaces the normal prune tracks and correctly removes the votes -- cgit