Commit 75af250c authored by Nigel McNie's avatar Nigel McNie Committed by Nigel McNie
Browse files

Insert a default institution and user when the installation is done, and

call it the "insert core data step".
parent f386e6cb
......@@ -33,10 +33,38 @@ $name = clean_requestdata('name', PARAM_ALPHAEXT, REQUEST_EITHER);
$install = clean_requestdata('install', PARAM_BOOL, REQUEST_EITHER);
if ($install) {
// @todo should probably report errors. Also see upgrade.php to make the js detect any errors
if (!get_config('installed')) {
set_config('installed', true);
try {
// Install the default institution
$institution = new StdClass;
$institution->name = 'mahara';
$institution->displayname = 'No Institution';
$institution->authplugin = 'internal';
insert_record('institution', $institution);
// Insert the root user
$user = new StdClass;
$user->username = 'root';
$user->password = 'mahara';
$user->institution = 'mahara';
$user->passwordchange = 1;
$user->firstname = 'Admin';
$user->lastname = 'User';
$user->email = 'admin@example.org';
insert_record('usr', $user);
set_config('installed', true);
}
catch (SQLException $e) {
echo json_encode(array(
'success' => 0,
'errormessage' => $e->getMessage()
));
exit;
}
}
echo json_encode(array('success' => 1));
exit;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment