/** * Singleton Method * * Returns an instance of OWA * * @return $owa object */ function &owa_getInstance() { static $owa; if (empty($owa)) { require_once OWA_BASE_CLASSES_DIR . 'owa_wp.php'; // create owa instance w/ config $owa = new owa_wp(); $owa->setSiteId(md5(get_settings('siteurl'))); $owa->setSetting('base', 'report_wrapper', 'wrapper_wordpress.tpl'); $owa->setSetting('base', 'link_template', '%s&%s'); $owa->setSetting('base', 'main_url', '../wp-admin/index.php?page=owa'); $owa->setSetting('base', 'main_absolute_url', get_bloginfo('url') . '/wp-admin/index.php?page=owa'); $owa->setSetting('base', 'action_url', get_bloginfo('url') . '/index.php?owa_specialAction'); $owa->setSetting('base', 'api_url', get_bloginfo('url') . '/index.php?owa_apiAction'); $owa->setSetting('base', 'is_embedded', true); // needed as old installs might have this turned on by default... $owa->setSetting('base', 'delay_first_hit', false); // Access WP current user object to check permissions //$current_user = owa_getCurrentWpUser(); //print_r($current_user); // Set OWA's current user info and mark as authenticated so that // downstream controllers don't have to authenticate //$cu->isInitialized = true; // register allowedSitesList filter $dispatch = owa_coreAPI::getEventDispatch(); // alternative auth method, sets auth status, role, and allowed sites list. $dispatch->attachFilter('auth_status', 'owa_wpAuthUser', 0); //print_r( $current_user ); } return $owa; }
/** * Singleton Method * * Returns an instance of OWA * * @return $owa object */ function &owa_getInstance() { static $owa; if (empty($owa)) { require_once OWA_BASE_CLASSES_DIR . 'owa_wp.php'; // create owa instance w/ config $owa = new owa_wp(); $owa->setSiteId(md5(get_settings('siteurl'))); $owa->setSetting('base', 'report_wrapper', 'wrapper_wordpress.tpl'); $owa->setSetting('base', 'link_template', '%s&%s'); $owa->setSetting('base', 'main_url', '../wp-admin/index.php?page=owa'); $owa->setSetting('base', 'main_absolute_url', get_bloginfo('url') . '/wp-admin/index.php?page=owa'); $owa->setSetting('base', 'action_url', get_bloginfo('url') . '/index.php?owa_specialAction'); $owa->setSetting('base', 'api_url', get_bloginfo('url') . '/index.php?owa_apiAction'); $owa->setSetting('base', 'is_embedded', true); // needed as old installs might have this turned on by default... $owa->setSetting('base', 'delay_first_hit', false); // Access WP current user object to check permissions $current_user = owa_getCurrentWpUser(); //print_r($current_user); // Set OWA's current user info and mark as authenticated so that // downstream controllers don't have to authenticate $cu =& owa_coreAPI::getCurrentUser(); if (isset($current_user->user_login)) { $cu->setUserData('user_id', $current_user->user_login); owa_coreAPI::debug("Wordpress User_id: " . $current_user->user_login); } if (isset($current_user->user_email)) { $cu->setUserData('email_address', $current_user->user_email); } if (isset($current_user->first_name)) { $cu->setUserData('real_name', $current_user->first_name . ' ' . $current_user->last_name); $cu->setRole(owa_translate_role($current_user->roles)); } owa_coreAPI::debug("Wordpress User Role: " . print_r($current_user->roles, true)); owa_coreAPI::debug("Wordpress Translated OWA User Role: " . $cu->getRole()); $cu->setAuthStatus(true); } return $owa; }