summaryrefslogtreecommitdiffstats
path: root/lib/class/user.class.php
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/class/user.class.php
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/class/user.class.php')
-rw-r--r--lib/class/user.class.php64
1 files changed, 64 insertions, 0 deletions
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