public function get_menus($access = null) { if (!is_array($access)) { $access[0] = 0; /* everyone */ } $menus = []; if ($access != NULL) { $key = $this->cache_prefix . '_' . o::filesafe(ci()->user->role_name); if (!($cache = ci()->cache->get($key))) { $cache = []; $results = $this->order_by('sort')->get_many_by('active', 1); foreach ((array) $results as $row) { $cache[$row->id] = $row; } ci()->cache->save($key, $cache); } /* does the user have access to this menu? */ foreach ($cache as $id => $rec) { /* access is the complete array */ if (in_array($rec->access_id, $access)) { $menus[$rec->id] = $rec; } } } return $menus; }