USE [Vigil-DVR]
GO

SET NOCOUNT ON
GO

-- Camera Setup Tab --------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 58) > 0
   DELETE FROM grouppermission WHERE permission_id = 58
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 58) > 0
    DELETE FROM perms WHERE permission_id = 58
GO
----------------------------------------------------------------------------

-- General Settings Tab ----------------------------------------------------
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 52) > 0
    UPDATE perms SET permission_desc_id = 17141 WHERE permission_id = 52
GO
----------------------------------------------------------------------------

-- COM Ports Tab -----------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 54) > 0
   DELETE FROM grouppermission WHERE permission_id = 54
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 54) > 0
    DELETE FROM perms WHERE permission_id = 54
GO
----------------------------------------------------------------------------

-- Relays/Alarms Tab -------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 56) > 0
   DELETE FROM grouppermission WHERE permission_id = 56
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 56) > 0
    DELETE FROM perms WHERE permission_id = 56
GO
----------------------------------------------------------------------------

-- Audio Tab ---------------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 62) > 0
   DELETE FROM grouppermission WHERE permission_id = 62
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 62) > 0
    DELETE FROM perms WHERE permission_id = 62
GO
----------------------------------------------------------------------------

-- CODEC Settings ----------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 59) > 0
    DELETE FROM grouppermission WHERE permission_id = 59
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 59) > 0
    DELETE FROM perms WHERE permission_id = 59
GO
----------------------------------------------------------------------------

-- Live --------------------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 61) > 0
    DELETE FROM grouppermission WHERE permission_id = 61
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 61) > 0
    DELETE FROM perms WHERE permission_id = 61
GO
----------------------------------------------------------------------------

-- Relay -------------------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 67) > 0
    DELETE FROM grouppermission WHERE permission_id = 67
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 67) > 0
    DELETE FROM perms WHERE permission_id = 67
GO
----------------------------------------------------------------------------

-- Audio Recorder ----------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 64) > 0
    DELETE FROM grouppermission WHERE permission_id = 64
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 64) > 0
    DELETE FROM perms WHERE permission_id = 64
GO
----------------------------------------------------------------------------

-- Audio Live --------------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 3500) > 0
    DELETE FROM grouppermission WHERE permission_id = 3500
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 3500) > 0
    DELETE FROM perms WHERE permission_id = 3500
GO
----------------------------------------------------------------------------

-- Audio Talk --------------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 3670) > 0
    DELETE FROM grouppermission WHERE permission_id = 3670
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 3670) > 0
    DELETE FROM perms WHERE permission_id = 3670
GO
----------------------------------------------------------------------------

-- Camera Control ----------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 90) > 0
    DELETE FROM grouppermission WHERE permission_id = 90
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 90) > 0
    DELETE FROM perms WHERE permission_id = 90
GO
----------------------------------------------------------------------------

-- Analog Output Config ----------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 91) > 0
    DELETE FROM grouppermission WHERE permission_id = 91
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 91) > 0
    DELETE FROM perms WHERE permission_id = 91
GO
----------------------------------------------------------------------------

-- Analog Sequence Control -------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 92) > 0
    DELETE FROM grouppermission WHERE permission_id = 92
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 92) > 0
    DELETE FROM perms WHERE permission_id = 92
GO
----------------------------------------------------------------------------

-- Chat --------------------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 3301) > 0
    DELETE FROM grouppermission WHERE permission_id = 3301
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 3301) > 0
    DELETE FROM perms WHERE permission_id = 3301
GO
----------------------------------------------------------------------------

-- Chat Auto Reply ---------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 3300) > 0
    DELETE FROM grouppermission WHERE permission_id = 3300
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 3300) > 0
    DELETE FROM perms WHERE permission_id = 3300
GO
----------------------------------------------------------------------------

-- Exit Vigil --------------------------------------------------------------
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 75) > 0
    UPDATE perms SET permission_desc_id = 17140 WHERE permission_id = 75
GO
----------------------------------------------------------------------------

-- Shutdown ----------------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 80) > 0
    DELETE FROM grouppermission WHERE permission_id = 80
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 80) > 0
    DELETE FROM perms WHERE permission_id = 80
GO
----------------------------------------------------------------------------

-- Launch V-POS ------------------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 93) > 0
    DELETE FROM grouppermission WHERE permission_id = 93
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 93) > 0
    DELETE FROM perms WHERE permission_id = 93
GO
----------------------------------------------------------------------------

-- V-POS Administrator -----------------------------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 10100) > 0
    DELETE FROM grouppermission WHERE permission_id = 10100
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 10100) > 0
    DELETE FROM perms WHERE permission_id = 10100
GO
----------------------------------------------------------------------------

-- Client Administrator - Main Interface Mode ------------------------------
IF (SELECT COUNT(*) FROM grouppermission WHERE permission_id = 10200) > 0
    DELETE FROM grouppermission WHERE permission_id = 10200
GO
IF (SELECT COUNT(*) FROM perms WHERE permission_id = 10200) > 0
    DELETE FROM perms WHERE permission_id = 10200
GO
----------------------------------------------------------------------------

SET NOCOUNT OFF
GO
