From 0bc1a36451aafe37d9c10f5ad17eb21c9b0d29bd Mon Sep 17 00:00:00 2001 From: David Anderson Date: Mon, 28 Feb 2011 19:02:59 +0000 Subject: [PATCH] - user web: add a feature allowing project admins to control whether news items are exported as notices. The creator of a news item is shown a "Don't export" or "Export" button on the thread page. By default, news items are exported. svn path=/trunk/boinc/; revision=23119 --- checkin_notes | 17 ++++++++++++ db/schema.sql | 2 ++ html/inc/news.inc | 9 +++++++ html/user/forum_thread.php | 45 ++++++++++++++++++++++--------- html/user/forum_thread_status.php | 4 ++- html/user/notices.php | 2 +- 6 files changed, 64 insertions(+), 15 deletions(-) diff --git a/checkin_notes b/checkin_notes index ef2eab40d0..fdc50c91ed 100644 --- a/checkin_notes +++ b/checkin_notes @@ -1201,3 +1201,20 @@ David 26 Feb 2011 trickle_echo.cpp validator.cpp Makefile.am + +David 26 Feb 2011 + - user web: add a feature allowing project admins to control + whether news items are exported as notices. + The creator of a news item is shown a "Don't export" or "Export" + button on the thread page. + By default, news items are exported. + + db/ + schema.sql + html/ + inc/ + news.inc + user/ + forum_thread.php + notices.php + forum_thread_status.php diff --git a/db/schema.sql b/db/schema.sql index 00eb09ae91..9ff310a51a 100644 --- a/db/schema.sql +++ b/db/schema.sql @@ -407,6 +407,8 @@ create table thread ( owner integer not null, -- user ID of creator status integer not null, + -- whether a question has been answered + -- News forum: it set, don't export as notice title varchar(254) not null, timestamp integer not null, -- time of last new or modified post diff --git a/html/inc/news.inc b/html/inc/news.inc index 112b141651..881d256385 100644 --- a/html/inc/news.inc +++ b/html/inc/news.inc @@ -55,6 +55,15 @@ function news_forum() { return BoincForum::lookup("parent_type=0 and title = '$forum_name'"); } +function is_news_forum($forum) { + if (defined("NEWS_FORUM_NAME")) { + $forum_name = NEWS_FORUM_NAME; + } else { + $forum_name = "News"; + } + return $forum->parent_type == 0 && ($forum->title === $forum_name); +} + function show_news($start, $count) { $forum = news_forum(); if (!$forum) { diff --git a/html/user/forum_thread.php b/html/user/forum_thread.php index 7fb74d19e6..030185cd2e 100644 --- a/html/user/forum_thread.php +++ b/html/user/forum_thread.php @@ -21,6 +21,7 @@ require_once('../inc/util.inc'); require_once('../inc/forum.inc'); +require_once('../inc/news.inc'); check_get_args(array("id", "sort", "nowrap", "filter")); @@ -122,21 +123,21 @@ if ($forum->parent_type == 0) { if ($thread->owner == $logged_in_user->id){ if ($thread->replies !=0) { // Show a "this question has been answered" to the author - echo "
-
id."\"> - -
- " . tra("If your question has been adequately answered please click here to close it!") . " -
" - ; + echo "

"; + show_button( + "forum_thread_status.php?id=$thread->id&action=set", + tra("My question was answered"), + tra("Click here if your question has been adequately answered") + ); } } else { - // and a "I also got this question" to everyone else if they havent already told so - echo "

-
id."\"> - -
-
"; + // and a "I also got this question" to everyone else + echo "

"; + show_button( + "forum_thread_vote.php?id=$thread->id", + tra("I've also got this question"), + tra("I've also got this question") + ); } } } @@ -236,6 +237,24 @@ if (is_moderator($logged_in_user, $forum)) { ); } +// let admins decide whether a news item should be exported as notice +// +if (is_news_forum($forum) && ($logged_in_user->id == $thread->owner)) { + if ($thread->status) { + show_button( + "forum_thread_status.php?action=clear&id=$thread->id", + "Export", + "Export this news item as a Notice" + ); + } else { + show_button( + "forum_thread_status.php?action=set&id=$thread->id", + "Don't export", + "Don't export this news item as a Notice" + ); + } +} + // Display a box that allows the user to select sorting of the posts echo " id, "\">" . diff --git a/html/user/forum_thread_status.php b/html/user/forum_thread_status.php index b392862585..6b95b84892 100644 --- a/html/user/forum_thread_status.php +++ b/html/user/forum_thread_status.php @@ -23,10 +23,12 @@ require_once('../inc/forum.inc'); -check_get_args(array("id")); +check_get_args(array("id", "action")); $threadid = get_int('id'); $thread = BoincThread::lookup_id($threadid); +if (!$thread) error_page("no such thread"); + $logged_in_user = get_logged_in_user(); $owner = BoincUser::lookup_id($thread->owner); diff --git a/html/user/notices.php b/html/user/notices.php index 537b9bfb44..eb04e35a28 100644 --- a/html/user/notices.php +++ b/html/user/notices.php @@ -72,7 +72,7 @@ $notifies = BoincNotify::enum("userid = $userid $since_clause"); $forum = news_forum(); if ($forum) { $threads = BoincThread::enum( - "forum = $forum->id and hidden=0 $since_clause" + "forum = $forum->id and hidden=0 and status=0 $since_clause" ); }