summaryrefslogtreecommitdiffstats
path: root/lib/class
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-10-29 06:47:00 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2008-10-29 06:47:00 +0000
commite8559dd683eba762b2bd374c731e7f7e8116bf70 (patch)
treed14ca2253febee2ea214d3501b02ca4e59010d2f /lib/class
parentf593f18131d6a0cbf30b558b208e86b9fc957f13 (diff)
downloadampache-e8559dd683eba762b2bd374c731e7f7e8116bf70.tar.gz
ampache-e8559dd683eba762b2bd374c731e7f7e8116bf70.tar.bz2
ampache-e8559dd683eba762b2bd374c731e7f7e8116bf70.zip
fix http auth issues, fix missing line sfrom dipsols patch, few other minor things
Diffstat (limited to 'lib/class')
-rw-r--r--lib/class/album.class.php2
-rw-r--r--lib/class/browse.class.php7
-rw-r--r--lib/class/catalog.class.php11
-rw-r--r--lib/class/database_object.abstract.php27
-rw-r--r--lib/class/tag.class.php36
-rw-r--r--lib/class/vauth.class.php10
6 files changed, 62 insertions, 31 deletions
diff --git a/lib/class/album.class.php b/lib/class/album.class.php
index 6b49eabe..c38bb927 100644
--- a/lib/class/album.class.php
+++ b/lib/class/album.class.php
@@ -725,7 +725,7 @@ class Album extends database_object {
$current_id = $this->id;
- if ($artist != $this->artist_id AND $artist > 0) {
+ if ($artist != $this->artist_id AND $artist) {
// Update every song
$songs = $this->get_songs();
foreach ($songs as $song_id) {
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php
index 4f6b6bcc..36f05597 100644
--- a/lib/class/browse.class.php
+++ b/lib/class/browse.class.php
@@ -222,7 +222,6 @@ class Browse {
$valid_array = array('show_art','starts_with','alpha_match');
break;
case 'artist':
- case 'genre':
case 'song':
case 'live_stream':
$valid_array = array('alpha_match','starts_with');
@@ -233,6 +232,9 @@ class Browse {
array_push($valid_array,'playlist_type');
}
break;
+ case 'tag':
+ $valid_array = array('object_type');
+ break;
default:
$valid_array = array();
break;
@@ -542,6 +544,9 @@ class Browse {
case 'shoutbox':
$sql = "SELECT `user_shout`.`id` FROM `user_shout` ";
break;
+ case 'tag':
+ $sql = "SELECT `tag`.`id` FROM `tag` LEFT JOIN `tag_map` ON `tag_map`.`tag_id`=`tag`.`id` ";
+ break;
case 'playlist_song':
case 'song':
default:
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index ec679b43..4929bb1e 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -106,6 +106,17 @@ class Catalog {
} // _create_filecache
/**
+ * get_from_path
+ * Try to figure out which catalog path most closely resembles this one
+ * This is useful when creating a new catalog to make sure we're not doubling up here
+ */
+ public static function get_from_path($path) {
+
+ // Break it down into its component parts and start looking for a catalog
+
+ } // get_from_path
+
+ /**
* format
* This makes the object human readable
*/
diff --git a/lib/class/database_object.abstract.php b/lib/class/database_object.abstract.php
index 5c6020c6..ed83d198 100644
--- a/lib/class/database_object.abstract.php
+++ b/lib/class/database_object.abstract.php
@@ -34,10 +34,6 @@ abstract class database_object {
/**
* get_info
* retrieves the info from the database and puts it in the cache
- *
- * @param string $id
- * @param string $table_name
- * @return array
*/
public function get_info($id,$table_name='') {
@@ -65,6 +61,9 @@ abstract class database_object {
* this checks the cache to see if the specified object is there
*/
public static function is_cached($index,$id) {
+
+ // Make sure we've got some parents here before we dive below
+ if (!isset(self::$object_cache) || !isset(self::$object_cache[$index])) { return false; }
return isset(self::$object_cache[$index][$id]);
@@ -73,10 +72,6 @@ abstract class database_object {
/**
* get_from_cache
* This attempts to retrive the specified object from the cache we've got here
- *
- * @param string $index
- * @param string $id
- * @return array
*/
public static function get_from_cache($index,$id) {
@@ -97,23 +92,11 @@ abstract class database_object {
/**
* add_to_cache
* This adds the specified object to the specified index in the cache
- *
- * @param string $index
- * @param string $id
- * @param array $data
- * @return boolean
*/
public static function add_to_cache($index,$id,$data) {
- $hasbeenset = false;
-
- // Set the data if it is set
- if (isset($data)) {
- self::$object_cache[$index][$id] = $data;
- $hasbeenset = true;
- }
-
- return $hasbeenset;
+ self::$object_cache[$index][$id] = $data;
+
} // add_to_cache
} // end database_object
diff --git a/lib/class/tag.class.php b/lib/class/tag.class.php
index 9f079102..0350e438 100644
--- a/lib/class/tag.class.php
+++ b/lib/class/tag.class.php
@@ -70,14 +70,14 @@ class Tag extends database_object {
*/
public function format($type=0,$object_id=0) {
- if (!self::validate_type($type)) { return false; }
+ if ($type AND !self::validate_type($type)) { return false; }
if ($type) {
$this->set_object($type,$object_id);
}
$size = 3 + ($this->weight-1) - ($this->count-1);
- if ($size > 4) { $size = 4; }
+ if (abs($size) > 4) { $size = 4; }
if ($this->owner == $GLOBALS['user']->id) {
$action = '?page=tag&action=remove_tag&type=' . scrub_out($type) . '&tag_id=' . intval($this->id) . '&object_id=' . intval($object_id);
@@ -89,6 +89,7 @@ class Tag extends database_object {
}
$class .= 'tag_size' . $size;
+ $this->f_class = $class;
$this->f_name = Ajax::text($action,$this->name,'modify_tag_' . $this->id . '_' . $object_id,'',$class);
@@ -361,7 +362,36 @@ class Tag extends database_object {
return $results;
- } // get_object_tags
+ } // get_object_tags
+
+ /**
+ * get_tags
+ * This is a non-object non type depedent function that just returns tags
+ * we've got, it can take filters (this is used by the tag cloud)
+ */
+ public static function get_tags($limit,$filters=array()) {
+
+ $sql = "SELECT `tag_map`.`tag_id`,COUNT(`tag_map`.`object_id`) AS `count` " .
+ "FROM `tag_map` " .
+ "LEFT JOIN `tag` ON `tag`.`id`=`tag_map`.`tag_id` " .
+ "GROUP BY `tag`.`name` ORDER BY `count` DESC " .
+ "LIMIT $limit";
+ $db_results = Dba::read($sql);
+
+ $results = array();
+
+ while ($row = Dba::fetch_assoc($db_results)) {
+ if ($row['count'] > $top) { $top = $row['count']; }
+ $results[$row['tag_id']] = array('id'=>$row['tag_id'],'count'=>$row['count']);
+ $count+= $row['count'];
+ }
+
+ // Do something with this
+ $min = $row['count'];
+
+ return $results;
+
+ } // get_tags
/**
* filter_with_prefs
diff --git a/lib/class/vauth.class.php b/lib/class/vauth.class.php
index 7bf4d16c..b9aeee6a 100644
--- a/lib/class/vauth.class.php
+++ b/lib/class/vauth.class.php
@@ -149,6 +149,9 @@ class vauth {
// If no key is passed try to find the session id
$key = $key ? $key : session_id();
+
+ // Nuke the cookie before all else
+ self::destroy($key);
// Do a quick check to see if this is an AJAX'd logout request
// if so use the iframe to redirect
@@ -169,7 +172,6 @@ class vauth {
echo xml_from_array($results);
}
- self::destroy($key);
/* Redirect them to the login page */
if (AJAX_INCLUDE != '1') {
@@ -648,7 +650,7 @@ class vauth {
public static function http_auth($username) {
/* Check if the user exists */
- if ($user = new User($username)) {
+ if ($user = User::get_from_username($username)) {
$results['success'] = true;
$results['type'] = 'mysql';
$results['username'] = $username;
@@ -658,8 +660,8 @@ class vauth {
}
/* If not then we auto-create the entry as a user.. :S */
- $user->create($username,$username,'',md5(rand()),'25');
- $user = new User($username);
+ $user_id = $user->create($username,$username,'',md5(rand()),'25');
+ $user = new User($user_id);
$results['success'] = true;
$results['type'] = 'mysql';