Example #1
0
    /**
     * Initialise titania:
     *	Session management, Cache, Language ...
     *
     * @return void
     */
    public static function initialise()
    {
        global $starttime;
        self::$page = htmlspecialchars(phpbb::$user->page['script_path'] . phpbb::$user->page['page_name']);
        self::$time = (int) $starttime;
        // Instantiate cache
        if (!class_exists('titania_cache')) {
            include TITANIA_ROOT . 'includes/core/cache.' . PHP_EXT;
        }
        self::$cache = new titania_cache();
        // Set the absolute titania/board path
        self::$absolute_path = generate_board_url(true) . '/' . self::$config->titania_script_path;
        self::$absolute_board = generate_board_url(true) . '/' . self::$config->phpbb_script_path;
        // Set the style path, template path, and template name
        if (!defined('IN_TITANIA_INSTALL') && !defined('USE_PHPBB_TEMPLATE')) {
            self::$images_path = self::$absolute_path . 'images/';
            self::$style_path = self::$absolute_path . 'styles/' . self::$config->style . '/';
            self::$template_path = self::$style_path . 'template';
            self::$theme_path = self::$style_path . 'theme';
            // Set the paths for phpBB
            self::set_custom_template();
        }
        // Setup the Access Level
        self::$access_level = TITANIA_ACCESS_PUBLIC;
        // The user might be in a group with team access even if it's not his default group.
        $group_ids = implode(', ', self::$config->team_groups);
        $sql = 'SELECT group_id, user_id, user_pending FROM ' . USER_GROUP_TABLE . '
				WHERE user_id = ' . phpbb::$user->data['user_id'] . '
				AND user_pending = 0
				AND group_id IN (' . $group_ids . ')';
        $result = phpbb::$db->sql_query_limit($sql, 1);
        if ($group_id = phpbb::$db->sql_fetchfield('group_id')) {
            self::$access_level = TITANIA_ACCESS_TEAMS;
        }
        phpbb::$db->sql_freeresult($result);
        // Add common titania language file
        self::add_lang('common');
        // Load the contrib types
        self::_include('types/base');
        titania_types::load_types();
        // Initialise the URL class
        titania_url::$root_url = self::$absolute_path;
        titania_url::decode_url(self::$config->titania_script_path);
        // Generate the root breadcrumb that displays on every page
        self::generate_breadcrumbs(array('CUSTOMISATION_DATABASE' => titania_url::build_url('')));
        // Load hooks
        self::load_hooks();
    }