diff -ruN moodle-1.7/admin/user.php public_html/admin/user.php
--- moodle-1.7/admin/user.php 2006-11-01 19:11:21.000000000 +0000
+++ public_html/admin/user.php 2006-11-01 18:34:42.000000000 +0000
@@ -111,7 +111,7 @@
}
}
- redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id");
+ redirect("$CFG->wwwroot/user/edit.php?id=$user->id&course=$site->id&createuser=1");
} else { // List all users for editing
diff -ruN moodle-1.7/user/edit.html public_html/user/edit.html
--- moodle-1.7/user/edit.html 2006-11-01 19:10:55.000000000 +0000
+++ public_html/user/edit.html 2006-11-01 19:21:22.000000000 +0000
@@ -26,6 +26,11 @@
if (has_capability('moodle/user:update', get_context_instance(CONTEXT_SYSTEM, SITEID))) {
$theadmin = get_admin(); // returns false during install
$adminself = (!empty($theadmin) and ($theadmin->id == $USER->id) and ($USER->id == $user->id));
+
+// if we are creating a user - remember this
+ if ( $createuser ){
+ echo "";
+ }
echo '
';
echo '| '.get_string('username').': | ';
if ($adminself || is_internal_auth($user->auth) ){
diff -ruN moodle-1.7/user/edit.php public_html/user/edit.php
--- moodle-1.7/user/edit.php 2006-11-01 19:10:54.000000000 +0000
+++ public_html/user/edit.php 2006-11-01 19:11:55.000000000 +0000
@@ -5,6 +5,7 @@
$id = optional_param('id', 0, PARAM_INT); // user id
$course = optional_param('course', SITEID, PARAM_INT); // course id (defaults to Site)
+ $createuser = optional_param('createuser', 0, PARAM_INT);
if (empty($id)) { // See your own profile by default
require_login();
@@ -232,6 +233,27 @@
}
$userold = get_record('user','id',$usernew->id);
+ // create new user if creating new user and old username isn't changeme
+ if( $createuser and ($userold->username != "changeme") ){
+ // this should be functionised really from admin/user.php
+ $blankuser = new object();
+ $blankuser->auth = 'manual';
+ $blankuser->firstname = '';
+ $blankuser->lastname = '';
+ $blankuser->username = 'changeme';
+ $blankuser->password = '';
+ $blankuser->email = '';
+ $blankuser->lang = $CFG->lang;
+ $blankuser->confirmed = 1;
+ $blankuser->timemodified = time();
+
+ if( ! $usernew->id = insert_record('user', $blankuser) ){
+ error('Could not start a new user!');
+ }
+ $userold = get_record('user','id',$usernew->id);
+ }
+
+
if (update_record("user", $usernew)) {
if (function_exists("auth_user_update")){
// pass a true $userold here