USE [Vigil-DVR]
GO

SET NOCOUNT ON
GO

INSERT INTO users (account_username, account_hashpass)
VALUES('User', dbo.CSIHASH('123'))
GO

INSERT INTO users (account_username, account_hashpass)
VALUES('Administrator', dbo.CSIHASH('123'))
GO

INSERT INTO groups (groupname)
VALUES('Administrators')
GO

INSERT INTO groups (groupname)
VALUES('Users')
GO

INSERT INTO usergroup (username, groupname)
VALUES('Administrator', 'Administrators')
GO

INSERT INTO usergroup (username, groupname)
VALUES('User', 'Users')
GO

INSERT INTO grouppermission(groupname, permission_id)
SELECT g.groupname, p.permission_id
FROM groups g, perms p
WHERE g.groupname = 'Administrators'
GO

-- Allow export file browsing
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 65)

-- Allow export file delete
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 76)

--cameras 1-256
DECLARE @camera int
DECLARE @perm int
SET @camera = 1

WHILE @camera <= 256
BEGIN
	IF @camera <= 32
		SET @perm = @camera * 100
	ELSE
		SET @perm = 1000000 + @camera * 100
		
	INSERT INTO grouppermission(groupname, permission_id) VALUES('Users', @perm)

	SET @camera = @camera + 1
END
GO

-- Update audio permission
INSERT INTO grouppermission(groupname, permission_id)
	SELECT g.groupname, p.permission_id
	FROM groups g, perms p
	WHERE g.groupname = 'Users'
	AND p.permission_ID >= 3500 AND p.permission_ID <= 10000

-- Allow export still image
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 70)

-- Allow email still image
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 71)

-- Allow export AVI
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 72)

-- Allow export authentic video
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 73)

-- Allow export data
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 74)

-- Allow export AVI (RapidStream)
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 78)

-- Allow export authentic video (RapidStream)
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 79)

-- Allow video playback
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 60)

-- Allow RapidStream on playback (local)
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 2026400)

-- Allow RapidStream on playback (remote)
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 2026500)

-- Allow live view
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 61)

-- Allow live feed speeds over 1 frame / sec
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 63)

-- Allow Sub Stream on live (local)
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 2026000)

-- Allow Sub Stream on live (remote)
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 2026100)

-- Allow RapidStream on live (local)
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 2026200)

-- Allow RapidStream on live (remote)
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 2026300)

-- Allow camera control
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 90)

-- Allow analog output configuration
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 91)

-- Allow analog sequence control
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 92)

-- Allow footage date/time range in client
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 10300)

-- Allow server alarms in client
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 10900)

-- Allow pos/atm live in client
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 11000)

-- Allow server exports in client
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 11100)

-- Allow vpos events in client
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 11200)

-- Allow vpos pos/atm search in client
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 11300)

-- Allow vpos quick search in client
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 11400)

-- Allow remote main stream in client
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 12300)

-- Allow access to custom help
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 68)

-- Allow access to print
INSERT INTO grouppermission(groupname, permission_id)
VALUES('Users', 11900)

SET NOCOUNT OFF
GO
