public function sessions($sessions) { $this->title($this('sessions')); $active_sessions = $this->load->library('table')->add_columns(array(array('content' => function ($data) { return $data['remember_me'] ? '<i class="fa fa-toggle-on text-green" data-toggle="tooltip" title="' . i18n('persistent_connection') . '"></i>' : '<i class="fa fa-toggle-off text-grey" data-toggle="tooltip" title="' . i18n('nonpersistent_connection') . '"></i>'; }, 'size' => TRUE, 'align' => 'center'), array('content' => function ($data) { return user_agent($data['user_agent']); }, 'size' => TRUE, 'align' => 'center'), array('title' => $this('ip_address'), 'content' => function ($data) { return geolocalisation($data['ip_address']) . '<span data-toggle="tooltip" data-original-title="' . $data['host_name'] . '">' . $data['ip_address'] . '</span>'; }), array('title' => $this('reference'), 'content' => function ($data, $loader) { return $data['referer'] ? urltolink($data['referer']) : $loader->lang('unknown'); }), array('title' => $this('initial_session_date'), 'content' => function ($data) { return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['date']) . '">' . time_span($data['date']) . '</span>'; }), array('title' => $this('last_activity'), 'content' => function ($data) { return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['last_activity']) . '">' . time_span($data['last_activity']) . '</span>'; }), array('content' => array(function ($data) { if ($data['session_id'] != NeoFrag::loader()->session('session_id')) { return button_delete('user/sessions/delete/' . $data['session_id'] . '.html'); } }))))->pagination(FALSE)->data($this->user->get_sessions())->save(); $sessions_history = $this->table->add_columns(array(array('content' => function ($data) { return user_agent($data['user_agent']); }, 'size' => TRUE, 'align' => 'center'), array('title' => $this('ip_address'), 'content' => function ($data) { return geolocalisation($data['ip_address']) . '<span data-toggle="tooltip" data-original-title="' . $data['host_name'] . '">' . $data['ip_address'] . '</span>'; }), array('title' => $this('reference'), 'content' => function ($data, $loader) { return $data['referer'] ? urltolink($data['referer']) : $loader->lang('unknown'); }), array('title' => $this('initial_session_date'), 'content' => function ($data) { return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['date']) . '">' . time_span($data['date']) . '</span>'; })))->data($sessions)->no_data($this('no_historic_available')); return array(new Panel(array('title' => $this('my_active_sessions'), 'icon' => 'fa-shield', 'content' => $active_sessions->display())), new Panel(array('title' => $this('sessions_historic'), 'icon' => 'fa-power-off', 'content' => $sessions_history->display())), new Button_back('user.html')); }
public function _sessions($sessions) { $this->title($this('sessions'))->subtitle($this('list_active_sessions'))->icon('fa-globe')->load->library('table')->preprocessing(function ($row) { $user_data = unserialize($row['user_data']); $row['date'] = $user_data['session']['date']; $row['history'] = array_reverse($user_data['session']['history']); $row['user_agent'] = $user_data['session']['user_agent']; $row['referer'] = $user_data['session']['referer']; unset($row['user_data']); return $row; })->add_columns(array(array('content' => function ($data) { return $data['remember_me'] ? '<i class="fa fa-toggle-on text-green" data-toggle="tooltip" title="Connexion persistante"></i>' : '<i class="fa fa-toggle-off text-grey" data-toggle="tooltip" title="Connexion non persistante"></i>'; }, 'size' => TRUE, 'align' => 'center'), array('title' => $this('user'), 'content' => function ($data, $loader) { return $data['user_id'] ? NeoFrag::loader()->user->link($data['user_id'], $data['username']) : '<i>' . $loader->lang('guest') . '</i>'; }, 'search' => function ($data, $loader) { return $data['user_id'] ? $data['username'] : $loader->lang('guest'); }, 'sort' => function ($data, $loader) { return $data['user_id'] ? $data['username'] : $loader->lang('guest'); }), array('content' => function ($data) { return user_agent($data['user_agent']); }, 'size' => TRUE, 'align' => 'center', 'search' => function ($data) { return $data['user_agent']; }, 'sort' => function ($data) { return $data['user_agent']; }), array('title' => $this('ip_address'), 'content' => function ($data) { return geolocalisation($data['ip_address']) . '<span data-toggle="tooltip" data-original-title="' . $data['host_name'] . '">' . $data['ip_address'] . '</span>'; }, 'search' => function ($data) { return $data['ip_address']; }, 'sort' => function ($data) { return $data['ip_address']; }), array('title' => $this('referer'), 'content' => function ($data, $loader) { return $data['referer'] ? urltolink($data['referer']) : $loader->lang('none'); }, 'search' => function ($data) { return $data['user_agent']; }, 'sort' => function ($data) { return $data['user_agent']; }), array('title' => $this('arrival_date'), 'content' => function ($data) { return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['date']) . '">' . time_span($data['date']) . '</span>'; }, 'sort' => function ($data) { return $data['date']; }), array('title' => $this('last_activity'), 'content' => function ($data) { return '<span data-toggle="tooltip" title="' . timetostr(NeoFrag::loader()->lang('date_time_long'), $data['last_activity']) . '">' . time_span($data['last_activity']) . '</span>'; }, 'sort' => function ($data) { return $data['last_activity']; }), array('title' => $this('history'), 'content' => function ($data, $loader) { $links = implode('<br />', array_map(function ($a) { return '<a href="' . url($a) . '">' . $a . '</a>'; }, $data['history'])); return '<span data-toggle="popover" title="' . $loader->lang('last_pages_visited') . '" data-content="' . utf8_htmlentities($links) . '" data-placement="auto" data-html="1">' . icon('fa-history') . ' ' . reset($data['history']) . '</span>'; }), array('content' => array(function ($data) { if ($data['user_id'] && $data['session_id'] != NeoFrag::loader()->session('session_id')) { return button_delete('admin/members/sessions/delete/' . $data['session_id'] . '.html'); } }))))->data($sessions); return new Panel(array('title' => $this('sessions'), 'icon' => 'fa-globe', 'content' => $this->table->display())); }