Exemplo n.º 1
0
/**
 * OWA Singelton
 *
 * Needed to avoid OWA loading for every mediawiki request
 */
function owa_singleton()
{
    static $owa;
    if (empty($owa)) {
        global $wgUser, $wgServer, $wgScriptPath, $wgScript, $wgMainCacheType, $wgMemCachedServers, $wgOwaSiteId, $wgOwaMemCachedServers;
        /* OWA CONFIGURATION OVERRIDES */
        $owa_config = array();
        // check for memcache. these need to be passed into OWA to avoid race condition.
        if ($wgMainCacheType === CACHE_MEMCACHED) {
            $owa_config['cacheType'] = 'memcached';
            $owa_config['memcachedServers'] = $wgMemCachedServers;
        }
        $owa = new owa_mw($owa_config);
        $owa->setSetting('base', 'report_wrapper', 'wrapper_mediawiki.tpl');
        $owa->setSetting('base', 'main_url', $wgScriptPath . '/index.php?title=Special:Owa');
        $owa->setSetting('base', 'main_absolute_url', $wgServer . $owa->getSetting('base', 'main_url'));
        $owa->setSetting('base', 'action_url', $wgServer . $wgScriptPath . '/index.php?action=owa&owa_specialAction');
        $owa->setSetting('base', 'api_url', $wgServer . $wgScriptPath . '/index.php?action=owa&owa_apiAction');
        $owa->setSetting('base', 'link_template', '%s&%s');
        $owa->setSetting('base', 'is_embedded', true);
        $owa->setSetting('base', 'query_string_filters', 'returnto');
        $owa->setSetting('base', 'delay_first_hit', false);
        if (!$wgOwaSiteId) {
            $wgOwaSiteId = md5($wgServer . $wgScriptPath);
        }
        $owa->setSiteId($wgOwaSiteId);
        // filter authentication
        $dispatch = owa_coreAPI::getEventDispatch();
        // alternative auth method, sets auth status, role, and allowed sites list.
        $dispatch->attachFilter('auth_status', 'owa_mwAuthUser', 0);
        //print_r( $current_user );
    }
    return $owa;
}
/**
 * OWA Singelton
 *
 * Needed to avoid OWA loading for every mediawiki request
 */
function owa_singleton()
{
    static $owa;
    if (empty($owa)) {
        global $wgUser, $wgServer, $wgScriptPath, $wgScript, $wgMainCacheType, $wgMemCachedServers, $wgOwaSiteId, $wgOwaMemCachedServers;
        /* OWA CONFIGURATION OVERRIDES */
        $owa_config = array();
        // check for memcache. these need to be passed into OWA to avoid race condition.
        if ($wgMainCacheType === CACHE_MEMCACHED) {
            $owa_config['cacheType'] = 'memcached';
            $owa_config['memcachedServers'] = $wgMemCachedServers;
        }
        $owa = new owa_mw($owa_config);
        $owa->setSetting('base', 'report_wrapper', 'wrapper_mediawiki.tpl');
        $owa->setSetting('base', 'main_url', $wgScriptPath . '/index.php?title=Special:Owa');
        $owa->setSetting('base', 'main_absolute_url', $wgServer . $owa->getSetting('base', 'main_url'));
        $owa->setSetting('base', 'action_url', $wgServer . $wgScriptPath . '/index.php?action=owa&owa_specialAction');
        $owa->setSetting('base', 'api_url', $wgServer . $wgScriptPath . '/index.php?action=owa&owa_apiAction');
        $owa->setSetting('base', 'link_template', '%s&%s');
        $owa->setSetting('base', 'is_embedded', true);
        $owa->setSetting('base', 'query_string_filters', 'returnto');
        $owa->setSetting('base', 'delay_first_hit', false);
        if (!$wgOwaSiteId) {
            $wgOwaSiteId = md5($wgServer . $wgScriptPath);
        }
        $owa->setSiteId($wgOwaSiteId);
        /**
         * Populates OWA's current user object with info about the current mediawiki user.
         * This info is needed by OWA authentication system as well as to add dimensions
         * requests that are logged.
         */
        $cu =& owa_coreAPI::getCurrentUser();
        $cu->setUserData('user_id', $wgUser->getName());
        $cu->setUserData('email_address', $wgUser->getEmail());
        $cu->setUserData('real_name', $wgUser->getRealName());
        $cu->setRole(owa_translate_role($wgUser->getGroups()));
        $cu->setAuthStatus(true);
    }
    return $owa;
}