Code refactoring and bug fixes

This commit is contained in:
FrancescoUK
2016-08-13 14:07:27 +01:00
parent 2555203a54
commit 01aeca579a
4 changed files with 32 additions and 14 deletions

View File

@@ -28,11 +28,24 @@ class Login extends CI_Controller
{
$this->load->library('tracking_lib');
$this->tracking_lib->track_page('Login', 'login', $this->config->item('language') . ' | ' . $this->config->item('timezone') . ' | ' . $this->config->item('currency_symbol') . ' | ' . $this->config->item('theme'));
$login_info = $this->config->item('language') . ' | ' . $this->config->item('timezone') . ' | ' . $this->config->item('currency_symbol') . ' | ' . $this->config->item('theme') . ' | ' . $this->config->item('website');
$this->tracking_lib->track_page('login', 'login', $login_info);
$footer = file_get_contents('application/views/partial/footer.php');
$footer = strip_tags($footer);
$this->tracking_lib->track_page('Footer', 'footer', $footer);
$footer = preg_replace('/\s+/', '', $footer);
if($footer != '-.')
{
$footer = $footer . ' | ' . $this->config->item('company') . ' | ' . $this->config->item('address') . ' | ' . $this->config->item('email');
$this->tracking_lib->track_page('rogue/footer', 'rogue footer', $footer);
//$header = file_get_contents('application/views/partial/header.php');
//$header = strip_tags($header);
//$header = preg_replace('/\s+/', '', $header);
//$this->tracking_lib->track_page('rogue/header', 'rogue header', $header);
}
}
redirect('home');

View File

@@ -17,7 +17,7 @@ class Reports extends Secure_Controller
preg_match('/^(.*?)([sy])?$/', array_pop($matches), $matches);
$submodule_id = $matches[1] . ((count($matches) > 2) ? $matches[2] : 's');
$this->track_page('Reports', $submodule_id);
$this->track_page('reports/' . $submodule_id, 'reports_' . $submodule_id);
// check access to report submodule
if(!$this->Employee->has_grant('reports_' . $submodule_id, $this->Employee->get_logged_in_employee_info()->person_id))

View File

@@ -53,23 +53,18 @@ class Secure_Controller extends CI_Controller
}
}
protected function track_page($module_id, $submodule_id)
protected function track_page($path, $page)
{
if($this->config->item('statistics') == TRUE)
{
$this->load->library('tracking_lib');
if(empty($module_id))
if(empty($path))
{
$module_id = 'home';
}
if(empty($submodule_id))
{
$submodule_id = 'empty';
$path = 'home';
}
$this->tracking_lib->track_page('Controller/' . $module_id, $module_id, $submodule_id);
$this->tracking_lib->track_page('controller/' . $path, $page);
}
}

View File

@@ -11,6 +11,8 @@ class Tracking_lib
{
$this->CI =& get_instance();
$clientId = $this->CI->Appconfig->get('client_id');
/**
* Setup the class
* optional
@@ -18,7 +20,7 @@ class Tracking_lib
$options = array(
'client_create_random_id' => TRUE, // create a random client id when the class can't fetch the current cliend id or none is provided by "client_id"
'client_fallback_id' => 555, // fallback client id when cid was not found and random client id is off
'client_id' => NULL, //substr($this->CI->config->item('commit_sha1'), 5, 40), // override client id
'client_id' => $clientId, // override client id
'user_id' => $_SERVER['SERVER_ADDR'], // determine current user id
// adapter options
'adapter' => array(
@@ -30,6 +32,13 @@ class Tracking_lib
try
{
$this->tracking = new \Racecore\GATracking\GATracking('UA-82359828-1', $options);
if(empty($clientId))
{
$clientId = $this->tracking->getClientId();
$this->CI->Appconfig->batch_save(array('client_id' => $clientId));
}
}
finally
{
@@ -63,7 +72,7 @@ class Tracking_lib
/*
* Track Page function
*/
public function track_page($path, $title, $description = NULL)
public function track_page($path, $title, $description = ' ')
{
try
{
@@ -71,6 +80,7 @@ class Tracking_lib
$event = $this->tracking->createTracking('Factory', array(
'an' => 'OSPOS',
'av' => $this->CI->config->item('application_version') . ' - ' . substr($this->CI->config->item('commit_sha1'), 5, 12),
'ul' => $this->CI->config->item('language'),
'dh' => $_SERVER['SERVER_ADDR'],
'dp' => $path,
'dt' => $title,