From 3beca9753a41a4a8627770d83c512b7dc32178e7 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 19 Mar 2018 11:45:35 +0100 Subject: [main] install: Make sure a user with userid 1 exists --- modules-available/main/install.inc.php | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'modules-available/main') diff --git a/modules-available/main/install.inc.php b/modules-available/main/install.inc.php index e364a905..ec8554fd 100644 --- a/modules-available/main/install.inc.php +++ b/modules-available/main/install.inc.php @@ -43,6 +43,7 @@ $res[] = tableCreate('user', " `email` varchar(100) DEFAULT NULL, `permissions` int(10) unsigned NOT NULL, `lasteventid` int(10) unsigned NOT NULL DEFAULT '0', + `serverid` int(10) unsigned NULL DEFAULT NULL, PRIMARY KEY (`userid`), UNIQUE KEY `login` (`login`) "); @@ -72,6 +73,20 @@ if (!tableHasColumn('callback', 'args')) { Database::exec("ALTER TABLE `callback` ADD `args` TEXT NOT NULL DEFAULT ''"); } +// ####################### +// ##### 2018-03-19 +// In preparation for LDAP/AD auth: Column to rembember origin server +if (!tableHasColumn('user', 'serverid')) { + Database::exec("ALTER TABLE `user` ADD `serverid` int(10) unsigned NULL DEFAULT NULL"); +} + +// Make sure that if any users exist, one of the has UID=1, otherwise if the permission module is +// used we'd lock out everyone +$someUser = Database::queryFirst('SELECT userid FROM user ORDER BY userid ASC LIMIT 1'); +if ($someUser !== false && (int)$someUser['userid'] !== 1) { + Database::exec('UPDATE user SET userid = 1 WHERE userid = :oldid', ['oldid' => $someUser['userid']]); +} + // Create response for browser if (in_array(UPDATE_DONE, $res)) { -- cgit v1.2.3-55-g7522