summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-03-29 09:17:04 +0000
committerKarl 'vollmerk' Vollmer <vollmer@ampache.org>2006-03-29 09:17:04 +0000
commite61a3b3ca1aae656a4c9f88713041e88c204eac5 (patch)
tree33442f09abee256d4af54638c697c4cabba5f893 /lib
parentc603a3c5c098393e8aaa72e293daec5a431ee0c9 (diff)
downloadampache-e61a3b3ca1aae656a4c9f88713041e88c204eac5.tar.gz
ampache-e61a3b3ca1aae656a4c9f88713041e88c204eac5.tar.bz2
ampache-e61a3b3ca1aae656a4c9f88713041e88c204eac5.zip
added in the manage users section and put in a temp disable songs section which currently does not work
Diffstat (limited to 'lib')
-rw-r--r--lib/class/catalog.class.php17
-rw-r--r--lib/class/flag.class.php6
-rw-r--r--lib/class/user.class.php64
3 files changed, 77 insertions, 10 deletions
diff --git a/lib/class/catalog.class.php b/lib/class/catalog.class.php
index 66b675b4..125fc4f5 100644
--- a/lib/class/catalog.class.php
+++ b/lib/class/catalog.class.php
@@ -555,17 +555,18 @@ class Catalog {
} //get_catalog_files
- /*!
- @function get_disabled
- @discussion Gets an array of the disabled songs for all catalogs
- and returns full song objects with them
- */
- function get_disabled() {
- global $conf;
+ /**
+ * get_disabled
+ * Gets an array of the disabled songs for all catalogs
+ * and returns full song objects with them
+ */
+ function get_disabled($count=0) {
$results = array();
- $sql = "SELECT id FROM song WHERE enabled='0'";
+ if ($count) { $limit_clause = " LIMIT $count"; }
+
+ $sql = "SELECT id FROM song WHERE enabled='0' $limit_clause";
$db_results = mysql_query($sql, dbh());
while ($r = mysql_fetch_array($db_results)) {
diff --git a/lib/class/flag.class.php b/lib/class/flag.class.php
index 59a07aaa..fe2f3047 100644
--- a/lib/class/flag.class.php
+++ b/lib/class/flag.class.php
@@ -90,14 +90,16 @@ class Flag {
if ($count) { $limit = " LIMIT " . intval($count); }
+ $results = array();
+
$sql = "SELECT id FROM flagged ORDER BY date " . $limit;
$db_results = mysql_query($sql, dbh());
while ($r = mysql_fetch_assoc($db_results)) {
- $results[] = $r;
+ $results[] = $r['id'];
}
- return $results['id'];
+ return $results;
} // get_recent
diff --git a/lib/class/user.class.php b/lib/class/user.class.php
index dbcbd97d..e4567ef0 100644
--- a/lib/class/user.class.php
+++ b/lib/class/user.class.php
@@ -531,6 +531,49 @@ class User {
return true;
} // update_password
+ /**
+ * format_user
+ * This function sets up the extra variables we need when we are displaying a
+ * user for an admin, these should not be normally called when creating a
+ * user object
+ */
+ function format_user() {
+
+ /* If they have a last seen date */
+ if (!$this->last_seen) { $this->f_last_seen = "Never"; }
+ else { $this->f_last_seen = date("m\/d\/Y - H:i",$this->last_seen); }
+
+ /* If they have a create date */
+ if (!$this->create_date) { $this->f_create_date = "Unknown"; }
+ else { $this->f_create_date = date("m\/d\/Y - H:i",$user->create_date); }
+
+ /* Calculate their total Bandwidth Useage */
+ $sql = "SELECT song.size FROM object_count LEFT JOIN song ON song.id=object_count.object_id " .
+ "WHERE object_count.userid='$this->id' AND object_count.object_type='song'";
+ $db_results = mysql_query($sql, dbh());
+
+ while ($r = mysql_fetch_assoc($db_results)) {
+ $total = $total + $r['size'];
+ }
+
+ $divided = 0;
+
+ while (strlen(floor($total)) > 3) {
+ $total = ($total / 1024);
+ $divided++;
+ }
+
+ switch ($divided) {
+ case '1': $name = "KB"; break;
+ case '2': $name = "MB"; break;
+ case '3': $name = "GB"; break;
+ case '4': $name = "TB"; break;
+ case '5': $name = "PB"; break;
+ } // end switch
+
+ $this->f_useage = round($total,2) . $name;
+
+ } // format_user
/*!
@function format_favorites
@@ -789,6 +832,27 @@ class User {
} // get_user_validation
+ /**
+ * get_recent
+ * This returns users by thier last login date
+ */
+ function get_recent($count=0) {
+
+ if ($count) { $limit_clause = " LIMIT $count"; }
+
+ $results = array();
+
+ $sql = "SELECT username FROM user ORDER BY last_seen $limit_clause";
+ $db_results = mysql_query($sql, dbh());
+
+ while ($r = mysql_fetch_assoc($db_results)) {
+ $results[] = $r['username'];
+ }
+
+ return $results;
+
+ } // get_recent
+
/*!
@function activate_user
@activates the user from public_registration