How To Predispose Your October CMS Backend List Views To Filtering

Posted By: admin

Published to Programming on Jul 05, 2014


Recently in developing our upcoming Helpdesk product for October CMS I had a need to filter backend list results based on the currently viewing user. There was not much in the way of info on how to do this.

You can use the listExtendQuery() from your backend controller.

So for my Tickets list, I first call the index() method and make the list.

    public function index()
        $this->bodyClass = 'slim-container';

Now that we have an active list, I can use the listExtendQuery() to check permissions and filter my Ticket List accordingly:

    public function listExtendQuery($query, $definition = null){
        $user = BackendAuth::getUser();
        if (!$user->hasAccess('radiantweb.helpdesk.access_helpdesk_all_tickets'))
            $uID = $user->id;
            $query->where('assigned_to', '=', $user->id);

Now my list view filters only tickets assigned to the currently viewing user if that user is not an admin or is not in the access_helpdesk_all_tickets permissions group.

Tags: Backend, Lists, Plugins

blog comments powered by Disqus