Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nickvergessen/386c19c606c9bf1e032f to your computer and use it in GitHub Desktop.
Save nickvergessen/386c19c606c9bf1e032f to your computer and use it in GitHub Desktop.
Move [c]$active_f_row = $active_t_row = array();[/c] to the top of the function,
Add event before [c]if ($userdata['user_posts'] > 5000)[/c] and make the if condition a event variable as well as active_t_row, active_f_row
if active_t/f_row are both not empty anymore, skip the [c]if (!empty($forum_ary))[/c]
[b]Variables:[/b]
[list]
[*]$link_topic
[*]$link_forum
[*]$link_pm
[*]$insert_url
[*]$view_url
[*]$title
[*]$skip_row[/list]
[b]Before:[/b][code]$template->assign_block_vars('draftrow', array([/code]
Directly add [c]topic_poster[/c] to the query
Should not be needed. We just load all for this user and then check the permissions before displaying them?
We should fix phpbb and deduplicate this into a parent method, then only 1 event should be required
@brunoais
Copy link

core.functions_display.display_user_activity.actives_after

if (!empty($forum_ary))
You mean... skip all the code for when that condition returns true?

core.functions_posting.load_drafts_draft_list_results

Edit the query in phpBB's code to include the topic poster?

core.functions_posting.load_drafts_topic_data_query

Where would be the best place to check them, then? In all places where f_read permission checks are, there's still no info about which topics are being checked (AFAIK). Did I miss anything?

core.phpbb_notification_type_*

Should I do a ticket about that?

@nickvergessen
Copy link
Author

if (!empty($forum_ary))
You mean... skip all the code for when that condition returns true?

diff --git a/phpBB/includes/functions_display.php b/phpBB/includes/functions_display.php
index 4606a9f..ba4fa76 100644
--- a/phpBB/includes/functions_display.php
+++ b/phpBB/includes/functions_display.php
@@ -1061,14 +1061,21 @@ function display_user_activity(&$userdata)
    global $auth, $template, $db, $user;
    global $phpbb_root_path, $phpEx, $phpbb_container;

+   $active_f_row = $active_t_row = array();
    // Do not display user activity for users having more than 5000 posts...
-   if ($userdata['user_posts'] > 5000)
+   $display_activity = $userdata['user_posts'] <= 5000;
+
+   // brunoais event here
+
+   if (!$display_activity)
    {
        return;
    }

    $forum_ary = array();

+   if (empty($active_f_row) || empty($active_t_row))
+   {
    $forum_read_ary = $auth->acl_getf('f_read');
    foreach ($forum_read_ary as $forum_id => $allowed)
    {
@@ -1079,8 +1086,8 @@ function display_user_activity(&$userdata)
    }

    $forum_ary = array_diff($forum_ary, $user->get_passworded_forums());
+   }

-   $active_f_row = $active_t_row = array();
    if (!empty($forum_ary))
    {
        $phpbb_content_visibility = $phpbb_container->get('content.visibility');

Edit the query in phpBB's code to include the topic poster?

yes

Where would be the best place to check them, then? In all places where f_read permission checks are, there's still no info about which topics are being checked (AFAIK). Did I miss anything?

<nickvergessen> you can check that in the event before $template->assign_block_vars('draftrow', array(
<nickvergessen> thats why I added a condition to skip it
<nickvergessen> after the event you add if ($skip_row) { continue; }

Should I do a ticket about that?

looking into it at the moment

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment