From 0861fbfeb6e9cf696c9ecf2abe09d02597644733 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 13 Jan 2013 23:47:23 +0100 Subject: [PATCH 1/7] Fix: Missing kenya currency --- htdocs/install/mysql/data/llx_c_currencies.sql | 1 + 1 file changed, 1 insertion(+) diff --git a/htdocs/install/mysql/data/llx_c_currencies.sql b/htdocs/install/mysql/data/llx_c_currencies.sql index fa84275d24f..293c1ea8796 100644 --- a/htdocs/install/mysql/data/llx_c_currencies.sql +++ b/htdocs/install/mysql/data/llx_c_currencies.sql @@ -85,6 +85,7 @@ INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'ILS' INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'JMD', '[74,36]', 1, 'Jamaica Dollar'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'JPY', '[165]', 1, 'Japan Yen'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'JEP', '[163]', 1, 'Jersey Pound'); +INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'KES', NULL, 1, 'Kenya Shilling'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'KZT', '[1083,1074]', 1, 'Kazakhstan Tenge'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'KPW', '[8361]', 1, 'Korea (North) Won'); INSERT INTO llx_c_currencies ( code_iso, unicode, active, label ) VALUES ( 'KRW', '[8361]', 1, 'Korea (South) Won'); From b9dc76ebaf525d18d2182bcc005d82685d8e3ac8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Jan 2013 12:27:19 +0100 Subject: [PATCH 2/7] Fix: List of contacts when connected as external user. --- htdocs/core/boxes/box_contacts.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php index 47741be9ec0..4d237051672 100755 --- a/htdocs/core/boxes/box_contacts.php +++ b/htdocs/core/boxes/box_contacts.php @@ -78,12 +78,11 @@ class box_contacts extends ModeleBoxes if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= ", ".MAIN_DB_PREFIX."societe_commerciaux as sc"; $sql.= " WHERE sp.entity IN (".getEntity('societe', 1).")"; if (! $user->rights->societe->client->voir && ! $user->societe_id) $sql.= " AND sp.rowid = sc.fk_soc AND sc.fk_user = " .$user->id; - if ($user->societe_id) $sql.= " AND sp.rowid = $user->societe_id"; + if ($user->societe_id) $sql.= " AND sp.fk_soc = $user->societe_id"; $sql.= " ORDER BY sp.tms DESC"; $sql.= $db->plimit($max, 0); $result = $db->query($sql); - if ($result) { $num = $db->num_rows($result); From 49313fff3be9b259ab56e5189724f086193e0462 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Jan 2013 13:06:08 +0100 Subject: [PATCH 3/7] Fix: External user should not see boxes of modules not allowed to external users. --- htdocs/core/boxes/box_comptes.php | 13 +++++++++---- htdocs/core/boxes/box_members.php | 16 +++++++++++----- htdocs/core/boxes/modules_boxes.php | 3 ++- htdocs/core/class/conf.class.php | 2 +- htdocs/core/class/infobox.class.php | 5 +++-- 5 files changed, 26 insertions(+), 13 deletions(-) diff --git a/htdocs/core/boxes/box_comptes.php b/htdocs/core/boxes/box_comptes.php index 64389354605..f2d96ad1e51 100644 --- a/htdocs/core/boxes/box_comptes.php +++ b/htdocs/core/boxes/box_comptes.php @@ -1,6 +1,6 @@ + * Copyright (C) 2005-2013 Laurent Destailleur * Copyright (C) 2005-2009 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -38,20 +38,25 @@ class box_comptes extends ModeleBoxes var $db; var $param; - + var $enabled = 1; + var $info_box_head = array(); var $info_box_contents = array(); - + /** * Constructor */ function __construct() { - global $langs; + global $conf, $langs, $user; $langs->load("boxes"); $this->boxlabel=$langs->transnoentitiesnoconv('BoxCurrentAccounts'); + + // disable module for such cases + $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users } /** diff --git a/htdocs/core/boxes/box_members.php b/htdocs/core/boxes/box_members.php index 89bce42088e..5c9e3a6f3ab 100755 --- a/htdocs/core/boxes/box_members.php +++ b/htdocs/core/boxes/box_members.php @@ -1,6 +1,6 @@ - * Copyright (C) 2004-2012 Laurent Destailleur + * Copyright (C) 2004-2013 Laurent Destailleur * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify @@ -19,8 +19,8 @@ /** * \file htdocs/core/boxes/box_members.php - * \ingroup societes - * \brief Module de generation de l'affichage de la box clients + * \ingroup adherent + * \brief Module to show box of members */ include_once DOL_DOCUMENT_ROOT.'/core/boxes/modules_boxes.php'; @@ -38,19 +38,25 @@ class box_members extends ModeleBoxes var $db; var $param; - + var $enabled = 1; + var $info_box_head = array(); var $info_box_contents = array(); + /** * Constructor */ function __construct() { - global $langs; + global $conf, $langs, $user; $langs->load("boxes"); $this->boxlabel=$langs->transnoentitiesnoconv("BoxLastMembers"); + + // disable module for such cases + $listofmodulesforexternal=explode(',',$conf->global->MAIN_MODULES_FOR_EXTERNAL); + if (! in_array('banque',$listofmodulesforexternal) && ! empty($user->societe_id)) $this->enabled=0; // disabled for external users } /** diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index 913e3d1627a..e0b2efd7489 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -32,7 +32,8 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty" var $db; var $error=''; var $max=5; - + var $enabled=1; + var $rowid; var $id; var $position; diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index d131db5e89b..9cf96f14aeb 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -409,7 +409,7 @@ class Conf $this->maxfilesize = (empty($this->global->MAIN_UPLOAD_DOC) ? 0 : $this->global->MAIN_UPLOAD_DOC * 1024); // Define list of limited modules - if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='facture,commande,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda'; // '' means 'all'. Note that contact is added here as it should be a module later. + if (! isset($this->global->MAIN_MODULES_FOR_EXTERNAL)) $this->global->MAIN_MODULES_FOR_EXTERNAL='facture,commande,fournisseur,contact,propal,projet,contrat,societe,ficheinter,expedition,agenda'; // '' means 'all'. Note that contact is added here as it should be a module later. // Timeouts if (empty($this->global->MAIN_USE_CONNECT_TIMEOUT)) $this->global->MAIN_USE_CONNECT_TIMEOUT=10; diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index 2d3ca1d6ae9..ce961a5868c 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -119,15 +119,16 @@ class InfoBox $box->box_id = (! empty($obj->box_id) ? $obj->box_id : ''); $box->note = (! empty($obj->note) ? $obj->note : ''); - $enabled=true; + $enabled=$box->enabled; if (isset($box->depends) && count($box->depends) > 0) { foreach($box->depends as $module) { //print $boxname.'-'.$module.'
'; - if (empty($conf->$module->enabled)) $enabled=false; + if (empty($conf->$module->enabled)) $enabled=0; } } + //print 'xx module='.$module.' enabled='.$enabled; if ($enabled) $boxes[]=$box; } } From 285bcbecb7f38d5ab39159752d61ce297cf1af82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 14 Jan 2013 17:12:13 +0100 Subject: [PATCH 4/7] Fix: init of new syslog handler system --- htdocs/admin/syslog.php | 2 +- htdocs/core/class/conf.class.php | 2 +- htdocs/core/lib/functions.lib.php | 4 ++-- htdocs/install/inc.php | 2 +- htdocs/install/mysql/data/llx_const.sql | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/htdocs/admin/syslog.php b/htdocs/admin/syslog.php index b0699f99aa5..941f1728c03 100644 --- a/htdocs/admin/syslog.php +++ b/htdocs/admin/syslog.php @@ -37,7 +37,7 @@ $action = GETPOST("action"); $syslogModules = array(); $activeModules = array(); -if (defined('SYSLOG_HANDLERS')) $activeModules = json_decode(SYSLOG_HANDLERS); +if (defined('SYSLOG_HANDLERS')) $activeModules = json_decode(constant('SYSLOG_HANDLERS')); $dir = dol_buildpath('/core/modules/syslog/'); diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index 9cf96f14aeb..9d44addfe81 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -152,7 +152,7 @@ class Conf $value=$objp->value; if ($key) { - if (! defined("$key")) define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_FILE_ON and SYSLOG_FILE during install) + if (! defined("$key")) define("$key", $value); // In some cases, the constant might be already forced (Example: SYSLOG_HANDLERS during install) $this->global->$key=$value; if ($value && preg_match('/^MAIN_MODULE_/',$key)) diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index f216bfb359b..04802d3d28f 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -473,8 +473,8 @@ function dol_strtoupper($utf8_string) /** * Write log message into outputs. Possible outputs can be: - * A file if SYSLOG_FILE_ON defined: file name is then defined by SYSLOG_FILE - * Syslog if SYSLOG_SYSLOG_ON defined: facility is then defined by SYSLOG_FACILITY + * SYSLOG_HANDLERS = ["mod_syslog_file"] file name is then defined by SYSLOG_FILE + * SYSLOG_HANDLERS = ["mod_syslog_syslog"] facility is then defined by SYSLOG_FACILITY * Warning, syslog functions are bugged on Windows, generating memory protection faults. To solve * this, use logging to files instead of syslog (see setup of module). * Note: If SYSLOG_FILE_NO_ERROR defined, we never output any error message when writing to log fails. diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 04d4ac6de93..4e913e7810b 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -303,7 +303,7 @@ function conf($dolibarr_main_document_root) // Force usage of log file for install and upgrades $conf->syslog->enabled=1; $conf->global->SYSLOG_LEVEL=constant('LOG_DEBUG'); - if (! defined('SYSLOG_FILE_ON')) define('SYSLOG_FILE_ON',1); + if (! defined('SYSLOG_HANDLERS')) define('SYSLOG_HANDLERS','["mod_syslog_file"]'); if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant already defined { if (@is_writable('/tmp')) define('SYSLOG_FILE','/tmp/dolibarr_install.log'); diff --git a/htdocs/install/mysql/data/llx_const.sql b/htdocs/install/mysql/data/llx_const.sql index 973152f119c..d9fdc2ba8da 100644 --- a/htdocs/install/mysql/data/llx_const.sql +++ b/htdocs/install/mysql/data/llx_const.sql @@ -35,7 +35,7 @@ insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_N insert into llx_const (name, value, type, note, visible, entity) values ('MAIN_FEATURES_LEVEL','0','chaine','Level of features to show (0=stable only, 1=stable+experimental, 2=stable+experimental+development',1,0); -- Hidden and common to all entities -insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_FILE_ON','1','chaine','Log to file Directory where to write log file',0,0); +insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_HANDLERS','["mod_syslog_file"]','chaine','Which logger to use',0,0); insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_FILE','DOL_DATA_ROOT/dolibarr.log','chaine','Directory where to write log file',0,0); insert into llx_const (name, value, type, note, visible, entity) values ('SYSLOG_LEVEL','7','chaine','Level of debug info to show',0,0); From f214c06b1e082dd7414cf515dc51a60471d788fa Mon Sep 17 00:00:00 2001 From: fhenry Date: Tue, 15 Jan 2013 10:20:19 +0100 Subject: [PATCH 5/7] Add option to fecth extrafield even if extranal extrafield module is enabled. Usefull for web service to fetch optionnal from llx_extrafields even if record or update is manage by hook with external module --- htdocs/core/class/extrafields.class.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 87e3eb5dce7..0b5fd2e90ed 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -431,16 +431,17 @@ class ExtraFields * Load array this->attribute_label * * @param string $elementtype Type of element + * @param boolean $forcecheck override test of MAIN_EXTRAFIELDS_DISABLED * @return array Array of attributes for all extra fields */ - function fetch_name_optionals_label($elementtype='member') + function fetch_name_optionals_label($elementtype='member',$forcecheck=false) { global $conf; $array_name_label=array(); // For avoid conflicts with external modules - if (! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) + if ((! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) && (!$forcecheck)) return $array_name_label; $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired"; From 52b4d988496011356a2e19a5c313fda00300cea8 Mon Sep 17 00:00:00 2001 From: fhenry Date: Tue, 15 Jan 2013 11:11:24 +0100 Subject: [PATCH 6/7] remove parenthesis not usefull --- htdocs/core/class/extrafields.class.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htdocs/core/class/extrafields.class.php b/htdocs/core/class/extrafields.class.php index 0b5fd2e90ed..bfced8e176d 100755 --- a/htdocs/core/class/extrafields.class.php +++ b/htdocs/core/class/extrafields.class.php @@ -441,7 +441,7 @@ class ExtraFields $array_name_label=array(); // For avoid conflicts with external modules - if ((! empty($conf->global->MAIN_EXTRAFIELDS_DISABLED)) && (!$forcecheck)) + if (!empty($conf->global->MAIN_EXTRAFIELDS_DISABLED) && !$forcecheck) return $array_name_label; $sql = "SELECT rowid,name,label,type,size,elementtype,fieldunique,fieldrequired"; From 11bb3d0137a7cae1acf45c7353f987e218a158ea Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 15 Jan 2013 11:35:10 +0100 Subject: [PATCH 7/7] Fix: Several fixes into boxes management: boxes was loaded twice, logs were wrong, global conf missing. --- htdocs/admin/boxes.php | 6 +-- htdocs/core/boxes/box_clients.php | 2 +- htdocs/core/boxes/box_prospect.php | 2 +- htdocs/core/boxes/modules_boxes.php | 2 +- htdocs/core/class/html.formother.class.php | 45 ++++++++++--------- htdocs/core/class/infobox.class.php | 26 +++++------ htdocs/core/class/menubase.class.php | 4 +- .../menus/standard/auguria_frontoffice.php | 2 + htdocs/core/menus/standard/eldy.lib.php | 2 +- .../core/menus/standard/eldy_frontoffice.php | 2 + 10 files changed, 50 insertions(+), 43 deletions(-) diff --git a/htdocs/admin/boxes.php b/htdocs/admin/boxes.php index b5fd35fe3ad..7e092c56abd 100644 --- a/htdocs/admin/boxes.php +++ b/htdocs/admin/boxes.php @@ -211,8 +211,6 @@ if ($action == 'switch') */ $form=new Form($db); -$emptyuser=new User($db); -//$infobox=new InfoBox($db); llxHeader('',$langs->trans("Boxes")); @@ -316,7 +314,7 @@ if ($resql) // Available boxes -$boxtoadd=InfoBox::listBoxes($db,'available',-1,$emptyuser,$actives); +$boxtoadd=InfoBox::listBoxes($db,'available',-1,null,$actives); print "
\n"; print_titre($langs->trans("BoxesAvailable")); @@ -366,7 +364,7 @@ print ''; // Activated boxes -$boxactivated=InfoBox::listBoxes($db,'activated',-1,$emptyuser); +$boxactivated=InfoBox::listBoxes($db,'activated',-1,null); print "
\n\n"; print_titre($langs->trans("BoxesActivated")); diff --git a/htdocs/core/boxes/box_clients.php b/htdocs/core/boxes/box_clients.php index 2d87db14a50..e30523660f3 100644 --- a/htdocs/core/boxes/box_clients.php +++ b/htdocs/core/boxes/box_clients.php @@ -83,8 +83,8 @@ class box_clients extends ModeleBoxes $sql.= " ORDER BY s.tms DESC"; $sql.= $db->plimit($max, 0); + dol_syslog(get_class($this)."::loadBox sql=".$sql,LOG_DEBUG); $result = $db->query($sql); - if ($result) { $num = $db->num_rows($result); diff --git a/htdocs/core/boxes/box_prospect.php b/htdocs/core/boxes/box_prospect.php index 12724d0bd33..3b5356a7285 100644 --- a/htdocs/core/boxes/box_prospect.php +++ b/htdocs/core/boxes/box_prospect.php @@ -88,7 +88,7 @@ class box_prospect extends ModeleBoxes $sql.= " ORDER BY s.tms DESC"; $sql.= $db->plimit($max, 0); - dol_syslog("box_prospect::loadBox sql=".$sql,LOG_DEBUG); + dol_syslog(get_class($this)."::loadBox sql=".$sql,LOG_DEBUG); $resql = $db->query($sql); if ($resql) { diff --git a/htdocs/core/boxes/modules_boxes.php b/htdocs/core/boxes/modules_boxes.php index e0b2efd7489..0c6bf08830d 100644 --- a/htdocs/core/boxes/modules_boxes.php +++ b/htdocs/core/boxes/modules_boxes.php @@ -123,7 +123,7 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty" $bcx[1] = 'class="box_impair"'; $var = false; - dol_syslog(get_Class($this)); + dol_syslog(get_class($this).'::showBox'); // Define nbcol and nblines of the box to show $nbcol=0; diff --git a/htdocs/core/class/html.formother.class.php b/htdocs/core/class/html.formother.class.php index 55fd08ab493..2a409374f2c 100644 --- a/htdocs/core/class/html.formother.class.php +++ b/htdocs/core/class/html.formother.class.php @@ -808,24 +808,27 @@ class FormOther include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php'; - //$infobox=new InfoBox($db); - $boxactivated=InfoBox::listBoxes($db,'activated',$areacode,$user); - $arrayboxactivatedid=array(); - foreach($boxactivated as $box) $arrayboxactivatedid[$box->id]=$box->id; - - $selectboxlist=''; - if (! empty($conf->use_javascript_ajax)) + $confuserzone='MAIN_BOXES_'.$areacode; + + $boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of user (or everybody if user has no specific setup) + + $boxidactivatedforuser=array(); + foreach($boxactivated as $box) { - $emptyuser=new User($db); - $boxavailable=InfoBox::listBoxes($db,'activated',$areacode,$emptyuser,$arrayboxactivatedid); // Get list of box available for empty user (minus already activated for user) - - $arrayboxtoactivatelabel=array(); - foreach($boxavailable as $box) - { - $arrayboxtoactivatelabel[$box->id]=$box->boxlabel; - } - $form=new Form($db); + if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user + } + + $selectboxlist=''; + $arrayboxtoactivatelabel=array(); + if (! empty($user->conf->$confuserzone)) + { + foreach($boxactivated as $box) + { + if (! empty($boxidactivatedforuser[$box->id])) continue; // Already visible for user + $arrayboxtoactivatelabel[$box->id]=$box->boxlabel; // We keep only boxes not shown for user, to show into combo list + } + $form=new Form($db); $selectboxlist=$form->selectarray('boxcombo', $arrayboxtoactivatelabel,'',1); } @@ -852,12 +855,14 @@ class FormOther '; } - $nbboxactivated=count($boxactivated); + $nbboxactivated=count($boxidactivatedforuser); print load_fiche_titre(($nbboxactivated?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes'); if ($nbboxactivated) { + $emptybox=new ModeleBoxes($db); + print ''; print '
'."\n"; @@ -873,6 +878,7 @@ class FormOther $ii=0; foreach ($boxactivated as $key => $box) { + if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='A'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 if (preg_match('/^A/i',$box->box_order)) // column A { @@ -885,7 +891,6 @@ class FormOther } } - $emptybox=new ModeleBoxes($db); $emptybox->box_id='A'; $emptybox->info_box_head=array(); $emptybox->info_box_contents=array(); @@ -902,7 +907,8 @@ class FormOther $ii=0; foreach ($boxactivated as $key => $box) { - if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='B'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 + if ((! empty($user->conf->$confuserzone) && $box->fk_user == 0) || (empty($user->conf->$confuserzone) && $box->fk_user != 0)) continue; + if (empty($box->box_order) && $ii < ($nbboxactivated / 2)) $box->box_order='B'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0 if (preg_match('/^B/i',$box->box_order)) // colonne B { $ii++; @@ -914,7 +920,6 @@ class FormOther } } - $emptybox=new ModeleBoxes($db); $emptybox->box_id='B'; $emptybox->info_box_head=array(); $emptybox->info_box_contents=array(); diff --git a/htdocs/core/class/infobox.class.php b/htdocs/core/class/infobox.class.php index ce961a5868c..b5a0e3ad7d0 100644 --- a/htdocs/core/class/infobox.class.php +++ b/htdocs/core/class/infobox.class.php @@ -33,7 +33,7 @@ class InfoBox * @param DoliDB $db Database handler * @param string $mode 'available' or 'activated' * @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...) - * @param User $user Objet user to filter (used only if $zone >= 0) + * @param User $user Objet user to filter * @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude * @return array Array of boxes */ @@ -52,7 +52,7 @@ class InfoBox $sql.= " WHERE b.box_id = d.rowid"; $sql.= " AND b.entity = ".$conf->entity; if ($zone >= 0) $sql.= " AND b.position = ".$zone; - if ($user->id && ! empty($user->conf->$confuserzone)) $sql.= " AND b.fk_user = ".$user->id; + if (is_object($user)) $sql.= " AND b.fk_user IN (0,".$user->id.")"; else $sql.= " AND b.fk_user = 0"; $sql.= " ORDER BY b.box_order"; } @@ -71,7 +71,7 @@ class InfoBox } } - dol_syslog(get_class()."::listBoxes get default box list sql=".$sql, LOG_DEBUG); + dol_syslog(get_class()."::listBoxes get default box list for mode=".$mode." userid=".(is_object($user)?$user->id:'')." sql=".$sql, LOG_DEBUG); $resql = $db->query($sql); if ($resql) { @@ -101,13 +101,13 @@ class InfoBox $box=new $boxname($db,$obj->note); // box properties - $box->rowid = (! empty($obj->rowid) ? $obj->rowid : ''); - $box->id = (! empty($obj->box_id) ? $obj->box_id : ''); - $box->position = (! empty($obj->position) ? $obj->position : ''); - $box->box_order = (! empty($obj->box_order) ? $obj->box_order : ''); - $box->fk_user = (! empty($obj->fk_user) ? $obj->fk_user : ''); + $box->rowid = (empty($obj->rowid) ? '' : $obj->rowid); + $box->id = (empty($obj->box_id) ? '' : $obj->box_id); + $box->position = (empty($obj->position) ? '' : $obj->position); + $box->box_order = (empty($obj->box_order) ? '' : $obj->box_order); + $box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user); $box->sourcefile=$relsourcefile; - if ($mode == 'activated' && (! $user->id || empty($user->conf->$confuserzone))) // List of activated box was not yet personalized into database + if ($mode == 'activated' && ! is_object($user)) // List of activated box was not yet personalized into database { if (is_numeric($box->box_order)) { @@ -116,8 +116,8 @@ class InfoBox } } // box_def properties - $box->box_id = (! empty($obj->box_id) ? $obj->box_id : ''); - $box->note = (! empty($obj->note) ? $obj->note : ''); + $box->box_id = (empty($obj->box_id) ? '' : $obj->box_id); + $box->note = (empty($obj->note) ? '' : $obj->note); $enabled=$box->enabled; if (isset($box->depends) && count($box->depends) > 0) @@ -128,6 +128,7 @@ class InfoBox if (empty($conf->$module->enabled)) $enabled=0; } } + //print 'xx module='.$module.' enabled='.$enabled; if ($enabled) $boxes[]=$box; } @@ -138,9 +139,8 @@ class InfoBox else { //dol_print_error($db); - $error=$db->error(); + $error=$db->lasterror(); dol_syslog(get_class()."::listBoxes Error ".$error, LOG_ERR); - return array(); } return $boxes; diff --git a/htdocs/core/class/menubase.class.php b/htdocs/core/class/menubase.class.php index ada707fe11f..24427f6b3c2 100644 --- a/htdocs/core/class/menubase.class.php +++ b/htdocs/core/class/menubase.class.php @@ -434,7 +434,7 @@ class Menubase $this->newmenu = $newmenu; // Load datas from database into $tabMenu, later we will complete this->newmenu with values into $tabMenu - if (count($tabMenu) == 0) + if (count($tabMenu) == 0) // To avoid to read into database a second time { $this->menuLoad($mainmenu, $leftmenu, $type_user, $menu_handler, $tabMenu); } @@ -535,7 +535,7 @@ class Menubase // If type_user == 2, no test required $sql.= " ORDER BY m.position, m.rowid"; - dol_syslog(get_class($this)."::menuLeftCharger sql=".$sql); + dol_syslog(get_class($this)."::menuLoad mymainmenu=".$mymainmenu." myleftmenu=".$myleftmenu." type_user=".$type_user." menu_handler=".$menu_handler." tabMenu size=".count($tabMenu)." sql=".$sql); $resql = $this->db->query($sql); if ($resql) { diff --git a/htdocs/core/menus/standard/auguria_frontoffice.php b/htdocs/core/menus/standard/auguria_frontoffice.php index 7d095d8e6d4..8432a29e9af 100644 --- a/htdocs/core/menus/standard/auguria_frontoffice.php +++ b/htdocs/core/menus/standard/auguria_frontoffice.php @@ -98,6 +98,8 @@ class MenuLeft */ function showmenu() { + global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php'; $res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after); diff --git a/htdocs/core/menus/standard/eldy.lib.php b/htdocs/core/menus/standard/eldy.lib.php index bb47d82fd9b..fed1dc70155 100644 --- a/htdocs/core/menus/standard/eldy.lib.php +++ b/htdocs/core/menus/standard/eldy.lib.php @@ -444,7 +444,7 @@ function print_eldy_menu($db,$atarget,$type_user) $tabMenu=array(); $menuArbo = new Menubase($db,'eldy','top'); - $newTabMenu = $menuArbo->menuTopCharger('','',$type_user,'eldy',$tabMenu); + $newTabMenu = $menuArbo->menuTopCharger('','',$type_user,'eldy',$tabMenu); // Return tabMenu with only top entries $num = count($newTabMenu); for($i = 0; $i < $num; $i++) diff --git a/htdocs/core/menus/standard/eldy_frontoffice.php b/htdocs/core/menus/standard/eldy_frontoffice.php index 355619e6832..9aec7ac62a4 100644 --- a/htdocs/core/menus/standard/eldy_frontoffice.php +++ b/htdocs/core/menus/standard/eldy_frontoffice.php @@ -96,6 +96,8 @@ class MenuLeft */ function showmenu() { + global $conf; + require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php'; $res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after);