tenants
Well-known member
I'm using template hooks to add a tab to the profile area, this requires 2 template hooks
1) For the tab name (member_view_tabs_heading)
2) For the tab content (member_view_tabs_content)
To get the permissions of the user (profile), it looks like I may need to do at least 1 additional query since looking at
global_permission_cache is not available for the ['user'] only the ['visitor']
To get the user permissions of the user, I could use:
But, this is probably unnecessary... and we don't need to get the user again (just the permissions)
Also, this would need to be applied in 2 areas:
member_view_tabs_heading and member_view_tabs_content, since if it wasn't applied in the content, the li order will go out of synch for the Tabs data-panes functionality (the ajax loading of the Tabs)
This would boost the query count for the profile area from 15 to 17 (that's before creating templates)
For the tab title and url, I am avoiding creating the template and getting the request path from the global params:
Not using $template->create seems to reduce the query count by one (and we no longer need to cache the template... this is good for titles / simple bits of data)
I'm wondering what others have done when needing to get the permissions of the profile user you are looking at (not the visitor) ... at most I think 1 additional query is needed (it's possible that the permissions of the user is already available, but I couldn't find it)
I've noticed that if people aren't careful in this area, adding bits (such as creating templates, query for user permissions, and getting counts for the stats) can quickly bloat this area, so I think a 0-1 query overhead for this area is important (even if we need to get the user permissions)
I have seen at least 2 add-ons increase this area from 15 to 20 queries (both add-ons together increase it from 15 to 25... that's hideous for just 2 add-ons)
1) For the tab name (member_view_tabs_heading)
2) For the tab content (member_view_tabs_content)
To get the permissions of the user (profile), it looks like I may need to do at least 1 additional query since looking at
Code:
$globalParams = $template->getParams();
To get the user permissions of the user, I could use:
Code:
$globalParams = $template->getParams();
$userModel = XenForo_Model::create('XenForo_Model_User');
$profileUser = $userModel->getUserById($globalParams['user']['user_id'], array(
'join' => XenForo_Model_User::FETCH_USER_PERMISSIONS
));
But, this is probably unnecessary... and we don't need to get the user again (just the permissions)
Also, this would need to be applied in 2 areas:
member_view_tabs_heading and member_view_tabs_content, since if it wasn't applied in the content, the li order will go out of synch for the Tabs data-panes functionality (the ajax loading of the Tabs)
This would boost the query count for the profile area from 15 to 17 (that's before creating templates)
For the tab title and url, I am avoiding creating the template and getting the request path from the global params:
Code:
$globalParams = $template->getParams();
$requestPaths = $globalParams["requestPaths"];
$contents = '<li><a href="' . $requestPaths['requestUri'] . '#tabname">tabname</a></li>'. $contents;
Not using $template->create seems to reduce the query count by one (and we no longer need to cache the template... this is good for titles / simple bits of data)
I'm wondering what others have done when needing to get the permissions of the profile user you are looking at (not the visitor) ... at most I think 1 additional query is needed (it's possible that the permissions of the user is already available, but I couldn't find it)
I've noticed that if people aren't careful in this area, adding bits (such as creating templates, query for user permissions, and getting counts for the stats) can quickly bloat this area, so I think a 0-1 query overhead for this area is important (even if we need to get the user permissions)
I have seen at least 2 add-ons increase this area from 15 to 20 queries (both add-ons together increase it from 15 to 25... that's hideous for just 2 add-ons)
Last edited: