if exists (select * from dbo.sysobjects where id = object_id(N'C_{objectQualifier}DMX_Categories') and OBJECTPROPERTY(id, N'IsConstraint') = 1)

ALTER TABLE {databaseOwner}{objectQualifier}DMX_Categories
  DROP CONSTRAINT C_{objectQualifier}DMX_Categories

GO

if not exists (select * from dbo.sysobjects where id = object_id(N'FK_{objectQualifier}DMX_Log_{objectQualifier}Users') and OBJECTPROPERTY(id, N'IsForeignKey') = 1)
ALTER TABLE {databaseOwner}{objectQualifier}DMX_Log ADD CONSTRAINT
	FK_{objectQualifier}DMX_Log_{objectQualifier}Users FOREIGN KEY
	(
    UserId
	) REFERENCES {databaseOwner}{objectQualifier}Users
	(
    UserID
	) ON DELETE CASCADE
	 NOT FOR REPLICATION

GO

/****** LOCALIZE EXTENSIONS ******/

if exists (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_Extensions') and OBJECTPROPERTY(id, N'IsTable') = 1)
ALTER TABLE {databaseOwner}{objectQualifier}DMX_Extensions
ADD [ResourceFile] NVARCHAR (255)
GO

if exists (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_Extensions') and OBJECTPROPERTY(id, N'IsTable') = 1)
ALTER TABLE {databaseOwner}{objectQualifier}DMX_Extensions
DROP COLUMN [Name]
GO

UPDATE {databaseOwner}{objectQualifier}DMX_Extensions SET
[ResourceFile] = 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources'
GO

IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetExtensions') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetExtensions
GO
IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetExtension') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetExtension
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetExtension
	@PortalId Int,
	@Addon NVarChar (50),
	@ExtensionKey NVarChar (50)
AS

SELECT
	[AccessRights],
	[Addon],
	[ControlToLoad],
	[Custom],
	[EntryTypes],
	[ExtensionKey],
	[Icon16],
	[Icon32],
	[IsPrivate],
	[MimeType],
	[PortalId],
	[ResourceFile],
	[SettingsControl],
	[ViewByDefault]
FROM
	{databaseOwner}{objectQualifier}DMX_Extensions
WHERE
	[PortalId] = @PortalId
	AND [Addon] = @Addon
	AND [ExtensionKey] = @ExtensionKey
GO


IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_AddExtensions') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_AddExtensions
GO
IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_AddExtension') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_AddExtension
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_AddExtension
	@PortalId Int,	@Addon NVarChar (50),	
	@ExtensionKey NVarChar (50),
	@AccessRights NVarChar (255),
	@ControlToLoad NVarChar (255),
	@Custom NVarChar (50),
	@EntryTypes NVarChar (255),
	@Icon16 NVarChar (100),
	@Icon32 NVarChar (100),
	@IsPrivate Bit,
	@MimeType NVarChar (50),
	@ResourceFile NVarChar (255),
	@SettingsControl NVarChar (250),
	@ViewByDefault Bit
AS

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions (
	[PortalId],
	[Addon],
	[ExtensionKey],
	AccessRights,
	ControlToLoad,
	Custom,
	EntryTypes,
	Icon16,
	Icon32,
	IsPrivate,
	MimeType,
	ResourceFile,
	SettingsControl,
	ViewByDefault
) VALUES (
	@PortalId,
	@Addon,
	@ExtensionKey,
	@AccessRights,
	@ControlToLoad,
	@Custom,
	@EntryTypes,
	@Icon16,
	@Icon32,
	@IsPrivate,
	@MimeType,
	@ResourceFile,
	@SettingsControl,
	@ViewByDefault
)

GO


IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_UpdateExtensions') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_UpdateExtensions
GO
IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_UpdateExtension') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_UpdateExtension
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_UpdateExtension
	@PortalId Int,
	@Addon NVarChar (50),
	@ExtensionKey NVarChar (50),
	@AccessRights NVarChar (255),
	@ControlToLoad NVarChar (255),
	@Custom NVarChar (50),
	@EntryTypes NVarChar (255),
	@Icon16 NVarChar (100),
	@Icon32 NVarChar (100),
	@IsPrivate Bit,
	@MimeType NVarChar (50),
	@ResourceFile NVarChar (255),
	@SettingsControl NVarChar (250),
	@ViewByDefault Bit
AS

UPDATE {databaseOwner}{objectQualifier}DMX_Extensions SET
	[AccessRights] = @AccessRights,
	[ControlToLoad] = @ControlToLoad,
	[Custom] = @Custom,
	[EntryTypes] = @EntryTypes,
	[Icon16] = @Icon16,
	[Icon32] = @Icon32,
	[IsPrivate] = @IsPrivate,
	[MimeType] = @MimeType,
	[ResourceFile] = @ResourceFile,
	[SettingsControl] = @SettingsControl,
	[ViewByDefault] = @ViewByDefault
WHERE
	[PortalId] = @PortalId
	AND [Addon] = @Addon
	AND [ExtensionKey] = @ExtensionKey
GO


IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_DeleteExtensions') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_DeleteExtensions
GO
IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_DeleteExtension') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_DeleteExtension
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_DeleteExtension
	@PortalId Int,
	@Addon NVarChar (50),
	@ExtensionKey NVarChar (50)
AS

DELETE FROM {databaseOwner}{objectQualifier}DMX_Extensions
WHERE
	[PortalId] = @PortalId
	AND [Addon] = @Addon
	AND [ExtensionKey] = @ExtensionKey
GO


IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetExtensionsByAddons') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetExtensionsByAddons
GO

IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetExtensionsByAddon') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetExtensionsByAddon
GO

IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetExtensionsByPortals') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetExtensionsByPortals
GO
IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetExtensionsByPortal') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetExtensionsByPortal
GO

/****** CHANGED OTHER SPROCS ******/

IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetCategoryContents') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetCategoryContents
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetCategoryContents
  @CategoryId Int, @PortalId Int, @UserId Int
AS

SELECT {databaseOwner}{objectQualifier}DMX_Entries.*, LTrim(RTrim({objectQualifier}Users.FirstName+' '+{objectQualifier}Users.LastName)) AS FullName, {databaseOwner}{objectQualifier}DMX_Extensions.ResourceFile, {databaseOwner}{objectQualifier}DMX_Extensions.Icon16, Entries_1.Description AS CollectionName, UserSubs.id, UserSubs.LastAccess
FROM ((({objectQualifier}Users RIGHT JOIN {databaseOwner}{objectQualifier}DMX_Entries ON {databaseOwner}{objectQualifier}Users.UserID={objectQualifier}DMX_Entries.UserId) LEFT JOIN {databaseOwner}{objectQualifier}DMX_Extensions ON {databaseOwner}{objectQualifier}DMX_Entries.EntryType={objectQualifier}DMX_Extensions.ExtensionKey) LEFT JOIN {databaseOwner}{objectQualifier}DMX_Entries AS Entries_1 ON {databaseOwner}{objectQualifier}DMX_Entries.CollectionId=Entries_1.EntryId) LEFT JOIN (SELECT * FROM {databaseOwner}{objectQualifier}DMX_Subscriptions WHERE {databaseOwner}{objectQualifier}DMX_Subscriptions.UserId=@UserId) AS UserSubs ON {databaseOwner}{objectQualifier}DMX_Entries.EntryId=UserSubs.EntryId
WHERE ((({objectQualifier}DMX_Entries.EntryId)=({objectQualifier}DMX_Entries.LastVersionId))
And (';' + {databaseOwner}{objectQualifier}DMX_Entries.Categories + ';' LIKE '%;' + LTRIM(RTRIM(STR(@CategoryId))) + ';%')
AND (({objectQualifier}DMX_Extensions.PortalId)=@PortalId)
AND (({objectQualifier}DMX_Entries.PortalId)=@PortalId))

GO

IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetCollectionContents') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetCollectionContents
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetCollectionContents
  @AllVersions Bit, @ParentId Int, @PortalId Int, @UserId Int
AS

SELECT
 {databaseOwner}{objectQualifier}DMX_Entries.*,
 LTrim(RTrim({objectQualifier}Users.FirstName+' '+{objectQualifier}Users.LastName)) AS FullName,
 {databaseOwner}{objectQualifier}DMX_Extensions.ResourceFile,
 {databaseOwner}{objectQualifier}DMX_Extensions.Icon16,
 UserSubs.id,
 UserSubs.LastAccess,
 (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DMX_Entries AS c WHERE CollectionId={objectQualifier}DMX_Entries.EntryId AND c.EntryId=c.LastVersionId) AS Children,
 (SELECT COUNT(*) FROM {databaseOwner}{objectQualifier}DMX_Entries AS c WHERE CollectionId={objectQualifier}DMX_Entries.EntryId AND c.EntryId=c.LastVersionId AND c.EntryType LIKE '%Collection%') AS Subcollections
FROM (({objectQualifier}Users RIGHT JOIN {databaseOwner}{objectQualifier}DMX_Entries ON {databaseOwner}{objectQualifier}Users.UserID = {databaseOwner}{objectQualifier}DMX_Entries.UserId) LEFT JOIN {databaseOwner}{objectQualifier}DMX_Extensions ON {databaseOwner}{objectQualifier}DMX_Entries.EntryType = {databaseOwner}{objectQualifier}DMX_Extensions.ExtensionKey) LEFT JOIN (SELECT * FROM {databaseOwner}{objectQualifier}DMX_Subscriptions WHERE {databaseOwner}{objectQualifier}DMX_Subscriptions.UserId=@UserId) AS UserSubs ON {databaseOwner}{objectQualifier}DMX_Entries.EntryId = UserSubs.EntryId
WHERE (((({objectQualifier}DMX_Entries.EntryId)=([{objectQualifier}DMX_Entries].[LastVersionId])) OR (@AllVersions=1))
AND (({objectQualifier}DMX_Entries.CollectionId)=@ParentId) 
AND (({objectQualifier}DMX_Extensions.PortalId)=@PortalId)
AND (({objectQualifier}DMX_Entries.PortalId)=@PortalId))

GO


IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetAllPortalCollections') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetAllPortalCollections
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetAllPortalCollections
  @PortalId Int
AS

SELECT {databaseOwner}{objectQualifier}DMX_Entries.Description, {databaseOwner}{objectQualifier}DMX_Entries.EntryId, {databaseOwner}{objectQualifier}DMX_Entries.CollectionId, {databaseOwner}{objectQualifier}DMX_Entries.EditRoles, {databaseOwner}{objectQualifier}DMX_Entries.ViewRoles, {databaseOwner}{objectQualifier}DMX_Extensions.ResourceFile, {databaseOwner}{objectQualifier}DMX_Extensions.Icon16
FROM {databaseOwner}{objectQualifier}DMX_Entries LEFT JOIN {databaseOwner}{objectQualifier}DMX_Extensions ON {databaseOwner}{objectQualifier}DMX_Entries.EntryType={objectQualifier}DMX_Extensions.ExtensionKey
WHERE (((LEFT({objectQualifier}DMX_Entries.EntryType,10)='Collection') Or (LEFT({objectQualifier}DMX_Entries.EntryType,17)='Custom.Collection')) And (({objectQualifier}DMX_Entries.Deleted)=0) And (({objectQualifier}DMX_Entries.PortalId)=@PortalId)
And (({objectQualifier}DMX_Extensions.PortalId)=@PortalId))
ORDER BY {databaseOwner}{objectQualifier}DMX_Entries.Description

GO

IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetUserSubscriptions') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetUserSubscriptions
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetUserSubscriptions
  @UserId Int, @PortalId Int
AS

SELECT {databaseOwner}{objectQualifier}DMX_Subscriptions.id, {databaseOwner}{objectQualifier}DMX_Subscriptions.LastAccess, {databaseOwner}{objectQualifier}DMX_Entries.*, {databaseOwner}{objectQualifier}DMX_Extensions.ResourceFile, {databaseOwner}{objectQualifier}DMX_Extensions.Icon16, Entries_1.Description AS CollectionName
FROM (({objectQualifier}DMX_Entries LEFT JOIN {databaseOwner}{objectQualifier}DMX_Entries AS Entries_1 ON {databaseOwner}{objectQualifier}DMX_Entries.CollectionId=Entries_1.EntryId) INNER JOIN {databaseOwner}{objectQualifier}DMX_Subscriptions ON {databaseOwner}{objectQualifier}DMX_Entries.EntryId={objectQualifier}DMX_Subscriptions.EntryId) LEFT JOIN {databaseOwner}{objectQualifier}DMX_Extensions ON {databaseOwner}{objectQualifier}DMX_Entries.EntryType={objectQualifier}DMX_Extensions.ExtensionKey
WHERE ((({objectQualifier}DMX_Subscriptions.UserId)=@UserId)
 AND (({objectQualifier}DMX_Entries.PortalId)=@PortalId)
 AND (({objectQualifier}DMX_Extensions.PortalId)=@PortalId))

GO


/****** REPAIR TRIGGER ******/

IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_Init') and OBJECTPROPERTY(id, N'IsTrigger') = 1)
DROP TRIGGER {databaseOwner}{objectQualifier}DMX_Init
GO

CREATE TRIGGER {databaseOwner}{objectQualifier}DMX_Init
ON {databaseOwner}{objectQualifier}Portals
AFTER INSERT
AS

BEGIN

DECLARE @PortalID INT
SET @PortalId = (SELECT PortalID FROM INSERTED)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewCollection.ascx', Null, 'Collection', 'DesktopModules/Bring2mind/DMX/images/Collection.Gif', 'DesktopModules/Bring2mind/DMX/images/Collection.Big.Gif', 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', Null, 'Command.Details', Null, Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/Download.aspx', Null, 'Command.Download', Null, Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/EditEntry.ascx', Null, 'Command.Edit', Null, Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/EditEntry.ascx', Null, 'Command.New', Null, Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/Search.ascx', Null, 'Command.Search', Null, Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewCategory.ascx', Null, 'Command.ViewCategory', Null, Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewCollection.ascx', Null, 'Command.ViewCollection', 'DesktopModules/Bring2mind/DMX/images/Collection.Gif', 'DesktopModules/Bring2mind/DMX/images/Collection.Big.Gif', 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewSubscriptions.ascx', Null, 'Command.ViewSubscriptions', Null, Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'pdf', 'File.Adobe.Acrobat', 'DesktopModules/Bring2mind/DMX/images/File.Adobe.Acrobat.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Adobe.Acrobat.Big.Gif', 0, 'application/pdf', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'indd', 'File.Adobe.InDesign', 'DesktopModules/Bring2mind/DMX/images/File.Adobe.InDesign.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Adobe.InDesign.Big.Gif', 0, 'application/octet-stream', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'psd', 'File.Adobe.Photoshop', 'DesktopModules/Bring2mind/DMX/images/File.Adobe.Photoshop.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Adobe.Photoshop.Big.Gif', 0, 'application/octet-stream', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'dwg', 'File.Autocad.Dwg', 'DesktopModules/Bring2mind/DMX/images/File.Dwg.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Dwg.Big.Gif', 0, 'application/acad', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'avi', 'File.Avi', 'DesktopModules/Bring2mind/DMX/images/File.Avi.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Avi.Big.Gif', 0, 'video/x-msvideo', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'bmp', 'File.Bmp', 'DesktopModules/Bring2mind/DMX/images/File.Bmp.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Bmp.Big.Gif', 0, 'image/bmp', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'dxf', 'File.Dxf', 'DesktopModules/Bring2mind/DMX/images/File.Dxf.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Dxf.Big.Gif', 0, 'application/dxf', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'emf', 'File.Emf', 'DesktopModules/Bring2mind/DMX/images/File.Emf.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Emf.Big.Gif', 0, 'application/octet-stream', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'eps', 'File.Eps', 'DesktopModules/Bring2mind/DMX/images/File.Eps.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Eps.Big.Gif', 0, 'application/postscript', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'gif', 'File.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Gif.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Gif.Big.Gif', 0, 'image/gif', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'htm;html', 'File.Htm', 'DesktopModules/Bring2mind/DMX/images/File.Htm.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Htm.Big.Gif', 0, 'text/html', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'jpg;jpeg', 'File.Jpg', 'DesktopModules/Bring2mind/DMX/images/File.Jpg.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Jpg.Big.Gif', 0, 'image/jpeg', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'xls', 'File.Microsoft.Excel', 'DesktopModules/Bring2mind/DMX/images/File.Microsoft.Excel.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Microsoft.Excel.Big.Gif', 0, 'application/vnd.ms-excel', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'xsn', 'File.Microsoft.Infopath', 'DesktopModules/Bring2mind/DMX/images/File.Microsoft.Infopath.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Microsoft.Infopath.Big.Gif', 0, 'application/octet-stream', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'ppt', 'File.Microsoft.Powerpoint', 'DesktopModules/Bring2mind/DMX/images/File.Microsoft.Powerpoint.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Microsoft.Powerpoint.Big.Gif', 0, 'application/powerpoint', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'doc', 'File.Microsoft.Word', 'DesktopModules/Bring2mind/DMX/images/File.Microsoft.Word.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Microsoft.Word.Big.Gif', 0, 'application/msword', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'mpg;mpeg;mpe', 'File.Mpeg', 'DesktopModules/Bring2mind/DMX/images/File.Mpeg.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Mpeg.Big.Gif', 0, 'video/mpeg', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'png', 'File.Png', 'DesktopModules/Bring2mind/DMX/images/File.Png.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Png.Big.Gif', 0, 'image/png', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'mov', 'File.Quicktime', 'DesktopModules/Bring2mind/DMX/images/File.Quicktime.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Quicktime.Big.Gif', 0, 'video/quicktime', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'rar', 'File.Rar', 'DesktopModules/Bring2mind/DMX/images/File.Rar.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Rar.Big.Gif', 0, 'application/octet-stream', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'rtf', 'File.Rtf', 'DesktopModules/Bring2mind/DMX/images/File.Rtf.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Rtf.Big.Gif', 0, 'text/richtext', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'svg', 'File.Svg', 'DesktopModules/Bring2mind/DMX/images/File.Svg.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Svg.Big.Gif', 0, 'application/svg', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'tga', 'File.Targa', 'DesktopModules/Bring2mind/DMX/images/File.Targa.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Targa.Big.Gif', 0, 'image/targa', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'txt', 'File.Text', 'DesktopModules/Bring2mind/DMX/images/File.Text.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Text.Big.Gif', 0, 'text/plain', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'tif;tiff', 'File.Tiff', 'DesktopModules/Bring2mind/DMX/images/File.Tiff.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Tiff.Big.Gif', 0, 'image/tiff', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'ttf', 'File.Ttf', 'DesktopModules/Bring2mind/DMX/images/File.Ttf.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Ttf.Big.Gif', 0, 'application/octet-stream', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', Null, 'File.Unknown', 'DesktopModules/Bring2mind/DMX/images/File.Unknown.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Unknown.Big.Gif', 0, 'application/octet-stream', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'wav', 'File.Wav', 'DesktopModules/Bring2mind/DMX/images/File.Wav.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Wav.Big.Gif', 0, 'audio/x-wav', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'wmf', 'File.Wmf', 'DesktopModules/Bring2mind/DMX/images/File.Wmf.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Wmf.Big.Gif', 0, 'application/octet-stream', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 1, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', 'zip', 'File.Zip', 'DesktopModules/Bring2mind/DMX/images/File.Zip.Gif', 'DesktopModules/Bring2mind/DMX/images/File.Zip.Big.Gif', 0, 'application/zip', 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Bring2mind/DMX/ViewDetails.ascx', Null, 'Hyperlink', 'DesktopModules/Bring2mind/DMX/images/Hyperlink.Gif', 'DesktopModules/Bring2mind/DMX/images/Hyperlink.Big.Gif', 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Command=Core.ViewCollection', '1', 'Navbutton.Collections', 'DesktopModules/Bring2mind/DMX/images/NB_Collections.gif', Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Command=Core.ViewCategory', '2', 'Navbutton.Categories', 'DesktopModules/Bring2mind/DMX/images/NB_Categories.gif', Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES ('-1;', 'Core', 'Command=Core.Search', '3', 'Navbutton.Search', 'DesktopModules/Bring2mind/DMX/images/NB_Search.gif', Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

INSERT INTO {databaseOwner}{objectQualifier}DMX_Extensions ([AccessRights], [Addon], [ControlToLoad], [Custom], [ExtensionKey], [Icon16], [Icon32], [IsPrivate], [MimeType], [ResourceFile], [PortalId], [ViewByDefault], [EntryTypes])
VALUES (Null, 'Core', 'Command=Core.ViewSubscriptions', '4', 'Navbutton.MySubscriptions', 'DesktopModules/Bring2mind/DMX/images/NB_MySubscriptions.gif', Null, 0, Null, 'DesktopModules/Bring2mind/DMX/App_LocalResources/SharedResources', @PortalId, 0, Null)

END

GO

sp_settriggerorder '{databaseOwner}{objectQualifier}DMX_Init', 'First', 'INSERT'

GO

/****** SMALL REPAIRS ******/
UPDATE {databaseOwner}{objectQualifier}DMX_Extensions SET
[ExtensionKey] = 'Navbutton.Categories'
WHERE
[ExtensionKey] = 'NavButton.Categories'


IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetEntryAttributeList') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetEntryAttributeList
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetEntryAttributeList
  @PortalId Int, @EntryId Int
AS

SELECT {databaseOwner}{objectQualifier}DMX_Attributes.*, {databaseOwner}{objectQualifier}DMX_EntryAttributes.id AS EntryAttributeId, {databaseOwner}{objectQualifier}DMX_EntryAttributes.Value
FROM {databaseOwner}{objectQualifier}DMX_Attributes LEFT OUTER JOIN {databaseOwner}{objectQualifier}DMX_EntryAttributes ON {databaseOwner}{objectQualifier}DMX_Attributes.id={objectQualifier}DMX_EntryAttributes.Attribute
 AND ({objectQualifier}DMX_Attributes.PortalId=@PortalId)
 AND ({objectQualifier}DMX_EntryAttributes.EntryId=@EntryId)
ORDER BY {databaseOwner}{objectQualifier}DMX_Attributes.ViewOrder

GO

IF EXISTS (select * from dbo.sysobjects where id = object_id(N'{objectQualifier}DMX_GetEntryAttributesByEntries') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
DROP PROCEDURE {databaseOwner}{objectQualifier}DMX_GetEntryAttributesByEntries
GO

CREATE PROCEDURE {databaseOwner}{objectQualifier}DMX_GetEntryAttributesByEntries
	@EntryId Int
AS

SELECT
	{databaseOwner}{objectQualifier}DMX_EntryAttributes.Attribute,
	{databaseOwner}{objectQualifier}DMX_EntryAttributes.EntryId,
	{databaseOwner}{objectQualifier}DMX_EntryAttributes.id,
	{databaseOwner}{objectQualifier}DMX_EntryAttributes.Value, 
	{databaseOwner}{objectQualifier}DMX_Attributes.Name AS AttributesName, 
	{databaseOwner}{objectQualifier}DMX_Attributes.ResourceFile, 
	{databaseOwner}{objectQualifier}DMX_Entries.Description AS EntriesDescription
FROM
	{databaseOwner}{objectQualifier}DMX_Entries INNER JOIN {databaseOwner}{objectQualifier}DMX_Attributes INNER JOIN {databaseOwner}{objectQualifier}DMX_EntryAttributes ON {databaseOwner}{objectQualifier}DMX_Attributes.id = {databaseOwner}{objectQualifier}DMX_EntryAttributes.Attribute ON {databaseOwner}{objectQualifier}DMX_Entries.EntryId = {databaseOwner}{objectQualifier}DMX_EntryAttributes.EntryId
WHERE
	{databaseOwner}{objectQualifier}DMX_EntryAttributes.EntryId = @EntryId
GO
