"Fossies" - the Fresh Open Source Software Archive

Member "Open-Web-Analytics-1.7.0/modules/base/classes/trackingEventHelpers.php" (16 Sep 2020, 22277 Bytes) of package /linux/www/Open-Web-Analytics-1.7.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "trackingEventHelpers.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 1.6.9_vs_1.7.0.

    1 <?php
    2 
    3 class owa_trackingEventHelpers {
    4 
    5     // incoming tracking event control flow:
    6     // 0. create event
    7     // 0. translate request property keys
    8     // 0. set all properties from request
    9     // 0. set environmental properties if not present
   10     // 0. queue or notify event
   11 
   12     // in event handler...
   13     // 0. register all filters callbacks for required, derived, and optional properties
   14     // 0. deconstruct custom variable properties
   15     // 0. filter existing event properties
   16     // 0. filter/set required event properties
   17     // 0. filter/set derived event properties
   18     // 0. handler specific logic
   19 
   20     static function getInstance() {
   21 
   22         static $o;
   23 
   24         if ( ! $o ) {
   25 
   26             $o = new owa_trackingEventHelpers();
   27         }
   28 
   29         return $o;
   30     }
   31 
   32     public function __construct() {
   33 
   34 
   35 
   36 
   37     }
   38 
   39     public function translateKeys( $event ) {
   40 
   41         foreach ( $this->translations as $k => $v ) {
   42 
   43             $event->set( $v, $event->get( $k ));
   44             $event->delete( $k );
   45         }
   46     }
   47 
   48 /*
   49     public function setEnvironmentals( $event ) {
   50 
   51         foreach ( $this->environmentals as $k => $v ) {
   52             // loop and execute call backs.
   53             if (! $event->get( $k ) ) {
   54                 
   55                 $event->set( $k, call_user_func( $this->environmentals[ $k ][ 'default_value' ][0] ) );
   56             }
   57         }
   58 
   59     }
   60 */
   61 
   62     public function registerCallbacks( $items, $priority = 0 ) {
   63 
   64         foreach ($items as $name => $item ) {
   65 
   66             if ( isset( $item['callbacks'] ) && ! empty($item['callbacks'] ) ) {
   67 
   68                 if ( is_array(  $item['callbacks'] ) ) {
   69 
   70 
   71                     foreach ($item['callbacks'] as $callback ) {
   72 
   73                         owa_coreAPI::registerFilter( $name, $callback,'', $priority);
   74                     }
   75                 } else {
   76 
   77                     owa_coreAPI::registerFilter( $name, $item['callbacks'],'', $priority);
   78                 }
   79             }
   80         }
   81     }
   82 
   83 /*
   84     public function generateIds( $event, $properties ) {
   85 
   86         $this->registerCallbacks( $properties, 0 );
   87 
   88     }
   89 */
   90 
   91     public function setTrackerProperties( $event, $properties ) {
   92 
   93         $this->registerCallbacks( $properties, 0 );
   94 
   95         $eq = owa_coreAPI::getEventDispatch();
   96 
   97         foreach ( $properties as $name => $property ) {
   98 
   99             $value = $event->get( $name );
  100 
  101             // if no value try alternate key
  102 
  103             if ( ! $value && $value !== 0 && $value !== "0" ) {
  104 
  105                 if ( isset( $property['alternative_key'] ) &&  $property['alternative_key'] ) {
  106 
  107                     $value = $event->get( $property['alternative_key'] );
  108                     // should we delete the original key on the event? if so:
  109                     //$event->delete( $name );
  110                     owa_coreAPI::debug('alt key value: '.$value);
  111                 }
  112             }
  113 
  114 
  115             // sanitize properties by datatype
  116             $data_type = '';
  117 
  118             if ( isset( $property['data_type'] ) && $property['data_type'] ) {
  119 
  120                 $data_type = $property['data_type'];
  121             }
  122 
  123             $value = $this->setDataType( $value, $data_type );
  124 
  125             $required = false;
  126 
  127             if ( isset( $property['required'] ) ) {
  128 
  129                 $required = $property['required'];
  130             }
  131 
  132             // filter value
  133             $value = $eq->filter( $name, $value, $event );
  134 
  135             //set default value
  136             if ( $required && ! $value && $value !== 0 && $value !== "0") {
  137 
  138                 if ( isset( $property['default_value'] ) && $property['default_value'] ) {
  139 
  140                     $value = $property['default_value'];
  141                 }
  142             }
  143 
  144             // set value on the event
  145             if ( $required || $value || $value === 0 || $value === "0" ) {
  146 
  147                 $event->set( $name,  $value );
  148             }
  149         }
  150     }
  151 
  152     static function setDataType( $var, $type = 'string' ) {
  153 
  154         switch( $type ) {
  155 
  156             case "integer":
  157 
  158                 $var = $var + 0;
  159                 break;
  160             case "string":
  161 
  162                 $var = owa_sanitize::cleanInput( $var, array('remove_html' => true) );
  163                 break;
  164             case "url":
  165 
  166                 $var = owa_sanitize::cleanUrl( $var );
  167                 break;
  168             case "json":
  169 
  170                 $var = owa_sanitize::cleanJson( $var );
  171                 break;
  172             case "boolean":
  173                 $var = boolval( $var );
  174                 break;
  175             default:
  176 
  177                 $var = owa_sanitize::cleanInput( $var, array('remove_html' => true) );
  178         }
  179 
  180         return $var;
  181     }
  182 
  183     function addCustomVariableProperties( $properties ) {
  184 
  185         $maxCustomVars = owa_coreAPI::getSetting( 'base', 'maxCustomVars' );
  186 
  187         for ($i = 1; $i <= $maxCustomVars; $i++) {
  188 
  189             $properties[ 'cv'.$i.'_name' ] = array(
  190 
  191                 'required'        => true,
  192                 'data_type'        => 'string',
  193                 'callbacks'        => array( 'owa_trackingEventHelpers::lowercaseString'),
  194                 'default_value'    => '(not set)'
  195             );
  196 
  197             $properties[ 'cv'.$i.'_value' ] = array(
  198 
  199                 'required'        => true,
  200                 'data_type'        => 'string',
  201                 'callbacks'        => array( 'owa_trackingEventHelpers::lowercaseString' ),
  202                 'default_value'    => '(not set)'
  203             );
  204 
  205         }
  206 
  207         return $properties;
  208     }
  209 
  210     function translateCustomVariables( $event ) {
  211 
  212         $maxCustomVars = owa_coreAPI::getSetting( 'base', 'maxCustomVars' );
  213 
  214         for ($i = 1; $i <= $maxCustomVars; $i++) {
  215 
  216             $cvar = $event->get( 'cv'.$i );
  217 
  218             if ( $cvar ) {
  219                 //split the string
  220                 $pieces = explode( '=' , trim( $cvar ) );
  221                 if ( isset( $pieces[1] ) ) {
  222                     $event->set( 'cv'.$i.'_name', $pieces[0] );
  223                     $event->set( 'cv'.$i.'_value', $pieces[1] );
  224                 }
  225 
  226                 $event->delete( 'cv'.$i );
  227             }
  228         }
  229     }
  230 
  231     static function remoteHostDefault() {
  232 
  233         return owa_coreAPI::getServerParam('REMOTE_HOST');
  234     }
  235 
  236     static function userAgentDefault( $ua = '') {
  237         
  238         if (! $ua ) {
  239             
  240             $ua = owa_coreAPI::getServerParam('HTTP_USER_AGENT');
  241         }
  242         return $ua;
  243     }
  244 
  245     static function httpHostDefault() {
  246 
  247         return owa_coreAPI::getServerParam('HTTP_HOST');
  248     }
  249 
  250     static function languageDefault() {
  251 
  252         return substr( owa_coreAPI::getServerParam( 'HTTP_ACCEPT_LANGUAGE' ), 0, 5 );
  253     }
  254 
  255     static function ipAddressDefault() {
  256 
  257         $ip = '';
  258 
  259         // array of SERVER params that could possibly contain the IP address
  260         // ordered by probability of relevant match
  261         $possible_ip_params = array(
  262 
  263             'HTTP_CLIENT_IP',
  264             'HTTP_X_FORWARDED_FOR',
  265             'HTTP_X_CLUSTER_CLIENT_IP',
  266             'HTTP_FORWARDED_FOR',
  267             'REMOTE_ADDR'
  268 
  269         );
  270 
  271         // check for IP address, break when found.
  272         foreach ( $possible_ip_params as $param ) {
  273 
  274             if ( owa_coreAPI::getServerParam( $param ) ) {
  275 
  276                  $ip = owa_coreAPI::getServerParam( $param );
  277                  owa_coreAPI::debug("ip address found in $param");
  278                  break;
  279              }
  280         }
  281 
  282          // check to see if there are multiple ips possibly passed from a poxy
  283          if ( strpos( $ip, ',' ) ) {
  284 
  285              owa_coreAPI::debug('multiple ip addresses found');
  286              // evaluate each IP to make sure it's valid and that it's not a private IP
  287              $candidate_ips = explode( ',', $ip );
  288 
  289              foreach ( $candidate_ips as $candidate_ip ) {
  290 
  291                  $candidate_ip = trim( $candidate_ip );
  292 
  293                  if ( owa_lib::isValidIp( $candidate_ip ) && ! owa_lib::isPrivateIp( $candidate_ip ) ) {
  294 
  295                      $ip = $candidate_ip;
  296 
  297                      break;
  298                  }
  299              }
  300 
  301              // if still no valid public IP then just use the first one found
  302              if ( strpos( $ip, ',' ) ) {
  303 
  304                  $ip = trim( $candidate_ips[0] ) ;
  305              }
  306 
  307          }
  308 
  309          // Anonymize IP if needed.
  310          if ( owa_coreAPI::getSetting( 'base', 'anonymize_ips' ) ) {
  311              if ( $ip && strpos( $ip , '.' ) ) {
  312 
  313                 $ip = explode( '.', $ip );
  314                 array_pop($ip);
  315                 $ip = implode('.', $ip);
  316                 $ip .= '.0';
  317             }
  318         }
  319 
  320          return $ip;
  321     }
  322 
  323     static function timestampDefault() {
  324 
  325         return owa_coreAPI::getRequestTimestamp();
  326     }
  327 
  328     static function microtimeDefault() {
  329 
  330         return microtime();
  331     }
  332 
  333     static function generateLocationId( $property_name, $event ) {
  334 
  335         if ( $event->get( 'country' ) ) {
  336             $s = owa_coreAPI::serviceSingleton();
  337             return $s->geolocation->generateId( $event->get( 'country' ), $event->get( 'state' ), $event->get( 'city' ) );
  338         }
  339     }
  340 
  341     static function generateDimensionId ( $property_value, $event ) {
  342 
  343         if ( $property_value ) {
  344 
  345             return owa_lib::setStringGuid( $property_value );
  346         }
  347 
  348     }
  349 
  350     static function setRepeatVisitorFlag( $flag, $event ) {
  351 
  352         // set repeat visitor type flag visitor is not new.
  353         if ( ! $event->get( 'is_new_visitor' ) ) {
  354 
  355             return true;
  356         }
  357     }
  358 
  359     static function deriveYear( $year, $event ) {
  360 
  361         return date( "Y", $event->get('timestamp') );
  362 
  363     }
  364 
  365     static function deriveMonth( $month, $event ) {
  366 
  367         return date("Ym", $event->get('timestamp') );
  368 
  369     }
  370 
  371     static function deriveDay( $day, $event ) {
  372 
  373         return date("d", $event->get('timestamp') );
  374 
  375     }
  376 
  377     static function deriveYyyymmdd( $yyyymmdd, $event ) {
  378 
  379         return date("Ymd", $event->get('timestamp') );
  380 
  381     }
  382 
  383     static function deriveDayOfWeek( $dayofweek, $event ) {
  384 
  385         return date("D", $event->get('timestamp') );
  386 
  387     }
  388 
  389     static function deriveDayOfYear( $dayofyear, $event ) {
  390 
  391         return date("z", $event->get('timestamp') );
  392 
  393     }
  394 
  395     static function deriveWeekOfYear( $weekofyear, $event ) {
  396 
  397         return date("W", $event->get('timestamp') );
  398 
  399     }
  400 
  401     static function deriveHour( $hour, $event ) {
  402 
  403         return date("G", $event->get('timestamp') );
  404 
  405     }
  406 
  407     static function deriveMinute( $minute, $event ) {
  408 
  409         return date("i", $event->get('timestamp') );
  410 
  411     }
  412 
  413     static function deriveSecond( $second, $event ) {
  414 
  415         return date("s", $event->get('timestamp') );
  416 
  417     }
  418 
  419     static function deriveSec( $sec, $event ) {
  420 
  421         list( $msec, $sec ) = explode( " ", $event->get( 'microtime' ) );
  422         return $sec;
  423     }
  424 
  425     static function deriveMsec( $msec, $event ) {
  426 
  427         list( $msec, $sec ) = explode( " ", $event->get( 'microtime' ) );
  428         return $msec;
  429     }
  430 
  431     static function derivePageUri( $page_uri, $event ) {
  432 
  433         $page_parse = parse_url( $event->get( 'page_url' ) );
  434 
  435         if ( ! array_key_exists( 'path', $page_parse ) || empty( $page_parse['path'] ) ) {
  436 
  437             $page_parse['path'] = '/';
  438         }
  439 
  440         if ( array_key_exists( 'query', $page_parse ) || ! empty( $page_parse['query'] ) ) {
  441 
  442             return sprintf( '%s?%s', $page_parse['path'], $page_parse['query'] );
  443 
  444         } else {
  445 
  446             return $page_parse['path'] ;
  447         }
  448     }
  449 
  450     /**
  451      * Filter function Strips a URL of certain defined session or tracking params
  452      *
  453      * @return string
  454      */
  455     static function makeUrlCanonical( $url, $event ) {
  456 
  457         $site_id = $event->getSiteId();
  458 
  459         if ( ! $site_id ) {
  460             owa_coreAPI::debug('no site_id passed to make makeUrlCanonical. Returning URL as is.');
  461             return $url;
  462         }
  463 
  464         $url = html_entity_decode( $url );
  465         // remove port, pass, user, and fragment
  466         $url = owa_lib::unparseUrl( parse_url( $url ), array( 'port', 'user', 'pass', 'fragment' ) );
  467 
  468         owa_coreAPI::debug('makeUrlCanonical using site_id: '.$site_id);
  469         $site = owa_coreAPI::entityFactory('base.site');
  470         $site->load( $site->generateId( $site_id ) );
  471 
  472         $filter_string = $site->getSiteSetting( 'query_string_filters' );
  473 
  474         if ($filter_string) {
  475             $filters = str_replace(' ', '', $filter_string);
  476             $filters = explode(',', $filter_string);
  477         } else {
  478             $filters = array();
  479         }
  480 
  481         // merge global filters
  482         $global_filters = owa_coreAPI::getSetting('base', 'query_string_filters');
  483         if ($global_filters) {
  484             $global_filters = str_replace(' ', '', $global_filters);
  485             $global_filters = explode(',', $global_filters);
  486             $filters = array_merge($global_filters, $filters);
  487         }
  488 
  489         // OWA specific params to filter
  490         array_push($filters, owa_coreAPI::getSetting('base', 'ns').'source');
  491         array_push($filters, owa_coreAPI::getSetting('base', 'ns').'medium');
  492         array_push($filters, owa_coreAPI::getSetting('base', 'ns').'campaign');
  493         array_push($filters, owa_coreAPI::getSetting('base', 'ns').'ad');
  494         array_push($filters, owa_coreAPI::getSetting('base', 'ns').'ad_type');
  495         array_push($filters, owa_coreAPI::getSetting('base', 'ns').'overlay');
  496         array_push($filters, owa_coreAPI::getSetting('base', 'ns').'state');
  497         array_push($filters, owa_coreAPI::getSetting('base', 'ns').owa_coreAPI::getSetting('base', 'feed_subscription_param'));
  498 
  499         //print_r($filters);
  500 
  501         foreach ($filters as $filter => $value) {
  502 
  503           $url = preg_replace(
  504             '#\?' .
  505             $value .
  506             '=.*$|&' .
  507             $value .
  508             '=.*$|' .
  509             $value .
  510             '=.*&#msiU',
  511             '',
  512             $url
  513           );
  514 
  515         }
  516 
  517 
  518         //check for dangling '?'. this might occure if all params are stripped.
  519 
  520         // returns last character of string
  521         $test = substr($url, -1);
  522 
  523         // if dangling '?' is found clean up the url by removing it.
  524         if ($test == '?') {
  525             $url = substr($url, 0, -1);
  526         }
  527 
  528         //check and remove default page
  529         $default_page = $site->getSiteSetting( 'default_page' );
  530 
  531         if ($default_page) {
  532 
  533             $default_length = strlen($default_page);
  534 
  535             if ($default_length) {
  536 
  537                 //test for string
  538                 $default_test = substr($url, 0 - $default_length, $default_length);
  539                 if ($default_test === $default_page) {
  540                     $url = substr($url, 0, 0 - $default_length);
  541                 }
  542             }
  543         }
  544 
  545         // check and remove trailing slash
  546         if (substr($url, -1) === '/') {
  547 
  548             $url = substr($url, 0, -1);
  549         }
  550 
  551         // check for domain aliases
  552         $das = $site->getSiteSetting( 'domain_aliases' );
  553 
  554         if ( $das ) {
  555 
  556             $site_domain = $site->getDomainName();
  557 
  558             if ( ! strpos( $url, '://'. $site_domain ) ) {
  559 
  560                 $das = explode(',', $das);
  561 
  562                 foreach ($das as $da) {
  563                     owa_coreAPI::debug("Checking URL for domain alias: $da");
  564                     $da = trim($da);
  565                     if ( strpos( $url, $da ) ) {
  566                         $url = str_replace($da, $site_domain, $url);
  567                         break;
  568                     }
  569                 }
  570             }
  571         }
  572 
  573          return $url;
  574 
  575     }
  576 
  577     static function utfEncodeProperty( $string, $event ) {
  578 
  579         return owa_lib::utf8Encode( trim( $string ) );
  580     }
  581 
  582     /**
  583      * Resolve hostname from IP address
  584      *
  585      * @access public
  586      */
  587     static function resolveFullHost( $full_host, $event ) {
  588 
  589         // See if host is already resolved
  590         if ( $event->get('REMOTE_HOST') === '(not set)'
  591              && $event->get( 'ip_address' )
  592              && owa_coreAPI::getSetting('base', 'resolve_hosts')
  593         ) {
  594 
  595             // Do the host lookup
  596             $ip_address = $event->get( 'ip_address' );
  597 
  598             // Do the host lookup
  599 
  600             if ( ! strpos( $ip_address, '.' ) ) {
  601 
  602                  $result = @dns_get_record($host_name,DNS_AAAA);
  603 
  604                  if ( is_array( $result ) && isset( $result[0] ) && isset( $result[0]['host'] ) ) {
  605 
  606                      $remote_host = $result[0]['host'];
  607                  }
  608 
  609             } else {
  610 
  611                 $remote_host = @gethostbyaddr( $ip_address );
  612             }
  613             owa_coreAPI::debug(print_r($remote_host, true));
  614             if ( $remote_host
  615                  && $remote_host != $ip_address
  616                  && $remote_host != 'unknown'
  617             ) {
  618 
  619                 return $remote_host;
  620             }
  621         } else {
  622 
  623             return $event->get('REMOTE_HOST');
  624         }
  625     }
  626 
  627     static function getHostDomain( $host, $event ) {
  628 
  629         $fullhost = $event->get( 'full_host' );
  630 
  631         if ( $fullhost ) {
  632 
  633             // Sometimes gethostbyaddr returns 'unknown' or the IP address if it can't resolve the host
  634             if ($fullhost === 'localhost') {
  635 
  636                 $host = 'localhost';
  637 
  638             } else {
  639 
  640                 // lookup the registered domain using the Public Suffix List.
  641                 $host = owa_coreAPI::getRegisteredDomain( $fullhost );
  642                 owa_coreAPI::debug("Registered domain is: $host");
  643             }
  644 
  645             return $host;
  646         }
  647     }
  648 
  649     static function resolveBrowserType( $browser_type, $event ) {
  650 
  651         $service = owa_coreAPI::serviceSingleton();
  652 
  653         $bcap = $service->getBrowscap();
  654 
  655         return $bcap->getUaFamily();
  656     }
  657 
  658     static function isBrowser( $is_browser , $event ) {
  659 
  660         if ( $event->get( 'browser_type' ) ) {
  661 
  662             return true;
  663         }
  664     }
  665 
  666     static function resolveBrowserVersion( $version, $event ) {
  667 
  668         $service = owa_coreAPI::serviceSingleton();
  669 
  670         $bcap = $service->getBrowscap();
  671 
  672         return $bcap->getUaVersion();
  673     }
  674 
  675     static function isRobot ( $is_robot, $event ) {
  676 
  677         $service = owa_coreAPI::serviceSingleton();
  678 
  679         $bcap = $service->getBrowscap();
  680 
  681         return $bcap->isRobot();
  682     }
  683 
  684     static function resolveOs ( $os, $event ) {
  685 
  686         $service = owa_coreAPI::serviceSingleton();
  687 
  688         $bcap = $service->getBrowscap();
  689 
  690         return $bcap->getOsFamily();
  691 
  692     }
  693 
  694     static function resolveEntryPage( $is_entry_page, $event ) {
  695         return $event->get('is_new_session') ? true : false;
  696     }
  697 
  698     static function resolveCountry ( $country, $event ) {
  699 
  700         // if country is set manually, use it
  701         if ($country) {
  702             return $country;
  703         }
  704 
  705         $location = owa_coreAPI::getGeolocationFromIpAddress($event->get('ip_address'));
  706 
  707         return $location->getCountry();
  708     }
  709 
  710     static function resolveCity ( $city, $event ) {
  711 
  712         // if city is set manually, use it
  713         if ($city) {
  714             return $city;
  715         }
  716 
  717         $location = owa_coreAPI::getGeolocationFromIpAddress( $event->get( 'ip_address' ) );
  718 
  719         return $location->getCity();
  720     }
  721 
  722     static function resolveLatitude ( $latitude, $event ) {
  723 
  724         // if latitude is set manually, use it
  725         if ($latitude) {
  726             return $latitude;
  727         }
  728 
  729         $location = owa_coreAPI::getGeolocationFromIpAddress( $event->get( 'ip_address' ) );
  730 
  731         return $location->getLatitude();
  732     }
  733 
  734     static function resolveLongitude ( $longitude, $event ) {
  735 
  736         // if longitude is set manually, use it
  737         if ($longitude) {
  738             return $longitude;
  739         }
  740 
  741         $location = owa_coreAPI::getGeolocationFromIpAddress( $event->get( 'ip_address' ) );
  742 
  743         return $location->getLongitude();
  744     }
  745 
  746     static function resolveCountryCode ( $country_code, $event ) {
  747 
  748         // if country_code is set manually, use it
  749         if ($country_code) {
  750             return $country_code;
  751         }
  752 
  753         $location = owa_coreAPI::getGeolocationFromIpAddress( $event->get( 'ip_address' ) );
  754 
  755         return $location->getCountryCode();
  756     }
  757 
  758     static function resolveState ( $state, $event ) {
  759 
  760         // if state is set manually, use it
  761         if ($state) {
  762             return $state;
  763         }
  764 
  765         $location = owa_coreAPI::getGeolocationFromIpAddress( $event->get( 'ip_address' ) );
  766 
  767         return $location->getState();
  768     }
  769 
  770     static function lowercaseString ( $string, $event ) {
  771 
  772         return strtolower( trim( $string ) );
  773     }
  774 
  775     static function setPriorPage ( $prior_page, $event ) {
  776 
  777         // if prior_page is set manually, use it
  778         if ($prior_page) {
  779             return $prior_page;
  780         }
  781 
  782         if ( $event->get( 'HTTP_REFERER' ) ) {
  783             // @todo is this parse done somewhere else already? source?
  784             $referer_parse = owa_lib::parse_url( $event->get('HTTP_REFERER') );
  785 
  786             $http_host = $event->get( 'HTTP_HOST' );
  787 
  788             if ( isset($referer_parse['host'] ) && $referer_parse['host'] === $http_host ) {
  789 
  790                 return $event->get('HTTP_REFERER');
  791             }
  792         }
  793 
  794         return null;
  795     }
  796 
  797     static function setSearchTerms ( $search_terms, $event ) {
  798 
  799         if ( $search_terms && $search_terms != '(not set)' ) {
  800 
  801             return trim( strtolower( $search_terms ) );
  802         }
  803     }
  804 
  805     static function setUserName( $user_name, $event ) {
  806 
  807         // record and filter personally identifiable info (PII)
  808         if ( owa_coreAPI::getSetting( 'base', 'log_visitor_pii' ) ) {
  809 
  810             // set user name if one does not already exist on event
  811             if ( ! $user_name && owa_coreAPI::getSetting( 'base', 'log_owa_user_names' ) ) {
  812 
  813                 $cu = owa_coreAPI::getCurrentUser();
  814 
  815                 $user_name = $cu->user->get( 'user_id' );
  816             }
  817 
  818             return $user_name;
  819         }
  820     }
  821 
  822     static function setEmailAddress ( $email_address, $event ) {
  823 
  824         if ( owa_coreAPI::getSetting( 'base', 'log_visitor_pii' ) ) {
  825 
  826             if ( ! $email_address && owa_coreAPI::getSetting( 'base', 'log_owa_user_names' ) ) {
  827 
  828                 $cu = owa_coreAPI::getCurrentUser();
  829 
  830                 $email_address = $cu->user->get( 'email_address' );
  831             }
  832 
  833             return $email_address;
  834         }
  835     }
  836 
  837 }
  838 
  839 ?>