diff options
author | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-06-21 14:48:21 +0000 |
---|---|---|
committer | Karl 'vollmerk' Vollmer <vollmer@ampache.org> | 2005-06-21 14:48:21 +0000 |
commit | a7e50222a51424ac0f101c7abe9f19b1f763b975 (patch) | |
tree | b8b957c7240240912d0beeb6aeae2866f86d38d0 | |
parent | 2ea7061ed6d4eb2c45f173f5168956b23b5295ca (diff) | |
download | ampache-a7e50222a51424ac0f101c7abe9f19b1f763b975.tar.gz ampache-a7e50222a51424ac0f101c7abe9f19b1f763b975.tar.bz2 ampache-a7e50222a51424ac0f101c7abe9f19b1f763b975.zip |
new disabled support
-rwxr-xr-x | docs/CHANGELOG | 1 | ||||
-rw-r--r-- | login.php | 2 | ||||
-rw-r--r-- | modules/class/update.php | 21 | ||||
-rw-r--r-- | modules/class/user.php | 20 | ||||
-rw-r--r-- | templates/show_users.inc | 58 | ||||
-rw-r--r-- | templates/userform.inc | 1 |
6 files changed, 63 insertions, 40 deletions
diff --git a/docs/CHANGELOG b/docs/CHANGELOG index 712f9f7d..f2676f97 100755 --- a/docs/CHANGELOG +++ b/docs/CHANGELOG @@ -25,6 +25,7 @@ - Fixed refresh link if Local Play is on it's own page (Thx XGizzmo) - Fixed a ton of HTML, and CSS errors (Thx XGizzmo) - Fixed MPD so that adding songs also starts playback + - Fixed access and disabled issues on admin::users (Thx Orion88) -------------------------------------------------------------------------- @@ -48,7 +48,7 @@ if ( $_POST['username'] && $_POST['password'] ) { $password = trim($_POST['password']); $auth = authenticate($username, $password); $user = new User($username); - if ($user->access === 'disabled') { + if ($user->disabled === '1') { $auth['success'] = false; $auth['error'] = "Error: User Disabled please contact Admin"; } // if user disabled diff --git a/modules/class/update.php b/modules/class/update.php index 5b0578c2..bea76ded 100644 --- a/modules/class/update.php +++ b/modules/class/update.php @@ -220,6 +220,10 @@ class Update { $update_string = "- Added Show bottom menu option.<br />"; $version[] = array('version' => '331002', 'description' => $update_string); + $update_string = "- Cleaned up user management.<br />"; + + $version[] = array('version' => '331003', 'description' => $update_string); + return $version; @@ -899,5 +903,22 @@ class Update { } // update_331002 + function update_331003() { + + /* Add `disabled` column to user table */ + $sql = "ALTER TABLE `user` ADD `disabled` TINYINT( 1 ) NOT NULL DEFAULT '0' AFTER `access`"; + $db_results = mysql_query($sql, dbh()); + + /* Set `disabled` to '1' to all users that have an access level of 'disabled', + * then change their access level to 'user' because an access level of 'disabled' + * is now going to cause problems. + */ + $sql = "UPDATE `user` SET `disabled`='1',`access`='user' WHERE `access`='disabled'"; + $db_results = mysql_query($sql, dbh()); + + $this->set_version('db_version','331003'); + + } //update 331003 + } // end update class ?> diff --git a/modules/class/user.php b/modules/class/user.php index e5c2771b..d3069651 100644 --- a/modules/class/user.php +++ b/modules/class/user.php @@ -33,6 +33,7 @@ class User { var $id=0; var $fullname; var $access; + var $disabled; var $offset_limit=25; var $email; var $last_seen; @@ -51,6 +52,7 @@ class User { $this->id = $info->id; $this->fullname = $info->fullname; $this->access = $info->access; + $this->disabled = $info->disabled; $this->offset_limit = $info->offset_limit; $this->email = $info->email; $this->last_seen = $info->last_seen; @@ -321,7 +323,7 @@ class User { /* Check for all disable */ if ($new_access == 'disabled') { - $sql = "SELECT id FROM user WHERE access != 'disabled' AND id != '$this->id'"; + $sql = "SELECT id FROM user WHERE disabled != '1' AND id != '$this->id'"; $db_results = mysql_query($sql,dbh()); if (!mysql_num_rows($db_results)) { return false; } } @@ -333,9 +335,19 @@ class User { if (!mysql_num_rows($db_results)) { return false; } } - $new_access = sql_escape($new_access); - $sql = "UPDATE user SET access='$new_access' WHERE id='$this->id'"; - $db_results = mysql_query($sql, dbh()); + if ($new_access == 'enabled') { + $new_access = sql_escape($new_access); + $sql = "UPDATE user SET disabled='0' WHERE id='$this->id'"; + $db_results = mysql_query($sql, dbh()); + } elseif ($new_access == 'disabled') { + $new_access = sql_escape($new_access); + $sql = "UPDATE user SET disabled='1' WHERE id='$this->id'"; + $db_results = mysql_query($sql, dbh()); + } else { + $new_access = sql_escape($new_access); + $sql = "UPDATE user SET access='$new_access' WHERE id='$this->id'"; + $db_results = mysql_query($sql, dbh()); + } } // update_access diff --git a/templates/show_users.inc b/templates/show_users.inc index 3108b079..8ef7048a 100644 --- a/templates/show_users.inc +++ b/templates/show_users.inc @@ -55,13 +55,10 @@ $admin_menu = "admin/"; <b><?php echo _("Prefs"); ?></b> </td> <td align="center"> - <b><?php echo _("Delete"); ?></b> - </td> - <td align="center"> - <b><?php echo _("Set Access"); ?></b> + <b><?php echo _("Access"); ?></b> </td> - <td align="center"> - <b><?php echo _("Disable"); ?></b> + <td align="center"> + <b><?php echo _("Delete"); ?></b> </td> <td align="center"> <b><?php echo _("On-line"); ?></b> @@ -86,44 +83,37 @@ while ( $results = mysql_fetch_object($db_result) ) { </td> <td> <a href="<?php echo conf('web_path'); ?>/admin/users.php?action=edit&user=<?php echo $user->username; ?>"> - <?php echo _("edit"); ?> + <?php echo _("Edit"); ?> </a> </td> <td> <a href="<?php echo conf('web_path'); ?>/admin/preferences.php?action=user&user_id=<?php echo $user->id; ?>"> - <?php echo _("prefs"); ?> + <?php echo _("Prefs"); ?> </a> </td> - <td> - <a href="<?php echo conf('web_path'); ?>/admin/users.php?action=delete&user=<?php echo $user->username; ?>"> - <?php echo _("delete"); ?> - </a> - </td> - <?php + <?php //FIXME: Fix this for the extra permission levels - if ($user->access == 'admin') { - echo "<td><a href=\"".conf('web_path')."/admin/users.php?action=update&user=$user->username&level=user\">" . _("set to user") . "</a></td>"; - echo "<td><a href=\"".conf('web_path')."/admin/users.php?action=update&user=$user->username&level=disabled\">" . _("disable") . "</a></td>"; + if ($user->disabled == '1') { + echo "<td><a href=\"".conf('web_path')."/admin/users.php?action=update&user=$user->username&level=enabled\">" . _("Enable") . "</a></td>"; } - elseif ($user->access == 'user') { - echo "<td><a href=\"".conf('web_path')."/admin/users.php?action=update&user=$user->username&level=admin\">" . _("set to admin") . "</a></td>"; - echo "<td><a href=\"".conf('web_path')."/admin/users.php?action=update&user=$user->username&level=disabled\">" . _("disable") . "</a></td>"; - } - elseif ($user->access == 'disabled') { - echo "<td><a href=\"".conf('web_path')."/admin/users.php?action=update&user=$user->username&level=admin\">" . _("set to admin") . "</a></td>"; - echo "<td><a href=\"".conf('web_path')."/admin/users.php?action=update&user=$user->username&level=user\">" . _("set to user") . "</a></td>"; - } - elseif ($user->access == '1') { - echo "<td><a href=\"".conf('web_path')."/admin/users.php?action=update&user=$user->username&level=user\">" . _("set to user") . "</a></td>"; - echo "<td><a href=\"".conf('web_path')."/admin/users.php?action=update&user=$user->username&level=disabled\">" . _("disable") ."</a></td>"; + else { + echo "<td><a href=\"".conf('web_path')."/admin/users.php?action=update&user=$user->username&level=disabled\">" . _("Disable") ."</a></td>"; } - if ( $user->is_logged_in() and $user->is_online() ) { - echo "<td bgcolor=\"green\"> </td>"; - } - else { - echo "<td bgcolor=\"red\"> </td>"; - } ?> +<td> + <a href="<?php echo conf('web_path'); ?>/admin/users.php?action=delete&user=<?php echo $user->username; ?>"> + <?php echo _("delete"); ?> + </a> +</td> + <?php + if ( $user->is_logged_in() and $user->is_online() ) { + echo "<td bgcolor=\"green\"> </td>"; + } elseif ( $user->disabled == 1) { + echo "<td bgcolor=\"gray\"> </td>"; + } else { + echo "<td bgcolor=\"darkred\"> </td>"; + } +?> </tr> <?php } ?> </table> diff --git a/templates/userform.inc b/templates/userform.inc index 3e487355..6ff5bfc9 100644 --- a/templates/userform.inc +++ b/templates/userform.inc @@ -85,7 +85,6 @@ else { <option value="1" <?php if($access==='1') echo "selected=\"selected\""; ?>>Guest</option> <option value="user" <?php if($access==='user') echo "selected=\"selected\""; ?>>User</option> <option value="admin" <?php if($access==='admin') echo "selected=\"selected\""; ?>>Admin</option> - <option value="disabled" <?php if($access==='diabled') echo "selected=\"selected\""; ?>>Disabled</option> </select> </td> </tr> |