diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-03-21 08:33:33 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2006-03-21 08:33:33 +0000 |
commit | abcb173edc821f5d652e388bdeb303e8c6c8edf7 (patch) | |
tree | 2422545a6b8fc15d5f30f08be12dfc2e6ac423c6 /lib | |
parent | 82e94fd071b42211c4d8a31ca080afbfa9669217 (diff) | |
download | ampache-abcb173edc821f5d652e388bdeb303e8c6c8edf7.tar.gz ampache-abcb173edc821f5d652e388bdeb303e8c6c8edf7.tar.bz2 ampache-abcb173edc821f5d652e388bdeb303e8c6c8edf7.zip |
I am not happy with it.. but its progress and I need sleep
Diffstat (limited to 'lib')
-rw-r--r-- | lib/class/flag.class.php | 112 | ||||
-rw-r--r-- | lib/class/update.class.php | 27 |
2 files changed, 137 insertions, 2 deletions
diff --git a/lib/class/flag.class.php b/lib/class/flag.class.php index 566822b2..8bbdc2c9 100644 --- a/lib/class/flag.class.php +++ b/lib/class/flag.class.php @@ -33,6 +33,8 @@ class Flag { var $object_type; var $comment; var $flag; + var $date; + var $approved=0; /** * Constructor @@ -51,6 +53,8 @@ class Flag { $this->object_type = $info['object_type']; $this->comment = $info['comment']; $this->flag = $info['flag']; + $this->date = $info['date']; + $this->approved = $info['approved']; return true; @@ -74,6 +78,41 @@ class Flag { } // _get_info /** + * get_recent + * 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 + */ + function get_recent($count=0) { + + if ($count) { $limit = " LIMIT " . intval($count); } + + $sql = "SELECT id FROM flagged ORDER BY date " . $limit; + $db_results = mysql_query($sql, dbh()); + + while ($r = mysql_fetch_assoc($db_results)) { + $results[] = $r; + } + + return $results; + + } // get_recent + + /** + * get_total + * Returns the total number of flagged objects + */ + function get_total() { + + $sql = "SELECT COUNT(id) FROM flagged"; + $db_results = mysql_query($sql, dbh()); + + $results = mysql_fetch_row($db_results); + + return $results['0']; + + } // get_total + + /** * add * 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 @@ -84,15 +123,84 @@ class Flag { $type = sql_escape($type); $flag = sql_escape($flag); $comment = sql_escape($comment); + $time = time(); + $approved = '0'; + + /* If they are an admin, it's auto approved */ + if ($GLOBALS['user']->has_access('100')) { $approved = '1'; } - $sql = "INSERT INTO flagged (`object_id`,`object_type`,`flag`,`comment`) VALUES " . - " ('$id','$type','$flag','$comment')"; + $sql = "INSERT INTO flagged (`object_id`,`object_type`,`flag`,`comment`,`date`,`approved`) VALUES " . + " ('$id','$type','$flag','$comment','$time','$approved')"; $db_results = mysql_query($sql, dbh()); return true; } // add + /** + * print_name + * This function formats and prints out a userfriendly name of the flagged + * object + */ + function print_name() { + + switch ($this->object_type) { + case 'song': + $song = new Song($this->object_id); + $song->format_song(); + $name = $song->f_title . " - " . $song->f_artist; + $title = $song->title . " - " . $song->get_artist_name(); + break; + default: + + break; + } // end switch on object type + + echo "<span title=\"$title\">$name</span>"; + + } // print_name + + + /** + * print_status + * This prints out a userfriendly version of the current status for this flagged + * object + */ + function print_status() { + + if ($this->approved) { echo _('Approved'); } + else { echo _('Pending'); } + + } // print_status + + /** + * print_flag + * This prints out a userfriendly version of the current flag type + */ + function print_flag() { + + switch ($this->flag) { + case 'delete': + $name = _('Delete'); + break; + case 'retag': + $name = _('Re-Tag'); + break; + case 'reencode': + $name = _('Re-encode'); + break; + case 'other': + $name = _('Other'); + break; + default: + $name = _('Unknown'); + break; + } // end switch + + echo $name; + + } // print_flag + } //end of flag class ?> diff --git a/lib/class/update.class.php b/lib/class/update.class.php index a2bdf6a2..318b9a9d 100644 --- a/lib/class/update.class.php +++ b/lib/class/update.class.php @@ -267,6 +267,10 @@ class Update { $version[] = array('version' => '332008','description' => $update_string); + $update_string = "- Add missing date and approval fields to Flagged table, can't belive I forgot these.<br />"; + + $version[] = array('version' => '332009','description' => $update_string); + return $version; } // populate_version @@ -1439,5 +1443,28 @@ class Update { } // update_332008 + /** + * update_332009 + * Wonderfull another update, this one adds the missing date and approved fields to flagged + * which I can't belive I forgot, and adds id back to the user table because warreng said so + */ + function update_332009() { + + /* Add the missing fields */ + $sql = "ALTER TABLE `flagged` ADD `date` INT( 11 ) UNSIGNED NOT NULL AFTER `flag` ," . + "ADD `approved` TINYINT( 1 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `date`"; + $db_results = mysql_query($sql, dbh()); + + $sql = "ALTER TABLE `flagged` ADD INDEX ( `date` , `approved` )"; + $db_results = mysql_query($sql, dbh()); + + /* Add the ID back to the user table because warreng said so */ + $sql = "ALTER TABLE `user` ADD `id` INT( 11 ) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY FIRST"; + $db_results = mysql_query($sql, dbh()); + + $this->set_version('db_version','332009'); + + } // update_332009 + } // end update class ?> |