public static function get_collections($onlysearchable = false) {
        global $DB;
        $cache = cache::make('core', 'tags');
        if (($tagcolls = $cache->get('tag_coll')) === false) {
            // Retrieve records from DB and create a default one if it is not present.
            $tagcolls = $DB->get_records('tag_coll', null, 'isdefault DESC, sortorder, id');
            if (empty($tagcolls)) {
                // When this method is called for the first time it automatically creates the default tag collection.
                $DB->insert_record('tag_coll', array('isdefault' => 1, 'sortorder' => 0));
                $tagcolls = $DB->get_records('tag_coll');
            } else {
                // Make sure sortorder is correct.
                $idx = 0;
                foreach ($tagcolls as $id => $tagcoll) {
                    if ($tagcoll->sortorder != $idx) {
                        $DB->update_record('tag_coll', array('sortorder' => $idx, 'id' => $id));
                        $tagcolls[$id]->sortorder = $idx;
                    }
                    $idx++;
                }
            }
            $cache->set('tag_coll', $tagcolls);
        }
        if ($onlysearchable) {
            $rv = array();
            foreach ($tagcolls as $id => $tagcoll) {
                if ($tagcoll->searchable) {
                    $rv[$id] = $tagcoll;
                }
            }
            return $rv;
        }
        return $tagcolls;
    }
public static function get_collections($onlysearchable = false) {
        global $DB;
        $cache = cache::make('core', 'tags');
        if (($tagcolls = $cache->get('tag_coll')) === false) {
            // Retrieve records from DB and create a default one if it is not present.
            $tagcolls = $DB->get_records('tag_coll', null, 'isdefault DESC, sortorder, id');
            if (empty($tagcolls)) {
                // When this method is called for the first time it automatically creates the default tag collection.
                $DB->insert_record('tag_coll', array('isdefault' => 1, 'sortorder' => 0));
                $tagcolls = $DB->get_records('tag_coll');
            } else {
                // Make sure sortorder is correct.
                $idx = 0;
                foreach ($tagcolls as $id => $tagcoll) {
                    if ($tagcoll->sortorder != $idx) {
                        $DB->update_record('tag_coll', array('sortorder' => $idx, 'id' => $id));
                        $tagcolls[$id]->sortorder = $idx;
                    }
                    $idx++;
                }
            }
            $cache->set('tag_coll', $tagcolls);
        }
        if ($onlysearchable) {
            $rv = array();
            foreach ($tagcolls as $id => $tagcoll) {
                if ($tagcoll->searchable) {
                    $rv[$id] = $tagcoll;
                }
            }
            return $rv;
        }
        return $tagcolls;
    }
public static function get_collections ( $ onlysearchable = false ) { global $ DB ; $ cache = cache :: make ( 'core' , 'tags' ) ; if ( ( $ tagcolls = $ cache -> get ( 'tag_coll' ) ) === false ) { // Retrieve records from DB and create a default one if it is not present. $ tagcolls = $ DB -> get_records ( 'tag_coll' , null , 'isdefault DESC, sortorder, id' ) ; if ( empty ( $ tagcolls ) ) { // When this method is called for the first time it automatically creates the default tag collection. $ DB -> insert_record ( 'tag_coll' , array ( 'isdefault' => 1 , 'sortorder' => 0 ) ) ; $ tagcolls = $ DB -> get_records ( 'tag_coll' ) ; } else { // Make sure sortorder is correct. $ idx = 0 ; foreach ( $ tagcolls as $ id => $ tagcoll ) { if ( $ tagcoll -> sortorder != $ idx ) { $ DB -> update_record ( 'tag_coll' , array ( 'sortorder' => $ idx , 'id' => $ id ) ) ; $ tagcolls [ $ id ] -> sortorder = $ idx ; } $ idx ++ ; } } $ cache -> set ( 'tag_coll' , $ tagcolls ) ; } if ( $ onlysearchable ) { $ rv = array ( ) ; foreach ( $ tagcolls as $ id => $ tagcoll ) { if ( $ tagcoll -> searchable ) { $ rv [ $ id ] = $ tagcoll ; } } return $ rv ; } return $ tagcolls ; }
Returns the list of tag collections defined in the system.

@param bool $onlysearchable only return collections that can be searched.
@return array array of objects where each object has properties: id, name, isdefault, itemtypes, sortorder
Returns the list of tag collections defined in the system .