[admin_groupassigndatabase]

Description

Link: [admin_groupassigndatabase]
Author: Jason Huck
Category: Administration
Version: 8.x
License:
Posted: Nov. 21, 2006
Updated: Jan. 01, 0001
More by this author...
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].

Parameters

-group string, required The group to which you are assigning the database.
-database string, required The name or alias of the database you are assigning to the group.
-perms string, optional Any combination of explicit permission codes (I,S,A,U,D,X,Q). Defaults to all.

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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
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

none

Email:


Password:



Newest

Most Popular

Support tagSwap.net