From abcb173edc821f5d652e388bdeb303e8c6c8edf7 Mon Sep 17 00:00:00 2001 From: Karl 'vollmerk' Vollmer Date: Tue, 21 Mar 2006 08:33:33 +0000 Subject: I am not happy with it.. but its progress and I need sleep --- admin/index.php | 10 ++-- lib/class/flag.class.php | 112 ++++++++++++++++++++++++++++++++++- lib/class/update.class.php | 27 +++++++++ templates/basestyle.inc.php | 11 ++++ templates/show_admin_catalog.inc.php | 77 ------------------------ templates/show_admin_info.inc.php | 19 ++++-- templates/show_admin_tools.inc.php | 93 +++++++++++++++++++++++++++++ templates/show_admin_user.inc.php | 27 --------- templates/show_flagged.inc.php | 51 ++++++++++++++++ 9 files changed, 310 insertions(+), 117 deletions(-) delete mode 100644 templates/show_admin_catalog.inc.php create mode 100644 templates/show_admin_tools.inc.php delete mode 100644 templates/show_admin_user.inc.php create mode 100644 templates/show_flagged.inc.php diff --git a/admin/index.php b/admin/index.php index 70540c49..0fcbec54 100644 --- a/admin/index.php +++ b/admin/index.php @@ -36,15 +36,13 @@ show_template('header'); - - - - - - +
+
+ +
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; @@ -73,6 +77,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 @@ -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 "$name"; + + } // 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.
"; + + $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 ?> diff --git a/templates/basestyle.inc.php b/templates/basestyle.inc.php index f22c5e46..de41587b 100644 --- a/templates/basestyle.inc.php +++ b/templates/basestyle.inc.php @@ -260,5 +260,16 @@ border-left:2px solid ; border-top:2px solid ; } + .text-action { + list-style: none; + margin-top:5px; + margin-bottom:5px; + } + .text-action a { + border:1px solid ; + padding-left:2px; + padding-right:2px; + text-decoration: none; + } --> diff --git a/templates/show_admin_catalog.inc.php b/templates/show_admin_catalog.inc.php deleted file mode 100644 index 9bbbf504..00000000 --- a/templates/show_admin_catalog.inc.php +++ /dev/null @@ -1,77 +0,0 @@ - - -
- - - - - - - - - - - - - - - - - -
- - name; ?> -   (path; ?>) - - -  |  - -  |  - -  |  - -  |  - - -
- -
-
- - - - -
-
-
-
-
-
-
-
-
-
diff --git a/templates/show_admin_info.inc.php b/templates/show_admin_info.inc.php index e57b2485..993bc03b 100644 --- a/templates/show_admin_info.inc.php +++ b/templates/show_admin_info.inc.php @@ -21,14 +21,23 @@ */ $web_path = conf('web_path'); +/* Setup the needed objects */ +$flagged = Flag::get_recent('10'); +$total_flagged = Flag::get_total(); + ?>
-
- +
+ +
  • ...
  • +


    - -
    +
    +  +

    +
    +
    - + 
    diff --git a/templates/show_admin_tools.inc.php b/templates/show_admin_tools.inc.php new file mode 100644 index 00000000..ee0e274f --- /dev/null +++ b/templates/show_admin_tools.inc.php @@ -0,0 +1,93 @@ + + +
    + + + + + + + + + + + + + + + + + +
    + + name; ?> +   (path; ?>) + + +  |  + +  |  + +  |  + +  |  + + +
    + +
    + + + + + +

    +
    +
    +
  • + +
  • +
  • +
    +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +

    + +
    +  +
    diff --git a/templates/show_admin_user.inc.php b/templates/show_admin_user.inc.php deleted file mode 100644 index 8269eb06..00000000 --- a/templates/show_admin_user.inc.php +++ /dev/null @@ -1,27 +0,0 @@ - -
    -
    -
    diff --git a/templates/show_flagged.inc.php b/templates/show_flagged.inc.php new file mode 100644 index 00000000..068f38af --- /dev/null +++ b/templates/show_flagged.inc.php @@ -0,0 +1,51 @@ + + + + + + + + + + + + + + + + +
    print_name(); ?>print_flag(); ?>print_status(); ?> + approved) { ?> + + + + + + + + +
    -- cgit