/**
  * (non-PHPdoc)
  * @see WP_List_Table::prepare_items()
  */
 function prepare_items()
 {
     $query_helper = new HA_Query_Helper();
     $query_helper->get_session_filters(array('last_days' => true, 'url' => true, 'page_width' => true, 'browser' => true, 'device' => true, 'os' => true));
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $query_helper->get_http_filters('POST');
     } else {
         $query_helper->get_http_filters('GET');
     }
     $query_helper->set_session_filters();
     // Register the columns
     $columns = $this->get_columns();
     $hidden = array('last_updt_date', 'user_env_id', 'user_id', 'device', 'browser', 'os', 'id', 'record_date', 'description');
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $items_per_page = 25;
     // Ensure paging is reset on filter submit by checking HTTP method as well
     $page_num = !empty($_GET["paged"]) && $_SERVER['REQUEST_METHOD'] != 'POST' ? mysql_real_escape_string($_GET["paged"]) : '';
     if (empty($page_num) || !is_numeric($page_num) || $page_num <= 0) {
         $page_num = 1;
     }
     global $ha_admin_controller;
     $data = $ha_admin_controller->get_data_services()->table_query('heatmaps_table_data', $query_helper->get_filters(), $items_per_page, $page_num);
     $this->set_pagination_args($data['pagination_args']);
     $this->items = $data['items'];
 }
 /**
  * (non-PHPdoc)
  * @see WP_List_Table::prepare_items()
  */
 function prepare_items()
 {
     $query_helper = new HA_Query_Helper();
     $query_helper->get_session_filters(array('ip_address' => true, 'session_id' => true, 'event_type' => true, 'url' => true));
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $query_helper->get_http_filters('POST');
     } else {
         $query_helper->get_http_filters('GET');
     }
     $query_helper->set_session_filters();
     // Register the columns
     $columns = $this->get_columns();
     $hidden = array('user_env_id', 'user_id', 'id');
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     $items_per_page = 25;
     // Ensure paging is reset on filter submit by checking HTTP method as well
     $page_num = !empty($_GET["paged"]) && $_SERVER['REQUEST_METHOD'] != 'POST' ? mysql_real_escape_string($_GET["paged"]) : '';
     if (empty($page_num) || !is_numeric($page_num) || $page_num <= 0) {
         $page_num = 1;
     }
     global $ha_admin_controller;
     $data = $ha_admin_controller->get_data_services()->table_query('user_activity_table_data', $query_helper->get_filters(), $items_per_page, $page_num);
     $this->set_pagination_args($data['pagination_args']);
     $this->items = isset($data['items']) ? $data['items'] : array();
     $index = count($this->items) + ($page_num - 1) * $items_per_page;
     foreach ($this->items as &$item) {
         $item['sequence'] = $index--;
     }
 }
 /**
  * (non-PHPdoc)
  * @see WP_List_Table::prepare_items()
  */
 function prepare_items()
 {
     global $wpdb;
     // Register the columns
     $columns = $this->get_columns();
     $hidden = array(HA_Common::ID_COLUMN);
     $sortable = $this->get_sortable_columns();
     $this->_column_headers = array($columns, $hidden, $sortable);
     // get table data
     $query_helper = new HA_Query_Helper();
     $query_helper->get_session_filters(array('last_days' => true, 'device' => true, 'os' => true, 'browser' => true));
     if ($_SERVER['REQUEST_METHOD'] == 'POST') {
         $query_helper->get_http_filters('POST');
     } else {
         $query_helper->get_http_filters('GET');
     }
     $query_helper->set_session_filters();
     $items_per_page = 25;
     // Ensure paging is reset on filter submit by checking HTTP method as well
     $page_num = !empty($_GET["paged"]) && $_SERVER['REQUEST_METHOD'] != 'POST' ? mysql_real_escape_string($_GET["paged"]) : '';
     if (empty($page_num) || !is_numeric($page_num) || $page_num <= 0) {
         $page_num = 1;
     }
     global $ha_admin_controller;
     $data = $ha_admin_controller->get_data_services()->table_query('event_statistics_table_report_data', $query_helper->get_filters(), $items_per_page, $page_num);
     if (isset($data['pagination_args'])) {
         $this->set_pagination_args($data['pagination_args']);
     }
     if (isset($data['items'])) {
         $this->items = $data['items'];
     }
 }
 /**
  * Retrieves all mouse clicks/touch screen taps
  *
  * @since 1.0
  */
 public function retrieve_user_events()
 {
     $ajax_nonce = $_GET['nonce'];
     $response = array();
     if (wp_verify_nonce($ajax_nonce, HA_Common::PLUGIN_ID . '-nonce')) {
         $response = array('status' => 'OK', 'message' => '');
         // GET parameters
         $url = isset($_GET['url']) ? HA_Common::normalize_url(urldecode($_GET['url'])) : null;
         $ignore_width = isset($_GET['ignoreWidth']) && $_GET['ignoreWidth'] == "true" ? true : false;
         $width_allowance = isset($_GET['widthAllowance']) && is_numeric($_GET['widthAllowance']) ? intval($_GET['widthAllowance']) : null;
         $page_width = isset($_GET['pageWidth']) && is_numeric($_GET['pageWidth']) ? intval($_GET['pageWidth']) : null;
         $user_event_id = isset($_GET['userEventId']) && is_numeric($_GET['userEventId']) ? intval($_GET['userEventId']) : null;
         $ignore_device = isset($_GET['ignoreDevice']) && $_GET['ignoreDevice'] == "true" ? true : false;
         $device = isset($_GET['device']) && strlen(trim($_GET['device'])) > 0 ? urldecode($_GET['device']) : null;
         $ignore_os = isset($_GET['ignoreOs']) && $_GET['ignoreOs'] == "true" ? true : false;
         $os = isset($_GET['os']) && strlen(trim($_GET['os'])) > 0 ? urldecode($_GET['os']) : null;
         $ignore_browser = isset($_GET['ignoreBrowser']) && $_GET['ignoreBrowser'] == "true" ? true : false;
         $browser = isset($_GET['browser']) && strlen(trim($_GET['browser'])) > 0 ? urldecode($_GET['browser']) : null;
         $hide_roles = isset($_GET['hideRoles']) && is_array($_GET['hideRoles']) ? $_GET['hideRoles'] : array();
         $spot_radius = isset($_GET['spotRadius']) && is_numeric($_GET['spotRadius']) ? intval($_GET['spotRadius']) : null;
         $event_types = isset($_GET['eventTypes']) && is_array($_GET['eventTypes']) ? $_GET['eventTypes'] : array();
         // validate data
         if (!$url || !count($event_types) > 0) {
             $response['status'] = 'Error';
             $response['message'] = 'Required data missing from request';
             echo json_encode($response);
             return;
         }
         global $wpdb;
         // base query - all user events for a given url
         $query = 'SELECT u_event.' . HA_Common::ID_COLUMN . ', u_event.' . HA_Common::X_COORD_COLUMN . ', u_event.' . HA_Common::Y_COORD_COLUMN . ', u_event.' . HA_Common::URL_COLUMN . ', u_event.' . HA_Common::EVENT_TYPE_COLUMN . ', u_event.' . HA_Common::PAGE_WIDTH_COLUMN . ' FROM ' . $wpdb->prefix . HA_Common::USER_EVENT_TBL_NAME . ' AS u_event, ' . $wpdb->prefix . HA_Common::USER_ENV_TBL_NAME . ' AS u_env, ' . $wpdb->prefix . HA_Common::USER_TBL_NAME . ' AS u WHERE u.' . HA_Common::ID_COLUMN . ' = u_event.' . HA_Common::USER_ID_COLUMN . ' AND u.' . HA_Common::ID_COLUMN . ' = u_env.' . HA_Common::USER_ID_COLUMN . ' AND u_event.' . HA_Common::URL_COLUMN . ' = "' . $url . '"';
         $query_filters = array('ignore_width' => $ignore_width, 'width_allowance' => $width_allowance, 'page_width' => $page_width, 'user_event_id' => $user_event_id, 'ignore_device' => $ignore_device, 'device' => $device, 'ignore_os' => $ignore_os, 'os' => $os, 'ignore_browser' => $ignore_browser, 'browser' => $browser, 'hide_roles' => $hide_roles, 'event_types' => $event_types, 'exact_match' => false);
         $query = HA_Query_Helper::apply_query_filters($query, $query_filters);
         $rows = $wpdb->get_results($query);
         $index = 0;
         foreach ($rows as $row) {
             $user_event_id = $row->id;
             $x_coord = $row->x_coord;
             $y_coord = $row->y_coord;
             $url = HA_Common::normalize_url($row->url);
             $page_width = $row->page_width;
             $heat_value = HA_Common::calculate_heat_value($x_coord, $y_coord, $user_event_id, $rows, $spot_radius);
             $response[$index++] = array('user_event_id' => $user_event_id, 'x_coord' => $x_coord, 'y_coord' => $y_coord, 'page_width' => $page_width, 'url' => $url, 'heat_value' => $heat_value, 'event_type' => $row->event_type);
         }
     }
     echo json_encode($response);
     die;
 }
 private function event_totals_bar_graph_report_data($filters)
 {
     global $wpdb;
     // Counts data
     $query = 'SELECT count(*) as count, u_event.' . HA_Common::EVENT_TYPE_COLUMN . ' FROM ' . $wpdb->prefix . HA_Common::USER_TBL_NAME . ' AS u, ' . $wpdb->prefix . HA_Common::USER_EVENT_TBL_NAME . ' AS u_event, ' . $wpdb->prefix . HA_Common::USER_ENV_TBL_NAME . ' AS u_env WHERE u_event.' . HA_Common::USER_ENV_ID_COLUMN . ' = u_env.' . HA_Common::ID_COLUMN . ' AND u.' . HA_Common::ID_COLUMN . ' = u_event.' . HA_Common::USER_ID_COLUMN;
     $query = HA_Query_Helper::apply_query_filters($query, $filters);
     $query .= ' GROUP BY ' . HA_Common::EVENT_TYPE_COLUMN;
     $rows = $wpdb->get_results($query);
     $count_data = array();
     foreach ($rows as $row) {
         $event_type = $row->event_type;
         $count = $row->count;
         array_push($count_data, array($event_type, $count));
     }
     return json_decode(json_encode(array('count_data' => $count_data)), false);
 }
    public static function show_user_activity_tab()
    {
        ?>
		<form method="post">
			<div class="tablenav top">
				<?php 
        $query_helper = new HA_Query_Helper();
        $filters = array('ip_address' => true, 'session_id' => true, 'event_type' => true, 'url' => true);
        $query_helper->get_session_filters($filters);
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $query_helper->get_http_filters('POST');
        } else {
            $query_helper->get_http_filters('GET');
        }
        $query_helper->set_session_filters();
        $query_helper->show_filters($filters);
        ?>
			</div>
			<div id="poststuff" class="">
		        <div id="post-body" class="metabox-holder">
	                <?php 
        wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false);
        ?>
	                <?php 
        wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false);
        ?>
	                <?php 
        add_meta_box("user-activity-summary-metabox", "Summary", array('HA_Report_View', "user_activity_summary_metabox"), HA_Common::REPORTS_PAGE_SLUG, "normal");
        ?>
	                <?php 
        do_meta_boxes(HA_Common::REPORTS_PAGE_SLUG, 'normal', array());
        ?>
	
				</div>
			</div>
			<?php 
        $user_activity_table = new HA_User_Activity_Table();
        $user_activity_table->prepare_items();
        $user_activity_table->display();
        ?>
		</form>
		<?php 
    }
Beispiel #7
0
    public static function user_activity_summary_metabox($params)
    {
        $query_helper = new HA_Query_Helper();
        $query_helper->get_session_filters(array('ip_address' => true, 'session_id' => true, 'event_type' => true, 'url' => true));
        if ($_SERVER['REQUEST_METHOD'] == 'POST') {
            $query_helper->get_http_filters('POST');
        } else {
            $query_helper->get_http_filters('GET');
        }
        $query_helper->set_session_filters();
        global $ha_admin_controller;
        $data = $ha_admin_controller->get_data_services()->simple_query('user_activity_summary_data', $query_helper->get_filters());
        if (isset($data->count_total) && $data->count_total > 0) {
            ?>
			<table class="form-table">
				<tbody>
					<tr valign="top">
						<th scope="row">IP Address</th>
						<td><?php 
            echo $data->ip_address;
            ?>
</td>
						<th scope="row">Session ID</th>
						<td><?php 
            echo $data->session_id;
            ?>
</td>
						<th scope="row">Duration</th>
						<td><?php 
            $latest_record_date = strtotime($data->latest_record_date);
            $oldest_record_date = strtotime($data->oldest_record_date);
            $human_time_diff = HA_Common::human_time_diff($oldest_record_date, $latest_record_date);
            echo $human_time_diff;
            ?>
</td>
					</tr>
					<tr valign="top">
						<th scope="row">Username</th>
						<td><?php 
            echo $data->username;
            ?>
</td>
						<th scope="row">Role</th>
						<td><?php 
            echo $data->role;
            ?>
</td>
						<th scope="row">Browser</th>
						<td><?php 
            echo $data->browser;
            ?>
</td>
					</tr>
					<tr valign="top">
						<th scope="row">Latest Record Date</th>
						<td><?php 
            echo date("F j, Y, g:i a", strtotime($data->latest_record_date));
            ?>
</td>
						<th scope="row">Page Views</th>
						<td><?php 
            echo $data->count_page_views;
            ?>
</td>
						<th scope="row">Device</th>
						<td><?php 
            echo $data->device;
            ?>
</td>
						
					</tr>
					<tr valign="top">
						<th scope="row">Mouse Clicks</th>
						<td><?php 
            echo $data->count_mouse_clicks;
            ?>
</td>
						<th scope="row">Touchscreen Taps</th>
						<td><?php 
            echo $data->count_touchscreen_taps;
            ?>
</td>
						<th scope="row">Operating System</th>
						<td><?php 
            echo $data->os;
            ?>
</td>
					</tr>
					<tr valign="top">
						<th scope="row">AJAX Actions</th>
						<td><?php 
            echo $data->count_ajax_actions;
            ?>
</td>
						<th scope="row">Custom Events</th>
						<td><?php 
            echo $data->count_total - $data->count_mouse_clicks - $data->count_touchscreen_taps - $data->count_page_views - $data->count_ajax_actions;
            ?>
</td>
						<th scope="row">Page Width</th>
						<td><?php 
            echo $data->page_width;
            ?>
px</td>
						</tr>
				</tbody>
			</table>
			<?php 
        } else {
            echo '<p>No summary found.</p>';
        }
    }