Make a loop instead of repeating almost identical text in install

This commit is contained in:
Evan Prodromou 2009-03-04 05:53:04 -08:00
parent 8d05768e2c
commit aa1bc6216e

View File

@ -182,26 +182,17 @@ function handlePost()
showForm(); showForm();
return; return;
} }
updateStatus("Adding SMS carrier data to database..."); foreach (array('sms_carrier' => 'SMS carrier',
$res = runDbScript(INSTALLDIR.'/db/sms_carrier.sql', $conn); 'notice_source' => 'notice source',
'foreign_services' => 'foreign service')
as $scr => $name) {
updateStatus(sprintf("Adding %s data to database...", $name));
$res = runDbScript(INSTALLDIR.'/db/'.$scr.'.sql', $conn);
if ($res === false) { if ($res === false) {
updateStatus("Can't run SMS carrier script.", true); updateStatus(sprintf("Can't run %d script.", $name), true);
showForm(); showForm();
return; return;
} }
updateStatus("Adding notice source data to database...");
$res = runDbScript(INSTALLDIR.'/db/notice_source.sql', $conn);
if ($res === false) {
updateStatus("Can't run notice source script.", true);
showForm();
return;
}
updateStatus("Adding foreign service data to database...");
$res = runDbScript(INSTALLDIR.'/db/foreign_services.sql', $conn);
if ($res === false) {
updateStatus("Can't run foreign service script.", true);
showForm();
return;
} }
updateStatus("Writing config file..."); updateStatus("Writing config file...");
$sqlUrl = "mysqli://$username:$password@$host/$database"; $sqlUrl = "mysqli://$username:$password@$host/$database";