/**
  * Default column
  * @param unknown_type $item
  * @param unknown_type $column_name
  * @return unknown|mixed
  */
 function column_default($item, $column_name)
 {
     switch ($column_name) {
         case 'action':
             return $item[$column_name];
             break;
         case 'time_elapsed':
             $sequence = intval($item['sequence']);
             if ($sequence > 1) {
                 $current_activity_time = strtotime($item['record_date']);
                 $page_num = $this->get_pagenum();
                 $items_per_page = $this->get_pagination_arg('per_page');
                 $previous_row = $this->items[count($this->items) - $sequence + 1 + ($page_num - 1) * $items_per_page];
                 $previous_activity_time = strtotime($previous_row['record_date']);
                 $human_time_diff = HA_Common::human_time_diff($previous_activity_time, $current_activity_time);
                 echo $human_time_diff;
             }
             break;
         case 'url':
             echo '<a href="' . $item[$column_name] . '">' . $item[$column_name] . '</a>';
             break;
         default:
             echo $item[$column_name];
             break;
     }
 }
Esempio n. 2
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>';
        }
    }