Select users with a_ or m_

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1942
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Select users with a_ or m_

Post by kinerity » Fri Oct 19, 2018 4:25 pm

I need to filter out a list of users with a_ or m_ permissions, but not sure how to go about this with the SQL below.

Code: Select all

$sql = 'SELECT user_id
    FROM ' . USERS_TABLE . '
    WHERE ' . $db->sql_in_set('user_id', $array) . "
        AND user_id <> " . $this->user->data['user_id'];
$result = $this->db->sql_query($sql);
while ($row = $this->db->sql_fetchrow($result))
{
    unset($array[$row['user_id']]);
}
Kailey Truscott - Community Team

User avatar
RMcGirr83
Recognised Extension Developer
Posts: 20953
Joined: Wed Jun 22, 2005 4:33 pm
Location: Your display
Name: Rich McGirr
Contact:

Re: Select users with a_ or m_

Post by RMcGirr83 » Fri Oct 19, 2018 6:13 pm

Look on GitHub for my stop forum spam extension. Within core there is sfsgroups which should help.
In times of change, learners inherit the earth, while the learned find themselves beautifully equipped to deal with a world that no longer exists - Eric Hoffer
Former Modifications/Extensions Team Member | My extensions
Appreciate the extensions/mods/support then buy me a beer
All requests for support via PM will be ignored

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1942
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Select users with a_ or m_

Post by kinerity » Fri Oct 19, 2018 6:35 pm

That does, thanks a bunch!
Kailey Truscott - Community Team

User avatar
Toxyy
Registered User
Posts: 542
Joined: Mon Oct 24, 2016 3:22 pm
Contact:

Re: Select users with a_ or m_

Post by Toxyy » Fri Oct 19, 2018 9:24 pm

Code: Select all

$admins = $this->auth->acl_get_list(false, 'a_', false);
$mods = $this->auth->acl_get_list(false, 'm_', false);
This is expensive to run so keep it to once per page if you can.
Last edited by Toxyy on Fri Oct 19, 2018 9:38 pm, edited 1 time in total.
I am a web developer/administrator, specializing in forums. If you have work you need done or are too lazy to do, pm me!

My extensions:
[3.2][BETA] Anonymous Posts || [3.2][RC] Show User Activity

User avatar
kinerity
Community Team Member
Community Team Member
Posts: 1942
Joined: Mon Sep 01, 2014 1:00 am
Location: sudo rm -rf /
Name: Kailey Truscott
Contact:

Re: Select users with a_ or m_

Post by kinerity » Fri Oct 19, 2018 11:20 pm

I plan on it as well as using caching. Thanks for the input though. ;)
Kailey Truscott - Community Team

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: Toxyy and 8 guests