Jon W
Well-known member
In XenForo_ControllerHelper_UserCriteria, there is a filter that checks whether all user states are ticked and, if so, unsets the criteria. This is done by checking whether there are EXACTLY 4 that are ticked, as follows:
This makes it difficult for a developer to add new user criteria, because it means that we have to add some sort of hack to any controller that calls that helper and add back the criteria (or something similar).
It would be much nicer if that number 4 was calculated by counting a static array of all the user states inside that helper (or something similar).
In other words, you would change to:
and then add:
to the top of the class.
The array of $userStates could then be easily added to by any add-on to get a correct count.
PHP:
if (isset($criteria['user_state']) && is_array($criteria['user_state']) && count($criteria['user_state']) == 4)
{
// all types selected, no filtering
unset($criteria['user_state']);
}
This makes it difficult for a developer to add new user criteria, because it means that we have to add some sort of hack to any controller that calls that helper and add back the criteria (or something similar).
It would be much nicer if that number 4 was calculated by counting a static array of all the user states inside that helper (or something similar).
In other words, you would change to:
PHP:
if (isset($criteria['user_state']) && is_array($criteria['user_state']) && count($criteria['user_state']) == count(self::$userStates))
{
// all types selected, no filtering
unset($criteria['user_state']);
}
PHP:
public static $userStates = array('email_confirm','email_confirm_edit','moderated','valid');
The array of $userStates could then be easily added to by any add-on to get a correct count.
Last edited:
Upvote
1