diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-07-29 16:49:44 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2007-07-29 16:49:44 +0000 |
commit | 20b425c3ac56d24068f56cfa455e07d5fa26f13d (patch) | |
tree | 460a7b1a78886d85c1decb6cf92664f726504ba9 /lib | |
parent | e00b5875aba6e3bad68096c59cb3641dbfb6dc4f (diff) | |
download | ampache-20b425c3ac56d24068f56cfa455e07d5fa26f13d.tar.gz ampache-20b425c3ac56d24068f56cfa455e07d5fa26f13d.tar.bz2 ampache-20b425c3ac56d24068f56cfa455e07d5fa26f13d.zip |
fixed song retaging, fixed the song view page tweaked sidebar browse and fixed a bug where sorting then viewing a object that could not be sorted by said type caused nothing to display
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/browse.class.php | 44 | ||||
-rw-r--r-- | lib/class/flag.class.php | 47 | ||||
-rw-r--r-- | lib/class/song.class.php | 66 |
3 files changed, 115 insertions, 42 deletions
diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index e86b6786..375afe8a 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -300,21 +300,37 @@ class Browse { if ($order != 'DESC') { $order == 'ASC'; } - if ($_SESSION['browse']['type'] == 'song') { - switch($field) { - case 'title'; - $sql = "`song`.`title`"; - break; - case 'year': - $sql = "`song`.`year`"; - break; - default: - // Rien a faire - break; - } // end switch - } // end if song + switch ($_SESSION['browse']['type']) { + case 'song': + switch($field) { + case 'title'; + $sql = "`song`.`title`"; + break; + case 'year': + $sql = "`song`.`year`"; + break; + default: + // Rien a faire + break; + } // end switch + break; + case 'album': + switch($field) { + case 'name': + $sql = "`album`.`name`"; + break; + case 'year': + $sql = "`album`.`year`"; + break; + } // end switch + default: + // Rien a faire + break; + } // end switch - return "$sql $order,"; + if ($sql) { $sql_sort = "$sql $order,"; } + + return $sql_sort; } // sql_sort diff --git a/lib/class/flag.class.php b/lib/class/flag.class.php index d54879f5..ed833c1b 100644 --- a/lib/class/flag.class.php +++ b/lib/class/flag.class.php @@ -1,13 +1,13 @@ <?php /* - Copyright 2001 - 2006 Ampache.org + Copyright 2001 - 2007 Ampache.org All Rights Reserved This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License - as published by the Free Software Foundation; either version 2 - of the License, or (at your option) any later version. + as published by the Free Software Foundation; version 2 + of the License. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of @@ -171,22 +171,22 @@ class Flag { * This adds a flag entry for an item, it takes an id, a type, the flag type * and a comment and then inserts the mofo */ - function add($id,$type,$flag,$comment) { + public static function add($id,$type,$flag,$comment) { - $id = sql_escape($id); - $type = sql_escape($type); - $flag = sql_escape($flag); - $user = sql_escape($GLOBALS['user']->id); - $comment = sql_escape($comment); + $id = Dba::escape($id); + $type = Dba::escape($type); + $flag = self::validate_flag($flag); + $user = Dba::escape($GLOBALS['user']->id); + $comment = Dba::escape($comment); $time = time(); $approved = '0'; - /* If they are an admin, it's auto approved */ - if ($GLOBALS['user']->has_access('100')) { $approved = '1'; } + /* If they are an content manager or higher, it's auto approved */ + if ($GLOBALS['user']->has_access('75')) { $approved = '1'; } - $sql = "INSERT INTO flagged (`object_id`,`object_type`,`flag`,`comment`,`date`,`approved`,`user`) VALUES " . + $sql = "INSERT INTO `flagged` (`object_id`,`object_type`,`flag`,`comment`,`date`,`approved`,`user`) VALUES " . " ('$id','$type','$flag','$comment','$time','$approved','$user')"; - $db_results = mysql_query($sql, dbh()); + $db_results = Dba::query($sql); return true; @@ -310,6 +310,27 @@ class Flag { } // print_flag + /** + * validate_flag + * This takes a flag input and makes sure it's one of the reigstered + * and valid 'flag' values + */ + public static function validate_flag($flag) { + + switch ($flag) { + case 'delete': + case 'retag': + case 'reencode': + case 'other': + return $flag; + break; + default: + return 'other'; + break; + } // end switch + + } // validate_flag + } //end of flag class ?> diff --git a/lib/class/song.class.php b/lib/class/song.class.php index 9e2e5da2..ed1f4036 100644 --- a/lib/class/song.class.php +++ b/lib/class/song.class.php @@ -386,6 +386,42 @@ class Song { /** * update + * This takes a key'd array of data does any cleaning it needs to + * do and then calls the helper functions as needed. This will also + * cause the song to be flagged + */ + public function update($data) { + + foreach ($data as $key=>$value) { + switch ($key) { + case 'title': + case 'album': + case 'artist': + case 'genre': + case 'track': + // Check to see if it needs to be updated + if ($value != $this->$key) { + $function = 'update_' . $key; + self::$function($value,$this->id); + $this->$key = $value; + $updated=1; + } + break; + default: + // Rien a faire + break; + } // end whitelist + } // end foreach + + // If a field was changed then we need to flag this mofo + Flag::add($this->id,'song','retag','Interface Update'); + + return true; + + } // update + + /** + * update_song * this is the main updater for a song it actually * calls a whole bunch of mini functions to update * each little part of the song... lastly it updates @@ -416,7 +452,7 @@ class Song { */ public function update_year($new_year,$song_id) { - self::_update_item('year',$new_year,$song_id,'100'); + self::_update_item('year',$new_year,$song_id,'50'); } // update_year @@ -426,7 +462,7 @@ class Song { */ public function update_comment($new_comment,$song_id) { - self::_update_ext_item('comment',$new_comment,$song_id,'100'); + self::_update_ext_item('comment',$new_comment,$song_id,'50'); } // update_comment @@ -436,7 +472,7 @@ class Song { */ public function update_lyrics($new_lyrics,$song_id) { - self::_update_ext_item('lyrics',$new_lyrics,$song_id,'100'); + self::_update_ext_item('lyrics',$new_lyrics,$song_id,'50'); } // update_lyrics @@ -446,7 +482,7 @@ class Song { */ public function update_title($new_title,$song_id) { - self::_update_item('title',$new_title,$song_id,'100'); + self::_update_item('title',$new_title,$song_id,'50'); } // update_title @@ -456,7 +492,7 @@ class Song { */ public function update_bitrate($new_bitrate,$song_id) { - self::_update_item('bitrate',$new_bitrate,$song_id,'100'); + self::_update_item('bitrate',$new_bitrate,$song_id,'50'); } // update_bitrate @@ -466,7 +502,7 @@ class Song { */ public function update_rate($new_rate,$song_id) { - self::_update_item('rate',$new_rate,$song_id,'100'); + self::_update_item('rate',$new_rate,$song_id,'50'); } // update_rate @@ -476,7 +512,7 @@ class Song { */ public function update_mode($new_mode,$song_id) { - self::_update_item('mode',$new_mode,$song_id,'100'); + self::_update_item('mode',$new_mode,$song_id,'50'); } // update_mode @@ -486,7 +522,7 @@ class Song { */ public function update_size($new_size,$song_id) { - self::_update_item('size',$new_size,$song_id,'100'); + self::_update_item('size',$new_size,$song_id,'50'); } // update_size @@ -496,7 +532,7 @@ class Song { */ public function update_time($new_time,$song_id) { - self::_update_item('time',$new_time,$song_id,'100'); + self::_update_item('time',$new_time,$song_id,'50'); } // update_time @@ -506,7 +542,7 @@ class Song { */ public function update_track($new_track,$song_id) { - self::_update_item('track',$new_track,$song_id,'100'); + self::_update_item('track',$new_track,$song_id,'50'); } // update_track @@ -516,7 +552,7 @@ class Song { */ public function update_artist($new_artist,$song_id) { - self::_update_item('artist',$new_artist,$song_id,'100'); + self::_update_item('artist',$new_artist,$song_id,'50'); } // update_artist @@ -526,7 +562,7 @@ class Song { */ public function update_genre($new_genre,$song_id) { - self::_update_item('genre',$new_genre,$song_id,'100'); + self::_update_item('genre',$new_genre,$song_id,'50'); } // update_genre @@ -536,7 +572,7 @@ class Song { */ public function update_album($new_album,$song_id) { - self::_update_item('album',$new_album,$song_id,'100'); + self::_update_item('album',$new_album,$song_id,'50'); } // update_album @@ -548,7 +584,7 @@ class Song { if (!$time) { $time = time(); } - self::_update_item('update_time',$time,$song_id,'100'); + self::_update_item('update_time',$time,$song_id,'75'); } // update_utime @@ -568,7 +604,7 @@ class Song { */ public function update_enabled($new_enabled,$song_id) { - self::_update_item('enabled',$new_enabled,$song_id,'100'); + self::_update_item('enabled',$new_enabled,$song_id,'75'); } // update_enabled |