dolibarr  20.0.0-beta
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-2020 Frederic France <frederic.france@netlogic.fr>
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14  * See the GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <https://www.gnu.org/licenses/>.
18  */
19 
26 include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php';
27 
32 {
33  public $boxcode = "lastlogin";
34  public $boximg = "object_user";
35  public $boxlabel = 'BoxLoginInformation';
36  public $depends = array("user");
37 
38  public $enabled = 1;
39 
46  public function __construct($db, $param)
47  {
48  global $conf;
49 
50  $this->db = $db;
51  }
52 
59  public function loadBox($max = 5)
60  {
61  global $conf, $user, $langs;
62 
63  $textHead = $langs->trans("BoxLoginInformation");
64  $this->info_box_head = array(
65  'text' => $textHead,
66  'limit'=> dol_strlen($textHead),
67  );
68 
69  $line = 0;
70  $this->info_box_contents[$line][0] = array(
71  'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
72  'text' => $langs->trans("User"),
73  );
74  $this->info_box_contents[$line][1] = array(
75  'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
76  'text' => $user->getNomUrl(-1),
77  'asis' => 1
78  );
79 
80  $line = 1;
81  $this->info_box_contents[$line][0] = array(
82  'td' => '',
83  'text' => $langs->trans("PreviousConnexion"),
84  );
85  if ($user->datepreviouslogin) {
86  $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuserrel');
87  } else {
88  $tmp = $langs->trans("Unknown");
89  }
90  $this->info_box_contents[$line][1] = array(
91  'td' => '',
92  'text' => $tmp,
93  );
94  }
95 
96 
105  public function showBox($head = null, $contents = null, $nooutput = 0)
106  {
107  return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
108  }
109 }
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_strlen($string, $stringencoding='UTF-8')
Make a strlen call.
dol_print_date($time, $format='', $tzoutput='auto', $outputlangs=null, $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).