install/database-structure.inc.php
author peter
Thu, 07 Aug 2008 18:45:13 +0000
changeset 192 3d18290ac993
parent 189 b918c891f81d
permissions -rw-r--r--
[feladat @ 302] Applied the patches supplied in #82 and #85. Also quoted some additional values before they are send to the database.

<?


$def_tables = 
	array(
		array(
			'table_name'	=>	'perm_items',
			'fields'	=>	array(
				    'id' => array(
				    	    'type'		=> 'integer',
					    'notnull' 		=> 1,
					    'length' 		=> 4,
					    'unsigned' 		=> 0,
					    'autoincrement'	=> 1,
					    'name' 		=> 'id',
					    'table' 		=> 'perm_items',
					    'flags' 		=> 'primary_keynot_null'
					),
				    'name' => array(
				    	    'type'		=> 'text',
					    'notnull' 		=> 1,
					    'length' 		=> 64,
					    'fixed' 		=> 0,
					    'default' 		=> 0,
					    'name' 		=> 'name',
					    'table' 		=> 'perm_items',
					    'flags' 		=> 'not_null'
					),
				    'descr' => array(
				    	    'type'		=> 'text',
					    'length'		=> 1024,
					    'notnull' 		=> 1,
					    'fixed' 		=> 0,
					    'default' 		=> 0,
					    'name' 		=> 'descr',
					    'table' 		=> 'perm_items',
					    'flags' 		=> 'not_null'
					)
				)
			),
		array(
			'table_name'	=>	'perm_templ',
			'fields'	=>	array(
				   'id' => array(
				    	    'type'		=> 'integer',
					    'notnull' 		=> 1,
					    'length' 		=> 4,
					    'unsigned' 		=> 0,
					    'default' 		=> 0,
					    'autoincrement'	=> 1,
					    'name' 		=> 'id',
					    'table' 		=> 'perm_templ',
					    'flags' 		=> 'primary_keynot_null'
					),
				    'name' => array(
				    	    'type'		=> 'text',
					    'notnull' 		=> 1,
					    'length' 		=> 128,
					    'fixed' 		=> 0,
					    'default' 		=> 0,
					    'name' 		=> 'name',
					    'table' 		=> 'perm_templ',
					    'flags' 		=> 'not_null'
					),
				    'descr' => array(
					    'notnull' 		=> 1,
					    'fixed' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'text',
					    'length'		=> 1024,
					    'name' 		=> 'descr',
					    'table' 		=> 'perm_templ',
					    'flags' 		=> 'not_null'
					)
				)
			),
		array(
			'table_name'	=>	'perm_templ_items',
			'fields'	=>	array(
				   'id' => array(
					    'notnull' 		=> 1,
					    'length' 		=> 4,
					    'unsigned' 		=> 0,
					    'default' 		=> 0,
					    'autoincrement'	=> 1,
					    'type' 		=> 'integer',
					    'name' 		=> 'id',
					    'table' 		=> 'perm_templ_items',
					    'flags' 		=> 'primary_keynot_null'
					),
				    'templ_id' => array(
					    'notnull' 		=> 1,
					    'length' 		=> 4,
					    'unsigned' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'integer',
					    'name' 		=> 'templ_id',
					    'table' 		=> 'perm_templ_items',
					    'flags' 		=> 'not_null'
					),
				    'perm_id' => array(
					    'notnull' 		=> 1,
					    'length' 		=> 4,
					    'unsigned' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'integer',
					    'name' 		=> 'perm_id',
					    'table' 		=> 'perm_templ_items',
					    'flags' 		=> 'not_null'
					)
				)
			),
		array(
			'table_name'	=>	'users',
			'fields'	=>	array(
				    'id' => array
					(
					    'notnull' 		=> 1,
					    'length' 		=> 4,
					    'unsigned' 		=> 0,
					    'default' 		=> 0,
					    'autoincrement'	=> 1,
					    'type' 		=> 'integer',
					    'name' 		=> 'id',
					    'table' 		=> 'users',
					    'flags' 		=> 'primary_keynot_null'
					),
				    'username' => array
					(
					    'notnull' 		=> 1,
					    'length' 		=> 16,
					    'fixed' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'text',
					    'name' 		=> 'username',
					    'table' 		=> 'users',
					    'flags' 		=> 'not_null'
					),
				    'password' => array
					(
					    'notnull' 		=> 1,
					    'length' 		=> 34,
					    'fixed' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'text',
					    'name' 		=> 'password',
					    'table' 		=> 'users',
					    'flags' 		=> 'not_null'
					),
				    'fullname' => array
					(
					    'notnull' 		=> 1,
					    'length' 		=> 255,
					    'fixed' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'text',
					    'name' 		=> 'fullname',
					    'table' 		=> 'users',
					    'flags' 		=> 'not_null'
					),
				    'email' => array
					(
					    'notnull' 		=> 1,
					    'length' 		=> 255,
					    'fixed' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'text',
					    'name' 		=> 'email',
					    'table' 		=> 'users',
					    'flags' 		=> 'not_null'
					),
				    'description' => array
					(
					    'notnull' 		=> 1,
					    'fixed' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'text',
					    'length'		=> 1024,
					    'name' 		=> 'description',
					    'table' 		=> 'users',
					    'flags' 		=> 'not_null'
					),
				    'perm_templ' => array
					(
					    'notnull' 		=> 1,
					    'length' 		=> 1,
					    'unsigned' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'integer',
					    'name' 		=> 'perm_templ',
					    'table' 		=> 'users',
					    'flags' 		=> 'not_null'
					),
				    'active' => array
					(
					    'notnull' 		=> 1,
					    'length' 		=> 1,
					    'unsigned' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'integer',
					    'name' 		=> 'active',
					    'table' 		=> 'users',
					    'flags' 		=> 'not_null'
					)
				)
			),
		array(
			'table_name'	=>	'zones',
			'fields'	=>	array(
				    'id' => array
					(
					    'notnull' 		=> 1,
					    'length' 		=> 4,
					    'unsigned' 		=> 0,
					    'default' 		=> 0,
					    'autoincrement'	=> 1,
					    'type' 		=> 'integer',
					    'name' 		=> 'id',
					    'table' 		=> 'zones',
					    'flags' 		=> 'primary_keynot_null'
					),
				    'domain_id' => array
					(
					    'notnull' 		=> 1,
					    'length' 		=> 4,
					    'unsigned' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'integer',
					    'name' 		=> 'domain_id',
					    'table' 		=> 'zones',
					    'flags' 		=> 'not_null'
					),
				    'owner' => array
					(
					    'notnull' 		=> 1,
					    'length' 		=> 4,
					    'unsigned' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'integer',
					    'name' 		=> 'owner',
					    'table' 		=> 'zones',
					    'flags' 		=> 'not_null'
					),
				    'comment' => array
					(
					    'notnull' 		=> 0,
					    'length' 		=> 1024,
					    'fixed' 		=> 0,
					    'default' 		=> 0,
					    'type' 		=> 'text',
					    'name' 		=> 'comment',
					    'table' 		=> 'zones',
					    'flags' 		=> ''
					)
				)
			)
		);

// Tables from PowerDNS
$grantTables = array('supermasters', 'domains', 'records');
// Include PowerAdmin tables
foreach($def_tables as $table) {
	$grantTables[] = $table['table_name'];
}

$def_permissions = array(
			array(41,'zone_master_add','User is allowed to add new master zones.'),
			array(42,'zone_slave_add','User is allowed to add new slave zones.'),
			array(43,'zone_content_view_own','User is allowed to see the content and meta data of zones he owns.'),
			array(44,'zone_content_edit_own','User is allowed to edit the content of zones he owns.'),
			array(45,'zone_meta_edit_own','User is allowed to edit the meta data of zones he owns.'),
			array(46,'zone_content_view_others','User is allowed to see the content and meta data of zones he does not own.'),
			array(47,'zone_content_edit_others','User is allowed to edit the content of zones he does not own.'),
			array(48,'zone_meta_edit_others','User is allowed to edit the meta data of zones he does not own.'),
			array(49,'search','User is allowed to perform searches.'),
			array(50,'supermaster_view','User is allowed to view supermasters.'),
			array(51,'supermaster_add','User is allowed to add new supermasters.'),
			array(52,'supermaster_edit','User is allowed to edit supermasters.'),
			array(53,'user_is_ueberuser','User has full access. God-like. Redeemer.'),
			array(54,'user_view_others','User is allowed to see other users and their details.'),
			array(55,'user_add_new','User is allowed to add new users.'),
			array(56,'user_edit_own','User is allowed to edit their own details.'),
			array(57,'user_edit_others','User is allowed to edit other users.'),
			array(58,'user_passwd_edit_others','User is allowed to edit the password of other users.'),
			array(59,'user_edit_templ_perm','User is allowed to change the permission template that is assigned to a user.'),
			array(60,'templ_perm_add','User is allowed to add new permission templates.'),
			array(61,'templ_perm_edit','User is allowed to edit existing permission templates.')
		);

$def_remaining_queries = array(
			"INSERT INTO users VALUES (1,'admin'," . $db->quote(md5($pa_pass)) . ",'Administrator','admin@example.net','Administrator with full rights.',1,1)",
			"INSERT INTO perm_templ VALUES (1,'Administrator','Administrator template with full rights.')",
			"INSERT INTO perm_templ_items VALUES (249,1,53)"
		);