dolibarr  20.0.0-beta
block-add.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')) {
30  define('NOTOKENRENEWAL', 1); // Disables token renewal
31 }
32 if (!defined('NOREQUIREMENU')) {
33  define('NOREQUIREMENU', '1');
34 }
35 if (!defined('NOREQUIREHTML')) {
36  define('NOREQUIREHTML', '1');
37 }
38 
39 $res = require '../../main.inc.php';
40 
41 $id = GETPOSTINT('id');
42 $element = GETPOST('element', 'alpha');
43 $action = GETPOST('action', 'aZ09');
44 
45 if ($element === 'facture') {
46  $result = restrictedArea($user, 'facture', $id, '', '', 'fk_soc', 'rowid', 0);
47 } else {
48  accessforbidden('Bad value for element');
49 }
50 
51 
52 /*
53  * View
54  */
55 
56 top_httphead();
57 
58 if (empty($action)) {
59  print 'No action logged. Empty action code.';
60  exit;
61 }
62 
63 if ($element === 'facture') {
64  require_once DOL_DOCUMENT_ROOT.'/blockedlog/class/blockedlog.class.php';
65  require_once DOL_DOCUMENT_ROOT.'/compta/facture/class/facture.class.php';
66 
67  $facture = new Facture($db);
68  if ($facture->fetch($id) > 0) {
69  $facture->call_trigger($action, $user);
70  }
71 
72  print 'Object '.$element.' logged with action code = '.$action;
73 }
Class to manage invoices.
GETPOSTINT($paramname, $method=0)
Return the value of a $_GET or $_POST supervariable, converted into integer.
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
if(!defined('NOREQUIREMENU')) if(!empty(GETPOST('seteventmessages', 'alpha'))) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1648
restrictedArea(User $user, $features, $object=0, $tableandshare='', $feature2='', $dbt_keyfield='fk_soc', $dbt_select='rowid', $isdraft=0, $mode=0)
Check permissions of a user to show a page and an object.
accessforbidden($message='', $printheader=1, $printfooter=1, $showonlymessage=0, $params=null)
Show a message to say access is forbidden and stop program.