diff options
author | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-03-14 20:14:52 +0000 |
---|---|---|
committer | Paul 'flowerysong' Arthur <flowerysong00@yahoo.com> | 2010-03-14 20:14:52 +0000 |
commit | 1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc (patch) | |
tree | 54655ff3e692a71a17f1d37cd97374b263557ca1 /lib/class/flag.class.php | |
parent | ef48bf3fbdca2a4d25f5d025f4c6ad23905e5369 (diff) | |
download | ampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.tar.gz ampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.tar.bz2 ampache-1cb0983ed04c65e06d502ae2ac9ed6d5e31d70dc.zip |
Cosmetics: remove trailing whitespace
Diffstat (limited to 'lib/class/flag.class.php')
-rw-r--r-- | lib/class/flag.class.php | 212 |
1 files changed, 106 insertions, 106 deletions
diff --git a/lib/class/flag.class.php b/lib/class/flag.class.php index 8105a247..3394019d 100644 --- a/lib/class/flag.class.php +++ b/lib/class/flag.class.php @@ -17,17 +17,17 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ /** * Flag Class - * This handles flagging of songs, albums and artists + * This handles flagging of songs, albums and artists */ class Flag extends database_object { - public $id; + public $id; public $user; public $object_id; public $object_type; @@ -44,13 +44,13 @@ class Flag extends database_object { * Constructor * This takes a flagged.id and then pulls in the information for said flag entry */ - public function __construct($flag_id) { + public function __construct($flag_id) { $info = $this->get_info($flag_id,'flagged'); - - foreach ($info as $key=>$value) { - $this->$key = $value; - } + + foreach ($info as $key=>$value) { + $this->$key = $value; + } return true; @@ -61,18 +61,18 @@ class Flag extends database_object { * This takes an array of ids and builds up a nice little cache * for us */ - public static function build_cache($ids) { + public static function build_cache($ids) { - if (!is_array($ids) OR !count($ids)) { return false; } + if (!is_array($ids) OR !count($ids)) { return false; } - $idlist = '(' . implode(',',$ids) . ')'; + $idlist = '(' . implode(',',$ids) . ')'; - $sql = "SELECT * FROM `flagged` WHERE `id` IN $idlist"; - $db_results = Dba::read($sql); + $sql = "SELECT * FROM `flagged` WHERE `id` IN $idlist"; + $db_results = Dba::read($sql); - while ($row = Dba::fetch_assoc($db_results)) { - parent::add_to_cache('flagged',$row['id'],$row); - } + while ($row = Dba::fetch_assoc($db_results)) { + parent::add_to_cache('flagged',$row['id'],$row); + } } // build_cache @@ -81,27 +81,27 @@ class Flag extends database_object { * This takes an array of ids and builds a map cache to avoid some of the object_type calls * we would normally have to make */ - public static function build_map_cache($ids,$type) { + public static function build_map_cache($ids,$type) { - if (!is_array($ids) OR !count($ids)) { return false; } + if (!is_array($ids) OR !count($ids)) { return false; } - $idlist = '(' . implode(',',$ids) . ')'; - $type = Dba::escape($type); + $idlist = '(' . implode(',',$ids) . ')'; + $type = Dba::escape($type); - $sql = "SELECT * FROM `flagged` " . - "WHERE `flagged`.`object_type`='$type' AND `flagged`.`object_id` IN $idlist"; - $db_results = Dba::read($sql); - - while ($row = Dba::fetch_assoc($db_results)) { - $results[$row['object_id']] = $row; - } - - // Itterate through the passed ids as we need to cache 'nulls' - foreach ($ids as $id) { - parent::add_to_cache('flagged_' . $type,$id,$results[$id]); - } + $sql = "SELECT * FROM `flagged` " . + "WHERE `flagged`.`object_type`='$type' AND `flagged`.`object_id` IN $idlist"; + $db_results = Dba::read($sql); + + while ($row = Dba::fetch_assoc($db_results)) { + $results[$row['object_id']] = $row; + } + + // Itterate through the passed ids as we need to cache 'nulls' + foreach ($ids as $id) { + parent::add_to_cache('flagged_' . $type,$id,$results[$id]); + } - return true; + return true; } // build_map_cache @@ -109,23 +109,23 @@ class Flag extends database_object { * has_flag * Static function, tries to check the cache, but falls back on a query */ - public static function has_flag($id,$type) { + public static function has_flag($id,$type) { + + if (parent::is_cached('flagged_' . $type,$id)) { + $data = parent::get_from_cache('flagged_' . $type,$id); + return $data['date']; + } - if (parent::is_cached('flagged_' . $type,$id)) { - $data = parent::get_from_cache('flagged_' . $type,$id); - return $data['date']; - } - // Ok we have to query this - $type = Dba::escape($type); + $type = Dba::escape($type); - $sql = "SELECT * FROM `flagged` WHERE `flagged`.`object_type`='$type' AND `flagged`.`object_id`='$id'"; - $db_results = Dba::read($sql); + $sql = "SELECT * FROM `flagged` WHERE `flagged`.`object_type`='$type' AND `flagged`.`object_id`='$id'"; + $db_results = Dba::read($sql); $row = Dba::fetch_assoc($db_results); - parent::add_to_cache('flagged_' . $type,$row['object_id'],$row); + parent::add_to_cache('flagged_' . $type,$row['object_id'],$row); - return $row['date']; + return $row['date']; } // has_flag @@ -134,19 +134,19 @@ class Flag extends database_object { * This returns the id's of the most recently flagged songs, it takes an int * as an argument which is the count of the object you want to return */ - public static function get_recent($count=0) { + public static function get_recent($count=0) { - if ($count) { $limit = " LIMIT " . intval($count); } + if ($count) { $limit = " LIMIT " . intval($count); } $results = array(); $sql = "SELECT id FROM flagged ORDER BY date " . $limit; $db_results = Dba::read($sql); - while ($r = Dba::fetch_assoc($db_results)) { + while ($r = Dba::fetch_assoc($db_results)) { $results[] = $r['id']; } - + return $results; } // get_recent @@ -156,18 +156,18 @@ class Flag extends database_object { * This returns all of the songs that have been disabled, this is * a form of being flagged */ - public static function get_disabled() { + public static function get_disabled() { - $sql = "SELECT `id` FROM `song` WHERE `enabled`='0'"; - $db_results = Dba::read($sql); + $sql = "SELECT `id` FROM `song` WHERE `enabled`='0'"; + $db_results = Dba::read($sql); + + $results = array(); - $results = array(); - - while ($row = Dba::fetch_assoc($db_results)) { - $results[] = $row['id']; - } + while ($row = Dba::fetch_assoc($db_results)) { + $results[] = $row['id']; + } - return $results; + return $results; } // get_disabled @@ -176,10 +176,10 @@ class Flag extends database_object { * This returns an array of ids of flagged songs if no limit is passed * it gets everything */ - public static function get_all($count=0) { + public static function get_all($count=0) { + + if ($count) { $limit_clause = "LIMIT " . intval($count); } - if ($count) { $limit_clause = "LIMIT " . intval($count); } - $sql = "SELECT `id` FROM `flagged` $limit_clause"; $db_results = Dba::read($sql); @@ -187,7 +187,7 @@ class Flag extends database_object { $results = array(); /* While the query */ - while ($row = Dba::fetch_assoc($db_results)) { + while ($row = Dba::fetch_assoc($db_results)) { $results[] = $row['id']; } @@ -199,17 +199,17 @@ class Flag extends database_object { * get_approved * This returns an array of approved flagged songs */ - public static function get_approved() { + public static function get_approved() { $sql = "SELECT `id` FROM `flagged` WHERE `approved`='1'"; - $db_results = Dba::read($sql); + $db_results = Dba::read($sql); /* Default the results array */ - $results = array(); + $results = array(); /* While it */ - while ($r = Dba::fetch_assoc($db_results)) { + while ($r = Dba::fetch_assoc($db_results)) { $results[] = $r['id']; } @@ -222,8 +222,8 @@ class Flag extends database_object { * 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 */ - public static function add($id,$type,$flag,$comment) { - + public static function add($id,$type,$flag,$comment) { + $id = Dba::escape($id); $type = Dba::escape($type); $flag = self::validate_flag($flag); @@ -233,9 +233,9 @@ class Flag extends database_object { $approved = '0'; /* If they are an content manager or higher, it's auto approved */ - if (Access::check('interface','75')) { $approved = '1'; } + if (Access::check('interface','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 = Dba::write($sql); @@ -249,18 +249,18 @@ class Flag extends database_object { * state, in a perfect world, I could just roll the changes back... not until 3.4 * or.. haha 3.5! */ - public function delete() { + public function delete() { // Re-scan the file - $song = new Song($this->object_id); - $info = Catalog::update_media_from_tags($song); + $song = new Song($this->object_id); + $info = Catalog::update_media_from_tags($song); // Delete the row $sql = "DELETE FROM `flagged` WHERE `id`='$this->id'"; $db_results = Dba::write($sql); - // Reset the Last-Updated date so that it'll get re-scaned - $song->update_utime($song->id,1); + // Reset the Last-Updated date so that it'll get re-scaned + $song->update_utime($song->id,1); return true; @@ -271,44 +271,44 @@ class Flag extends database_object { * This approves the current flag object ($this->id) by setting approved to * 1 */ - public function approve() { + public function approve() { $sql = "UPDATE `flagged` SET `approved`='1' WHERE `id`='$this->id'"; $db_results = Dba::write($sql); - $this->approved = 1; + $this->approved = 1; return true; - + } // approve - + /** * format * This function figures out what kind of object we've got and sets up all the * vars all nice and fuzzy like */ - public function format() { + public function format() { - switch ($this->object_type) { - case 'song': + switch ($this->object_type) { + case 'song': $song = new Song($this->object_id); - $song->format(); + $song->format(); $this->f_name = $song->f_link; break; - } // end switch on type + } // end switch on type $client = new User($this->user); - $client->format(); - $this->f_user = $client->f_link; + $client->format(); + $this->f_user = $client->f_link; } // format - + /** * print_status * This prints out a userfriendly version of the current status for this flagged * object */ - public function print_status() { + public function print_status() { if ($this->approved) { echo _('Approved'); } else { echo _('Pending'); } @@ -319,20 +319,20 @@ class Flag extends database_object { * print_flag * This prints out a userfriendly version of the current flag type */ - public function print_flag() { + public function print_flag() { - switch ($this->flag) { + switch ($this->flag) { case 'delete': $name = _('Delete'); break; case 'retag': - $name = _('Re-Tag'); + $name = _('Re-Tag'); break; case 'reencode': $name = _('Re-encode'); break; case 'other': - $name = _('Other'); + $name = _('Other'); break; default: $name = _('Unknown'); @@ -340,7 +340,7 @@ class Flag extends database_object { } // end switch echo $name; - + } // print_flag /** @@ -348,17 +348,17 @@ class Flag extends database_object { * 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; + public static function validate_flag($flag) { + + switch ($flag) { + case 'delete': + case 'retag': + case 'reencode': + case 'other': + return $flag; break; - default: - return 'other'; + default: + return 'other'; break; } // end switch @@ -366,14 +366,14 @@ class Flag extends database_object { /** * fill_tags - * This is used by the write_tags script. + * This is used by the write_tags script. */ public static function fill_tags( $tagWriter, $song, $type = 'comment' ) { // Set all of the attributes for the tag to be written(All pulled from the song object) // Use a function since ID3v1, ID3v2, and vorbis/flac/ape are different - switch ($type) { - case 'comment': + switch ($type) { + case 'comment': $tagWriter->comments['title'] = $song->title; $tagWriter->comments['date'] = $song->year; $tagWriter->comments['year'] = $song->year; @@ -384,7 +384,7 @@ class Flag extends database_object { $tagWriter->comments['artist'] = $song->get_artist_name(); $tagWriter->comments['genre'] = $song->get_genre_name(); $tagWriter->comments['track'] = $song->track; - break; + break; case 'id3v1': $tagWriter->title = $song->title; $tagWriter->year = $song->year; |