Author: Lars Michelsen <[email protected]>
Date: Mon Mar 5 19:11:23 2012 +0100
Committer: Lars Michelsen <[email protected]>
Commit-Date: Mon Mar 5 19:11:23 2012 +0100
Now really fix MySQL auth db update problem
---
share/server/core/classes/CoreMySQLHandler.php | 21 ++++++++++++++-------
1 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/share/server/core/classes/CoreMySQLHandler.php
b/share/server/core/classes/CoreMySQLHandler.php
index 25b5d3f..529cbcf 100644
--- a/share/server/core/classes/CoreMySQLHandler.php
+++ b/share/server/core/classes/CoreMySQLHandler.php
@@ -161,7 +161,14 @@ class CoreMySQLHandler {
}
private function addRolePerm($roleId, $mod, $act, $obj) {
- $this->query('INSERT INTO roles2perms (roleId, permId) VALUES
('.$roleId.', (SELECT permId FROM perms WHERE `mod`=\''.$mod.'\' AND
`act`=\''.$act.'\' AND obj=\''.$obj.'\'))');
+ // Only create when not existing
+ if($this->count('SELECT `roleId` FROM roles2perms WHERE
`roleId`='.$roleId.' AND `permId`=(SELECT permId FROM perms WHERE
`mod`=\''.$mod.'\' AND `act`=\''.$act.'\' AND obj=\''.$obj.'\')') <= 0) {
+ $this->query('INSERT INTO roles2perms (roleId, permId) VALUES
('.$roleId.', (SELECT permId FROM perms WHERE `mod`=\''.$mod.'\' AND
`act`=\''.$act.'\' AND obj=\''.$obj.'\'))');
+ }
+ }
+
+ public function createPerm($mod, $act, $obj) {
+ $this->query('INSERT IGNORE INTO perms (`mod`, `act`, `obj`) VALUES
(\''.$mod.'\', \''.$act.'\', \''.$obj.'\')');
}
public function updateDb() {
@@ -191,7 +198,7 @@ class CoreMySQLHandler {
private function updateDb1060500() {
// Create permissions for Url/view/*
- $this->query('INSERT INTO perms (`mod`, `act`, `obj`) VALUES (\'Url\',
\'view\', \'*\')');
+ $this->createPerm('Url', 'view', '*');
// Assign the new permission to the managers, users, guests
$RES = $this->query('SELECT roleId FROM roles WHERE name=\'Managers\'
or \'Users (read-only)\' or name=\'Guests\'');
@@ -234,7 +241,7 @@ class CoreMySQLHandler {
private function updateDb1060022() {
// Create permissions for User/setOption
- $this->query('INSERT INTO perms (`mod`, `act`, `obj`) VALUES
(\'User\', \'setOption\', \'*\')');
+ $this->createPerm('User', 'setOption', '*');
// Assign the new permission to the managers, users, guests
$RES = $this->query('SELECT roleId FROM roles WHERE name=\'Managers\'
or \'Users (read-only)\' or name=\'Guests\'');
@@ -250,7 +257,7 @@ class CoreMySQLHandler {
private function updateDb1050400() {
// Create permissions for the multisite webservice
- $this->query('INSERT INTO perms (`mod`, `act`, obj) VALUES
(\'Multisite\', \'getMaps\', \'*\')');
+ $this->createPerm('Multisite', 'getMaps', '*');
// Assign the new permission to the managers
$RES = $this->query('SELECT roleId FROM roles WHERE name=\'Managers\'
or \'Users (read-only)\' or name=\'Guests\'');
@@ -266,9 +273,9 @@ class CoreMySQLHandler {
private function updateDb1050300() {
// Create permissions for WUI management pages
- $this->query('INSERT INTO perms (`mod`, `act`, obj) VALUES
(\'ManageBackgrounds\', \'manage\', \'*\')');
- $this->query('INSERT INTO perms (`mod`, `act`, obj) VALUES
(\'ManageShapes\', \'manage\', \'*\')');
- $this->query('INSERT INTO perms (`mod`, `act`, obj) VALUES (\'Map\',
\'manage\', \'*\')');
+ $this->createPerm('ManageBackgrounds', 'manage', '*');
+ $this->createPerm('ManageShapes', 'manage', '*');
+ $this->createPerm('Map', 'manage', '*');
// Assign the new permission to the managers
$RES = $this->query('SELECT roleId FROM roles WHERE
name=\'Managers\'');
------------------------------------------------------------------------------
Try before you buy = See our experts in action!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-dev2
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins