本文整理汇总了PHP中owa_coreAPI::getCurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP owa_coreAPI::getCurrentUser方法的具体用法?PHP owa_coreAPI::getCurrentUser怎么用?PHP owa_coreAPI::getCurrentUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类owa_coreAPI
的用法示例。
在下文中一共展示了owa_coreAPI::getCurrentUser方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: action
function action()
{
$cu = owa_coreAPI::getCurrentUser();
$this->set('go', $this->getParam('go'));
$this->set('user_id', $cu->getUserData('user_id'));
$this->setView('base.loginForm');
}
示例2: action
function action()
{
$service =& owa_coreAPI::serviceSingleton();
$this->e->notice('starting Embedded install');
//create config file
$this->c->createConfigFile($this->params);
$this->c->applyConfigConstants();
// install schema
$base = $service->getModule('base');
$status = $base->install();
// schema was installed successfully
if ($status === true) {
//create admin user
$cu = owa_coreAPI::getCurrentUser();
$this->createAdminUser($cu->getUserData('email_address'), $cu->getUserData('real_name'));
// create default site
$this->createDefaultSite($this->getParam('domain'), $this->getParam('name'), $this->getParam('description'), $this->getParam('site_family'), $this->getParam('site_id'));
// Persist install complete flag.
$this->c->persistSetting('base', 'install_complete', true);
$save_status = $this->c->save();
if ($save_status === true) {
$this->e->notice('Install Complete Flag added to configuration');
} else {
$this->e->notice('Could not persist Install Complete Flag to the Database');
}
$this->setView('base.installFinishEmbedded');
// schema was not installed successfully
} else {
$this->e->notice('Aborting embedded install due to errors installing schema. Try dropping all OWA tables and try again.');
return false;
}
}
示例3: up
function up()
{
// create admin user for embedded installs.
// embedded installs did not create admin users until this release (v1.2.1)
$cu = owa_coreAPI::getCurrentUser();
$this->createAdminUser($cu->getUserData('email_address'));
$ds = owa_coreAPI::entityFactory('base.domstream');
$ret = $ds->createTable();
if ($ret == true) {
$this->e->notice('Domstream entity table created');
return true;
} else {
$this->e->notice('Domstream entity table creation failed');
return false;
}
}
示例4: setEmailAddress
static function setEmailAddress($email_address, $event)
{
if (owa_coreAPI::getSetting('base', 'log_visitor_pii')) {
$cu = owa_coreAPI::getCurrentUser();
return $cu->user->get('email_address');
}
}
示例5: createNonce
public static function createNonce($action)
{
$time = owa_coreAPI::getNonceTimeInterval();
$cu = owa_coreAPI::getCurrentUser();
$user_id = $cu->getUserData('user_id');
$full_nonce = $time . $action . $user_id . 'owa_nonce';
$nonce = substr(owa_coreAPI::saltedHash($full_nonce, 'nonce'), -12, 10);
return $nonce;
}
示例6: getCurrentUser
function getCurrentUser()
{
return owa_coreAPI::getCurrentUser();
}
示例7: pre
//.........这里部分代码省略.........
/* moved */
$this->event->set('is_browser', true);
/* moved */
$this->event->set('browser_type', $this->eq->filter('browser_type', $bcap->getUaFamily()));
/* moved */
if ($bcap->getUaVersion()) {
$this->event->set('browser', $this->eq->filter('browser', $bcap->getUaVersion()));
} else {
$this->event->set('browser', $this->eq->filter('browser', '(unknown)'));
}
//Check for what kind of page request this is
/* moved */
if ($bcap->isRobot()) {
$this->event->set('is_robot', true);
$this->event->set('is_browser', false);
}
/* moved */
$this->event->set('os', $this->eq->filter('operating_system', $bcap->getOsFamily(), $this->event->get('HTTP_USER_AGENT')));
/*moved */
if ($this->event->get('is_new_session')) {
//mark entry page flag on current request
$this->event->set('is_entry_page', true);
}
/* moved */
$this->setGeolocation();
// set prior page properties
/* moved */
if ($this->event->get('HTTP_REFERER')) {
$referer_parse = owa_lib::parse_url($this->event->get('HTTP_REFERER'));
if ($referer_parse['host'] === $page_parse['host']) {
$this->event->set('prior_page', $this->eq->filter('prior_page', $this->event->get('HTTP_REFERER'), $this->event->get('site_id')));
}
}
// set search terms
/* moved */
$search_terms = $this->event->get('search_terms');
if ($search_terms && $search_terms != '(not set)') {
$this->event->set('search_terms', $this->eq->filter('search_terms', trim(strtolower($this->event->get('search_terms')))));
}
// ID GENERATION
//set user agent id
/* moved */
$this->event->set('ua_id', owa_lib::setStringGuid($this->event->get('HTTP_USER_AGENT')));
// set document/page id
/* moved */
if ($this->event->get('page_url')) {
$this->event->set('document_id', owa_lib::setStringGuid($this->event->get('page_url')));
}
// Generate host_id
/* moved */
$this->event->set('host_id', owa_lib::setStringGuid($this->event->get('host')));
// generate os_id
/* moved */
$this->event->set('os_id', owa_lib::setStringGuid($this->event->get('os')));
/* moved */
if ($this->event->get('campaign')) {
$this->event->set('campaign_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('campaign')))));
}
/* moved */
if ($this->event->get('ad')) {
$this->event->set('ad_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('ad')))));
}
/* moved */
if ($this->event->get('source')) {
$this->event->set('source_id', owa_lib::setStringGuid($this->event->get('source')));
}
// set session referer (the site that originally referer the visit)
/* moved */
if ($this->event->get('session_referer')) {
// generate referer_id for downstream handlers
$this->event->set('referer_id', owa_lib::setStringGuid($this->event->get('session_referer')));
}
/* moved */
if ($this->event->get('search_terms')) {
$this->event->set('referring_search_term_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('search_terms')))));
}
// SHOULD BE A FILTER
// record and filter personally identifiable info (PII)
if (owa_coreAPI::getSetting('base', 'log_visitor_pii')) {
// set user name if one does not already exist on event
/* moved */
if (!$this->event->get('user_name') && owa_coreAPI::getSetting('base', 'log_owa_user_names')) {
$cu = owa_coreAPI::getCurrentUser();
$this->event->set('user_name', $cu->user->get('user_id'));
}
$this->event->set('user_name', $this->eq->filter('user_name', $this->event->get('user_name')));
// set email_address if one does not already exist on event
/* moved */
if (!$this->event->get('email_address')) {
$cu = owa_coreAPI::getCurrentUser();
$this->event->set('email_address', $cu->user->get('email_address'));
}
$this->event->set('user_email', $this->eq->filter('user_email', $this->event->get('email_address')));
}
// anonymize Ip address
if (owa_coreAPI::getSetting('base', 'anonymize_ips')) {
$this->event->set('ip_address', $this->anonymizeIpAddress($this->event->get('ip_address')));
$this->event->set('full_host', '(not set)');
}
}
示例8: setCurrentUser
function setCurrentUser($role, $login_name = '')
{
$cu =& owa_coreAPI::getCurrentUser();
$cu->setRole($role);
$cu->setAuthStatus(true);
}
示例9: owa_wpAuthUser
/**
* OWA authentication filter method
*
* This filter function authenticates the user and populates the
* the current user in OWA with the proper role, and allowed sites list.
*
* This method kicks in after all over OWA's built in auth methods have failed
* in the owa_auth class.
*
* @param $auth_status boolean
* @return $auth_status boolean
*/
function owa_wpAuthUser($auth_status)
{
$current_user = wp_get_current_user();
if ($current_user instanceof WP_User) {
// logged in, authenticated
$cu = owa_coreAPI::getCurrentUser();
$cu->setAuthStatus(true);
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());
// fetch the list of allowed blogs from WP
$domains = array();
$allowedBlogs = get_blogs_of_user($current_user->ID);
foreach ($allowedBlogs as $blog) {
$domains[] = $blog->siteurl;
}
// check to see if we are installing before trying to load sites
// other wise you run into a race condition as config file
// might not be created.
if (!defined('OWA_INSTALLING')) {
// load assigned sites list by domain
$cu->loadAssignedSitesByDomain($domains);
}
$cu->setInitialized();
return true;
} else {
// not logged in to WP and therefor not authenticated
return false;
}
}
示例10: owa_mwAuthUser
/**
* 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.
*/
function owa_mwAuthUser($auth_status)
{
global $wgUser, $wgOwaSiteId;
if ($wgUser->isLoggedIn()) {
$cu = owa_coreAPI::getCurrentUser();
$cu->setAuthStatus(true);
$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()));
// set list of allowed sites. In this case it's only this wiki.
$domains = array($wgOwaSiteId);
// load assigned sites list by domain
$cu->loadAssignedSitesByDomain($domains);
$cu->setInitialized();
return true;
} else {
// not logged in
return false;
}
}
示例11: isUser
/**
* Checks to see if the user credentials match a real user object in the DB
*
* @return boolean
*/
function isUser()
{
// get current user
$cu =& owa_coreAPI::getCurrentUser();
// fetches user object from DB
$this->getUser();
if ($this->credentials['user_id'] === $this->u->get('user_id')) {
if ($this->credentials['password'] === $this->u->get('password')) {
$this->_is_user = true;
// set as new current user in service layer
$cu->loadNewUserByObject($this->u);
$cu->setAuthStatus(true);
return true;
} else {
$this->_is_user = false;
return false;
}
} else {
$this->_is_user = false;
return false;
}
}
示例12: owa_wp
/**
* 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;
}
示例13: getSitesAllowedForCurrentUser
/**
* Returns array of owa_site entities where the current user has access to, taken the current controller cap into account
* @return array
*/
protected function getSitesAllowedForCurrentUser()
{
owa_coreAPI::debug('get Sites Allowed for user');
$currentUser = owa_coreAPI::getCurrentUser();
if ($currentUser->isAnonymousUser() || $currentUser->isAdmin()) {
$result = array();
$relations = owa_coreAPI::getSitesList();
foreach ($relations as $siteRow) {
$site = owa_coreAPI::entityFactory('base.site');
owa_coreAPI::debug('getSitesAllowedforuser');
$site->load($siteRow['id']);
$result[$siteRow['site_id']] = $site;
}
return $result;
} else {
return $currentUser->getAssignedSites();
}
}
示例14: owa_singleton
/**
* 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;
}
示例15: pre
//.........这里部分代码省略.........
// Set Ip Address
if (!$this->event->get('ip_address')) {
$this->event->set('ip_address', owa_coreAPI::getServerParam('REMOTE_ADDR'));
}
$this->event->set('ip_address', $this->eq->filter('ip_address', $this->event->get('ip_address')));
// check to see if IP should be excluded
if ($this->isIpAddressExcluded($this->event->get('ip_address'))) {
$this->event->set('do_not_log', true);
return;
}
// Set host related properties
if (!$this->event->get('REMOTE_HOST')) {
$this->event->set('REMOTE_HOST', owa_coreAPI::getServerParam('REMOTE_HOST'));
}
// host properties
$this->event->set('full_host', $this->eq->filter('full_host', $this->event->get('REMOTE_HOST'), $this->event->get('ip_address')));
if (!$this->event->get('full_host')) {
$this->event->set('full_host', '(not set)');
}
$this->event->set('host', $this->eq->filter('host', $this->event->get('full_host'), $this->event->get('ip_address')));
if (!$this->event->get('host')) {
$this->event->set('host', '(not set)');
}
// Generate host_id
$this->event->set('host_id', owa_lib::setStringGuid($this->event->get('host')));
// Browser related properties
$service = owa_coreAPI::serviceSingleton();
$bcap = $service->getBrowscap();
// Assume browser untill told otherwise
$this->event->set('is_browser', true);
$this->event->set('browser_type', $this->eq->filter('browser_type', $bcap->get('Browser')));
if ($bcap->get('Version')) {
$this->event->set('browser', $this->eq->filter('browser', $bcap->get('Browser') . ' ' . $bcap->get('Version')));
} else {
$this->event->set('browser', $this->eq->filter('browser', $bcap->get('Browser')));
}
// Set Operating System
$this->event->set('os', $this->eq->filter('operating_system', $bcap->get('Platform'), $this->event->get('HTTP_USER_AGENT')));
$this->event->set('os_id', owa_lib::setStringGuid($this->event->get('os')));
//Check for what kind of page request this is
if ($bcap->get('Crawler')) {
$this->event->set('is_robot', true);
$this->event->set('is_browser', false);
}
// feed request properties
$et = $this->event->getEventType();
if ($et === 'base.feed_request') {
// Feed subscription tracking code
if (!$this->event->get('feed_subscription_id')) {
$this->event->set('feed_subscription_id', $this->getParam(owa_coreAPI::getSetting('base', 'feed_subscription_param')));
}
// needed??
$this->event->set('feed_reader_guid', $this->event->setEnvGUID());
// set feedreader flag to true, browser flag to false
$this->event->set('is_feedreader', true);
$this->event->set('is_browser', false);
}
// record and filter personally identifiable info (PII)
if (owa_coreAPI::getSetting('base', 'log_visitor_pii')) {
// set user name if one does not already exist on event
if (!$this->event->get('user_name') && owa_coreAPI::getSetting('base', 'log_owa_user_names')) {
$cu = owa_coreAPI::getCurrentUser();
$this->event->set('user_name', $cu->user->get('user_id'));
}
$this->event->set('user_name', $this->eq->filter('user_name', $this->event->get('user_name')));
// set email_address if one does not already exist on event
if (!$this->event->get('email_address')) {
$cu = owa_coreAPI::getCurrentUser();
$this->event->set('email_address', $cu->user->get('email_address'));
}
$this->event->set('user_email', $this->eq->filter('user_email', $this->event->get('email_address')));
}
$this->event->set('days_since_first_session', $this->event->get('dsfs'));
$this->event->set('days_since_prior_session', $this->event->get('dsps'));
$this->event->set('num_prior_sessions', $this->event->get('nps'));
if ($this->event->get('is_new_session')) {
//mark entry page flag on current request
$this->event->set('is_entry_page', true);
}
if ($this->event->get('medium')) {
$this->event->set('medium', $this->eq->filter('medium', trim(strtolower($this->event->get('medium')))));
}
if ($this->event->get('source')) {
$this->event->set('source', $this->eq->filter('source', trim(strtolower($this->event->get('source')))));
$this->event->set('source_id', owa_lib::setStringGuid($this->event->get('source')));
}
if ($this->event->get('campaign')) {
$this->event->set('campaign_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('campaign')))));
}
if ($this->event->get('ad')) {
$this->event->set('ad_id', owa_lib::setStringGuid(trim(strtolower($this->event->get('ad')))));
}
$this->setCustomVariables();
$this->setGeolocation();
// anonymize Ip address
if (owa_coreAPI::getSetting('base', 'anonymize_ips')) {
$this->event->set('ip_address', $this->anonymizeIpAddress($this->event->get('ip_address')));
$this->event->set('full_host', '(not set)');
}
}