Skip to content

web: require credit to post outside Help categories#6962

Merged
AenBleidd merged 1 commit intomasterfrom
dpa_forum12
Apr 7, 2026
Merged

web: require credit to post outside Help categories#6962
AenBleidd merged 1 commit intomasterfrom
dpa_forum12

Conversation

@davidpanderson
Copy link
Copy Markdown
Contributor

@davidpanderson davidpanderson commented Apr 7, 2026

Configurable by NEED_CREDIT_TO_POST_EXCEPT_HELP in project.inc (default true)

Also minor code cleanup

Also change ops/delete_account.php to use wipe_account()


Summary by cubic

Require computing credit to post outside Help categories, controlled by NEED_CREDIT_TO_POST_EXCEPT_HELP (default true). Also update the delete-user CLI to use wipe_account().

  • New Features

    • Block creating threads and replies if the user has zero credit, except in Help categories.
    • Prevent posting in News (dev blog) for non-admins with a clear error message.
    • Keep the “New thread” button visible to logged-in users; server-side checks enforce access.
  • Refactors

    • Replace user_can_create_thread() with show_post_button() and centralize rules in check_post_access().
    • Define NEED_CREDIT_TO_POST_EXCEPT_HELP in forum.inc (default true).
    • Switch html/ops/delete_user.php to call wipe_account().
    • Add clarifying comments in delete_account.inc and minor copy cleanups.

Written for commit 673b3e7. Summary will update on new commits.

Configurable by NEED_CREDIT_TO_POST_EXCEPT_HELP in project.inc (default true)

Also minor code cleanup

Also change ops/delete_account.php to use wipe_account()
Copilot AI review requested due to automatic review settings April 7, 2026 00:54
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 5 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="html/inc/forum.inc">

<violation number="1" location="html/inc/forum.inc:1330">
P1: The new help-category credit check can dereference null on team forums because it looks up a category using a team id.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

Comment thread html/inc/forum.inc
if (NEED_CREDIT_TO_POST_EXCEPT_HELP) {
if ($user->total_credit == 0) {
$category = BoincCategory::lookup_id($forum->category);
if (!$category->is_helpdesk) {
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1: The new help-category credit check can dereference null on team forums because it looks up a category using a team id.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At html/inc/forum.inc, line 1330:

<comment>The new help-category credit check can dereference null on team forums because it looks up a category using a team id.</comment>

<file context>
@@ -1306,34 +1314,49 @@ function check_post_access($user, $forum) {
+    if (NEED_CREDIT_TO_POST_EXCEPT_HELP) {
+        if ($user->total_credit == 0) {
+            $category = BoincCategory::lookup_id($forum->category);
+            if (!$category->is_helpdesk) {
+                error_page(
+                    tra("To create a thread you must have computing credit.")
</file context>
Fix with Cubic

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds a configurable rule requiring users to have credit to create threads outside Helpdesk categories, plus some forum posting UX/permission refactoring and an ops script update to use wipe_account() for deletions.

Changes:

  • Introduce NEED_CREDIT_TO_POST_EXCEPT_HELP (default true) and enforce “must have credit” outside Helpdesk categories.
  • Refactor “New thread” button logic (user_can_create_threadshow_post_button) and move thread-create permission checks into check_post_access().
  • Update ops user deletion to call wipe_account().

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
html/user/forum_post.php Removes inline create-thread gating in favor of centralized check_post_access().
html/user/forum_forum.php Updates “New thread” button rendering to use show_post_button().
html/ops/delete_user.php Switches deletion implementation to wipe_account().
html/inc/forum.inc Adds new config flag + new credit gating logic; refactors post button + access checks.
html/inc/delete_account.inc Clarifies deletion-method docs and adds editorial note.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread html/inc/forum.inc
Comment on lines +1327 to 1336
if (NEED_CREDIT_TO_POST_EXCEPT_HELP) {
if ($user->total_credit == 0) {
$category = BoincCategory::lookup_id($forum->category);
if (!$category->is_helpdesk) {
error_page(
tra("To create a thread you must have computing credit.")
);
}
}
}
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$forum->category is not always a BoincCategory ID (e.g., team forums use category as a team ID—see existing is_moderator() logic). In those cases BoincCategory::lookup_id($forum->category) will return the wrong record or null, and $category->is_helpdesk can break. Fix by applying the Helpdesk exception only for parent_type == 0 (public forums/categories), or otherwise branching per parent_type and only doing BoincCategory lookup when the ID is actually a category ID.

Copilot uses AI. Check for mistakes.
Comment thread html/inc/forum.inc
function check_post_access($user, $forum) {
if (is_admin($user)) return;
if ($forum->is_dev_blog) {
error_page("Can't post to News");
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This introduces a non-localized error string in a user-facing path while nearby errors use tra(). Wrap the message in tra() for translation consistency, and consider aligning wording with the action being blocked (e.g., thread creation vs posting generally) since this function is used for access enforcement.

Suggested change
error_page("Can't post to News");
error_page(tra("Can't post to News"));

Copilot uses AI. Check for mistakes.
Comment thread html/ops/delete_user.php
$user = BoincUser::lookup_id((int) $argv[1]);
if (!$user) die("no such user\n");
$retval = delete_account($user);
$retval = wipe_account($user);
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR description says it changes ops/delete_account.php to use wipe_account(), but the actual change here is in html/ops/delete_user.php. Please update the PR description to match the filename being modified (or adjust the code change if the intent was a different script).

Copilot uses AI. Check for mistakes.
// delete_account(): call one of these (or project-supplied func)
// based on config setting
//
// NOTE: this is way too complex. Just use the wipe option.
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The NOTE is editorial and not actionable documentation for maintainers/users of this API. Consider rephrasing to an objective recommendation (e.g., when/why wipe_account() is preferred) or removing it to keep the header comment focused on behavior and selection logic.

Suggested change
// NOTE: this is way too complex. Just use the wipe option.
// Projects that intend to remove the account and all related DB records
// should prefer the wipe method.

Copilot uses AI. Check for mistakes.
Comment thread html/inc/forum.inc
if (!defined('MAXIMUM_EDIT_TIME')) {
define('MAXIMUM_EDIT_TIME', 3600);
// allow edits of forums posts up till one hour after posting.
// allow edits of forums posts up to one hour after posting.
Copy link

Copilot AI Apr 7, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct the phrase 'forums posts' to 'forum posts'.

Suggested change
// allow edits of forums posts up to one hour after posting.
// allow edits of forum posts up to one hour after posting.

Copilot uses AI. Check for mistakes.
@AenBleidd AenBleidd added this to Server Apr 7, 2026
@github-project-automation github-project-automation Bot moved this to Backlog in Server Apr 7, 2026
@AenBleidd AenBleidd added this to the Server Release 1.6.2 milestone Apr 7, 2026
@AenBleidd AenBleidd merged commit b2c2eaa into master Apr 7, 2026
460 of 461 checks passed
@AenBleidd AenBleidd deleted the dpa_forum12 branch April 7, 2026 01:39
@github-project-automation github-project-automation Bot moved this from Backlog to Done in Server Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants