"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "wp_plugin.php" between
Open-Web-Analytics-1.6.9.tar.gz and Open-Web-Analytics-1.7.0.tar.gz

About: Open Web Analytics (OWA) is web analytics software to track and analyze how people use your web sites and applications.

wp_plugin.php  (Open-Web-Analytics-1.6.9):wp_plugin.php  (Open-Web-Analytics-1.7.0)
<?php <?php
/* /*
Plugin Name: Open Web Analytics Plugin Name: Open Web Analytics
Plugin URI: http://www.openwebanalytics.com Plugin URI: http://www.openwebanalytics.com
Description: This plugin enables Wordpress blog owners to use the Open Web Analy tics Framework. Description: This plugin enables Wordpress blog owners to use the Open Web Analy tics Framework.
Author: Peter Adams Author: Peter Adams
Version: 1.6.9 Version: master
Author URI: http://www.openwebanalytics.com Author URI: http://www.openwebanalytics.com
*/ */
// //
// Open Web Analytics - An Open Source Web Analytics Framework // Open Web Analytics - An Open Source Web Analytics Framework
// //
// Copyright 2008 Peter Adams. All rights reserved. // Copyright 2008 Peter Adams. All rights reserved.
// //
// Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html // Licensed under GPL v2.0 http://www.gnu.org/copyleft/gpl.html
// //
skipping to change at line 1129 skipping to change at line 1129
/////////////////////// Methods that require OWA on server ////////////// ////////////// /////////////////////// Methods that require OWA on server ////////////// //////////////
// gets an instance of your OWA as a php object // gets an instance of your OWA as a php object
public static function getOwaInstance() { public static function getOwaInstance() {
static $owa; static $owa;
if( empty( $owa ) ) { if( empty( $owa ) ) {
require_once('owa_env.php'); require_once('owa_env.php');
require_once(OWA_BASE_CLASSES_DIR.'owa_php.php'); require_once(OWA_BASE_CLASSES_DIR.'owa_php.php');
// create owa instance w/ config // create owa instance w/ config
$owa = new owa_php(); $owa = new owa_php();
if ( $owa->isOwaInstalled() ) { if ( $owa->isOwaInstalled() ) {
$owa->setSiteId( self::generateSiteId() ) ; $owa->setSiteId( self::generateSiteId() );
$owa->setSetting( 'base', 'is_embedded', true ); $owa->setSetting( 'base', 'is_embedded', true );
$current_user = wp_get_current_user(); $current_user = wp_get_current_user();
owa_coreAPI::debug( 'get owa instance cur owa_coreAPI::debug( 'WordPress login: '.$current_
ent user obj' ); user->user_login );
owa_coreAPI::debug( 'WordPress login: '.$ if ( $current_user->user_login ) {
current_user->user_login );
if ( $current_user->user_login ) {
// check to see if user exists in OWA.
$user = owa_coreApi::entityFactory('base.
user');
$user->load($current_user->user_login, 'u
ser_id');
if (! $user->get('id') ) {
// if not create it
$user->createNewUser(
$current_user->user_login
,
owa_wp_plugin::translateA
uthRole( $current_user->roles ),
$password = '',
$current_user->user_email
,
$current_user->first_name
.' '.$current_user->last_name
);
} else {
// or load from db
owa_coreAPI::debug('loading OWA c urrent user'); owa_coreAPI::debug('loading OWA c urrent user');
$cu = owa_coreAPI::getCurrentUser (); $cu = owa_coreAPI::getCurrentUser ();
$cu->load( $current_user->user_lo gin ); $cu->load( $current_user->user_lo gin );
} }
// register allowedSitesList filter
$dispatch = owa_coreAPI::getEventDispatch
();
// alternative auth method, sets auth sta
tus, role, and allowed sites list.
$dispatch->attachFilter('auth_status', 'o
wa_wp_plugin::wpAuthUser', 0);
} }
}
} }
return $owa; return $owa;
} }
public static function generateSiteId() { public static function generateSiteId() {
return md5( get_option( 'siteurl' ) ); return md5( get_option( 'siteurl' ) );
} }
skipping to change at line 1198 skipping to change at line 1212
echo sprintf('<div class="notice notice-info is-d ismissible"><p>Your OWA user id is: <B><em>%s</em></b>. Password reset email is <b><em>%s</em></b>. You may need to <a href="%s">reset your OWA password here</a > to login.</p></div><BR>', $user_id, $email, $reset_url); echo sprintf('<div class="notice notice-info is-d ismissible"><p>Your OWA user id is: <B><em>%s</em></b>. Password reset email is <b><em>%s</em></b>. You may need to <a href="%s">reset your OWA password here</a > to login.</p></div><BR>', $user_id, $email, $reset_url);
} }
} }
// insert iframe of OWA endpoint // insert iframe of OWA endpoint
echo sprintf('<iframe id="owa_wp_analytics" src="%s" style="displ ay: block; width: 100%%; height:100vh;border: none; overflow-y: hidden; overflow -x: hidden;" height="100%%" >', $url); echo sprintf('<iframe id="owa_wp_analytics" src="%s" style="displ ay: block; width: 100%%; height:100vh;border: none; overflow-y: hidden; overflow -x: hidden;" height="100%%" >', $url);
} }
/** /**
* OWA Schema and setting installation
*
*/
public static function install() {
define('OWA_INSTALLING', true);
$owa = self::getOwaInstance($params);
if ( $owa ) {
owa_coreAPI::notice( 'Starting Embedded Install...' );
$owa->setSetting( 'base', 'cache_objects', false );
$public_url = plugin_dir_url( __FILE__ );
$install_params = array('site_id' => md5(ge
t_option('siteurl')),
'name'
=> get_bloginfo('name'),
'domain'
=> get_option('siteurl'),
'descript
ion' => get_bloginfo('description'),
'action'
=> 'base.installEmbedded',
'db_type'
=> 'mysql',
'db_name'
=> DB_NAME,
'db_host'
=> DB_HOST,
'db_user'
=> DB_USER,
'db_passw
ord' => DB_PASSWORD,
'public_u
rl' => $public_url
);
$owa->handleRequest($install_params);
}
}
/**
* OWA Authenication filter
*
* Uses WordPress priviledge system to determine OWA authentication level
s.
*
* @return boolean
*/
static function 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_l
ogin);
owa_coreAPI::debug("Wordpress User_id: ".$current
_user->user_login);
$cu->load( $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->firs
t_name.' '.$current_user->last_name);
$cu->setRole( owa_wp_plugin::translateAuthRole( $
current_user->roles ) );
}
owa_coreAPI::debug("Wordpress User Role: ".print_r($curre
nt_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 loa
d sites
// other wise you run into a race condition as config fil
e
// 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;
}
}
/**
* Translate WordPress to OWA Authentication Roles * Translate WordPress to OWA Authentication Roles
* *
* @param $roles array array of WP roles * @param $roles array array of WP roles
* @return string * @return string
*/ */
static function translateAuthRole( $roles ) { static function translateAuthRole( $roles ) {
if (!empty($roles)) { if (!empty($roles)) {
if (in_array('administrator', $roles)) { if (in_array('administrator', $roles)) {
 End of changes. 11 change blocks. 
135 lines changed or deleted 37 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)