[feladat @ 213]
authorpeter
Sun, 30 Mar 2008 11:46:45 +0000
changeset 113 e7a448dba024
parent 112 0e5d362abf5a
child 114 7c8af2b598eb
[feladat @ 213] Modified the inserts in the pgsql db structure to make sure no duplicate key errors are shown when a new records is created. Also moved the Ueber_user permision item upfront, to make sure it is created with id 1 so the permission template can be created correctly. Added an additional query to check what the ID is of the ueber_user, as it set hardcoded to 53 in the query.
docs/poweradmin-pgsql-db-structure.sql
inc/users.inc.php
--- a/docs/poweradmin-pgsql-db-structure.sql	Sun Mar 30 11:00:36 2008 +0000
+++ b/docs/poweradmin-pgsql-db-structure.sql	Sun Mar 30 11:46:45 2008 +0000
@@ -9,7 +9,7 @@
   active smallint default 0
 );
 
-INSERT INTO users VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3','Administrator','admin@example.net','Administrator with full rights.',1,1);
+INSERT INTO users (username, password, fullname, email, description, perm_templ, active) VALUES ('admin','21232f297a57a5a743894a0e4a801fc3','Administrator','admin@example.net','Administrator with full rights.',1,1);
 
 CREATE TABLE perm_items (
   id SERIAL PRIMARY KEY,
@@ -17,7 +17,7 @@
   descr text NOT NULL
 );
 
-INSERT INTO perm_items VALUES (41,'zone_master_add','User is allowed to add new master zones.'),(42,'zone_slave_add','User is allowed to add new slave zones.'),(43,'zone_content_view_own','User is allowed to see the content and meta data of zones he owns.'),(44,'zone_content_edit_own','User is allowed to edit the content of zones he owns.'),(45,'zone_meta_edit_own','User is allowed to edit the meta data of zones he owns.'),(46,'zone_content_view_others','User is allowed to see the content and meta data of zones he does not own.'),(47,'zone_content_edit_others','User is allowed to edit the content of zones he does not own.'),(48,'zone_meta_edit_others','User is allowed to edit the meta data of zones he does not own.'),(49,'search','User is allowed to perform searches.'),(50,'supermaster_view','User is allowed to view supermasters.'),(51,'supermaster_add','User is allowed to add new supermasters.'),(52,'supermaster_edit','User is allowed to edit supermasters.'),(53,'user_is_ueberuser','User has full access. God-like. Redeemer.'),(54,'user_view_others','User is allowed to see other users and their details.'),(55,'user_add_new','User is allowed to add new users.'),(56,'user_edit_own','User is allowed to edit their own details.'),(57,'user_edit_others','User is allowed to edit other users.'),(58,'user_passwd_edit_others','User is allowed to edit the password of other users.'),(59,'user_edit_templ_perm','User is allowed to change the permission template that is assigned to a user.'),(60,'templ_perm_add','User is allowed to add new permission templates.'),(61,'templ_perm_edit','User is allowed to edit existing permission templates.');
+INSERT INTO perm_items (name, descr) VALUES ('user_is_ueberuser','User has full access. God-like. Redeemer.'),('zone_master_add','User is allowed to add new master zones.'),('zone_slave_add','User is allowed to add new slave zones.'),('zone_content_view_own','User is allowed to see the content and meta data of zones he owns.'),('zone_content_edit_own','User is allowed to edit the content of zones he owns.'),('zone_meta_edit_own','User is allowed to edit the meta data of zones he owns.'),('zone_content_view_others','User is allowed to see the content and meta data of zones he does not own.'),('zone_content_edit_others','User is allowed to edit the content of zones he does not own.'),('zone_meta_edit_others','User is allowed to edit the meta data of zones he does not own.'),('search','User is allowed to perform searches.'),('supermaster_view','User is allowed to view supermasters.'),('supermaster_add','User is allowed to add new supermasters.'),('supermaster_edit','User is allowed to edit supermasters.'),('user_view_others','User is allowed to see other users and their details.'),('user_add_new','User is allowed to add new users.'),('user_edit_own','User is allowed to edit their own details.'),('user_edit_others','User is allowed to edit other users.'),('user_passwd_edit_others','User is allowed to edit the password of other users.'),('user_edit_templ_perm','User is allowed to change the permission template that is assigned to a user.'),('templ_perm_add','User is allowed to add new permission templates.'),('templ_perm_edit','User is allowed to edit existing permission templates.');
 
 CREATE TABLE perm_templ (
   id SERIAL PRIMARY KEY,
@@ -25,7 +25,7 @@
   descr text NOT NULL
 );
 
-INSERT INTO perm_templ VALUES (1,'Administrator','Administrator template with full rights.');
+INSERT INTO perm_templ (name, descr) VALUES ('Administrator','Administrator template with full rights.');
 
 CREATE TABLE perm_templ_items (
   id SERIAL PRIMARY KEY,
@@ -33,7 +33,7 @@
   perm_id integer NOT NULL
 );
 
-INSERT INTO perm_templ_items VALUES (249,1,53);
+INSERT INTO perm_templ_items (templ_id, perm_id) VALUES (1,1);
 
 CREATE TABLE zones (
   id SERIAL PRIMARY KEY,
--- a/inc/users.inc.php	Sun Mar 30 11:00:36 2008 +0000
+++ b/inc/users.inc.php	Sun Mar 30 11:46:45 2008 +0000
@@ -40,6 +40,9 @@
         // Set current user ID.
         $userid=$_SESSION['userid'];
 
+		$query = 'SELECT id FROM perm_items WHERE name='.$db->quote('user_is_ueberuser');
+		$ueberUserId = $db->queryOne($query);
+
         // Find the template ID that this user has been assigned.
         $query = "SELECT perm_templ
 			FROM users 
@@ -50,7 +53,7 @@
         $query = "SELECT id 
 			FROM perm_templ_items 
 			WHERE templ_id = " . $db->quote($templ_id) . " 
-			AND perm_id = '53'";
+			AND perm_id = ".$ueberUserId;
         $result = $db->query($query);
         if ( $result->numRows() > 0 ) {
                 return 1;