Link | admin_groupassignpath |
Author | Jason Huck |
Category | Administration |
Version | 8.x |
License | http://opensource.org/licenses/artistic-license.php |
Posted | 21 Nov 2006 |
Updated | 21 Nov 2006 |
More by this author... |
Assigns the given path to the given group. Requires authentication as a user with permissions on Lasso's internal db's, i.e., with [auth_admin].
// to assign all valid paths to the given group iterate(admin_allowedfileroots, local('i')); admin_groupassignpath( -group='TestGroup', -path=#i->second ); /iterate;
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( 'groupassignpath', -namespace='admin_', -req='group', -req='path', -opt='perms', -priority='replace', -description='Assigns the given path to the given group.' ); // validate path local('pathID' = 0); iterate(admin_allowedfileroots, local('i')); if(#i->second == #path); #pathID = #i->first; loop_abort; /if; /iterate; !#pathID ? return(false); // if no permissions are specified, default to all local('columns') = array( 'create', 'read', 'write', 'move', 'copy', 'delete', 'inspect', 'any_extension' ); !local_defined('perms') ? local('perms') = #columns; // wrap all inlines in a single connection inline( -database='lasso_internal', -sql='SELECT 1'); // retrieve the group ID local('sql' = ' SELECT id FROM security_groups WHERE name = \'' + #group + '\' '); inline( -sql=#sql); local('groupID') = field('id'); /inline; // look for an existing record local('sql' = ' SELECT id FROM security_group_file_perms WHERE id_group = ' + #groupID + ' AND allow_root = ' + #pathID + ' '); protect; inline( -sql=#sql); // if one exists, update it if(found_count); local('updateperms' = string); iterate(#columns, local('i')); #updateperms += 'allow_' + #i + ' = \'' + (#perms >> #i ? 'Y' | 'N') + '\', '; /iterate; #updateperms->removetrailing(', '); local('sql' = ' UPDATE security_group_file_perms SET ' + #updateperms + ' WHERE id = ' + field('id') + ' '); inline( -sql=#sql); /inline; // otherwise, insert a new one else; local( 'insertvalues' = string, 'insertcolumns' = string ); iterate(#columns, local('i')); #insertvalues += '\'' + (#perms >> #i ? 'Y' | 'N') + '\',\n'; #insertcolumns += 'allow_' + #i + ',\n'; /iterate; #insertvalues->removetrailing(',\n'); #insertcolumns->removetrailing(',\n'); local('sql' = ' INSERT INTO security_group_file_perms ( id_group, allow_root, ' + #insertcolumns + ' ) VALUES ( ' + #groupID + ', ' + #pathID + ', ' + #insertvalues + ' ) '); inline( -sql=#sql); /inline; /if; /inline; return(true); handle_error; return(false); /handle_error; /protect; /inline; /define_tag;
No comments
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft