/** * Notify Event Handler * * @param unknown_type $event * @access public */ function notify($event) { // Make entity $f = owa_coreAPI::entityFactory('base.feed_request'); $f->load($event->get('guid')); if (!$f->wasPersisted()) { $f->setProperties($event->getProperties()); // Set Primary Key $f->set('id', $event->get('guid')); // Make ua id $f->set('ua_id', owa_lib::setStringGuid($event->get('HTTP_USER_AGENT'))); // Make OS id $f->set('os_id', owa_lib::setStringGuid($event->get('os'))); // Make document id $f->set('document_id', owa_lib::setStringGuid($event->get('page_url'))); // Generate Host id $f->set('host_id', owa_lib::setStringGuid($event->get('host'))); $f->set('subscription_id', $event->get('feed_subscription_id')); // Persist to database $ret = $f->create(); if ($ret) { $eq = owa_coreAPI::getEventDispatch(); $nevent = $eq->makeEvent($event->getEventType() . '_persisted'); $nevent->setProperties($event->getProperties()); $eq->notify($nevent); return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { owa_coreAPI::debug('Not persisting. Feed request already exists.'); return OWA_EHS_EVENT_HANDLED; } }
function action() { $site = owa_coreAPI::entityFactory('base.site'); $site->delete($site->generateId($this->getParam('siteId'))); $this->setRedirectAction('base.sites'); $this->set('status_code', 3204); }
function createAdminUser($email_address) { //create user entity $u = owa_coreAPI::entityFactory('base.user'); // check to see if an admin user already exists $u->getByColumn('role', 'admin'); $id_check = $u->get('id'); // if not then proceed if (empty($id_check)) { //Check to see if user name already exists $u->getByColumn('user_id', 'admin'); $id = $u->get('id'); // Set user object Params if (empty($id)) { $password = $u->generateRandomPassword(); $u->set('user_id', 'admin'); $u->set('role', 'admin'); $u->set('real_name', ''); $u->set('email_address', $email_address); $u->set('password', owa_lib::encryptPassword($password)); $u->set('creation_date', time()); $u->set('last_update_date', time()); $ret = $u->create(); owa_coreAPI::debug("Admin user created successfully."); return $password; } else { owa_coreAPI::debug($this->getMsg(3306)); } } else { owa_coreAPI::debug("Admin user already exists."); } }
/** * Notify Handler * * @access public * @param object $event */ function notify($event) { $r = owa_coreAPI::entityFactory('base.request'); $r->load($event->get('guid')); if (!$r->wasPersisted()) { $r->setProperties($event->getProperties()); // Set Primary Key $r->set('id', $event->get('guid')); // Make prior document id $r->set('prior_document_id', owa_lib::setStringGuid($event->get('prior_page'))); // Generate Host id $r->set('num_prior_sessions', $event->get('num_prior_sessions')); $result = $r->create(); if ($result == true) { $eq = owa_coreAPI::getEventDispatch(); $nevent = $eq->makeEvent($event->getEventType() . '_logged'); $nevent->setProperties($event->getProperties()); $eq->asyncNotify($nevent); return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { owa_coreAPI::debug('Not persisting. Request already exists.'); return OWA_EHS_EVENT_HANDLED; } }
/** * Notify Event Handler * * @param unknown_type $event * @access public */ function notify($event) { if ($event->get('source')) { $s = owa_coreAPI::entityFactory('base.source_dim'); $new_id = $s->generateId(trim(strtolower($event->get('source')))); $s->getByPk('id', $new_id); $id = $s->get('id'); if (!$id) { $s->set('id', $new_id); $s->set('source_domain', $event->get('source')); $ret = $s->create(); if ($ret) { return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { owa_coreAPI::debug('Not Persisting. Source already exists.'); return OWA_EHS_EVENT_HANDLED; } } else { owa_coreAPI::debug('Noting to handle. No source properties found on event.'); return OWA_EHS_EVENT_HANDLED; } }
/** * Notify Event Handler * * @param unknown_type $event * @access public */ function notify($event) { $v = owa_coreAPI::entityFactory('base.visitor'); $v->load($event->get('visitor_id')); if (!$v->wasPersisted()) { $v->setProperties($event->getProperties()); // Set Primary Key $v->set('id', $event->get('visitor_id')); $v->set('first_session_id', $event->get('session_id')); $v->set('first_session_year', $event->get('year')); $v->set('first_session_month', $event->get('month')); $v->set('first_session_day', $event->get('day')); $v->set('first_session_dayofyear', $event->get('dayofyear')); $v->set('first_session_timestamp', $event->get('timestamp')); $ret = $v->create(); if ($ret) { return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { owa_coreAPI::debug("Not persisting. Visitor already exists."); return OWA_EHS_EVENT_HANDLED; } }
function render() { $site = $this->get('site'); if ($this->get('edit')) { $this->body->set('action', 'base.sitesEdit'); $this->body->set('headline', 'Edit Site Profile for: ' . $site['domain']); $siteEntity = owa_coreAPI::entityFactory('base.site'); $siteEntity->getByColumn('site_id', $this->get('siteId')); $this->body->set('siteEntity', $siteEntity); } else { $this->body->set('action', 'base.sitesAdd'); $this->body->set('headline', 'Add a New Tracked Site Profile'); } if (isset($site['domain'])) { $this->t->set('page_title', 'Site Profile for: ' . $site['domain']); } else { $this->t->set('page_title', 'Site Profile for new Site'); } $this->body->set('users', $this->getAllUserRows()); $this->body->set('site', $site); $this->body->set('edit', $this->get('edit')); $this->body->set('site_id', $this->get('siteId')); $this->body->set('config', $this->get('config')); //print_r($this->get('config')); $this->body->set_template('sites_addoredit.tpl'); }
function action() { // Load the core API $api =& owa_coreAPI::singleton($this->params); if ($this->params['site_id']) { //get site labels $s = owa_coreAPI::entityFactory('base.site'); $s->getByColumn('site_id', $this->getParam('site_id')); $this->set('site_name', $s->get('name')); $this->set('site_description', $s->get('description')); } else { $this->set('site_name', 'All Sites'); $this->set('site_description', 'All Sites Tracked by OWA'); } //setup Metrics $m = owa_coreApi::metricFactory('base.latestVisits'); $m->setConstraint('site_id', $this->getParam('site_id')); $m->setPeriod($this->getPeriod()); $m->setOrder(OWA_SQL_DESCENDING); $m->setLimit(15); $results = $m->generate(); $this->set('latest_visits', $results); $this->setView('base.kmlVisitsGeolocation'); return; }
/** * Notify method * * @param object $event * @access public */ function notify($event) { $ds = owa_coreAPI::entityFactory('base.domstream'); $ds->load($event->get('guid')); if (!$ds->wasPersisted()) { $ds->setProperties($event->getProperties()); $ds->set('id', $event->get('guid')); $ds->set('domstream_guid', $event->get('domstream_guid')); $ds->set('document_id', $ds->generateId($event->get('page_url'))); $ds->set('page_url', $event->get('page_url')); $ds->set('events', $event->get('stream_events')); $ds->set('duration', $event->get('duration')); $ret = $ds->create(); if ($ret) { // Tell others that "dom.stream" has been logged $eq = owa_coreAPI::getEventDispatch(); $nevent = $eq->makeEvent($event->getEventType() . '_logged'); $nevent->setProperties($event->getProperties()); $eq->asyncNotify($nevent); return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { owa_coreAPI::debug('No persisting. Domsteam already exists.'); return OWA_EHS_EVENT_HANDLED; } }
function createDefaultSite($domain, $name = '', $description = '', $site_family = '', $site_id = '') { if (!$name) { $name = $domain; } $site = owa_coreAPI::entityFactory('base.site'); if (!$site_id) { $site_id = $site->generateSiteId($domain); } // Check to see if default site already exists $this->e->notice('Checking for existence of default site.'); // create site_id....how??? $site->getByColumn('site_id', $site_id); $id = $site->get('id'); if (empty($id)) { // Create default site $site->set('id', $site->generateId($site_id)); $site->set('site_id', $site_id); $site->set('name', $name); $site->set('description', $description); $site->set('domain', $domain); $site->set('site_family', $site_family); $site_status = $site->create(); if ($site_status == true) { $this->e->notice('Created default site.'); } else { $this->e->notice('Creation of default site failed.'); } } else { $this->e->notice(sprintf("Default site already exists (id = %s). nothing to do here.", $id)); } return $site->get('site_id'); }
function action() { $d = owa_coreAPI::entityFactory('base.document'); if ($this->getParam('pageUrl')) { $pageUrl = $this->getParam('pageUrl'); $d->getByColumn('url', $pageUrl); $this->set('constraints', 'pageUrl==' . urlencode($pageUrl)); $title_slug = $pageUrl; } if ($this->getParam('pagePath')) { $pagePath = $this->getParam('pagePath'); $d->getByColumn('uri', $pagePath); $this->set('constraints', 'pagePath==' . urlencode($pagePath)); $title_slug = $pagePath; } if ($this->getParam('document_id')) { $did = $this->getParam('document_id'); $d->load($did); $pagePath = $d->get('uri'); $this->set('constraints', 'pagePath==' . urlencode($pagePath)); $title_slug = $pagePath; } $this->setTitle('Dom Clicks: ', $title_slug); $this->set('document', $d); $this->setSubview('base.reportDomClicks'); $this->set('metrics', 'domClicks'); $this->set('sort', 'domClicks'); $this->set('resultsPerPage', 30); $this->set('trendChartMetric', 'domClicks'); $this->set('trendTitle', 'There were <*= this.d.resultSet.aggregates.domClicks.formatted_value *> dom clicks for this web page.'); }
/** * Notify Handler * * @access public * @param object $event */ function notify($event) { $c = owa_coreAPI::entityFactory('base.click'); $c->load($event->get('guid')); if (!$c->wasPersisted()) { $c->set('id', $event->get('guid')); $c->setProperties($event->getProperties()); $c->set('visitor_id', $event->get('visitor_id')); $c->set('session_id', $event->get('session_id')); $c->set('ua_id', owa_lib::setStringGuid($event->get('HTTP_USER_AGENT'))); // Make document id $c->set('document_id', owa_lib::setStringGuid($event->get('page_url'))); // Make Target page id $c->set('target_id', owa_lib::setStringGuid($c->get('target_url'))); // Make position id used for group bys $c->set('position', $c->get('click_x') . $c->get('click_y')); $ret = $c->create(); if ($ret) { return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { return OWA_EHS_EVENT_HANDLED; } }
/** * Notify Event Handler * * @param unknown_type $event * @access public */ function notify($event) { // create entity $d = owa_coreAPI::entityFactory('base.document'); // get document id from event $id = $event->get('document_id'); // if no document_id present attempt to make one from the page_url property if (!$id) { $page_url = $event->get('page_url'); if ($page_url) { $id = $d->generateId($page_url); } else { owa_coreAPI::debug('Not persisting Document, no page_url or document_id event property found.'); return OWA_EHS_EVENT_HANDLED; } } $d->load($id); if (!$d->wasPersisted()) { $d->setProperties($event->getProperties()); $d->set('url', $event->get('page_url')); $d->set('uri', $event->get('page_uri')); $d->set('id', $id); $ret = $d->create(); if ($ret) { return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { owa_coreAPI::debug('Not logging Document, already exists'); return OWA_EHS_EVENT_HANDLED; } }
/** * Notify Handler * * @access public * @param object $event */ function notify($event) { $c = owa_coreAPI::entityFactory('base.click'); $c->load($event->get('guid')); if (!$c->wasPersisted()) { $c->set('id', $event->get('guid')); $c->setProperties($event->getProperties()); $c->set('visitor_id', $event->get('visitor_id')); $c->set('session_id', $event->get('session_id')); $c->set('ua_id', owa_lib::setStringGuid($event->get('HTTP_USER_AGENT'))); // Make document id $c->set('document_id', owa_lib::setStringGuid($event->get('page_url'))); // Make Target page id $c->set('target_id', owa_lib::setStringGuid($c->get('target_url'))); // Make position id used for group bys $c->set('position', $c->get('click_x') . $c->get('click_y')); $ret = $c->create(); if ($ret) { // Tell others that "dom.click" has been logged $eq = owa_coreAPI::getEventDispatch(); $nevent = $eq->makeEvent($event->getEventType() . '_logged'); $nevent->setProperties($event->getProperties()); $eq->asyncNotify($nevent); return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { return OWA_EHS_EVENT_HANDLED; } }
function action() { $document_id = ''; // get period $p = $this->getPeriod(); // check for limits if ($this->getParam('document_id') || $this->getParam('pageUrl') || $this->getParam('pagePath')) { $doc = owa_coreAPI::entityFactory('base.document'); if ($this->getParam('pageUrl')) { $doc->getByColumn('url', $this->getParam('pageUrl')); } elseif ($this->getParam('pagePath')) { $doc->getByColumn('uri', $this->getParam('pagePath')); } else { $doc->load($this->getParam('document_id')); } $document_id = $doc->get('id'); $this->setTitle('Domstream Recordings: ', $doc->get('url')); $this->set('document', $doc->_getProperties()); $this->set('item_properties', $doc); } else { // latest domstream report $this->setTitle('Latest Domstreams'); } $ds = owa_coreAPI::executeApiCommand(array('do' => 'getDomstreams', 'startDate' => $p->getStartDate()->getYyyymmdd(), 'endDate' => $p->getEndDate()->getYyyymmdd(), 'document_id' => $document_id, 'siteId' => $this->getParam('siteId'), 'page' => $this->getParam('page'), 'resultsPerPage' => 50, 'format' => $this->getParam('format'))); $this->set('domstreams', $ds); //print_r($ds); // set view stuff $this->setSubview('base.reportDomstreams'); }
/** * Notify Event Handler * * @param unknown_type $event * @access public */ function notify($event) { $terms = trim(strtolower($event->get('search_terms'))); if ($terms) { $st = owa_coreAPI::entityFactory('base.search_term_dim'); $st_id = owa_lib::setStringGuid($terms); $st->getByPk('id', $st_id); $id = $st->get('id'); if (!$id) { $st->set('id', $st_id); $st->set('terms', $terms); $ret = str_replace("", "", $terms, $count); $st->set('term_count', $count); $ret = $st->create(); if ($ret) { return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { owa_coreAPI::debug('Not Logging. Search term already exists.'); return OWA_EHS_EVENT_HANDLED; } } else { return OWA_EHS_EVENT_HANDLED; } }
/** * Notify Event Handler * * @param unknown_type $event * @access public */ function notify($event) { if ($event->get('ad')) { $d = owa_coreAPI::entityFactory('base.ad_dim'); $new_id = $d->generateId(trim(strtolower($event->get('ad')))); $d->getByPk('id', $new_id); $id = $d->get('id'); if (!$id) { $d->set('id', $new_id); $d->set('name', trim(strtolower($event->get('ad')))); $d->set('type', trim(strtolower($event->get('ad_type')))); $ret = $d->create(); if ($ret) { return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { owa_coreAPI::debug('Not Persisting. Ad already exists.'); return OWA_EHS_EVENT_HANDLED; } } else { owa_coreAPI::debug('Noting to handle. No Ad properties found on event.'); return OWA_EHS_EVENT_HANDLED; } }
/** * Notify Event Handler * * @param unknown_type $event * @access public */ function notify($event) { if ($event->get('location_id') || $event->get('ip_address')) { $h = owa_coreAPI::entityFactory('base.location_dim'); // look for location id on the event. This happens when // another event has already created it. if ($event->get('location_id')) { $location_id = $event->get('location_id'); // else look to see if he event has the minimal geo properties // if it does then assume that geo properties are set. } elseif ($event->get('country')) { $key = $event->get('country') . $event->get('city'); $location_id = $h->generateId($key); // load the geo properties from the geo service. } else { $location = owa_coreAPI::getGeolocationFromIpAddress($event->get('ip_address')); owa_coreAPI::debug('geolocation: ' . print_r($location, true)); //set properties of the session $event->set('country', $location->getCountry()); $event->set('city', $location->getCity()); $event->set('latitude', $location->getLatitude()); $event->set('longitude', $location->getLongitude()); $event->set('country_code', $location->getCountryCode()); $event->set('state', $location->getState()); $key = $event->get('country') . $event->get('city'); $location_id = $h->generateId($key); } // look up the county code if it's missing if (!$event->get('country_code') && $event->get('country')) { $event->set('country_code', $this->lookupCountryCodeFromName($event->get('country'))); } $h->getByPk('id', $location_id); $id = $h->get('id'); if (!$id) { $location = owa_coreAPI::getGeolocationFromIpAddress($event->get('ip_address')); owa_coreAPI::debug('geolocation: ' . print_r($location, true)); //set properties of the session $h->set('country', $event->get('country')); $h->set('city', $event->get('city')); $h->set('latitude', $event->get('latitude')); $h->set('longitude', $event->get('longitude')); $h->set('country_code', $event->get('country_code')); $h->set('state', $event->get('state')); $h->set('id', $location_id); $ret = $h->create(); if ($ret) { return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } } else { owa_coreAPI::debug('Not Logging. Location already exists'); return OWA_EHS_EVENT_HANDLED; } } else { owa_coreAPI::notice('Not persisting location dimension. Location id or ip address missing from event.'); return OWA_EHS_EVENT_HANDLED; } }
function action() { $s = owa_coreAPI::entityFactory('base.site'); $sites = owa_coreAPI::getSitesList(); $this->set('tracked_sites', $sites); $this->setSubview('base.sites'); $this->setView('base.options'); }
function deleteUser($user_id) { $u = owa_coreAPI::entityFactory('base.user'); $ret = $u->delete($user_id, 'user_id'); if ($ret) { return true; } else { return false; } }
function action() { $site_id = $this->getParam('siteId'); $this->set('site_id', $site_id); $s = owa_coreAPI::entityFactory('base.site'); $s->getByColumn('site_id', $site_id); $this->set('site', $s); $this->setSubview('base.sitesInvocation'); $this->setView('base.options'); }
/** * Notify Handler * * @access public * @param object $event */ function notify($event) { $s = owa_coreAPI::entityFactory('base.site'); $s->getByPk('siteId', $event->get('siteId')); if ($s->wasPersisted()) { $ret = owa_coreAPI::performAction('base.notifyNewSession', array('site' => $s, 'event' => $event)); return OWA_EHS_EVENT_HANDLED; } else { return OWA_EHS_EVENT_FAILED; } }
function action() { $s = owa_coreAPI::entityFactory('base.site'); $sites = $this->getSitesAllowedForCurrentUser(); $this->set('tracked_sites', $sites); $this->setSubview('base.sites'); $this->setView('base.report'); $this->set('title', 'Sites Roster'); $this->hideReportingNavigation(); $this->hideSitesFilter(); }
function errorAction() { $this->setView('base.options'); $this->setSubview('base.sitesProfile'); $this->set('error_code', 3311); $site_id = $this->getParam('siteId'); $site = owa_coreAPI::entityFactory('base.site'); $site->load($site->generateId($site_id)); $this->set('site', $site); $this->set('config', $this->params); }
function action() { $visitorId = $this->getParam('visitorId'); if (!$visitorId) { $visitorId = $this->getParam('visitor_id'); } $v = owa_coreAPI::entityFactory('base.visitor'); $v->load($visitorId); $this->set('visitor_id', $visitorId); $this->set('visitor', $v); $this->setView('base.report'); $this->setSubview('base.reportVisitor'); $this->setTitle('Visitor History:', $v->getVisitorName()); }
function action() { // This needs form validation in a bad way. $site = owa_coreAPI::entityFactory('base.site'); $site->set('site_id', $this->params['siteId']); $site->set('name', $this->params['name']); $site->set('domain', $this->params['domain']); $site->set('description', $this->params['description']); $site->update('site_id'); $data['view_method'] = 'redirect'; $data['do'] = 'base.sites'; $data['status_code'] = 3201; return $data; }
function validate() { $entity = owa_coreAPI::entityFactory($this->getConfig('entity')); $entity->getByColumn($this->getConfig('column'), $this->getValues()); $error = $this->getErrorMsg(); if (empty($error)) { $this->setErrorMessage('An entity with that value already exists.'); } $id = $entity->get('id'); // validation logic if (!empty($id)) { $this->hasError(); } return; }
function action() { // This needs form validation in a bad way. $u = owa_coreAPI::entityFactory('base.user'); $u->getByColumn('user_id', $this->getParam('user_id')); $u->set('email_address', $this->getParam('email_address')); $u->set('real_name', $this->getParam('real_name')); // never change the role of the admin user if ($u->get('user_id') != 'admin') { $u->set('role', $this->getParam('role')); } $u->update(); $this->set('status_code', 3003); $this->setRedirectAction('base.users'); }
function action() { // setup overlay cookiestate //owa_coreAPI::setState('overlay', '', urldecode($this->getParam('overlay_params')), 'cookie'); // load entity for document id to get URL $d = owa_coreAPI::entityFactory('base.document'); $d->load($this->getParam('document_id')); $url = trim($d->get('url')); if (strpos($url, '#')) { $parts = explode('#', $url); $url = $parts[0]; } $url = $url . '#owa_overlay.' . trim(base64_encode(urlencode($this->getParam('overlay_params'))), '\\u0000'); // redirect browser $this->redirectBrowserToUrl($url); }
function action() { $referral = $this->getParam('referralPageUrl'); $this->setSubview('base.reportDimensionDetail'); $this->setTitle('Referral:'); $r = owa_coreAPI::entityFactory('base.referer'); $r->getByColumn('url', $referral); $this->set('dimension_properties', array('page_title' => $r->get('page_title'), 'url' => $r->get('url'), 'snippet' => $r->get('snippet'))); $this->set('dimension_template', 'dimension_referral.php'); $this->set('metrics', 'visits,pageViews,bounces'); $this->set('dimensions', 'referralPageTitle,referralWebSite'); $this->set('sort', 'visits-'); $this->set('resultsPerPage', 25); $this->set('constraints', 'referralPageUrl==' . urlencode($referral)); $this->set('trendChartMetric', 'visits'); $this->set('trendTitle', 'There were <*= this.d.resultSet.aggregates.visits.formatted_value *> visits from this referral.'); }