/* Check the table to see if there are any users defined, yet. If not, this is a new install, so create an admin user (all rights) as the current user. */ $table = $usePeople ? 'fac_People' : 'fac_User'; $sql = "SELECT COUNT(*) AS TotalUsers FROM {$table};"; $users = $dbh->query($sql)->fetchColumn(); if ($users == 0) { $person->Name = "Default Admin"; foreach ($person as $prop => $value) { if (strstr($prop, "Admin") || strstr($prop, "Access")) { $person->{$prop} = true; } } $person->Disabled = false; $person->CreatePerson(); } // This will be reloading the rights for a new install but for upgrades // it will be the actual rights load $person->GetUserRights(); // Re-read the config $config->Config(); // Check to see if we have any users in the database. $sth = $dbh->prepare("SELECT * FROM {$table} WHERE SiteAdmin=1;"); $sth->execute(); if ($sth->rowCount() < 1) { // no users in the system or no users with site admin rights, either way we're missing the class of people we need // put stuff here like correcting for a missing site admin print "There are no users in the database with sufficient privileges to perform this update"; exit; $rightserror = 1;