Example #1
0
    /**
     * Loads all board names from the forum into a variable and cache (if possible)
     * This helps reduce the number of queries needed for SimpleSEF to run
     *
     * @global array $smcFunc
     * @global string $language
     * @param boolean $force Forces a reload of board names
     */
    private static function loadBoardNames($force = FALSE)
    {
        global $language;
        if ($force || (self::$boardNames = CacheAPI::getCache('simplesef_board_list', 3600)) == NULL) {
            loadLanguage('index', $language, false);
            $request = smf_db_query('
				SELECT id_board, name
				FROM {db_prefix}boards', array());
            $boards = array();
            while ($row = mysql_fetch_assoc($request)) {
                // A bit extra overhead to account for duplicate board names
                $temp_name = self::encode($row['name']);
                $i = 0;
                while (!empty($boards[$temp_name . (!empty($i) ? $i + 1 : '')])) {
                    $i++;
                }
                //$boards[$temp_name . (!empty($i) ? $i + 1 : '')] = $row['id_board'];
                $boards[$temp_name . '.' . trim($row['id_board'])] = $row['id_board'];
            }
            mysql_free_result($request);
            self::$boardNames = array_flip($boards);
            // Add one to the query cound and put the data into the cache
            self::$queryCount++;
            CacheAPI::putCache('simplesef_board_list', self::$boardNames, 3600);
            //self::log('Cache hit failed, reloading board names');
        }
    }