/** * A hook that is used to initialise the Subject Prefix core * @param phpbb_hook $phpbb_hook The phpBB hook object * @return void */ public static function subject_prefix_init(&$hook) { // Load the phpBB class if (!class_exists('sp_phpbb')) { global $phpbb_root_path, $phpEx; require $phpbb_root_path . 'includes/mods/subject_prefix/sp_phpbb.' . $phpEx; sp_phpbb::init(); } // Load the Subject Prefix cache if (!class_exists('sp_cache')) { require PHPBB_ROOT_PATH . 'includes/mods/subject_prefix/sp_cache.' . PHP_EXT; } // Load the Subject Prefix core if (!class_exists('sp_core')) { require PHPBB_ROOT_PATH . 'includes/mods/subject_prefix/sp_core.' . PHP_EXT; sp_core::init(); } }
} // Fetch from the cache $sql_ary = array('SELECT' => 'f.forum_id, f.forum_name, sp.*, spt.prefix_order', 'FROM' => array(SUBJECT_PREFIX_TABLE => 'sp', SUBJECT_PREFIX_FORUMS_TABLE => 'spt'), 'LEFT_JOIN' => array(array('FROM' => array(FORUMS_TABLE => 'f'), 'ON' => 'f.forum_id = spt.forum_id')), 'WHERE' => 'spt.prefix_id = sp.prefix_id', 'ORDER_BY' => 'spt.prefix_order'); $result = sp_phpbb::$db->sql_query(sp_phpbb::$db->sql_build_query('SELECT', $sql_ary)); while ($row = sp_phpbb::$db->sql_fetchrow($result)) { if (!isset($_pft['tree'][$row['forum_id']])) { $_pft['tree'][$row['forum_id']] = array(); $_pft['forums'][$row['forum_id']] = $row['forum_name']; } $_pft['tree'][$row['forum_id']][$row['prefix_id']] = array('prefix_id' => $row['prefix_id'], 'prefix_title' => $row['prefix_title'], 'prefix_colour' => $row['prefix_colour'], 'prefix_order' => $row['prefix_order']); } sp_phpbb::$db->sql_freeresult($result); // Cache $this->put('_prefix_forum_tree', $_pft); // Send back $tree = $_pft['tree']; $forums = $_pft['forums']; } /** * One method all gone */ public static function subject_prefix_quick_clear() { sp_phpbb::$cache->destroy('_subject_prefixes'); sp_phpbb::$cache->destroy('_prefix_forum_tree'); } } // Drop the phpBB cache and overwrite it with the custom cache sp_phpbb::$cache = null; sp_phpbb::$cache = new sp_cache();