[Adding User rename facility
tony@tonywhitmore.co.uk**20050922210026] {
addfile ./login/editusername.php
hunk ./CHANGELOG 17
+* Login / SATYR: Added a rename user functionality (editusername.php), with the option to rename all SATYR requests matching the username.
hunk ./TODO 45
-Interal anchors for groups
hunk ./includes/STORM/login/html/nav_admin.inc 37
+echo "
| \n";
+echo "
+ Edit a STORM user's username
+ | \n";
hunk ./includes/STORM/login/html/nav_admin.inc 48
- \n";
+ \n";
+
+echo "
\n";
+
hunk ./includes/STORM/login/html/nav_admin.inc 55
- \n";
-
-echo "
\n";
-
+ \n";
+echo " | \n";
hunk ./login/editusername.php 1
+\n";
+ // Produce the table that asks for the username.
echo "\n";
+ echo "\n";
+
+ // Produce a link back to the main page.
+ echo "Back to the main menu
\n";
+}
+
+if ( isset($_POST['not_new']) )
+ {
+ // Validate the submitted username(s).
+ $errmsg = checkusernames();
+ if ( $errmsg != "" )
+ {
+ echo $errmsg;
+ produce_form();
+ exit();
+ }
+ // The username has been validated, and can be edited
+ if ( ($_POST['not_new'] == "yes") ){
+ echo "\n";
+
+ // Produce a link back to the main page.
+ echo "Back to the main menu
\n";
+ }
+
+ if ( ($_POST['not_new'] == "edited") ){
+ // Check the new username doesn't already exist
+ $query = "SELECT username FROM users WHERE username = \"" . $_POST['new_username'] . "\"";
+ $result = $db->query($query);
+ if (DB::isError($db)) {die($db->getMessage());}
+ $num_rows = $result->numRows();
+ if ( $num_rows == "0" ) {
+ // Rename the user record
+ $query = "UPDATE users SET username=\"" . $_POST['new_username'] . "\" WHERE username=\"" . $_POST['username'] . "\"";
+ $result = $db->query($query);
+ if (DB::isError($db)) {die($db->getMessage());}
+ if ( ($_POST['update_SATYR'] == "on") ) {
+ // Update SATYR records with the new username
+ $query = "UPDATE SATYR SET username=\"" . $_POST['new_username'] . "\" WHERE username=\"" . $_POST['username'] . "\"";
+ $result = $db->query($query);
+ if (DB::isError($db)) {die($db->getMessage());}
+ }
+ // Produce a success message.
+ echo "The username \"" . $_POST['username'] . "\" has been changed to \"" . $_POST['new_username'] . "\"!
\n";
+ if ( ($_POST['update_SATYR'] == "on") ) {
+ echo "All SATYR support requests submitted under the old username have been updated with the new username.
\n";
+ }
+ navbutton("menu.php","OK");
+ }
+ else {
+ echo "Sorry, username \"" . $_POST['new_username'] . "\" already exists. Please choose another.
";
+ echo "\n";
+ echo "\n";
+ echo "
\n";
+ // Produce a link back to the main page.
+ echo "Back to the main menu
\n";
+ }
+ }
+ }
+else
+ {
+ produce_form();
+ }
+
+?>
hunk ./login/resetpass.php 48
- // Produce the table that asks for the username to be deleted.
+ // Produce the table that asks for the username.
}