summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-03-21 08:33:33 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-03-21 08:33:33 +0000
commitabcb173edc821f5d652e388bdeb303e8c6c8edf7 (patch)
tree2422545a6b8fc15d5f30f08be12dfc2e6ac423c6
parent82e94fd071b42211c4d8a31ca080afbfa9669217 (diff)
downloadampache-abcb173edc821f5d652e388bdeb303e8c6c8edf7.tar.gz
ampache-abcb173edc821f5d652e388bdeb303e8c6c8edf7.tar.bz2
ampache-abcb173edc821f5d652e388bdeb303e8c6c8edf7.zip
I am not happy with it.. but its progress and I need sleep
-rw-r--r--admin/index.php10
-rw-r--r--lib/class/flag.class.php112
-rw-r--r--lib/class/update.class.php27
-rw-r--r--templates/basestyle.inc.php11
-rw-r--r--templates/show_admin_info.inc.php19
-rw-r--r--templates/show_admin_tools.inc.php (renamed from templates/show_admin_catalog.inc.php)42
-rw-r--r--templates/show_admin_user.inc.php27
-rw-r--r--templates/show_flagged.inc.php51
8 files changed, 246 insertions, 53 deletions
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');
<table>
<tr>
<!-- Needs Attention Cell -->
- <td rowspan="2" valign="top" width="50%">
+ <td valign="top">
<?php require (conf('prefix') . '/templates/show_admin_info.inc.php'); ?>
</td>
<!-- Catalog Cell -->
- <td width="50%"><?php require (conf('prefix') . '/templates/show_admin_catalog.inc.php'); ?></td>
-</tr>
-<tr>
- <!-- Users Cell -->
- <td><?php require (conf('prefix') . '/templates/show_admin_user.inc.php'); ?></td>
+ <td valign="top">
+ <?php require (conf('prefix') . '/templates/show_admin_tools.inc.php'); ?>
+ </td>
</tr>
</table>
<?php show_footer(); ?>
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
?>
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 <?php echo conf('bg_color2'); ?>;
border-top:2px solid <?php echo conf('bg_color2'); ?>;
}
+ .text-action {
+ list-style: none;
+ margin-top:5px;
+ margin-bottom:5px;
+ }
+ .text-action a {
+ border:1px solid <?php echo conf('bg_color2'); ?>;
+ padding-left:2px;
+ padding-right:2px;
+ text-decoration: none;
+ }
-->
</style>
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();
+
?>
<span class="header1"><?php echo _('Information'); ?></span><br />
<div class="text-box">
-<span class="header2"><?php echo _('Flagged Songs'); ?></span><br />
-<!-- Show Last 10 Flagged Songs -->
+<span class="header2"><?php echo _('Last Ten Flagged Songs'); ?></span><br />
+<?php require (conf('prefix') . '/templates/show_flagged.inc.php'); ?>
+<li class="text-action"><a href="<?php echo $web_path; ?>/admin/flag.php?action=show_flagged"><?php echo _('Show All'); ?>...</a></li>
+</div><br />
<span class="header2"><?php echo _('Disabled Songs'); ?></span><br />
-<!-- Show Last 10 Disabled Songs -->
-<span class="header2"><?php echo _('Active Users'); ?></span><br />
+<div class="text-box">
+<!-- Show Last 10 Disabled Songs -->&nbsp;
+</div><br />
+<span class="header2"><?php echo _('User Activity'); ?></span><br />
+<div class="text-box">
<!-- Show Last 10 Active Users (Bandwidth Usage guess) -->
-
+&nbsp;
</div>
diff --git a/templates/show_admin_catalog.inc.php b/templates/show_admin_tools.inc.php
index 9bbbf504..ee0e274f 100644
--- a/templates/show_admin_catalog.inc.php
+++ b/templates/show_admin_tools.inc.php
@@ -61,17 +61,33 @@ $catalogs = Catalog::get_catalogs();
<?php } // end if no catalogs ?>
</table>
<form id="catalog_tools" method="post" enctype="multipart/form-data" style="Display:inline;">
-<input class="button" type="button" value="<?php echo _('Clean Everything'); ?>" onclick="return SubmitToPage('catalog_tools','<?php echo $web_path; ?>/admin/catalog.php?action=clean_all_catalogs');" />
-<input class="button" type="button" value="<?php echo _('Verify Everything'); ?>" onclick="return SubmitToPage('catalog_tools','<?php echo $web_path; ?>/admin/catalog.php?action=update_all_catalogs');" />
-<input class="button" type="button" value="<?php echo _('Add to Everything'); ?>" onclick="return SubmitToPage('catalog_tools',<?php echo $web_path; ?>/admin/catalog.php?action=add_to_all_catalogs');" />
-<input class="button" type="button" value="<?php echo _('Update Everything'); ?>" onclick="return SubmitToPage('catalog_tools',<?php echo $web_path; ?>/admin/catalog.php?action=full_service');" />
-<br />
-<span class="header2"><?php echo _('Other Tools'); ?></span><br />
-<a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_add_catalog"><?php echo _('Add a Catalog'); ?></a><br />
-<a href="<?php echo $web_path; ?>/admin/duplicates.php"><?php echo _('Show Duplicate Songs'); ?></a><br />
-<a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_disabled"><?php echo _('Show Disabled Songs'); ?></a><br />
-<a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_clear_stats"><?php echo _('Clear Catalog Stats'); ?></a><br />
-<a href="<?php echo $web_path; ?>/admin/catalog.php?action=clear_now_playing"><?php echo _('Clear Now Playing'); ?></a><br />
-<a href="<?php echo $web_path; ?>/admin/catalog.php?action=gather_album_art"><?php echo _('Gather Album Art'); ?></a><br />
+<input class="button" type="button" value="<?php echo _('Clean All'); ?>" onclick="return SubmitToPage('catalog_tools','<?php echo $web_path; ?>/admin/catalog.php?action=clean_all_catalogs');" />
+<input class="button" type="button" value="<?php echo _('Verify All'); ?>" onclick="return SubmitToPage('catalog_tools','<?php echo $web_path; ?>/admin/catalog.php?action=update_all_catalogs');" />
+<input class="button" type="button" value="<?php echo _('Add to All'); ?>" onclick="return SubmitToPage('catalog_tools',<?php echo $web_path; ?>/admin/catalog.php?action=add_to_all_catalogs');" />
+<input class="button" type="button" value="<?php echo _('Update All'); ?>" onclick="return SubmitToPage('catalog_tools',<?php echo $web_path; ?>/admin/catalog.php?action=full_service');" />
+</div><br />
+<span class="header1"><?php echo _('Other Tools'); ?></span><br />
+<div class="text-box">
+<li class="text-action">
+ <a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_add_catalog"><?php echo _('Add a Catalog'); ?></a>
+</li>
+<li class="text-action">
+ <a href="<?php echo $web_path; ?>/admin/duplicates.php"><?php echo _('Show Duplicate Songs'); ?></a><br />
+</li>
+<li class="text-action">
+ <a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_disabled"><?php echo _('Show Disabled Songs'); ?></a>
+</li>
+<li class="text-action">
+ <a href="<?php echo $web_path; ?>/admin/catalog.php?action=show_clear_stats"><?php echo _('Clear Catalog Stats'); ?></a>
+</li>
+<li class="text-action">
+ <a href="<?php echo $web_path; ?>/admin/catalog.php?action=clear_now_playing"><?php echo _('Clear Now Playing'); ?></a>
+</li>
+<li class="text-action">
+ <a href="<?php echo $web_path; ?>/admin/catalog.php?action=gather_album_art"><?php echo _('Gather Album Art'); ?></a>
+</li>
+</div><br />
+<span class="header1"><?php echo _('Manage Users'); ?></span>
+<div class="text-box">
+&nbsp;
</div>
-<br />
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 @@
-<?php
-/*
-
- Copyright (c) 2001 - 2006 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.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU General Public License for more details.
-
- 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.
-
-*/
-$web_path = conf('web_path');
-
-?>
-<div class="text-box">
-<span class="header2"><?php echo _('Users'); ?></span><br />
-</div>
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 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2006 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.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ 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.
+
+*/
+
+$web_path = conf('web_path');
+
+?>
+<table class="border" cellspacing="0" cellpadding="0">
+<tr class="table-header">
+ <th><?php echo _('Object'); ?></th>
+ <th><?php echo _('Flag'); ?></th>
+ <th><?php echo _('Status'); ?></th>
+ <th><?php echo _('Action'); ?></th>
+</tr>
+<?php foreach ($flagged as $flag_id) { $flag = new Flag($flag_id); ?>
+<tr class="<?php echo flip_class(); ?>">
+ <td><?php $flag->print_name(); ?></td>
+ <td><?php $flag->print_flag(); ?></td>
+ <td><?php $flag->print_status(); ?></td>
+ <td>
+ <?php if ($flag->approved) { ?>
+ <a href="<?php echo $web_path; ?>/admin/flag.php?action=reject_flag&amp;flag_id=<?php echo $flag->id; ?>">
+ <?php echo _('Reject'); ?>
+ </a>
+ <?php } else { ?>
+ <a href="<?php echo $web_path; ?>/admin/flag.php?action=approve_flag&amp;flag_id=<?php echo $flag->id; ?>">
+ <?php echo _('Approve'); ?>
+ </a>
+ <?php } ?>
+ </td>
+</tr>
+<?php } ?>
+</table>