summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-01-01 22:34:12 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-01-01 22:34:12 +0000
commit6a0573d1fe8b12f1adacf3924de9808401f8e7b6 (patch)
tree17143ae90ed05facaf54e00825bc190bd20e21aa
parent850edbb1f20ce3cfd8be5f6fe93207ba9a56db3a (diff)
downloadampache-6a0573d1fe8b12f1adacf3924de9808401f8e7b6.tar.gz
ampache-6a0573d1fe8b12f1adacf3924de9808401f8e7b6.tar.bz2
ampache-6a0573d1fe8b12f1adacf3924de9808401f8e7b6.zip
slight tweak to the random album art, needs improvement will look funny on catalogs with no art (for now) editing an mpd instance works, need to fix httpq editing and add instance testing
-rw-r--r--lib/album.lib.php14
-rw-r--r--lib/class/localplay.abstract.php1
-rw-r--r--lib/class/localplay.class.php2
-rw-r--r--lib/class/update.class.php17
-rw-r--r--lib/log.lib.php2
-rw-r--r--modules/localplay/httpq.controller.php10
-rw-r--r--modules/localplay/mpd.controller.php19
-rw-r--r--templates/show_localplay_edit_instance.inc.php2
8 files changed, 58 insertions, 9 deletions
diff --git a/lib/album.lib.php b/lib/album.lib.php
index 4317c799..30e55c7f 100644
--- a/lib/album.lib.php
+++ b/lib/album.lib.php
@@ -130,22 +130,24 @@ function get_random_albums($count=6) {
$sql .= ' FROM `album`';
$db_results = Dba::query($sql);
- $sql = '';
+ $in_sql = '`album_id` IN (';
$row = Dba::fetch_row($db_results);
for ($i = 0; $i < ceil($count * 1.5); $i++) {
- if ($i > 0) $sql .= ' UNION ';
- $sql .= "SELECT `id` FROM (SELECT `id` FROM `album` LIMIT $row[$i],1) t".$i ;
+ $in_sql .= "'$row[$i]',";
}
-
- $db_results = Dba::query($sql);
+
+ $in_sql = rtrim($in_sql,',') . ')';
+ $sql = "SELECT `album_id` FROM `album_data` WHERE $in_sql AND `art` IS NOT NULL";
+
+ $db_results = Dba::query($sql);
$results = array();
for ($i = 0; $i < $count; $i++) {
$row = Dba::fetch_assoc($db_results);
- $results[] = $row['id'];
+ $results[] = $row['album_id'];
}
return $results;
diff --git a/lib/class/localplay.abstract.php b/lib/class/localplay.abstract.php
index 36901a67..9eebdbe2 100644
--- a/lib/class/localplay.abstract.php
+++ b/lib/class/localplay.abstract.php
@@ -41,6 +41,7 @@ abstract class localplay_controller {
// For display we need the following 'instance' functions
abstract public function add_instance($data);
abstract public function delete_instance($id);
+ abstract public function update_instance($id,$post);
abstract public function get_instances();
abstract public function instance_fields();
abstract public function set_active_instance($uid);
diff --git a/lib/class/localplay.class.php b/lib/class/localplay.class.php
index 43d4bca1..1a4c8bef 100644
--- a/lib/class/localplay.class.php
+++ b/lib/class/localplay.class.php
@@ -545,7 +545,7 @@ class Localplay {
*/
public function update_instance($uid,$data) {
- $data = $this->_player->update_instance($uid);
+ $data = $this->_player->update_instance($uid,$data);
return $data;
diff --git a/lib/class/update.class.php b/lib/class/update.class.php
index 9a6be243..75bc8fc3 100644
--- a/lib/class/update.class.php
+++ b/lib/class/update.class.php
@@ -1108,5 +1108,22 @@ class Update {
} // update_340014
+ /**
+ * update_340015
+ * This update tweaks the playlist table responding to complaints from usres
+ * who say it doesn't work, unreproduceable. This also adds an index to the
+ * album art table to try to make the random album art faster
+ */
+ public static function update_340015() {
+
+ $sql = "ALTER TABLE `album_data` ADD INDEX `album_art` `album_id`,`art`(5)";
+ $db_results = Dba::query($sql);
+
+ $sql = "ALTER TABLE `playlist` CHANGE `date` `date` INT ( 11 ) UNSIGNED";
+ $db_results = Dba::query($sql);
+
+
+ } // update_340015
+
} // end update class
?>
diff --git a/lib/log.lib.php b/lib/log.lib.php
index e7e9510a..a1798e3a 100644
--- a/lib/log.lib.php
+++ b/lib/log.lib.php
@@ -90,7 +90,7 @@ function ampache_error_handler($errno, $errstr, $errfile, $errline) {
}
if (strstr($errstr,"date.timezone")) {
- $errstr = "You have not set a timezone (date.timezone) in your php.ini file. Please set it.";
+ $errstr = "You have not set a timezone (date.timezone) in your php.ini file. Please set it. This error is non-critical, and not caused by Ampache.";
}
/* The XML-RPC lib is broken, well kind of
diff --git a/modules/localplay/httpq.controller.php b/modules/localplay/httpq.controller.php
index accdcd1c..990cc00e 100644
--- a/modules/localplay/httpq.controller.php
+++ b/modules/localplay/httpq.controller.php
@@ -188,6 +188,16 @@ class AmpacheHttpq extends localplay_controller {
} // get_instances
/**
+ * update_instance
+ * This takes an ID and an array of data and updates the instance specified
+ */
+ public function update_instance($uid,$data) {
+
+
+
+ } // update_instance
+
+ /**
* instance_fields
* This returns a key'd array of [NAME]=>array([DESCRIPTION]=>VALUE,[TYPE]=>VALUE) for the
* fields so that we can on-the-fly generate a form
diff --git a/modules/localplay/mpd.controller.php b/modules/localplay/mpd.controller.php
index 7fe5b778..90a1e9a7 100644
--- a/modules/localplay/mpd.controller.php
+++ b/modules/localplay/mpd.controller.php
@@ -204,6 +204,25 @@ class AmpacheMpd extends localplay_controller {
} // get_instance
/**
+ * update_instance
+ * This takes an ID and an array of data and updates the instance specified
+ */
+ public function update_instance($uid,$data) {
+
+ $uid = Dba::escape($uid);
+ $host = $data['host'] ? Dba::escape($data['host']) : '127.0.0.1';
+ $port = $data['port'] ? Dba::escape($data['port']) : '6600';
+ $name = Dba::escape($data['name']);
+ $pass = Dba::escape($data['password']);
+
+ $sql = "UPDATE `localplay_mpd` SET `host`='$host', `port`='$port', `name`='$name', `password`='$pass' WHERE `id`='$uid'";
+ $db_results = Dba::query($sql);
+
+ return true;
+
+ } // update_instance
+
+ /**
* instance_fields
* This returns a key'd array of [NAME]=>array([DESCRIPTION]=>VALUE,[TYPE]=>VALUE) for the
* fields so that we can on-the-fly generate a form
diff --git a/templates/show_localplay_edit_instance.inc.php b/templates/show_localplay_edit_instance.inc.php
index b6060671..49a34d5c 100644
--- a/templates/show_localplay_edit_instance.inc.php
+++ b/templates/show_localplay_edit_instance.inc.php
@@ -26,7 +26,7 @@
<?php foreach ($fields as $key=>$field) { ?>
<tr>
<td><?php echo $field['description']; ?></td>
- <td><input type="textbox" name="<?php echo $key; ?>" value="<?php echo scrub_out($instance->$key); ?>" /></td>
+ <td><input type="textbox" name="<?php echo $key; ?>" value="<?php echo scrub_out($instance[$key]); ?>" /></td>
</tr>
<?php } ?>
</table>