Fix: Several fixes into boxes management: boxes was loaded twice, logs
were wrong, global conf missing.
This commit is contained in:
parent
285bcbecb7
commit
11bb3d0137
@ -211,8 +211,6 @@ if ($action == 'switch')
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
$form=new Form($db);
|
$form=new Form($db);
|
||||||
$emptyuser=new User($db);
|
|
||||||
//$infobox=new InfoBox($db);
|
|
||||||
|
|
||||||
llxHeader('',$langs->trans("Boxes"));
|
llxHeader('',$langs->trans("Boxes"));
|
||||||
|
|
||||||
@ -316,7 +314,7 @@ if ($resql)
|
|||||||
|
|
||||||
|
|
||||||
// Available boxes
|
// Available boxes
|
||||||
$boxtoadd=InfoBox::listBoxes($db,'available',-1,$emptyuser,$actives);
|
$boxtoadd=InfoBox::listBoxes($db,'available',-1,null,$actives);
|
||||||
|
|
||||||
print "<br>\n";
|
print "<br>\n";
|
||||||
print_titre($langs->trans("BoxesAvailable"));
|
print_titre($langs->trans("BoxesAvailable"));
|
||||||
@ -366,7 +364,7 @@ print '</table>';
|
|||||||
|
|
||||||
|
|
||||||
// Activated boxes
|
// Activated boxes
|
||||||
$boxactivated=InfoBox::listBoxes($db,'activated',-1,$emptyuser);
|
$boxactivated=InfoBox::listBoxes($db,'activated',-1,null);
|
||||||
|
|
||||||
print "<br>\n\n";
|
print "<br>\n\n";
|
||||||
print_titre($langs->trans("BoxesActivated"));
|
print_titre($langs->trans("BoxesActivated"));
|
||||||
|
|||||||
@ -83,8 +83,8 @@ class box_clients extends ModeleBoxes
|
|||||||
$sql.= " ORDER BY s.tms DESC";
|
$sql.= " ORDER BY s.tms DESC";
|
||||||
$sql.= $db->plimit($max, 0);
|
$sql.= $db->plimit($max, 0);
|
||||||
|
|
||||||
|
dol_syslog(get_class($this)."::loadBox sql=".$sql,LOG_DEBUG);
|
||||||
$result = $db->query($sql);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
if ($result)
|
if ($result)
|
||||||
{
|
{
|
||||||
$num = $db->num_rows($result);
|
$num = $db->num_rows($result);
|
||||||
|
|||||||
@ -88,7 +88,7 @@ class box_prospect extends ModeleBoxes
|
|||||||
$sql.= " ORDER BY s.tms DESC";
|
$sql.= " ORDER BY s.tms DESC";
|
||||||
$sql.= $db->plimit($max, 0);
|
$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);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -123,7 +123,7 @@ class ModeleBoxes // Can't be abtract as it is instanciated to build "empty"
|
|||||||
$bcx[1] = 'class="box_impair"';
|
$bcx[1] = 'class="box_impair"';
|
||||||
$var = false;
|
$var = false;
|
||||||
|
|
||||||
dol_syslog(get_Class($this));
|
dol_syslog(get_class($this).'::showBox');
|
||||||
|
|
||||||
// Define nbcol and nblines of the box to show
|
// Define nbcol and nblines of the box to show
|
||||||
$nbcol=0;
|
$nbcol=0;
|
||||||
|
|||||||
@ -808,24 +808,27 @@ class FormOther
|
|||||||
|
|
||||||
include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
|
include_once DOL_DOCUMENT_ROOT.'/core/class/infobox.class.php';
|
||||||
|
|
||||||
//$infobox=new InfoBox($db);
|
$confuserzone='MAIN_BOXES_'.$areacode;
|
||||||
$boxactivated=InfoBox::listBoxes($db,'activated',$areacode,$user);
|
|
||||||
$arrayboxactivatedid=array();
|
$boxactivated=InfoBox::listBoxes($db,'activated',$areacode,(empty($user->conf->$confuserzone)?null:$user)); // Search boxes of user (or everybody if user has no specific setup)
|
||||||
foreach($boxactivated as $box) $arrayboxactivatedid[$box->id]=$box->id;
|
|
||||||
|
$boxidactivatedforuser=array();
|
||||||
|
foreach($boxactivated as $box)
|
||||||
|
{
|
||||||
|
if (empty($user->conf->$confuserzone) || $box->fk_user == $user->id) $boxidactivatedforuser[$box->id]=$box->id; // We keep only boxes to show for user
|
||||||
|
}
|
||||||
|
|
||||||
$selectboxlist='';
|
$selectboxlist='';
|
||||||
if (! empty($conf->use_javascript_ajax))
|
|
||||||
{
|
|
||||||
$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();
|
$arrayboxtoactivatelabel=array();
|
||||||
foreach($boxavailable as $box)
|
if (! empty($user->conf->$confuserzone))
|
||||||
{
|
{
|
||||||
$arrayboxtoactivatelabel[$box->id]=$box->boxlabel;
|
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);
|
|
||||||
|
|
||||||
|
$form=new Form($db);
|
||||||
$selectboxlist=$form->selectarray('boxcombo', $arrayboxtoactivatelabel,'',1);
|
$selectboxlist=$form->selectarray('boxcombo', $arrayboxtoactivatelabel,'',1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -852,12 +855,14 @@ class FormOther
|
|||||||
</script>';
|
</script>';
|
||||||
}
|
}
|
||||||
|
|
||||||
$nbboxactivated=count($boxactivated);
|
$nbboxactivated=count($boxidactivatedforuser);
|
||||||
|
|
||||||
print load_fiche_titre(($nbboxactivated?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes');
|
print load_fiche_titre(($nbboxactivated?$langs->trans("OtherInformationsBoxes"):''),$selectboxlist,'','','otherboxes');
|
||||||
|
|
||||||
if ($nbboxactivated)
|
if ($nbboxactivated)
|
||||||
{
|
{
|
||||||
|
$emptybox=new ModeleBoxes($db);
|
||||||
|
|
||||||
print '<table width="100%" class="notopnoleftnoright">';
|
print '<table width="100%" class="notopnoleftnoright">';
|
||||||
print '<tr><td class="notopnoleftnoright">'."\n";
|
print '<tr><td class="notopnoleftnoright">'."\n";
|
||||||
|
|
||||||
@ -873,6 +878,7 @@ class FormOther
|
|||||||
$ii=0;
|
$ii=0;
|
||||||
foreach ($boxactivated as $key => $box)
|
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 (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
|
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->box_id='A';
|
||||||
$emptybox->info_box_head=array();
|
$emptybox->info_box_head=array();
|
||||||
$emptybox->info_box_contents=array();
|
$emptybox->info_box_contents=array();
|
||||||
@ -902,6 +907,7 @@ class FormOther
|
|||||||
$ii=0;
|
$ii=0;
|
||||||
foreach ($boxactivated as $key => $box)
|
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='B'.sprintf("%02d",($ii+1)); // When box_order was not yet set to Axx or Bxx and is still 0
|
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
|
if (preg_match('/^B/i',$box->box_order)) // colonne B
|
||||||
{
|
{
|
||||||
@ -914,7 +920,6 @@ class FormOther
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$emptybox=new ModeleBoxes($db);
|
|
||||||
$emptybox->box_id='B';
|
$emptybox->box_id='B';
|
||||||
$emptybox->info_box_head=array();
|
$emptybox->info_box_head=array();
|
||||||
$emptybox->info_box_contents=array();
|
$emptybox->info_box_contents=array();
|
||||||
|
|||||||
@ -33,7 +33,7 @@ class InfoBox
|
|||||||
* @param DoliDB $db Database handler
|
* @param DoliDB $db Database handler
|
||||||
* @param string $mode 'available' or 'activated'
|
* @param string $mode 'available' or 'activated'
|
||||||
* @param string $zone Name or area (-1 for all, 0 for Homepage, 1 for xxx, ...)
|
* @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
|
* @param array $excludelist Array of box id (box.box_id = boxes_def.rowid) to exclude
|
||||||
* @return array Array of boxes
|
* @return array Array of boxes
|
||||||
*/
|
*/
|
||||||
@ -52,7 +52,7 @@ class InfoBox
|
|||||||
$sql.= " WHERE b.box_id = d.rowid";
|
$sql.= " WHERE b.box_id = d.rowid";
|
||||||
$sql.= " AND b.entity = ".$conf->entity;
|
$sql.= " AND b.entity = ".$conf->entity;
|
||||||
if ($zone >= 0) $sql.= " AND b.position = ".$zone;
|
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";
|
else $sql.= " AND b.fk_user = 0";
|
||||||
$sql.= " ORDER BY b.box_order";
|
$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);
|
$resql = $db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
@ -101,13 +101,13 @@ class InfoBox
|
|||||||
$box=new $boxname($db,$obj->note);
|
$box=new $boxname($db,$obj->note);
|
||||||
|
|
||||||
// box properties
|
// box properties
|
||||||
$box->rowid = (! empty($obj->rowid) ? $obj->rowid : '');
|
$box->rowid = (empty($obj->rowid) ? '' : $obj->rowid);
|
||||||
$box->id = (! empty($obj->box_id) ? $obj->box_id : '');
|
$box->id = (empty($obj->box_id) ? '' : $obj->box_id);
|
||||||
$box->position = (! empty($obj->position) ? $obj->position : '');
|
$box->position = (empty($obj->position) ? '' : $obj->position);
|
||||||
$box->box_order = (! empty($obj->box_order) ? $obj->box_order : '');
|
$box->box_order = (empty($obj->box_order) ? '' : $obj->box_order);
|
||||||
$box->fk_user = (! empty($obj->fk_user) ? $obj->fk_user : '');
|
$box->fk_user = (empty($obj->fk_user) ? 0 : $obj->fk_user);
|
||||||
$box->sourcefile=$relsourcefile;
|
$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))
|
if (is_numeric($box->box_order))
|
||||||
{
|
{
|
||||||
@ -116,8 +116,8 @@ class InfoBox
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// box_def properties
|
// box_def properties
|
||||||
$box->box_id = (! empty($obj->box_id) ? $obj->box_id : '');
|
$box->box_id = (empty($obj->box_id) ? '' : $obj->box_id);
|
||||||
$box->note = (! empty($obj->note) ? $obj->note : '');
|
$box->note = (empty($obj->note) ? '' : $obj->note);
|
||||||
|
|
||||||
$enabled=$box->enabled;
|
$enabled=$box->enabled;
|
||||||
if (isset($box->depends) && count($box->depends) > 0)
|
if (isset($box->depends) && count($box->depends) > 0)
|
||||||
@ -128,6 +128,7 @@ class InfoBox
|
|||||||
if (empty($conf->$module->enabled)) $enabled=0;
|
if (empty($conf->$module->enabled)) $enabled=0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//print 'xx module='.$module.' enabled='.$enabled;
|
//print 'xx module='.$module.' enabled='.$enabled;
|
||||||
if ($enabled) $boxes[]=$box;
|
if ($enabled) $boxes[]=$box;
|
||||||
}
|
}
|
||||||
@ -138,9 +139,8 @@ class InfoBox
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
//dol_print_error($db);
|
//dol_print_error($db);
|
||||||
$error=$db->error();
|
$error=$db->lasterror();
|
||||||
dol_syslog(get_class()."::listBoxes Error ".$error, LOG_ERR);
|
dol_syslog(get_class()."::listBoxes Error ".$error, LOG_ERR);
|
||||||
return array();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return $boxes;
|
return $boxes;
|
||||||
|
|||||||
@ -434,7 +434,7 @@ class Menubase
|
|||||||
$this->newmenu = $newmenu;
|
$this->newmenu = $newmenu;
|
||||||
|
|
||||||
// Load datas from database into $tabMenu, later we will complete this->newmenu with values into $tabMenu
|
// 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);
|
$this->menuLoad($mainmenu, $leftmenu, $type_user, $menu_handler, $tabMenu);
|
||||||
}
|
}
|
||||||
@ -535,7 +535,7 @@ class Menubase
|
|||||||
// If type_user == 2, no test required
|
// If type_user == 2, no test required
|
||||||
$sql.= " ORDER BY m.position, m.rowid";
|
$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);
|
$resql = $this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -98,6 +98,8 @@ class MenuLeft
|
|||||||
*/
|
*/
|
||||||
function showmenu()
|
function showmenu()
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/auguria.lib.php';
|
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);
|
$res=print_left_auguria_menu($this->db,$this->menu_array,$this->menu_array_after);
|
||||||
|
|||||||
@ -444,7 +444,7 @@ function print_eldy_menu($db,$atarget,$type_user)
|
|||||||
|
|
||||||
$tabMenu=array();
|
$tabMenu=array();
|
||||||
$menuArbo = new Menubase($db,'eldy','top');
|
$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);
|
$num = count($newTabMenu);
|
||||||
for($i = 0; $i < $num; $i++)
|
for($i = 0; $i < $num; $i++)
|
||||||
|
|||||||
@ -96,6 +96,8 @@ class MenuLeft
|
|||||||
*/
|
*/
|
||||||
function showmenu()
|
function showmenu()
|
||||||
{
|
{
|
||||||
|
global $conf;
|
||||||
|
|
||||||
require_once DOL_DOCUMENT_ROOT.'/core/menus/standard/eldy.lib.php';
|
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);
|
$res=print_left_eldy_menu($this->db,$this->menu_array,$this->menu_array_after);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user