dolibarr  13.0.2
block-info.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2017 Laurent Destailleur <eldy@users.sourceforge.net>
3  * Copyright (C) 2017 ATM Consulting <contact@atm-consulting.fr>
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <https://www.gnu.org/licenses/>.
17  */
18 
26 // This script is called with a POST method.
27 // Directory to scan (full path) is inside POST['dir'].
28 
29 if (!defined('NOTOKENRENEWAL')) define('NOTOKENRENEWAL', 1); // Disables token renewal
30 if (!defined('NOREQUIREMENU')) define('NOREQUIREMENU', '1');
31 if (!defined('NOREQUIREHTML')) define('NOREQUIREHTML', '1');
32 
33 
34 require '../../main.inc.php';
35 require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
36 
37 $id = GETPOST('id', 'int');
38 $block = new BlockedLog($db);
39 
40 if ((!$user->admin && !$user->rights->blockedlog->read) || empty($conf->blockedlog->enabled)) accessforbidden();
41 
42 $langs->loadLangs(array("admin"));
43 
44 
45 /*
46  * View
47  */
48 
49 print '<div id="pop-info"><table width="100%" height="80%" class="border"><thead><th width="50%" class="left">'.$langs->trans('Field').'</th><th class="left">'.$langs->trans('Value').'</th></thead>';
50 print '<tbody>';
51 
52 if ($block->fetch($id) > 0)
53 {
54  $objtoshow = $block->object_data;
55  print formatObject($objtoshow, '');
56 } else {
57  print 'Error, failed to get unalterable log with id '.$id;
58 }
59 
60 print '</tbody>';
61 print '</table></div>';
62 
63 
64 $db->close();
65 
66 
74 function formatObject($objtoshow, $prefix)
75 {
76  $s = '';
77 
78  $newobjtoshow = $objtoshow;
79 
80  if (is_object($newobjtoshow) || is_array($newobjtoshow))
81  {
82  //var_dump($newobjtoshow);
83  foreach ($newobjtoshow as $key => $val)
84  {
85  if (!is_object($val) && !is_array($val))
86  {
87  // TODO $val can be '__PHP_Incomplete_Class', the is_object return false
88  $s .= '<tr><td>'.($prefix ? $prefix.' > ' : '').$key.'</td>';
89  $s .= '<td>';
90  if (in_array($key, array('date', 'datef', 'dateh', 'datec', 'datem', 'datep')))
91  {
92  /*var_dump(is_object($val));
93  var_dump(is_array($val));
94  var_dump(is_array($val));
95  var_dump(@get_class($val));
96  var_dump($val);*/
97  $s .= dol_print_date($val, 'dayhour');
98  } else {
99  $s .= $val;
100  }
101  $s .= '</td></tr>';
102  } elseif (is_array($val))
103  {
104  $s .= formatObject($val, ($prefix ? $prefix.' > ' : '').$key);
105  } elseif (is_object($val))
106  {
107  $s .= formatObject($val, ($prefix ? $prefix.' > ' : '').$key);
108  }
109  }
110  }
111 
112  return $s;
113 }
GETPOST($paramname, $check= 'alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Class to manage Blocked Log.
accessforbidden($message= '', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program Calling this function terminate execution ...
print
Draft customers invoices.
Definition: index.php:89
dol_print_date($time, $format= '', $tzoutput= 'auto', $outputlangs= '', $encodetooutput=false)
Output date in a string format according to outputlangs (or langs if not defined).
if(!defined('CSRFCHECK_WITH_TOKEN')) define('CSRFCHECK_WITH_TOKEN'
Draft customers invoices.