dolibarr  16.0.5
box.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (C) 2005-2012 Regis Houssin <regis.houssin@inodbox.com>
3  * Copyright (C) 2007-2012 Laurent Destailleur <eldy@users.sourceforge.net>
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 
24 if (!defined('NOTOKENRENEWAL')) {
25  define('NOTOKENRENEWAL', '1'); // Disables token renewal
26 }
27 if (!defined('NOREQUIREMENU')) {
28  define('NOREQUIREMENU', '1');
29 }
30 if (!defined('NOREQUIREHTML')) {
31  define('NOREQUIREHTML', '1');
32 }
33 if (!defined('NOREQUIREAJAX')) {
34  define('NOREQUIREAJAX', '1');
35 }
36 if (!defined('NOREQUIRESOC')) {
37  define('NOREQUIRESOC', '1');
38 }
39 
40 require '../../main.inc.php';
41 require_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
42 
43 $boxid = GETPOST('boxid', 'int');
44 $boxorder = GETPOST('boxorder');
45 $zone = GETPOST('zone', 'int');
46 $userid = GETPOST('userid', 'int');
47 
48 
49 /*
50  * View
51  */
52 
53 // Ajout directives pour resoudre bug IE
54 //header('Cache-Control: Public, must-revalidate');
55 //header('Pragma: public');
56 
57 //top_htmlhead("", "", 1); // Replaced with top_httphead. An ajax page does not need html header.
58 top_httphead();
59 
60 print '<!-- Ajax page called with url '.dol_escape_htmltag($_SERVER["PHP_SELF"]).'?'.dol_escape_htmltag($_SERVER["QUERY_STRING"]).' -->'."\n";
61 
62 // Add a box
63 if ($boxid > 0 && $zone != '' && $userid > 0) {
64  $tmp = explode('-', $boxorder);
65  $nbboxonleft = substr_count($tmp[0], ',');
66  $nbboxonright = substr_count($tmp[1], ',');
67  print $nbboxonleft.'-'.$nbboxonright;
68  if ($nbboxonleft > $nbboxonright) {
69  $boxorder = preg_replace('/B:/', 'B:'.$boxid.',', $boxorder); // Insert id of new box into list
70  } else {
71  $boxorder = preg_replace('/^A:/', 'A:'.$boxid.',', $boxorder); // Insert id of new box into list
72  }
73 }
74 
75 // Registering the location of boxes after a move
76 if ($boxorder && $zone != '' && $userid > 0) {
77  // boxorder value is the target order: "A:idboxA1,idboxA2,A-B:idboxB1,idboxB2,B"
78  dol_syslog("AjaxBox boxorder=".$boxorder." zone=".$zone." userid=".$userid, LOG_DEBUG);
79 
80  $result = InfoBox::saveboxorder($db, $zone, $boxorder, $userid);
81  if ($result > 0) {
82  $langs->load("boxes");
83  if (!GETPOST('closing')) {
84  setEventMessages($langs->trans("BoxAdded"), null);
85  }
86  }
87 }
dol_escape_htmltag
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0)
Returns text escaped for inclusion in HTML alt or title tags, or into values of HTML input fields.
Definition: functions.lib.php:1468
GETPOST
GETPOST($paramname, $check='alphanohtml', $method=0, $filter=null, $options=null, $noreplace=0)
Return value of a param into GET or POST supervariable.
Definition: functions.lib.php:484
top_httphead
if(!defined('NOREQUIREMENU')) if(!function_exists("llxHeader")) top_httphead($contenttype='text/html', $forcenocache=0)
Show HTTP header.
Definition: main.inc.php:1407
InfoBox\saveboxorder
static saveboxorder($dbs, $zone, $boxorder, $userid=0)
Save order of boxes for area and user.
Definition: infobox.class.php:224
dol_syslog
dol_syslog($message, $level=LOG_INFO, $ident=0, $suffixinfilename='', $restricttologhandler='', $logcontext=null)
Write log message into outputs.
Definition: functions.lib.php:1603
setEventMessages
setEventMessages($mesg, $mesgs, $style='mesgs', $messagekey='')
Set event messages in dol_events session object.
Definition: functions.lib.php:8137