📄 cs_post_update.prc
字号:
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[cs_Post_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[cs_Post_Update]
GO
CREATE PROCEDURE [dbo].cs_Post_Update
(
@SectionID int = null,
@PostID int,
@Subject nvarchar(256),
@Body ntext,
@FormattedBody ntext,
@EmoticonID int = 0,
@IsSticky bit = null,
@StickyDate datetime = null,
@IsLocked bit,
@IsAnnouncement bit,
@EditedBy int,
@EditNotes ntext = null,
@PropertyNames ntext = null,
@PropertyValues ntext = null,
@SettingsID int,
@PostConfiguration int = 0
)
AS
DECLARE @ThreadID int
DECLARE @CurrentStickyDate datetime
-- this sproc updates a post (called from the moderate/admin page)
UPDATE
cs_Posts
SET
Subject = @Subject,
Body = @Body,
FormattedBody = @FormattedBody,
IsLocked = @IsLocked,
EmoticonID = @EmoticonID,
PropertyNames = @PropertyNames,
PropertyValues = @PropertyValues,
PostConfiguration = @PostConfiguration
WHERE
PostID = @PostID and SettingsID = @SettingsID
-- Get the thread and postdate this applies to
SELECT
@ThreadID = P.ThreadID,
@CurrentStickyDate = T.StickyDate
FROM
cs_Posts P
LEFT JOIN
cs_Threads T ON T.ThreadID = P.ThreadID
WHERE
P.PostID = @PostID and P.SettingsID = @SettingsID
-- Update most recent info in cs_Threads
IF @ThreadID > 0
EXEC cs_system_UpdateThread @ThreadID, @PostID, @SettingsID
-- Update most recent info in cs_Sections
IF @SectionID > 0
EXEC cs_system_UpdateForum @SectionID, @ThreadID, @PostID, @SettingsID
-- Allow thread to update sticky properties.
IF (@IsSticky IS NOT NULL) AND (@StickyDate IS NOT NULL)
BEGIN
IF (@StickyDate > '1/1/2000')
BEGIN
-- valid date range given
UPDATE
cs_Threads
SET
IsSticky = @IsSticky,
StickyDate = @StickyDate,
IsLocked = @IsAnnouncement
WHERE
ThreadID = @ThreadID and SettingsID = @SettingsID
END
ELSE BEGIN
-- trying to remove a sticky
UPDATE
cs_Threads
SET
IsSticky = @IsSticky,
StickyDate = @CurrentStickyDate,
IsLocked = @IsAnnouncement
WHERE
ThreadID = @ThreadID and SettingsID = @SettingsID
END
END
IF @EditNotes IS NOT NULL
IF EXISTS (SELECT PostID FROM cs_PostEditNotes WHERE PostID = @PostID)
UPDATE
cs_PostEditNotes
SET
EditNotes = @EditNotes
WHERE
PostID = @PostID and SettingsID = @SettingsID
ELSE
INSERT INTO
cs_PostEditNotes
VALUES
(@PostID, @EditNotes, @SettingsID)
-- We want to track what happened
exec cs_system_ModerationAction_AuditEntry 2, @EditedBy, @PostID, NULL, NULL, @SettingsID, @EditNotes
-- if this is the most recent post and this is the thread starter we need to update the sections
/* deprected: update anyway on top
IF (SELECT PostLevel FROM cs_Posts WHERE PostID = @PostID) = 1
BEGIN
DECLARE @SectionID as int
SET @SectionID = (SELECT SectionID FROM cs_Sections WHERE MostRecentPostID = @PostID)
IF @SectionID > 0
EXEC cs_system_UpdateForum @SectionID, @ThreadID, @PostID, @SettingsID
END
*/
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
grant execute on [dbo].[cs_Post_Update] to public
go
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -