diff --git a/checkin_notes b/checkin_notes index e56da62ecd..5fdeea3b8b 100755 --- a/checkin_notes +++ b/checkin_notes @@ -12506,3 +12506,20 @@ David 9 Nov 2006 cpu_sched.C cs_prefs.C cs_scheduler.C + +Rytis 10 Nov 2006 + - User web: forum thread locking. + + NOTE: requires DB update. + + html/ + inc/ + forum.inc + forum_thread.inc + user/ + forum_forum.php + forum_reply.php + forum_moderate_thread_action.php + forum_thread.php + ops/ + db_update.php \ No newline at end of file diff --git a/html/inc/forum.inc b/html/inc/forum.inc index d3b98297ef..de9ad6163c 100644 --- a/html/inc/forum.inc +++ b/html/inc/forum.inc @@ -33,7 +33,11 @@ define("EXCERPT_LENGTH", "120"); define('NEW_IMAGE', 'img/unread_post.png'); define('NEW_IMAGE_STICKY', 'img/unread_sticky.png'); -define('STICKY_IMAGE', 'img/sticky_post.png'); +define('NEW_IMAGE_LOCKED', 'img/unread_locked.png'); +define('NEW_IMAGE_STICKY_LOCKED', 'img/unread_sticky_locked.png'); +define('IMAGE_STICKY', 'img/sticky_post.png'); +define('IMAGE_LOCKED', 'img/locked_post.png'); +define('IMAGE_STICKY_LOCKED', 'img/sticky_locked_post.png'); define('NEW_IMAGE_HEIGHT','15'); define('EMPHASIZE_IMAGE', 'img/emphasized_post.png'); define('EMPHASIZE_IMAGE_HEIGHT','15'); diff --git a/html/inc/forum_thread.inc b/html/inc/forum_thread.inc index 683cd3cfdf..cb09fb6017 100644 --- a/html/inc/forum_thread.inc +++ b/html/inc/forum_thread.inc @@ -124,6 +124,21 @@ class Thread { return $result; } + /** + * Return thread lock state. + **/ + function isLocked(){ + return $this->dbObj->locked; + } + + /** + * Update thread lock state. + **/ + function setLocked($bool){ + $result = $this->dbhandler->updateThread($this, "locked", $bool?1:0); + return $result; + } + /** * Return even more fields from the thread **/ diff --git a/html/ops/db_update.php b/html/ops/db_update.php index 262c18e894..fdb0b78d38 100644 --- a/html/ops/db_update.php +++ b/html/ops/db_update.php @@ -342,6 +342,10 @@ function update_10_26_2006() { do_query("ALTER TABLE team ADD INDEX team_userid (userid)"); } -//update_10_26_2006(); +function update_11_10_2006() { + do_query("ALTER TABLE `thread` ADD `locked` SMALLINT NOT NULL DEFAULT '0'"); +} + +//update_11_10_2006(); ?> diff --git a/html/user/forum_forum.php b/html/user/forum_forum.php index 177a2e424f..e2ad901542 100644 --- a/html/user/forum_forum.php +++ b/html/user/forum_forum.php @@ -26,7 +26,7 @@ if (!$sort_style) { } else { // set the sort style if ($user){ - $user->setForumSortStyle($sort_style); + $user->setForumSortStyle($sort_style); } else { list($old_style,$thread_style)=explode("|",$_COOKIE['sorting']); setcookie('sorting', implode("|",array($sort_style,$thread_style)), time()+3600*24*365); @@ -115,15 +115,33 @@ function show_forum($forum, $start, $sort_style, $user) { if ($thread->isHidden()) { echo "X"; } - if ($unread && !$thread->isSticky()) { - echo "\"Unread"; - } - elseif($unread) { - echo "\"Unread"; - } - elseif($thread->isSticky()) { - echo "\"Sticky\""; - } + if ($unread) { + if ($thread->isSticky()) { + if ($thread->isLocked()) { + echo "\"Unread"; + } else { + echo "\"Unread"; + } + } else { + if ($thread->isLocked()) { + echo "\"Unread"; + } else { + echo "\"Unread"; + } + } + } else { + if ($thread->isSticky()) { + if ($thread->isLocked()) { + echo "\"Sticky,"; + } else { + echo "\"Sticky\""; + } + } else { + if ($thread->isLocked()) { + echo "\"Thread"; + } + } + } echo ""; $titlelength = 48; diff --git a/html/user/forum_moderate_thread_action.php b/html/user/forum_moderate_thread_action.php index 8d2581e940..93ffe0af4d 100644 --- a/html/user/forum_moderate_thread_action.php +++ b/html/user/forum_moderate_thread_action.php @@ -38,6 +38,10 @@ if ($action=="hide"){ $result = $thread->setSticky(true); } elseif ($action=="desticky"){ $result = $thread->setSticky(false); +} elseif ($action == "lock") { + $result = $thread->setLocked(true); +} elseif ($action == "unlock") { + $result = $thread->setLocked(false); } elseif ($action=="move"){ $forum = new Forum(post_int('forumid')); $result = $thread->moveTo($forum); diff --git a/html/user/forum_reply.php b/html/user/forum_reply.php index 199aa079ab..cc58385df8 100644 --- a/html/user/forum_reply.php +++ b/html/user/forum_reply.php @@ -14,6 +14,12 @@ $logged_in_user = re_get_logged_in_user(true); check_banished($logged_in_user); $thread = new Thread (get_int('thread')); + +if ($thread->isLocked() && !$logged_in_user->isSpecialUser(S_MODERATOR) + && !$logged_in_user->isSpecialUser(S_ADMIN)) { + error_page("This thread is locked. Only forum moderators and administrators are allowed to post there."); +} + $forum = $thread->getForum(); $category = $forum->getCategory(); diff --git a/html/user/forum_thread.php b/html/user/forum_thread.php index cfea5afe42..ae6cce4be6 100644 --- a/html/user/forum_thread.php +++ b/html/user/forum_thread.php @@ -92,7 +92,10 @@ if (($thread->isHidden()) && $logged_in_user && (!$logged_in_user->isSpecialUser
"; - echo $reply_text = "getID()."#input\">".tr(FORUM_THREAD_REPLY)."
"; + + if (!$thread->isLocked() || ($logged_in_user && $logged_in_user->isSpecialUser(S_MODERATOR))) { + echo $reply_text = "getID()."#input\">".tr(FORUM_THREAD_REPLY)."
"; + } if ($is_subscribed) { echo tr(FORUM_THREAD_SUBSCRIBED)." "; @@ -103,16 +106,21 @@ if (($thread->isHidden()) && $logged_in_user && (!$logged_in_user->isSpecialUser //If the logged in user is moderator enable some extra features if ($logged_in_user && $logged_in_user->isSpecialUser(S_MODERATOR)){ - if ($thread->isHidden()){ - echo "
getID()."\">Un-Delete this thread"; - } else { - echo "
getID()."\">Delete this thread"; - } - if($thread->isSticky()){ - echo "
getID()."\">De-sticky this thread"; - } else { - echo "
getID()."\">Make this thread sticky"; - } + if ($thread->isHidden()){ + echo "
getID()."\">Un-Delete this thread"; + } else { + echo "
getID()."\">Delete this thread"; + } + if ($thread->isSticky()){ + echo "
getID()."\">De-sticky this thread"; + } else { + echo "
getID()."\">Make this thread sticky"; + } + if ($thread->isLocked()) { + echo "
getID()."\">Unlock thread"; + } else { + echo "
getID()."\">Lock thread"; + } echo "
getID()."\">Move this thread"; echo "
getID()."\">Edit thread title"; } diff --git a/html/user/img/locked_post.png b/html/user/img/locked_post.png new file mode 100644 index 0000000000..eb13ee1610 Binary files /dev/null and b/html/user/img/locked_post.png differ diff --git a/html/user/img/sticky_locked_post.png b/html/user/img/sticky_locked_post.png new file mode 100644 index 0000000000..a754718ab4 Binary files /dev/null and b/html/user/img/sticky_locked_post.png differ diff --git a/html/user/img/unread_locked.png b/html/user/img/unread_locked.png new file mode 100644 index 0000000000..e089bae91a Binary files /dev/null and b/html/user/img/unread_locked.png differ diff --git a/html/user/img/unread_sticky_locked.png b/html/user/img/unread_sticky_locked.png new file mode 100644 index 0000000000..5e5ff645b8 Binary files /dev/null and b/html/user/img/unread_sticky_locked.png differ