summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/class/tmpplaylist.class.php22
-rw-r--r--lib/song.php8
-rw-r--r--modules/vauth/session.lib.php8
-rw-r--r--stats.php7
-rw-r--r--templates/show_account.inc.php62
-rw-r--r--templates/show_album.inc.php6
-rw-r--r--templates/show_index.inc.php2
-rw-r--r--templates/show_now_playing_row.inc.php7
-rw-r--r--templates/show_preferences.inc.php14
-rw-r--r--templates/show_recently_played.inc.php2
-rw-r--r--templates/show_user.inc.php72
11 files changed, 156 insertions, 54 deletions
diff --git a/lib/class/tmpplaylist.class.php b/lib/class/tmpplaylist.class.php
index b59417d5..a9110098 100644
--- a/lib/class/tmpplaylist.class.php
+++ b/lib/class/tmpplaylist.class.php
@@ -98,6 +98,28 @@ class tmpPlaylist {
} // get_from_session
/**
+ * get_from_userid
+ * This returns a tmp playlist object based on a userid passed
+ * this is used for the user profiles page
+ */
+ public static function get_from_userid($user_id) {
+
+ // This is a little stupid, because we don't have the user_id in the session or
+ // in the tmp_playlist table we have to do it this way.
+ $client = new User($user_id);
+ $username = Dba::escape($client->username);
+
+ $sql = "SELECT `tmp_playlist`.`id` FROM `tmp_playlist` LEFT JOIN `session` ON `session`.`id`=`tmp_playlist`.`session` " .
+ " WHERE `session`.`username`='$username' ORDER BY `session`.`expire` DESC";
+ $db_results = Dba::query($sql);
+
+ $data = Dba::fetch_assoc($db_results);
+
+ return $data['id'];
+
+ } // get_from_userid
+
+ /**
* get_items
* This returns an array of all object_ids currently in this tmpPlaylist
*/
diff --git a/lib/song.php b/lib/song.php
index 5a26d183..fc987943 100644
--- a/lib/song.php
+++ b/lib/song.php
@@ -82,11 +82,15 @@ function get_songs_from_type($type,$results,$artist_id='') {
* This function returns the last X songs that have been played
* It uses the 'popular' threshold to determine how many to pull
*/
-function get_recently_played() {
+function get_recently_played($user_id='') {
+
+ if ($user_id) {
+ $user_limit = " AND object_count.user='" . Dba::escape($user_id) . "'";
+ }
$sql = "SELECT object_count.object_id, object_count.user, object_count.object_type, object_count.date " .
"FROM object_count " .
- "WHERE object_type='song' " .
+ "WHERE object_type='song'$user_limit " .
"ORDER by object_count.date DESC " .
"LIMIT " . Config::get('popular_threshold');
$db_results = Dba::query($sql);
diff --git a/modules/vauth/session.lib.php b/modules/vauth/session.lib.php
index a6845a26..6d71bf9c 100644
--- a/modules/vauth/session.lib.php
+++ b/modules/vauth/session.lib.php
@@ -126,8 +126,8 @@ function vauth_sess_destory($key) {
*/
function vauth_sess_gc($maxlifetime) {
- $sql = "DELETE FROM session WHERE expire < '" . time() . "'";
- $db_results = mysql_query($sql, vauth_dbh());
+ $sql = "DELETE FROM `session` WHERE `expire` < '" . time() . "'";
+ $db_results = Dba::query($sql);
return true;
@@ -152,8 +152,8 @@ function vauth_get_session($key) {
$key = Dba::escape($key);
- $sql = "SELECT * FROM session WHERE id='$key' AND expire > '" . time() . "'";
- $db_results = mysql_query($sql, vauth_dbh());
+ $sql = "SELECT * FROM `session` WHERE `id`='$key' AND `expire` > '" . time() . "'";
+ $db_results = Dba::query($sql);
$results = mysql_fetch_assoc($db_results);
diff --git a/stats.php b/stats.php
index 49b486bf..63fa4f3a 100644
--- a/stats.php
+++ b/stats.php
@@ -24,10 +24,15 @@
*/
require_once 'lib/init.php';
-require_once Config::get('prefix') . '/templates/header.inc.php';
+show_header();
/* Switch on the action to be performed */
switch ($_REQUEST['action']) {
+ // Show a Users "Profile" page
+ case 'show_user':
+ $client = new User($_REQUEST['user_id']);
+ require_once Config::get('prefix') . '/templates/show_user.inc.php';
+ break;
case 'user_stats':
/* Get em! */
$working_user = new User($_REQUEST['user_id']);
diff --git a/templates/show_account.inc.php b/templates/show_account.inc.php
new file mode 100644
index 00000000..fc380c6f
--- /dev/null
+++ b/templates/show_account.inc.php
@@ -0,0 +1,62 @@
+<?php
+/*
+
+ Copyright (c) 2001 - 2007 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 v2
+ as published by the Free Software Foundation.
+
+ 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.
+
+*/
+?>
+<table class="tabledata">
+<tr>
+ <td><?php echo _('Name'); ?>:</td>
+ <td>
+ <input type="text" name="fullname" size="27" value="<?php echo scrub_out($client->fullname); ?>" />
+ </td>
+</tr>
+<tr>
+ <td><?php echo _('E-mail'); ?>:</td>
+ <td>
+ <input type="text" name="email" size="27" value="<?php echo scrub_out($client->email); ?>" />
+ </td>
+</tr>
+<tr>
+ <td><?php echo _('New Password'); ?>:</td>
+ <td>
+ <?php Error::display('password'); ?>
+ <input type="password" name="password1" size="27" />
+ </td>
+</tr>
+<tr>
+ <td><?php echo _('Confirm Password'); ?>:</td>
+ <td>
+ <input type="password" name="password2" size="27" />
+ </td>
+</tr>
+<tr>
+ <td><?php echo _('Clear Stats'); ?>:</td>
+ <td>
+ <input type="checkbox" name="clear_stats" value="1" />
+ </td>
+</tr>
+<tr>
+ <td colspan="2">
+ <input type="hidden" name="user_id" value="<?php echo scrub_out($client->id); ?>" />
+ <input type="hidden" name="action" value="update_user" />
+ <input type="hidden" name="tab" value="<?php echo scrub_out($_REQUEST['tab']); ?>" />
+ <input class="button" type="submit" value="<?php echo _('Update Account'); ?>" />
+ </td>
+</tr>
+</table>
diff --git a/templates/show_album.inc.php b/templates/show_album.inc.php
index 72c39ca5..61f2750e 100644
--- a/templates/show_album.inc.php
+++ b/templates/show_album.inc.php
@@ -58,3 +58,9 @@ $title = scrub_out($album->name) . ' -- ' . $album->f_artist;
<?php } ?>
</div>
<?php show_box_bottom(); ?>
+<?php
+ show_box_top(_('Songs'));
+ $object_ids = $album->get_songs();
+ require Config::get('prefix') . '/templates/show_songs.inc.php';
+ show_box_bottom();
+?>
diff --git a/templates/show_index.inc.php b/templates/show_index.inc.php
index 0afacb0e..226fbff4 100644
--- a/templates/show_index.inc.php
+++ b/templates/show_index.inc.php
@@ -38,7 +38,9 @@ if (isset($_REQUEST['xspf']) && isset ($_REQUEST['play_info'])){
<div id="recently_played">
<?php
$data = get_recently_played();
+ show_box_top(_('Recently Player'));
if (count($data)) { require_once Config::get('prefix') . '/templates/show_recently_played.inc.php'; }
+ show_box_bottom();
?>
</div>
<div id="catalog_info">
diff --git a/templates/show_now_playing_row.inc.php b/templates/show_now_playing_row.inc.php
index 46594411..ef9a0b68 100644
--- a/templates/show_now_playing_row.inc.php
+++ b/templates/show_now_playing_row.inc.php
@@ -23,9 +23,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
$title = scrub_out(truncate_with_ellipse($song->title,'25'));
$album = scrub_out(truncate_with_ellipse($song->f_album_full,'25'));
$artist = scrub_out(truncate_with_ellipse($song->f_artist_full,'25'));
-
?>
-<td class="np_cell"><?php echo scrub_out($np_user->fullname); ?></td>
+<td class="np_cell">
+ <a href="<?php echo $web_path; ?>/stats.php?action=show_user&amp;user_id=<?php echo $np_user->id; ?>">
+ <?php echo scrub_out($np_user->fullname); ?>
+ </a>
+</td>
<td class="np_cell">
<a title="<?php echo scrub_out($song->title); ?>" href="<?php echo $web_path; ?>/song.php?action=single_song&amp;song_id=<?php echo $song->id; ?>">
<?php echo $title; ?>
diff --git a/templates/show_preferences.inc.php b/templates/show_preferences.inc.php
index 31500393..c2cb94e0 100644
--- a/templates/show_preferences.inc.php
+++ b/templates/show_preferences.inc.php
@@ -28,23 +28,19 @@
<?php show_box_top(_('Editing') . ' ' . $fullname . ' ' . _('preferences')); ?>
<form method="post" name="preferences" action="<?php echo Config::get('web_path'); ?>/preferences.php?action=update_preferences" enctype="multipart/form-data">
<?php
-if ($current_tab != 'account' && $current_tab != 'modules') {
+if ($_REQUEST['tab'] != 'account' && $_REQUEST['tab'] != 'modules') {
show_preference_box($preferences[$_REQUEST['tab']]);
?>
<input class="button" type="submit" value="<?php echo _('Update Preferences'); ?>" />
- <input type="hidden" name="action" value="update_preferences" />
<input type="hidden" name="tab" value="<?php echo scrub_out($current_tab); ?>" />
<input type="hidden" name="method" value="<?php echo scrub_out($_REQUEST['action']); ?>" />
<input class="button" type="submit" name="action" value="<?php echo _("Cancel"); ?>" />
<?php
- }
-if ($current_tab == 'modules') {
- require (conf('prefix') . '/templates/show_modules.inc.php');
-}
-if ($current_tab == 'account') {
- $this_user = new User($user_id);
- require (conf('prefix') . '/templates/show_user.inc.php');
+} // end if not account
+if ($_REQUEST['tab'] == 'account') {
+ $client = $GLOBALS['user'];
+ require Config::get('prefix') . '/templates/show_account.inc.php';
}
?>
</form>
diff --git a/templates/show_recently_played.inc.php b/templates/show_recently_played.inc.php
index eff14df9..47c383a7 100644
--- a/templates/show_recently_played.inc.php
+++ b/templates/show_recently_played.inc.php
@@ -23,7 +23,6 @@
$time_unit = array('',_('seconds ago'),_('minutes ago'),_('hours ago'),_('days ago'),_('weeks ago'),_('months ago'),_('years ago'));
?>
-<?php show_box_top(_('Recently Played')); ?>
<table>
<tr class="table-header">
<td><?php echo _('Username'); ?></td>
@@ -75,4 +74,3 @@ $time_unit = array('',_('seconds ago'),_('minutes ago'),_('hours ago'),_('days a
</tr>
<?php } ?>
</table>
-<?php show_box_bottom(); ?>
diff --git a/templates/show_user.inc.php b/templates/show_user.inc.php
index 82b965ae..d13b1b88 100644
--- a/templates/show_user.inc.php
+++ b/templates/show_user.inc.php
@@ -1,12 +1,13 @@
<?php
/*
- Copyright (c) 2001 - 2006 Ampache.org
+ Copyright (c) 2001 - 2007 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 v2
- as published by the Free Software Foundation.
+ 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
@@ -18,45 +19,48 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
+$last_seen = $client->last_seen ? date("m\/d\/y - H:i",$client->last_seen) : _('Never');
+$create_date = $client->create_date ? date("m\/d\/y - H:i",$client->create_date) : _('Unknown');
+$client->format();
?>
-<table class="tabledata">
+<?php show_box_top($client->fullname); ?>
+<table border="0" cellspacing="0">
<tr>
- <td><?php echo _('Name'); ?>:</td>
- <td>
- <input type="text" name="fullname" size="27" value="<?php echo scrub_out($this_user->fullname); ?>" />
+ <td valign="top">
+ <strong><?php echo _('Full Name'); ?>:</strong> <?php echo $client->fullname; ?><br />
+ <strong><?php echo _('Create Date'); ?>:</strong> <?php echo $create_date; ?><br />
+ <strong><?php echo _('Last Seen'); ?>:</strong> <?php echo $last_seen; ?><br />
+ <strong><?php echo _('Activity'); ?>:</strong> <?php echo $client->f_useage; ?><br />
+ <?php if ($client->is_logged_in() AND $client->is_online()) { ?>
+ <i style="color:green;"><?php echo _('User is Online Now'); ?></i>
+ <?php } else { ?>
+ <i style="color:red;"><?php echo _('User is Offline Now'); ?></i>
+ <?php } ?>
</td>
-</tr>
-<tr>
- <td><?php echo _('E-mail'); ?>:</td>
- <td>
- <input type="text" name="email" size="27" value="<?php echo scrub_out($this_user->email); ?>" />
- </td>
-</tr>
-<tr>
- <td><?php echo _('New Password'); ?>:</td>
- <td>
- <?php $GLOBALS['error']->print_error('password'); ?>
- <input type="password" name="password1" size="27" />
+ <td valign="top">
+ <h2><?php echo _('Active Playlist'); ?></h2>
+ <?php
+ $tmp_playlist = new tmpPlaylist(tmpPlaylist::get_from_userid($client->id));
+ $object_ids = $tmp_playlist->get_items();
+ foreach ($object_ids as $song_id) {
+ $song = new Song($song_id);
+ $song->format();
+ ?>
+ <?php echo $song->f_link; ?><br />
+ <?php } ?>
</td>
</tr>
<tr>
- <td><?php echo _('Confirm Password'); ?>:</td>
- <td>
- <input type="password" name="password2" size="27" />
+ <td valign="top">
+ <h2><?php echo _('Recently Rated'); ?></h2>
</td>
-</tr>
-<tr>
- <td><?php echo _('Clear Stats'); ?>:</td>
<td>
- <input type="checkbox" name="clear_stats" value="1" />
- </td>
-</tr>
-<tr>
- <td colspan="2">
- <input type="hidden" name="user_id" value="<?php echo scrub_out($this_user->id); ?>" />
- <input type="hidden" name="action" value="update_user" />
- <input type="hidden" name="tab" value="<?php echo scrub_out($current_tab); ?>" />
- <input class="button" type="submit" value="<?php echo _('Update Account'); ?>" />
+ <?php
+ echo "<h2>" . _('Recently Played') . "</h2>\n";
+ $data = get_recently_played($client->id);
+ require Config::get('prefix') . '/templates/show_recently_played.inc.php';
+ ?>
</td>
</tr>
</table>
+<?php show_box_bottom(); ?>