. // create, manage, or read a team message board require_once("../inc/util.inc"); require_once("../inc/team.inc"); require_once("../inc/forum_db.inc"); check_get_args(array("tnow", "ttok", "teamid", "cmd")); function create_confirm($user, $team) { page_head(tra("Create Message Board")); echo tra("You may create a message board for use by %1.", $team->name)." "; $tokens = url_tokens($user->authenticator); show_button( "team_forum.php?teamid=$team->id&cmd=create$tokens", tra("Create Message Board"), tra("Create a message board for %1", $team->name) ); page_tail(); } function create_forum($user, $team) { $f = BoincForum::lookup("parent_type=1 and category=$team->id"); if ($f) { error_page(tra("Team already has a message board")); } $id = BoincForum::insert("(category, parent_type) values ($team->id, 1)"); $forum = BoincForum::lookup_id($id); if (!$forum) { error_page("couldn't create message board"); } edit_form($user, $team, $forum, true); } function edit_form($user, $team, $forum, $first) { page_head(tra("Team Message Board")); echo "
id> "; echo form_tokens($user->authenticator); start_table(); if (!strlen($forum->title)) $forum->title = $team->name; if (!strlen($forum->description)) $forum->description = tra("Discussion among members of %1", $team->name); row2(tra("Title"), "title\">"); row2(tra("Description"), ""); row2(tra("Minimum time between posts (seconds)"), "post_min_interval>" ); row2(tra("Minimum total credit to post"), "post_min_total_credit>" ); row2(tra("Minimum average credit to post"), "post_min_expavg_credit>" ); row2("", ""); end_table(); echo "
"; if (!$first) { echo "

id&cmd=remove_confirm$tokens> ".tra("Remove your team's message board.")." "; } page_tail(); } function remove_confirm($user, $team) { $tokens = url_tokens($user->authenticator); page_head(tra("Really remove message board?")); echo tra("Are you sure you want to remove your team's message board? All threads and posts will be permanently removed. (You may, however, create a new message board later).") ."

id&cmd=remove>".tra("Yes - remove message board")." "; page_tail(); } function remove($team) { $forum = BoincForum::lookup("parent_type=1 and category=$team->id"); if (!$forum) error_page("message board not found"); // delete threads and posts // $threads = BoincThread::enum("forum=$forum->id"); foreach ($threads as $thread) { $posts = BoincPost::enum("thread=$thread->id"); foreach ($posts as $post) { $post->delete(); } $thread->delete(); } $forum->delete(); page_head(tra("Message board removed")); echo "

" .tra( "Your team's message board has been removed. You may now %1create a new one%2.", "id&cmd=manage>", "" ) ."

" ; page_tail(); } function edit_action($forum) { $title = sanitize_tags(post_str('title')); $title = BoincDb::escape_string($title); $description = sanitize_tags(post_str('description')); $description = BoincDb::escape_string($description); $post_min_interval = post_int('post_min_interval'); $post_min_total_credit = post_int('post_min_total_credit'); $post_min_expavg_credit = post_int('post_min_expavg_credit'); $ret = $forum->update("title='$title', description='$description', post_min_interval=$post_min_interval, post_min_total_credit=$post_min_total_credit, post_min_expavg_credit=$post_min_expavg_credit"); if ($ret) { page_head(tra("Team Message Board Updated")); echo tra("Update successful"); page_tail(); } else { error_page(tra("Update failed")); } } function show_forum($team) { $forum = BoincForum::lookup("parent_type=1 and category=$team->id"); if (!$forum) { error_page(tra("Team has no forum")); } Header("Location: forum_forum.php?id=$forum->id"); } $teamid = get_int("teamid", true); if (!$teamid) $teamid = post_int('teamid'); $team = BoincTeam::lookup_id($teamid); if (!$team) { error_page("no such team"); } $cmd = get_str('cmd', true); if (!$cmd) $cmd = post_str('cmd', true); if ($cmd == 'manage') { $user = get_logged_in_user(); require_founder_login($user, $team); $forum = BoincForum::lookup("parent_type=1 and category=$teamid"); if (!$forum) { create_confirm($user, $team); } else { edit_form($user, $team, $forum, false); } } else if ($cmd == 'create') { $user = get_logged_in_user(); check_tokens($user->authenticator); require_founder_login($user, $team); create_forum($user, $team); } else if ($cmd == 'edit_action') { $user = get_logged_in_user(); require_founder_login($user, $team); check_tokens($user->authenticator); $forum = BoincForum::lookup("parent_type=1 and category=$teamid"); if (!$forum) error_page("no such forum"); edit_action($forum); } else if ($cmd == "remove_confirm") { $user = get_logged_in_user(); require_founder_login($user, $team); remove_confirm($user, $team); } else if ($cmd == "remove") { $user = get_logged_in_user(); require_founder_login($user, $team); remove($team); } else if ($cmd != "") { error_page("unknown command $cmd"); } else { show_forum($team); } ?>