maybe today!In the while 2.8.4 will be published very soon, probably today!
Code: Select all
private static function last_forums_topics($ntopics = 10){
Code: Select all
private static function last_forums_topics($ntopics = 10){
# Note that userID 2 in phpBB goes into default phpBB guest user group
# because $w3all_phpbb_usession is empty for this uid (excluded)
global $w3all_phpbb_connection,$w3all_phpbb_usession,$w3all_config,$w3all_exclude_phpbb_forums,$w3all_wlastopicspost_max,$w3all_lasttopic_avatar_num,$w3all_get_topics_x_ugroup,$w3all_heartbeat_phpbb_lastopics_num;
if( empty($w3all_phpbb_connection) ) return;
$topics = array();
$ntopics0 = $w3all_wlastopicspost_max > $w3all_lasttopic_avatar_num ? $w3all_wlastopicspost_max : $w3all_lasttopic_avatar_num;
$ntopics = $ntopics0 > $ntopics ? $ntopics0 : $ntopics;
$ntopics = $w3all_heartbeat_phpbb_lastopics_num > $ntopics ? $w3all_heartbeat_phpbb_lastopics_num : $ntopics;
$ntopics = $ntopics > $ntopics0 ? $ntopics : 10;
$topics_x_ugroup = $no_forums_list = '';
if($w3all_get_topics_x_ugroup == 1){
if (!empty($w3all_phpbb_usession)) {
$ug = $w3all_phpbb_usession->group_id;
$ui = $w3all_phpbb_usession->user_id;
} else {
$ug = $ui = 1; // the default phpBB guest user group
}
# 16 ROLE_FORUM_NOACCESS into acl_roles table
# get all forums ids which the user have no permissions to read
$gaf = $w3all_phpbb_connection->get_results("SELECT AG.forum_id
FROM ".$w3all_config["table_prefix"]."acl_groups AS AG
JOIN ".$w3all_config["table_prefix"]."user_group AS UG ON( UG.user_id = ".$ui."
AND UG.group_id = AG.group_id
AND AG.auth_role_id = 16 )");
if(!empty($gaf)){
$gf = '';
foreach( $gaf as $v ){
$gf .= $v->forum_id.',';
}
$gf = substr($gf, 0, -1);
$topics_x_ugroup = "AND T.forum_id NOT IN(".$gf.")";
}
}
if ( preg_match('/^[0-9,]+$/', $w3all_exclude_phpbb_forums ))
{
$exp = explode(",", $w3all_exclude_phpbb_forums);
$exc_forums_list = '';
foreach($exp as $k => $v){
$exc_forums_list .= "'".$v."',";
}
$nfl = substr($exc_forums_list, 0, -1);
$exc_forums_list = "AND T.forum_id NOT IN(".$nfl.")";
} else { $exc_forums_list = ''; }
$topics = $w3all_phpbb_connection->get_results("SELECT
T.topic_id,T.forum_id,T.topic_title,T.topic_last_post_id,T.topic_last_poster_id,T.topic_last_poster_name,T.topic_last_post_time,
P.post_id,P.topic_id,P.forum_id,P.poster_id,P.post_time,P.post_username,P.post_subject,P.post_text,P.post_visibility,
U.user_id,U.username,U.user_email
FROM ".$w3all_config["table_prefix"]."topics AS T
JOIN ".$w3all_config["table_prefix"]."posts AS P on (T.topic_last_post_id = P.post_id and T.forum_id = P.forum_id)
JOIN ".$w3all_config["table_prefix"]."users AS U on U.user_id = T.topic_last_poster_id
WHERE T.topic_visibility = 1
".$exc_forums_list."
".$topics_x_ugroup."
AND P.post_visibility = 1
ORDER BY T.topic_last_post_time DESC
LIMIT 0,$ntopics");
$t = is_array($topics) ? serialize($topics) : serialize(array());
if(!defined("W3PHPBBLASTOPICS")){
define( "W3PHPBBLASTOPICS", $t ); // see also wp_w3all.php and wp_w3all_assoc_phpbb_wp_users in this class
}
return $topics;
}
1) the serialization of the resulting array, that since Php 7.2 (if not wrong) is not necessary because a CONSTANT can be array.
But it is really a secondary aspect soon resolved on next.
2) the fact that the new added Last Topics block widget for Gutenberg, seem to be hard to be hooked so to know earlier, the number of posts for each widget (all widgets that could co-exists into a page), and so to calculate and know the max num of posts to be retrieved, useful to not call the last topics function more times to get different number of topics/posts for each widget.
This seem very hard to be resolved, if not adding an option where an admin could put the max number of topics that will be retrieved.
Anyway the point has been fixed re-calling the function with the proper num of topics to be retrieved, whenever, and only if, into a page/post, there is more than one Last Posts widget, and in the case that the first instance, that retrieve posts through the Last Topics function, call the function with a num of posts that's minor, respect the second widget that will call same function on same page/post.
[EDITED]