diff options
author | Simon Rettberg | 2019-02-21 11:09:17 +0100 |
---|---|---|
committer | Simon Rettberg | 2019-02-21 11:09:17 +0100 |
commit | 67c915aa7094a32b0dfdd4ef60382bb1d3eeb506 (patch) | |
tree | 89e1222a4bd6ed6076e739e151b3af5a80c4aff8 /modules-available/permissionmanager/install.inc.php | |
parent | AAAAAnd I'm retarded (diff) | |
download | slx-admin-67c915aa7094a32b0dfdd4ef60382bb1d3eeb506.tar.gz slx-admin-67c915aa7094a32b0dfdd4ef60382bb1d3eeb506.tar.xz slx-admin-67c915aa7094a32b0dfdd4ef60382bb1d3eeb506.zip |
Fix UUID handling; refactor constraints for machineuuid
Diffstat (limited to 'modules-available/permissionmanager/install.inc.php')
-rw-r--r-- | modules-available/permissionmanager/install.inc.php | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/modules-available/permissionmanager/install.inc.php b/modules-available/permissionmanager/install.inc.php index 7f9c80ef..d0f8cdeb 100644 --- a/modules-available/permissionmanager/install.inc.php +++ b/modules-available/permissionmanager/install.inc.php @@ -51,50 +51,40 @@ if (tableHasColumn('role_x_location', 'id')) { if (!tableExists('user') || !tableExists('location')) { finalResponse(UPDATE_RETRY, 'Cannot add constraint yet. Please retry.'); } else { - $c = tableGetContraints('role_x_user', 'userid', 'user', 'userid'); - if ($c === false) - finalResponse(UPDATE_FAILED, 'Cannot get constraints of user table: ' . Database::lastError()); - if (empty($c)) { + $c = tableGetConstraints('role_x_user', 'userid', 'user', 'userid'); + if ($c === false) { $alter = Database::exec('ALTER TABLE role_x_user ADD FOREIGN KEY (userid) REFERENCES user (userid) ON DELETE CASCADE ON UPDATE CASCADE'); if ($alter === false) finalResponse(UPDATE_FAILED, 'Cannot add userid constraint referencing user table: ' . Database::lastError()); $res[] = UPDATE_DONE; } - $c = tableGetContraints('role_x_user', 'roleid', 'role', 'roleid'); - if ($c === false) - finalResponse(UPDATE_FAILED, 'Cannot get constraints of role table: ' . Database::lastError()); - if (empty($c)) { + $c = tableGetConstraints('role_x_user', 'roleid', 'role', 'roleid'); + if ($c === false) { $alter = Database::exec('ALTER TABLE role_x_user ADD FOREIGN KEY (roleid) REFERENCES role (roleid) ON DELETE CASCADE ON UPDATE CASCADE'); if ($alter === false) finalResponse(UPDATE_FAILED, 'Cannot add roleid constraint referencing role table: ' . Database::lastError()); $res[] = UPDATE_DONE; } - $c = tableGetContraints('role_x_location', 'roleid', 'role', 'roleid'); - if ($c === false) - finalResponse(UPDATE_FAILED, 'Cannot get constraints of role table: ' . Database::lastError()); - if (empty($c)) { + $c = tableGetConstraints('role_x_location', 'roleid', 'role', 'roleid'); + if ($c === false) { $alter = Database::exec('ALTER TABLE role_x_location ADD FOREIGN KEY (roleid) REFERENCES role (roleid) ON DELETE CASCADE ON UPDATE CASCADE'); if ($alter === false) finalResponse(UPDATE_FAILED, 'Cannot add roleid constraint referencing role table: ' . Database::lastError()); $res[] = UPDATE_DONE; } - $c = tableGetContraints('role_x_location', 'locationid', 'location', 'locationid'); - if ($c === false) - finalResponse(UPDATE_FAILED, 'Cannot get constraints of location table: ' . Database::lastError()); - if (empty($c)) { + $c = tableGetConstraints('role_x_location', 'locationid', 'location', 'locationid'); + if ($c === false) { $alter = Database::exec('ALTER TABLE role_x_location ADD FOREIGN KEY (locationid) REFERENCES location (locationid) ON DELETE CASCADE ON UPDATE CASCADE'); if ($alter === false) finalResponse(UPDATE_FAILED, 'Cannot add locationid constraint referencing location table: ' . Database::lastError()); $res[] = UPDATE_DONE; } - $c = tableGetContraints('role_x_permission', 'roleid', 'role', 'roleid'); - if ($c === false) - finalResponse(UPDATE_FAILED, 'Cannot get constraints of role table: ' . Database::lastError()); - if (empty($c)) { + $c = tableGetConstraints('role_x_permission', 'roleid', 'role', 'roleid'); + if ($c === false) { $alter = Database::exec('ALTER TABLE role_x_permission ADD FOREIGN KEY (roleid) REFERENCES role (roleid) ON DELETE CASCADE ON UPDATE CASCADE'); if ($alter === false) finalResponse(UPDATE_FAILED, 'Cannot add roleid constraint referencing role table: ' . Database::lastError()); |