📄 cs_weblog_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_weblog_Post_Update]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[cs_weblog_Post_Update]
GO
CREATE PROCEDURE [dbo].cs_weblog_Post_Update
(
@PostID int,
@SectionID int,
@Subject nvarchar(256),
@Body ntext,
@FormattedBody ntext,
@EmoticonID int = 0,
@IsSticky bit = null,
@StickyDate datetime = null,
@IsLocked bit,
@IsApproved bit = 0,
@IsTracked bit = 0,
@EditedBy int,
@Excerpt nvarchar(500) = null,
@PostName nvarchar(256) = null,
@TitleUrl nvarchar(256) = null,
@PostConfig int = 0,
@BlogPostType tinyint = 1,
@Categories nvarchar(4000) = null,
@CategoryType tinyint = 1,
@PropertyNames ntext = null,
@PropertyValues ntext = null,
@SettingsID int,
@BloggerTime datetime,
@PostDate datetime
)
AS
if(@PostName is not null)
Begin
if exists(Select b.PostID FROM cs_weblog_Posts b, cs_Posts p where b.PostID = p.PostID and p.SectionID = @SectionID and b.PostName = @PostName and b.BlogPostType = @BlogPostType and p.PostID <> @PostID)
Begin
Return 2
End
End
DECLARE @ThreadID int
--DECLARE @PostDate datetime
Select @ThreadID = ThreadID FROM cs_Posts where PostID = @PostID
-- 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,
IsApproved = @IsApproved,
PropertyNames = @PropertyNames,
PropertyValues = @PropertyValues,
PostDate = @PostDate
WHERE
PostID = @PostID and SettingsID = @SettingsID
UPDATE
cs_weblog_Posts
SET
PostName = @PostName,
Excerpt = @Excerpt,
TitleUrl = @TitleUrl,
PostConfig = @PostConfig,
BlogPostType = @BlogPostType,
BloggerTime = @BloggerTime
Where
PostID = @PostID and SettingsID = @SettingsID
Update cs_Threads
Set IsApproved = @IsApproved
Where
ThreadID = @ThreadID
-- Allow thread to update sticky properties.
IF (@IsSticky IS NOT NULL) AND (@StickyDate IS NOT NULL)
BEGIN
-- Get the thread and postdate this applies to
SELECT
@ThreadID = ThreadID,
@PostDate = PostDate
FROM
cs_Posts
WHERE
PostID = @PostID and SettingsID = @SettingsID
IF (@StickyDate > '1/1/2000')
BEGIN
-- valid date range given
UPDATE
cs_Threads
SET
IsSticky = @IsSticky,
StickyDate = @StickyDate
WHERE
ThreadID = @ThreadID and SettingsID = @SettingsID
END
ELSE BEGIN
-- trying to remove a sticky
UPDATE
cs_Threads
SET
IsSticky = @IsSticky,
StickyDate = @PostDate
WHERE
ThreadID = @ThreadID and SettingsID = @SettingsID
END
END
IF(@BlogPostType = 1 OR @BlogPostType = 2)
BEGIN
IF @IsTracked = 1
BEGIN
-- If a row already exists to track this thread for this user, do nothing - otherwise add the row
IF NOT EXISTS ( SELECT ThreadID FROM cs_TrackedThreads (nolock) WHERE ThreadID = @ThreadID AND UserID = @EditedBy )
INSERT INTO cs_TrackedThreads ( ThreadID, UserID, SettingsID )
VALUES ( @ThreadID, @EditedBy, @SettingsID)
END
Else
Begin
DELETE FROM cs_TrackedThreads where ThreadID = @ThreadID and UserID = @EditedBy and SettingsID = @SettingsID
End
exec cs_Posts_UpdatePostsInCategories @Categories, @SectionID, @PostID, @CategoryType, @SettingsID, 0
END
UPDATE
cs_Threads
SET
TotalReplies = (SELECT COUNT(*) FROM cs_Posts WHERE ThreadID = @ThreadID AND IsApproved = 1 AND PostLevel > 1)
WHERE
ThreadID = @ThreadID
--exec cs_weblog_UpdateContentHistory @SectionID, @BlogPostType
GO
SET QUOTED_IDENTIFIER OFF
GO
SET ANSI_NULLS ON
GO
grant execute on [dbo].[cs_weblog_Post_Update] to public
go
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -