labtech
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
sp_GetMobileGroupPolicy
Parameters
Name
Type
Mode
argUserId
int
IN
argMobileId
int
IN
Definition
BEGIN DECLARE userClassIds VARCHAR(1000); DECLARE mobileGroups VARCHAR(10000); DECLARE userAssignedGroups VARCHAR(10000); DECLARE userAssignedChildren VARCHAR(10000); SELECT ClientId FROM users WHERE userid = argUserId INTO userClassIds; IF (SELECT (BIT_OR(u.Permissions)& 1) FROM userclasses u WHERE FIND_IN_SET(u.classid,userClassIds)) = 1 THEN SELECT 2147483647 AS SuperPermissions; ELSE SELECT IFNULL(GROUP_CONCAT(GROUPID),'') FROM MobileSubGroups WHERE MobileId=argMobileId INTO mobileGroups; SELECT TRIM(TRAILING ',' FROM AssignedGroups) FROM MobileLabTechUsers WHERE UserId=argUserId INTO userAssignedGroups; SELECT IFNULL(TRIM(TRAILING ',' FROM GROUP_CONCAT(Children SEPARATOR '')),'') FROM MobileMasterGroups WHERE FIND_IN_SET(GroupID,userAssignedGroups) INTO userAssignedChildren; SELECT BIT_OR(MobilePermissions.Permission) AS Permissions FROM MobilePermissions WHERE FIND_IN_SET(classid,userClassIds) AND FIND_IN_SET(permid,CONCAT(userAssignedGroups,',',userAssignedChildren)) AND FIND_IN_SET(permid,mobileGroups); END IF; END