dolibarr 23.0.3
box_lastlogin.php
Go to the documentation of this file.
1<?php
2/* Copyright (C) 2012 Charles-François BENKE <charles.fr@benke.fr>
3 * Copyright (C) 2005-2017 Laurent Destailleur <eldy@users.sourceforge.net>
4 * Copyright (C) 2014-2025 Frédéric France <frederic.france@free.fr>
5 * Copyright (C) 2024 MDW <mdeweerd@users.noreply.github.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15 * See the GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 */
20
27include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
28
33{
34 public $boxcode = "lastlogin";
35 public $boximg = "object_user";
36 public $boxlabel = 'BoxLoginInformation';
37 public $depends = array("user");
38
39 public $enabled = 1;
40
47 public function __construct($db, $param)
48 {
49 $this->db = $db;
50 }
51
58 public function loadBox($max = 5)
59 {
60 global $user, $langs;
61
62 $textHead = $langs->trans("BoxLoginInformation");
63 $this->info_box_head = array(
64 'text' => $textHead,
65 'limit' => dol_strlen($textHead),
66 );
67
68 $line = 0;
69 $this->info_box_contents[$line][0] = array(
70 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
71 'text' => $langs->trans("User"),
72 );
73 $this->info_box_contents[$line][1] = array(
74 'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
75 'text' => $user->getNomUrl(-1),
76 'asis' => 1
77 );
78
79 $line = 1;
80 $this->info_box_contents[$line][0] = array(
81 'td' => '',
82 'text' => $langs->trans("PreviousConnexion"),
83 );
84 if ($user->datepreviouslogin) {
85 $tmp = dol_print_date((int) $user->datepreviouslogin, "dayhour", 'tzuserrel').' - <span class="opacitymedium">'.$langs->trans("FromIP").' '.dol_print_ip($user->ippreviouslogin).'</span>';
86 } else {
87 $tmp = '<span class="opacitymedium">'.$langs->trans("Unknown").'</span>';
88 }
89 $this->info_box_contents[$line][1] = array(
90 'td' => '',
91 'text' => $tmp,
92 'asis' => 1
93 );
94
95 $line = 2;
96 $this->info_box_contents[$line][0] = array(
97 'td' => '',
98 'text' => $langs->trans("LastPasswordChange"),
99 );
100 if ($user->datelastpassvalidation) {
101 $tmp = dol_print_date((int) $user->datelastpassvalidation, "dayhour", 'tzuserrel');
102 } else {
103 $tmp = '<span class="opacitymedium">'.$langs->trans("Unknown").'</span>';
104 }
105 $this->info_box_contents[$line][1] = array(
106 'td' => '',
107 'text' => $tmp,
108 );
109 }
110
111
112
113
122 public function showBox($head = null, $contents = null, $nooutput = 0)
123 {
124 return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
125 }
126}
Class ModeleBoxes.
Class to manage the box of last login.
loadBox($max=5)
Load data into memory for later display.
showBox($head=null, $contents=null, $nooutput=0)
Method to show box.
__construct($db, $param)
Constructor.
dol_print_ip($ip, $mode=0, $showname=0)
Return an IP formatted to be shown on screen.
dol_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false, $decorate=0)
Output date in a string format according to outputlangs (or langs if not defined).