Lasso Soft Inc. > Home

[admin_groupassigndatabase]

Linkadmin_groupassigndatabase
AuthorJason Huck
CategoryAdministration
Version8.x
Licensehttp://opensource.org/licenses/artistic-license.php
Posted21 Nov 2006
Updated21 Nov 2006
More by this author...

Description

Assigns the specified database to the specified group. Requires authentication as a user with permissions on Lasso's internal db's, i.e., with [auth_admin].

Sample Usage

admin_groupassigndatabase(
	-database='TestDB',
	-group='TestGroup'
);

Source Code

Click the "Download" button below to retrieve a copy of this tag, including the complete documentation and sample usage shown on this page. Place the downloaded ".inc" file in your LassoStartup folder, restart Lasso, and you can begin using this tag immediately.

define_tag(
	'groupassigndatabase',
	-namespace='admin_',
	-req='group',
	-req='database',
	-opt='perms',
	-priority='replace',
	-description='Assigns the specified database to the specified group.'
);
	!local_defined('perms') ? local('perms' = 'I,S,A,U,D,X,Q');

	inline( -database='lasso_internal', -sql='SELECT 1');		
		local('sql' = '
			SELECT id 
			FROM security_groups 
			WHERE name = \'' + #group + '\'
		');
		
		inline( -sql=#sql);
			local('groupID') = field('id');
		/inline;

		local('sql' = '
			SELECT id
			FROM security_datasource_databases
			WHERE (alias IS NULL AND name = \'' + #database + '\')
				OR alias = \'' + #database + '\'
		');
		
		inline( -sql=#sql);
			local('dbID') = field('id');
		/inline;
		
		local('sql' = '
			SELECT id
			FROM security_group_db_map
			WHERE id_database = ' + #dbID + '
				AND id_group = ' + #groupID + '
		');
		
		protect;
			inline( -sql=#sql);
				if(found_count);
					local('sql' = '
						UPDATE security_group_db_map
						SET allow = \'' + #perms + '\'
						WHERE id = ' + field('id') + '
					');
					
					inline( -sql=#sql); /inline;
				else;
					local('sql' = '
						INSERT INTO security_group_db_map (
							id_database,
							id_group,
							allow
						) VALUES (
							' + #dbID + ',
							' + #groupID + ',
							\'' + #perms + '\'
						)
					');
					
					inline( -sql=#sql); /inline;
				/if;
			/inline;
			
			return(true);
			
			handle_error;
				return(false);
			/handle_error;
		/protect;
	/inline;
/define_tag;

Related Tags

Comments

No comments

Please log in to comment

Subscribe to the LassoTalk mail list

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft