dolibarr  17.0.4
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. See the
14  * 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 
41  public $db;
42 
43  public $param;
44  public $enabled = 1;
45 
46  public $info_box_head = array();
47  public $info_box_contents = array();
48 
49 
56  public function __construct($db, $param)
57  {
58  global $conf;
59 
60  $this->db = $db;
61  }
62 
69  public function loadBox($max = 5)
70  {
71  global $conf, $user, $langs;
72 
73  $textHead = $langs->trans("BoxLoginInformation");
74  $this->info_box_head = array(
75  'text' => $textHead,
76  'limit'=> dol_strlen($textHead),
77  );
78 
79  $line = 0;
80  $this->info_box_contents[$line][0] = array(
81  'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
82  'text' => $langs->trans("User"),
83  );
84  $this->info_box_contents[$line][1] = array(
85  'td' => 'class="tdoverflowmax150 maxwidth150onsmartphone"',
86  'text' => $user->getNomUrl(-1),
87  'asis' => 1
88  );
89 
90  $line = 1;
91  $this->info_box_contents[$line][0] = array(
92  'td' => '',
93  'text' => $langs->trans("PreviousConnexion"),
94  );
95  if ($user->datepreviouslogin) {
96  $tmp = dol_print_date($user->datepreviouslogin, "dayhour", 'tzuserrel');
97  } else {
98  $tmp = $langs->trans("Unknown");
99  }
100  $this->info_box_contents[$line][1] = array(
101  'td' => '',
102  'text' => $tmp,
103  );
104  }
105 
106 
115  public function showBox($head = null, $contents = null, $nooutput = 0)
116  {
117  return parent::showBox($this->info_box_head, $this->info_box_contents, $nooutput);
118  }
119 }
Class ModeleBoxes.
Class to manage the box of last login.
loadBox($max=5)
Charge les donnees en memoire pour affichage ulterieur.
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='', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
$conf db
API class for accounts.
Definition: inc.php:41