Return the list of available search areas.

@param bool $enabled Return only the enabled ones.
@return \core_search\base[]
334959
public static function get_search_areas_list($enabled = false) {

        // Two different arrays, we don't expect these arrays to be big.
        if (static::$allsearchareas !== null) {
            if (!$enabled) {
                return static::$allsearchareas;
            } else {
                return static::$enabledsearchareas;
            }
        }

        static::$allsearchareas = array();
        static::$enabledsearchareas = array();
        $searchclasses = \core_component::get_component_classes_in_namespace(null, 'search');

        foreach ($searchclasses as $classname => $classpath) {
            $areaname = substr(strrchr($classname, '\\'), 1);
            $componentname = strstr($classname, '\\', 1);
            if (!static::is_search_area($classname)) {
                continue;
            }

            $areaid = static::generate_areaid($componentname, $areaname);
            $searchclass = new $classname();
            static::$allsearchareas[$areaid] = $searchclass;
            if ($searchclass->is_enabled()) {
                static::$enabledsearchareas[$areaid] = $searchclass;
            }
        }

        if ($enabled) {
            return static::$enabledsearchareas;
        }
        return static::$allsearchareas;
    }
643085
public function getEnabledProviders()
    {
        $result = [];

        foreach (Port1HybridAuth::PROVIDERS as $provider) {
            if ((Boolean)$this->config->getByNamespace('Port1HybridAuth', strtolower($provider) . '_enabled')) {
                $label = $this->snippetManager->getNamespace('frontend/account/login')->get('SignInWith' . $provider);

                $result[$provider] = $label;
            }
        }
1192184
public function getAvailable(): array
    {
        $result = [];

        $dbLanguages = $this->find('list', ['keyField' => 'code', 'valueField' => 'name'])
                            ->where(['trashed IS' => null])
                            ->toArray();
        $supportedLanguages = $this->getSupported();
        $result = array_diff_assoc($supportedLanguages, $dbLanguages);

        return $result;
    }
657115
public static function getList($sorted = false, $activeOnly = false)
    {
        $list = [];
        $db = Loader::db();
        $q = $db->query('SELECT * FROM AuthenticationTypes'
            . ($activeOnly ? ' WHERE authTypeIsEnabled=1 ' : '')
            . ' ORDER BY ' . ($sorted ? 'authTypeDisplayOrder' : 'authTypeID'));
        while ($row = $q->fetchRow()) {
            $list[] = self::load($row);
        }

        return $list;
    }
301056
public static function get_all_models($enabled = false, $trained = false, $predictioncontext = false) {
        global $DB;

        $params = array();

        $sql = "SELECT am.* FROM {analytics_models} am";

        if ($enabled || $trained || $predictioncontext) {
            $conditions = [];
            if ($enabled) {
                $conditions[] = 'am.enabled = :enabled';
                $params['enabled'] = 1;
            }
            if ($trained) {
                $conditions[] = 'am.trained = :trained';
                $params['trained'] = 1;
            }
            if ($predictioncontext) {
                $conditions[] = "EXISTS (SELECT 'x'
                                           FROM {analytics_predictions} ap
                                          WHERE ap.modelid = am.id AND ap.contextid = :contextid)";
                $params['contextid'] = $predictioncontext->id;
            }
            $sql .= ' WHERE ' . implode(' AND ', $conditions);
        }
        $sql .= ' ORDER BY am.enabled DESC, am.timemodified DESC';

        $modelobjs = $DB->get_records_sql($sql, $params);

        $models = array();
        foreach ($modelobjs as $modelobj) {
            $model = new \core_analytics\model($modelobj);
            if ($model->is_available()) {
                $models[$modelobj->id] = $model;
            }
        }
        return $models;
    }
657967
public static function get_search_area_categories() {
        if (!isset(static::$searchareacategories)) {
            $categories = self::get_core_search_area_categories();

            // Go through all existing search areas and get categories they are assigned to.
            $areacategories = [];
            foreach (self::get_search_areas_list() as $searcharea) {
                foreach ($searcharea->get_category_names() as $categoryname) {
                    if (!key_exists($categoryname, $areacategories)) {
                        $areacategories[$categoryname] = [];
                    }

                    $areacategories[$categoryname][] = $searcharea;
                }
            }

            // Populate core categories by areas.
            foreach ($areacategories as $name => $searchareas) {
                if (key_exists($name, $categories)) {
                    $categories[$name]->set_areas($searchareas);
                } else {
                    throw new \coding_exception('Unknown core search area category ' . $name);
                }
            }

            // Get additional categories.
            $additionalcategories = self::get_additional_search_area_categories();
            foreach ($additionalcategories as $additionalcategory) {
                if (!key_exists($additionalcategory->get_name(), $categories)) {
                    $categories[$additionalcategory->get_name()] = $additionalcategory;
                }
            }

            // Remove categories without areas.
            foreach ($categories as $key => $category) {
                if (empty($category->get_areas())) {
                    unset($categories[$key]);
                }
            }

            // Sort categories by order.
            uasort($categories, function($category1, $category2) {
                return $category1->get_order() > $category2->get_order();
            });

            static::$searchareacategories = $categories;
        }

        return static::$searchareacategories;
    }
136927
public static function get_enabled_plugins() {
        $plugins = core_plugin_manager::instance()->get_installed_plugins('qbehaviour');
        if (!$plugins) {
            return array();
        }
        if ($disabled = get_config('question', 'disabledbehaviours')) {
            $disabled = explode(',', $disabled);
        } else {
            $disabled = array();
        }

        $enabled = array();
        foreach ($plugins as $plugin => $version) {
            if (in_array($plugin, $disabled)) {
                continue;
            }
            $enabled[$plugin] = $plugin;
        }

        return $enabled;
    }
51093
public static function getList($excluded = ['core_desktop'])
    {
        $result = [];
        $app = Application::getFacadeApplication();
        $db = $app->make(Connection::class);
        if (empty($excluded)) {
            $rs = $db->executeQuery('select btsID from BlockTypeSets order by btsDisplayOrder asc');
        } else {
            $rs = $db->executeQuery('select btsID from BlockTypeSets where btsHandle not in (?) order by btsDisplayOrder asc',
                [$excluded],
                [Connection::PARAM_STR_ARRAY]
            );
        }
        while (($btsID = $rs->fetchColumn()) !== false) {
            $result[] = static::getByID($btsID);
        }

        return $result;
    }
439613
public function includeInactive($enable = true)
    {
        $this->includeInactive = (bool) $enable;

        $this->refreshSettingDependentCriteria();

        return $this;
    }
1358115
protected static function doFindFilters(array $filters, array $enabledFilters, $all)
    {
        $reactivateFilters = [];

        foreach ($enabledFilters as $name => $filter) {
            if (\in_array($name, $filters, true) || $all) {
                $reactivateFilters[] = $name;
            }
        }

        return $reactivateFilters;
    }
525970
public function getBlocksFromAppliedBlockSets($area = null, $includeDisabled = false)
	{
		$blocks = ArrayList::create();
		$sets = $this->getAppliedSets();

		if (!$sets->count()) {
			return $blocks;
		}

		foreach ($sets as $set) {
			$setBlocks = $set->Blocks()->sort('Sort DESC');

			if (!$includeDisabled) {
				$setBlocks = $setBlocks->exclude('ID', $this->owner->DisabledBlocks()->column('ID'));
			}

			if ($area) {
				$setBlocks = $setBlocks->filter('BlockArea', $area);
			}

			$blocks->merge($setBlocks);
		}

		$blocks->removeDuplicates();

		return $blocks;
	}
478732
public function enabled($enabled = true)
    {
        if (is_bool($enabled)) {
            return $this->andWhere(['enabled' => $enabled == true ? 1 : 0]);
        }
        return $this;
    }
785134
private function getBelongTo(): array
    {
        $result = [];

        if (! isset($this->capabilities['action'][Utils::getTypeBelongs()])) {
            return $result;
        }

        $table = TableRegistry::getTableLocator()->get('RolesCapabilities.Capabilities');
        Assert::isInstanceOf($table, CapabilitiesTable::class);

        $groups = $table->getUserGroups($this->user['id']);
        // check user capabilities against action's belongs capabilities
        foreach ($this->capabilities['action'][Utils::getTypeBelongs()] as $capability) {
            if (in_array($capability->getName(), $this->capabilities['user'])) {
                // if user has owner capability for current action add appropriate conditions to where clause
                $result[$this->table->aliasField($capability->getField()) . ' IN'] = array_keys($groups);
            }
        }

        return $result;
    }
74435
public function enableCache($enabled = true)
    {
        if ($enabled && extension_loaded('apcu')) {
            $this->_cache = true;
        } else {
            $this->_cache = false;
        }

        return $this->_cache;
    }
896567
public function getAddons($active = false) {
        if ($active) {
            return array_keys($this->enabled);
        }
        return array_keys($this->addons);
    }
459024
public function get_config() {
        list($componentname, $varname) = $this->get_config_var_name();

        $config = [];
        $settingnames = self::get_settingnames();
        foreach ($settingnames as $name) {
            $config[$varname . $name] = get_config($componentname, $varname . $name);
        }

        // Search areas are enabled by default.
        if ($config[$varname . '_enabled'] === false) {
            $config[$varname . '_enabled'] = 1;
        }
        return $config;
    }
222652
public function getSiteRoles(bool $force = false) : CNabuSiteRoleList
    {
        if ($this->nb_site_role_list->isEmpty() || $force) {
            $this->nb_site_role_list->clear();
            $this->nb_site_role_list->merge(CNabuSiteRole::getSiteRolesForSite($this));
        }

        return $this->nb_site_role_list;
    }