diff options
-rw-r--r-- | admin/users.php | 154 | ||||
-rw-r--r-- | lib/class/browse.class.php | 9 | ||||
-rw-r--r-- | lib/class/user.class.php | 152 | ||||
-rw-r--r-- | lib/general.lib.php | 19 | ||||
-rw-r--r-- | lib/ui.lib.php | 11 | ||||
-rw-r--r-- | templates/show_add_user.inc.php | 9 | ||||
-rw-r--r-- | templates/show_edit_user.inc.php | 18 | ||||
-rw-r--r-- | templates/show_users.inc.php | 92 | ||||
-rw-r--r-- | templates/sidebar_admin.inc.php | 4 |
9 files changed, 219 insertions, 249 deletions
diff --git a/admin/users.php b/admin/users.php index 75a280cf..56a6fcf5 100644 --- a/admin/users.php +++ b/admin/users.php @@ -20,28 +20,20 @@ */ -require_once ('../lib/init.php'); - +require_once '../lib/init.php'; if (!$GLOBALS['user']->has_access(100)) { access_denied(); exit(); } - -$action = scrub_in($_REQUEST['action']); $user_id = scrub_in($_REQUEST['user_id']); -show_template('header'); +show_header(); // Switch on the actions -switch ($action) { - case 'edit': - if (conf('demo_mode')) { break; } - $working_user = new User($user_id); - require_once(conf('prefix') . '/templates/show_edit_user.inc.php'); - break; +switch ($_REQUEST['action']) { case 'update_user': - if (conf('demo_mode')) { break; } + if (Config::get('demo_mode')) { break; } /* Clean up the variables */ $user_id = scrub_in($_REQUEST['user_id']); @@ -53,84 +45,79 @@ switch ($action) { $pass2 = scrub_in($_REQUEST['password_2']); /* Setup the temp user */ - $working_user = new User($user_id); + $client = new User($user_id); /* Verify Input */ if (empty($username)) { - $GLOBALS['error']->add_error('username',_("Error Username Required")); + Error::add('username',_("Error Username Required")); } - if ($pass1 !== $pass2 AND !empty($pass1)) { - $GLOBALS['error']->add_error('password',_("Error Passwords don't match")); + if ($pass1 !== $pass2 && !empty($pass1)) { + Error::add('password',_("Error Passwords don't match")); } /* If we've got an error then break! */ - if ($GLOBALS['error']->error_state) { - require_once(conf('prefix') . '/templates/show_edit_user.inc.php'); + if (Error::$state) { + $_REQUEST['action'] = 'show_edit'; break; } // if we've had an oops! - if ($access != $working_user->access) { - $working_user->update_access($access); + if ($access != $client->access) { + $client->update_access($access); } - if ($email != $working_user->email) { - $working_user->update_email($email); + if ($email != $client->email) { + $client->update_email($email); } - if ($username != $working_user->username) { - $working_user->update_username($username); + if ($username != $client->username) { + $client->update_username($username); } - if ($fullname != $working_user->fullname) { - $working_user->update_fullname($fullname); + if ($fullname != $client->fullname) { + $client->update_fullname($fullname); } if ($pass1 == $pass2 && strlen($pass1)) { - $working_user->update_password($pass1); + $client->update_password($pass1); } - show_confirmation(_('User Updated'), $working_user->fullname . "(" . $working_user->username . ")" . _('updated'),'admin/users.php'); + show_confirmation(_('User Updated'), $client->fullname . "(" . $client->username . ")" . _('updated'),'admin/users.php'); break; case 'add_user': - if (conf('demo_mode')) { break; } + if (Config::get('demo_mode')) { break; } $username = scrub_in($_REQUEST['username']); $fullname = scrub_in($_REQUEST['fullname']); $email = scrub_in($_REQUEST['email']); $access = scrub_in($_REQUEST['access']); $pass1 = scrub_in($_REQUEST['password_1']); $pass2 = scrub_in($_REQUEST['password_2']); - if (($pass1 !== $pass2)) { - $GLOBALS['error']->add_error('password',_("Error Passwords don't match")); + + if ($pass1 !== $pass2) { + Error::add('password',_("Error Passwords don't match")); } if (empty($username)) { - $GLOBALS['error']->add_error('username',_("Error Username Required")); - } - if (is_numeric($username)) { - $GLOBALS['error']->add_error('username',"Error: Due to the incompetance of the programmer numeric usernames would cause the whole of existance to cease. Please add a letter or something"); + Error::add('username',_('Error Username Required')); } /* make sure the username doesn't already exist */ - if (!check_username($username)) { - $GLOBALS['error']->add_error('username',_("Error Username already exists")); + if (!User::check_username($username)) { + Error::add('username',_('Error Username already exists')); } - if (!$GLOBALS['error']->error_state) { - + if (!Error::$state) { /* Attempt to create the user */ - if (!$user->create($username, $fullname, $email, $pass1, $access)) { - $GLOBALS['error']->add_error('general',"Error: Insert Failed"); + $user_id = User::create($username, $fullname, $email, $pass1, $access); + if (!$user_id) { + Error::add('general',"Error: Insert Failed"); } } // if no errors - - /* If we end up with an error */ - if ($GLOBALS['error']->error_state) { - $type = 'new_user'; - require_once(conf('prefix') . '/templates/show_edit_user.inc.php'); + else { + $_REQUEST['action'] = 'show_add_user'; break; } - if ($access == 5){ $access = "Guest";} - elseif ($access == 25){ $access = "User";} - elseif ($access == 100){ $access = "Admin";} + if ($access == 5){ $access = _('Guest');} + elseif ($access == 25){ $access = _('User');} + elseif ($access == 100){ $access = _('Admin');} - show_confirmation("New User Added",$username . " has been created with an access level of " . $access,"admin/users.php"); + show_confirmation(_('New User Added'),__('%user% has been created with an access level of ' . $access,'%user%',$username),'admin/users.php'); break; case 'delete': if (conf('demo_mode')) { break; } @@ -139,6 +126,35 @@ switch ($action) { _('Are you sure you want to permanently delete') . " $working_user->fullname ($working_user->username)?", "admin/users.php?action=confirm_delete&user_id=$user_id",1); break; + case 'enable': + $working_user = new User($user_id); + $working_user->enable(); + show_confirmation(_('User Enabled'),'','admin/users.php'); + break; + case 'disable': + $working_user = new User($user_id); + if ($working_user->disable()) { + show_confirmation(_('User Disabled'),'','admin/users.php'); + } + else { + show_confirmation(_('Error'),_('Unable to Disabled last Administrator'),'admin/users.php'); + } + break; + +} // End Work Switch + + +/** + * This is the second half, it handles displaying anything + * the first half (work half) potentially has 'adjusted' the user + * input + */ +switch ($_REQUEST['action']) { + case 'show_edit': + if (Config::get('demo_mode')) { break; } + $client = new User($user_id); + require_once Config::get('prefix') . '/templates/show_edit_user.inc.php'; + break; case 'confirm_delete': if (conf('demo_mode')) { break; } $working_user = new User($_REQUEST['user_id']); @@ -161,22 +177,8 @@ switch ($action) { require (conf('prefix') . '/templates/show_ip_history.inc.php'); break; case 'show_add_user': - if (conf('demo_mode')) { break; } - require_once(conf('prefix') . '/templates/show_add_user.inc.php'); - break; - case 'enable': - $working_user = new User($user_id); - $working_user->enable(); - show_confirmation(_('User Enabled'),'','admin/users.php'); - break; - case 'disable': - $working_user = new User($user_id); - if ($working_user->disable()) { - show_confirmation(_('User Disabled'),'','admin/users.php'); - } - else { - show_confirmation(_('Error'),_('Unable to Disabled last Administrator'),'admin/users.php'); - } + if (Config::get('demo_mode')) { break; } + require_once Config::get('prefix') . '/templates/show_add_user.inc.php'; break; case 'show_inactive': $view = new View(); @@ -201,23 +203,9 @@ switch ($action) { break; default: - // Setup the View Object - $view = new View(); - $view->import_session_view(); - - // If we are returning - if ($_REQUEST['keep_view']) { - $view->initialize(); - } - else { - $sql = "SELECT `id` FROM `user`"; - $db_results = mysql_query($sql,dbh()); - $total_items = mysql_num_rows($db_results); - $view = new View($sql,'admin/users.php','fullname',$total_items,$user->prefs['offset_limit']); - } - - $users = get_users($view->sql); - require_once(conf('prefix') . '/templates/show_users.inc.php'); + Browse::set_type('user'); + $user_ids = Browse::get_objects(); + Browse::show_objects($user_ids); break; } // end switch on action diff --git a/lib/class/browse.class.php b/lib/class/browse.class.php index 8613559f..91fd067b 100644 --- a/lib/class/browse.class.php +++ b/lib/class/browse.class.php @@ -84,6 +84,7 @@ class Browse { public static function set_type($type) { switch($type) { + case 'user': case 'song': case 'album': case 'artist': @@ -161,6 +162,9 @@ class Browse { case 'genre': $sql = "SELECT `genre`.`id` FROM `genre` "; break; + case 'user': + $sql = "SELECT `user`.`id` FROM `user` "; + break; case 'song': default: $sql = "SELECT `song`.`id` FROM `song` "; @@ -308,6 +312,11 @@ class Browse { require_once Config::get('prefix') . '/templates/show_genres.inc.php'; show_box_bottom(); break; + case 'user': + show_box_top(_('Manage Users')); + require_once Config::get('prefix') . '/templates/show_users.inc.php'; + show_box_bottom(); + break; case 'artist': show_box_top(); require_once Config::get('prefix') . '/templates/show_artists.inc.php'; diff --git a/lib/class/user.class.php b/lib/class/user.class.php index fe75d587..4019ba98 100644 --- a/lib/class/user.class.php +++ b/lib/class/user.class.php @@ -293,17 +293,19 @@ class User { } // get_recommendations - /*! - @function is_logged_in - @discussion checks to see if $this user is logged in - */ - function is_logged_in() { + /** + * is_logged_in + * checks to see if $this user is logged in + */ + public function is_logged_in() { - $sql = "SELECT id FROM session WHERE `username`='$this->username'" . - " AND expire > ". time(); - $db_results = mysql_query($sql,dbh()); + $username = Dba::escape($this->username); + + $sql = "SELECT `id` FROM `session` WHERE `username`='$username'" . + " AND `expire` > ". time(); + $db_results = Dba::query($sql); - if (mysql_num_rows($db_results)) { + if (Dba::num_rows($db_results)) { return true; } @@ -385,16 +387,16 @@ class User { } // add_preference - /*! - @function update_username - @discussion updates their username - */ - function update_username($new_username) { + /** + * update_username + * updates their username + */ + public function update_username($new_username) { - $new_username = sql_escape($new_username); + $new_username = Dba::escape($new_username); $sql = "UPDATE `user` SET `username`='$new_username' WHERE `id`='$this->id'"; $this->username = $new_username; - $db_results = mysql_query($sql, dbh()); + $db_results = Dba::query($sql); } // update_username @@ -415,27 +417,27 @@ class User { } // update_validation - /*! - @function update_fullname - @discussion updates their fullname - */ - function update_fullname($new_fullname) { + /** + * update_fullname + * updates their fullname + */ + public function update_fullname($new_fullname) { - $new_fullname = sql_escape($new_fullname); - $sql = "UPDATE user SET fullname='$new_fullname' WHERE `id`='$this->id'"; - $db_results = mysql_query($sql, dbh()); + $new_fullname = Dba::escape($new_fullname); + $sql = "UPDATE `user` SET `fullname`='$new_fullname' WHERE `id`='$this->id'"; + $db_results = Dba::query($sql); } // update_fullname - /*! - @function update_email - @discussion updates their email address - */ - function update_email($new_email) { + /** + * update_email + * updates their email address + */ + public function update_email($new_email) { - $new_email = sql_escape($new_email); - $sql = "UPDATE user SET email='$new_email' WHERE `id`='$this->id'"; - $db_results = mysql_query($sql, dbh()); + $new_email = Dba::escape($new_email); + $sql = "UPDATE `user` SET `email`='$new_email' WHERE `id`='$this->id'"; + $db_results = Dba::query($sql); } // update_email @@ -478,20 +480,19 @@ class User { /** * update_access * updates their access level - * @todo Remove References to the named version of access */ - function update_access($new_access) { + public function update_access($new_access) { /* Prevent Only User accounts */ if ($new_access < '100') { $sql = "SELECT `id` FROM user WHERE `access`='100' AND `id` != '$this->id'"; - $db_results = mysql_query($sql, dbh()); - if (!mysql_num_rows($db_results)) { return false; } + $db_results = Dba::query($sql); + if (!Dba::num_rows($db_results)) { return false; } } - $new_access = sql_escape($new_access); + $new_access = Dba::escape($new_access); $sql = "UPDATE `user` SET `access`='$new_access' WHERE `id`='$this->id'"; - $db_results = mysql_query($sql, dbh()); + $db_results = Dba::query($sql); } // update_access @@ -610,41 +611,40 @@ class User { } // create - /*! - @function update_password - @discussion updates a users password - */ - function update_password($new_password) { + /** + * update_password + * updates a users password + */ + public function update_password($new_password) { - $new_password = sql_escape($new_password); - $sql = "UPDATE user SET password=PASSWORD('$new_password') WHERE `id`='$this->id'"; - $db_results = mysql_query($sql, dbh()); + $new_password = Dba::escape($new_password); + $sql = "UPDATE `user` SET `password`=PASSWORD('$new_password') WHERE `id`='$this->id'"; + $db_results = Dba::query($sql); - return true; } // update_password /** - * format_user + * format * 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() { + public function format() { /* If they have a last seen date */ - if (!$this->last_seen) { $this->f_last_seen = "Never"; } + 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); } + if (!$this->create_date) { $this->f_create_date = _('Unknown'); } + else { $this->f_create_date = date("m\/d\/Y - H:i",$this->create_date); } /* Calculate their total Bandwidth Useage */ - $sql = "SELECT song.size FROM song LEFT JOIN object_count ON song.id=object_count.object_id " . - "WHERE object_count.user='$this->id' AND object_count.object_type='song'"; - $db_results = mysql_query($sql, dbh()); + $sql = "SELECT `song`.`size` FROM `song` LEFT JOIN `object_count` ON `song`.`id`=`object_count`.`object_id` " . + "WHERE `object_count`.`user`='$this->id' AND `object_count`.`object_type`='song'"; + $db_results = Dba::query($sql); - while ($r = mysql_fetch_assoc($db_results)) { + while ($r = Dba::fetch_assoc($db_results)) { $total = $total + $r['size']; } @@ -656,6 +656,7 @@ class User { } switch ($divided) { + default: case '1': $name = "KB"; break; case '2': $name = "MB"; break; case '3': $name = "GB"; break; @@ -937,28 +938,31 @@ class User { /** * get_ip_history * This returns the ip_history from the - * last conf('user_ip_cardinality') days + * last Config::get('user_ip_cardinality') days */ - function get_ip_history($count='',$distinct='') { + public function get_ip_history($count='',$distinct='') { - $username = sql_escape($this->id); + $username = Dba::escape($this->id); if ($count) { $limit_sql = "LIMIT " . intval($count); } + else { + $limit_sql = "LIMIT " . intval(Config::get('user_ip_cardinality')); + } if ($distinct) { - $group_sql = "GROUP BY ip"; + $group_sql = "GROUP BY `ip`"; } /* Select ip history */ - $sql = "SELECT ip,date FROM ip_history" . - " WHERE user='$username'" . + $sql = "SELECT `ip`,`date` FROM `ip_history`" . + " WHERE `user`='$username'" . " $group_sql ORDER BY `date` DESC $limit_sql"; - $db_results = mysql_query($sql, dbh()); + $db_results = Dba::query($sql); $results = array(); - while ($r = mysql_fetch_assoc($db_results)) { + while ($r = Dba::fetch_assoc($db_results)) { $results[] = $r; } @@ -997,6 +1001,26 @@ class User { return true; } // is_xmlrpc + + /** + * check_username + * This checks to make sure the username passed doesn't already + * exist in this instance of ampache + */ + public static function check_username($username) { + + $usrename = Dba::escape($username); + + $sql = "SELECT `id` FROM `user` WHERE `username`='$username'"; + $db_results = Dba::query($sql); + + if (Dba::num_rows($db_results)) { + return false; + } + + return true; + + } // check_username } //end user class diff --git a/lib/general.lib.php b/lib/general.lib.php index 4ee9796f..a72bb4fd 100644 --- a/lib/general.lib.php +++ b/lib/general.lib.php @@ -556,25 +556,6 @@ function clear_catalog_stats() { } // clear_catalog_stats /** - * check_username - * this function checks to make sure the specified username doesn't already exist - * @package General - * @catagory Users - */ -function check_username($username) { - - $sql = "SELECT username FROM user WHERE username = '" . sql_escape($username) . "'"; - $db_results = mysql_query($sql, dbh()); - - if (mysql_fetch_row($db_results)) { - return false; - } - - return true; - -} // check_username - -/** * scrub_out * This function is used to escape user data that is getting redisplayed * onto the page, it htmlentities the mojo diff --git a/lib/ui.lib.php b/lib/ui.lib.php index 88cfc3c2..be447091 100644 --- a/lib/ui.lib.php +++ b/lib/ui.lib.php @@ -236,6 +236,17 @@ function truncate_with_ellipsis($text, $max=27) { } // truncate_with_ellipsis /** + * show_header + * This shows the header.inc.php, it may do something + * more in the future + */ +function show_header() { + + require_once Config::get('prefix') . '/templates/header.inc.php'; + +} // show_header + +/** * show_footer * shows the footer of the page */ diff --git a/templates/show_add_user.inc.php b/templates/show_add_user.inc.php index bbb79671..ed9ac236 100644 --- a/templates/show_add_user.inc.php +++ b/templates/show_add_user.inc.php @@ -21,8 +21,8 @@ */ ?> <?php show_box_top(_('Adding a New User')); ?> -<?php $GLOBALS['error']->print_error('general'); ?> -<form name="add_user" enctype="multpart/form-data" method="post" action="<?php echo conf('web_path') . "/admin/users.php"; ?>"> +<?php Error::display('general'); ?> +<form name="add_user" enctype="multpart/form-data" method="post" action="<?php echo Config::get('web_path') . "/admin/users.php?action=add_user"; ?>"> <table class="tabledata" cellspacing="0" cellpadding="0" border="0"> <tr> <td> @@ -30,7 +30,7 @@ </td> <td> <input type="text" name="username" size="30" maxlength="128" value="<?php echo scrub_out($_POST['username']); ?>" /> - <?php $GLOBALS['error']->print_error('username'); ?> + <?php Error::display('username'); ?> </td> </tr> <tr> @@ -53,7 +53,7 @@ </td> <td> <input type="password" name="password_1" size="30" value="" /> - <?php $GLOBALS['error']->print_error('password'); ?> + <?php Error::display('password'); ?> </td> </tr> <tr> @@ -79,7 +79,6 @@ </tr> <td colspan="2"> <input type="submit" value="<?php echo _('Add User'); ?>" /> - <input type="hidden" name="action" value="add_user" /> </td> </tr> </table> diff --git a/templates/show_edit_user.inc.php b/templates/show_edit_user.inc.php index a2779938..1c227cca 100644 --- a/templates/show_edit_user.inc.php +++ b/templates/show_edit_user.inc.php @@ -21,22 +21,22 @@ */ ?> <?php show_box_top(_('Editing existing User')); ?> -<?php $GLOBALS['error']->print_error('general'); ?> -<form name="update_user" enctype="multipart/form-data" method="post" action="<?php echo conf('web_path') . "/admin/users.php"; ?>"> +<?php Error::display('general'); ?> +<form name="update_user" enctype="multipart/form-data" method="post" action="<?php echo Config::get('web_path') . "/admin/users.php"; ?>"> <table class="tabledata" cellspacing="0" cellpadding="0" border="0"> <tr> <td> <?php echo _('Username'); ?>: </td> <td> - <input type="text" name="username" size="30" maxlength="128" value="<?php echo scrub_out($working_user->username); ?>" /> - <?php $GLOBALS['error']->print_error('username'); ?> + <input type="text" name="username" size="30" maxlength="128" value="<?php echo scrub_out($client->username); ?>" /> + <?php Error::display('username'); ?> </td> </tr> <tr> <td><?php echo _('Full Name'); ?>:</td> <td> - <input type="text" name="fullname" size="30" value="<?php echo scrub_out($working_user->fullname); ?>" /> + <input type="text" name="fullname" size="30" value="<?php echo scrub_out($client->fullname); ?>" /> </td> </tr> <tr> @@ -44,7 +44,7 @@ <?php echo _('E-mail'); ?>: </td> <td> - <input type="text" name="email" size="30" value="<?php echo scrub_out($working_user->email); ?>" /> + <input type="text" name="email" size="30" value="<?php echo scrub_out($client->email); ?>" /> </td> </tr> <tr> @@ -53,7 +53,7 @@ </td> <td> <input type="password" name="password_1" size="30" value="" /> - <?php $GLOBALS['error']->print_error('password'); ?> + <?php Error::display('password'); ?> </td> </tr> <tr> @@ -69,7 +69,7 @@ <?php echo _('User Access Level'); ?>: </td> <td> - <?php $var_name = "on_" . $working_user->access; ${$var_name} = 'selected="selected"'; ?> + <?php $var_name = "on_" . $client->access; ${$var_name} = 'selected="selected"'; ?> <select name="access"> <option value="5" <?php echo $on_5; ?>><?php echo _('Guest'); ?></option> <option value="25" <?php echo $on_25; ?>><?php echo _('User'); ?></option> @@ -81,7 +81,7 @@ <td colspan="2"> <input type="hidden" name="action" value="update_user" /> <input type="submit" value="<?php echo _('Update User'); ?>" /> - <input type="hidden" name="user_id" value="<?php echo $working_user->id; ?>" /> + <input type="hidden" name="user_id" value="<?php echo $client->id; ?>" /> </td> </tr> </table> diff --git a/templates/show_users.inc.php b/templates/show_users.inc.php index 3bb1abd4..640978c7 100644 --- a/templates/show_users.inc.php +++ b/templates/show_users.inc.php @@ -19,46 +19,13 @@ */ -$web_path = conf('web_path'); -$total_items = $view->total_items; -$admin_menu = "admin/"; +$web_path = Config::get('web_path'); -show_box_top(_('Manage Users')); ?> -<table class="tabledata" cellpadding="0" cellspacing="10" border="0"> -<tr> -<td> -<?php - echo get_user_icon('add_user') . ' '; - echo '<a href="' . $web_path . '/admin/users.php?action=show_add_user">' . _('Add a new user') . '</a>'; - if (isset ($_REQUEST['action']) && $_REQUEST['action'] == "show_inactive"){ - ?> -</td> -</tr> -<form name="show_inactive" enctype="multipart/form-data" method="request" action="<?php echo conf('web_path') . "/admin/users.php"; ?>"> -<tr align="center"> - <td> - Inactive users for <input type=text name="days" size="4" value="<?php if (isset ($_REQUEST['days'])){ echo $_REQUEST['days'];}?>" /> days - </td> -</tr> -<tr> - <td> - <input type="hidden" name="action" value="show_inactive" /> - <input type="Submit" /> - </td> -</tr> -</form> - <?php - }?> -</table> -<?php -show_box_bottom(); -?> -<?php show_box_top(); ?> <table class="tabledata" cellpadding="0" cellspacing="0" border="0"> <tr class="table-header" align="center"> <td colspan="11"> - <?php if ($view->offset_limit) { require (conf('prefix') . "/templates/list_header.inc"); } ?> + <?php if ($view->offset_limit) { require Config::get('prefix') . '/templates/list_header.inc'; } ?> </td> </tr> <tr class="table-header"> @@ -83,28 +50,27 @@ show_box_bottom(); <td align="center"> <b><?php echo _('Activity'); ?></b> </td> - <?php if (conf('track_user_ip')) { ?> + <?php if (Config::get('track_user_ip')) { ?> <td align="center"> <b><?php echo _('Last Ip'); ?></b> </td> <?php } ?> - <td colspan="5"> </td> + <td align="center"><strong><?php echo _('Action'); ?></strong></td> <td align="center"> <b><?php echo _('On-line'); ?></b> </td> </tr> <?php -foreach ($users as $working_user) { - $working_user->format_user(); - $last_seen = date("m\/d\/Y - H:i",$working_user->last_seen); - if (!$working_user->last_seen) { $last_seen = _('Never'); } - $create_date = date("m\/d\/Y - H:i",$working_user->create_date); - if (!$working_user->create_date) { $create_date = _('Unknown'); } +foreach ($object_ids as $user_id) { + $client = new User($user_id); + $client->format(); + $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'); ?> <tr class="<?php echo flip_class(); ?>" align="center"> <td align="left"> - <a href="<?php echo $web_path; ?>/admin/users.php?action=edit&user_id=<?php echo $working_user->id; ?>"> - <?php echo $working_user->fullname; ?> (<?php echo $working_user->username; ?>) + <a href="<?php echo $web_path; ?>/admin/users.php?action=edit&user_id=<?php echo $client->id; ?>"> + <?php echo $client->fullname; ?> (<?php echo $client->username; ?>) </a> </td> <td> @@ -115,48 +81,37 @@ foreach ($users as $working_user) { </td> <td> - <?php echo $working_user->f_useage; ?> + <?php echo $client->f_useage; ?> </td> - <?php if (conf('track_user_ip')) { ?> - <td> - <a href="<?php echo $web_path; ?>/admin/users.php?action=show_ip_history&user_id=<?php echo $working_user->id; ?>"> - <?php echo $working_user->ip_history; ?> + <td> + <?php if (Config::get('track_user_ip')) { ?> + <a href="<?php echo $web_path; ?>/admin/users.php?action=show_ip_history&user_id=<?php echo $client->id; ?>"> + <?php echo $client->ip_history; ?> </a> - </td> <?php } ?> - <td> - <a href="<?php echo $web_path; ?>/admin/users.php?action=edit&user_id=<?php echo $working_user->id; ?>"> + <a href="<?php echo $web_path; ?>/admin/users.php?action=show_edit&user_id=<?php echo $client->id; ?>"> <?php echo get_user_icon('edit'); ?> </a> - </td> - <td> - <a href="<?php echo $web_path; ?>/admin/preferences.php?action=user&user_id=<?php echo $working_user->id; ?>"> + <a href="<?php echo $web_path; ?>/admin/preferences.php?action=user&user_id=<?php echo $client->id; ?>"> <?php echo get_user_icon('preferences'); ?> </a> - </td> - <td> - <a href="<?php echo $web_path; ?>/stats.php?action=user_stats&user_id=<?php echo $working_user->id; ?>"> - <?php echo get_user_icon('statistics'); ?> - </a> - </td> <?php //FIXME: Fix this for the extra permission levels if ($working_user->disabled == '1') { - echo "<td><a href=\"".$web_path."/admin/users.php?action=enable&user_id=$working_user->id\">" . get_user_icon('enable') . "</a></td>"; + echo "<a href=\"".$web_path."/admin/users.php?action=enable&user_id=$client->id\">" . get_user_icon('enable') . "</a>"; } else { - echo "<td><a href=\"".$web_path."/admin/users.php?action=disable&user_id=$working_user->id\">" . get_user_icon('disable') ."</a></td>"; + echo "<a href=\"".$web_path."/admin/users.php?action=disable&user_id=$client->id\">" . get_user_icon('disable') ."</a>"; } ?> - <td> - <a href="<?php echo $web_path; ?>/admin/users.php?action=delete&user_id=<?php echo $working_user->id; ?>"> + <a href="<?php echo $web_path; ?>/admin/users.php?action=delete&user_id=<?php echo $client->id; ?>"> <?php echo get_user_icon('delete'); ?> </a> </td> <?php - if (($working_user->is_logged_in()) and ($working_user->is_online())) { + if (($client->is_logged_in()) AND ($client->is_online())) { echo "<td class=\"user_online\"> </td>"; - } elseif ($working_user->disabled == 1) { + } elseif ($client->disabled == 1) { echo "<td class=\"user_disabled\"> </td>"; } else { echo "<td class=\"user_offline\"> </td>"; @@ -165,4 +120,3 @@ foreach ($users as $working_user) { </tr> <?php } //end foreach users ?> </table> -<?php show_box_bottom(); ?> diff --git a/templates/sidebar_admin.inc.php b/templates/sidebar_admin.inc.php index a7e91364..e35d1d98 100644 --- a/templates/sidebar_admin.inc.php +++ b/templates/sidebar_admin.inc.php @@ -14,6 +14,10 @@ | <a href="<?php echo $web_path; ?>/admin/catalog.php?action=clean_catalog&catalogs[]=<?php echo $catalog->id; ?>"><?php echo _('Clean'); ?></a> <?php } ?> <hr /> +<h4><?php echo _('User Tools'); ?></h4> +<span><a href="<?php echo $web_path; ?>/admin/users.php?action=show_add_user"><?php echo _('Add User'); ?></a></span> +<span><a href="<?php echo $web_path; ?>/admin/users.php"><?php echo _('Browse Users'); ?></a></span> +<hr /> <h4><?php echo _('Other Tools'); ?></h4> <span><a href="<?php echo $web_path; ?>/admin/catalog.php?action=clear_now_playing"><?php echo _('Clear Now Playing'); ?></a></span> <span><a href="<?php echo $web_path; ?>/admin/catalog.php?action=clear_stats"><?php echo _('Clear Catalog Stats'); ?></a></span> |