Fix: strict mode paradise

This commit is contained in:
Regis Houssin 2012-07-28 11:28:37 +02:00
parent 3390a514e1
commit a157327859
20 changed files with 142 additions and 143 deletions

View File

@ -223,7 +223,7 @@ if ($socid)
print '</td></tr>'; print '</td></tr>';
} }
if ($conf->global->MAIN_MODULE_BARCODE) if (! empty($conf->global->MAIN_MODULE_BARCODE))
{ {
print '<tr><td>'.$langs->trans('Gencod').'</td><td colspan="3">'.$soc->barcode.'</td></tr>'; print '<tr><td>'.$langs->trans('Gencod').'</td><td colspan="3">'.$soc->barcode.'</td></tr>';
} }

View File

@ -34,6 +34,12 @@ $type=GETPOST('type');
$action=GETPOST('action'); $action=GETPOST('action');
$confirm=GETPOST('confirm'); $confirm=GETPOST('confirm');
$socid=GETPOST('socid','int');
$nom=GETPOST('nom');
$description=GETPOST('description');
$visible=GETPOST('visible');
$catMere=GETPOST('catMere');
if ($id == "") if ($id == "")
{ {
dol_print_error('','Missing parameter id'); dol_print_error('','Missing parameter id');
@ -55,13 +61,13 @@ if ($action == 'update' && $user->rights->categorie->creer)
$categorie = new Categorie($db); $categorie = new Categorie($db);
$result=$categorie->fetch($id); $result=$categorie->fetch($id);
$categorie->label = $_POST["nom"]; $categorie->label = $nom;
$categorie->description = $_POST["description"]; $categorie->description = $description;
$categorie->socid = ($_POST["socid"] ? $_POST["socid"] : 'null'); $categorie->socid = ($socid ? $socid : 'null');
$categorie->visible = $_POST["visible"]; $categorie->visible = $visible;
if($_POST['catMere'] != "-1") if ($catMere != "-1")
$categorie->id_mere = $_POST['catMere']; $categorie->id_mere = $catMere;
else else
$categorie->id_mere = ""; $categorie->id_mere = "";
@ -76,7 +82,7 @@ if ($action == 'update' && $user->rights->categorie->creer)
$_GET["action"] = 'create'; $_GET["action"] = 'create';
$mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Description")); $mesg = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Description"));
} }
if (! $categorie->error) if (empty($categorie->error))
{ {
if ($categorie->update($user) > 0) if ($categorie->update($user) > 0)
{ {

View File

@ -1,7 +1,7 @@
<?php <?php
/* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org> /* Copyright (C) 2005 Matthieu Valleton <mv@seeschloss.org>
* Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net> * Copyright (C) 2006-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * Copyright (C) 2005-2012 Regis Houssin <regis@dolibarr.fr>
* Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com> * Copyright (C) 2007 Patrick Raguin <patrick.raguin@gmail.com>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -41,6 +41,12 @@ $catorigin = GETPOST('catorigin','int');
$type = GETPOST('type','alpha'); $type = GETPOST('type','alpha');
$urlfrom = GETPOST('urlfrom','alpha'); $urlfrom = GETPOST('urlfrom','alpha');
$socid=GETPOST('socid','int');
$nom=GETPOST('nom');
$description=GETPOST('description');
$visible=GETPOST('visible');
$catMere=GETPOST('catMere');
if ($origin) if ($origin)
{ {
if ($type == 0) $idProdOrigin = $origin; if ($type == 0) $idProdOrigin = $origin;
@ -101,22 +107,23 @@ if ($action == 'add' && $user->rights->categorie->creer)
$object = new Categorie($db); $object = new Categorie($db);
$object->label = $_POST["nom"]; $object->label = $nom;
$object->description = $_POST["description"]; $object->description = $description;
$object->socid = ($_POST["socid"] ? $_POST["socid"] : 'null'); $object->socid = ($socid ? $socid : 'null');
$object->visible = $_POST["visible"]; $object->visible = $visible;
$object->type = $type; $object->type = $type;
if($_POST['catMere'] != "-1") $object->id_mere = $_POST['catMere']; if ($catMere != "-1") $object->id_mere = $catMere;
if (! $object->label) if (! $object->label)
{ {
$object->error = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref")); $error++;
$_GET["action"] = 'create'; $errors[] = $langs->trans("ErrorFieldRequired",$langs->transnoentities("Ref"));
$action = 'create';
} }
// Create category in database // Create category in database
if (! $object->error) if (! $error)
{ {
$result = $object->create(); $result = $object->create();
if ($result > 0) if ($result > 0)
@ -197,19 +204,19 @@ if ($user->rights->categorie->creer)
print_fiche_titre($langs->trans("CreateCat")); print_fiche_titre($langs->trans("CreateCat"));
dol_htmloutput_errors($object->error); dol_htmloutput_errors('',$errors);
print '<table width="100%" class="border">'; print '<table width="100%" class="border">';
// Ref // Ref
print '<tr>'; print '<tr>';
print '<td width="25%" class="fieldrequired">'.$langs->trans("Ref").'</td><td><input name="nom" size="25" value="'.$object->label.'">'; print '<td width="25%" class="fieldrequired">'.$langs->trans("Ref").'</td><td><input name="nom" size="25" value="'.$nom.'">';
print'</td></tr>'; print'</td></tr>';
// Description // Description
print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>'; print '<tr><td valign="top">'.$langs->trans("Description").'</td><td>';
require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/class/doleditor.class.php");
$doleditor=new DolEditor('description',$object->description,'',200,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,ROWS_6,50); $doleditor=new DolEditor('description',$description,'',200,'dolibarr_notes','',false,true,$conf->global->FCKEDITOR_ENABLE_PRODUCTDESC,ROWS_6,50);
$doleditor->Create(); $doleditor->Create();
print '</td></tr>'; print '</td></tr>';

View File

@ -35,6 +35,8 @@ if (! $user->rights->categorie->lire) accessforbidden();
$id=GETPOST('id','int'); $id=GETPOST('id','int');
$type=(GETPOST('type') ? GETPOST('type') : 0); $type=(GETPOST('type') ? GETPOST('type') : 0);
$catname=GETPOST('catname','alpha');
$section=(GETPOST('section')?GETPOST('section'):0);
/* /*
@ -70,7 +72,7 @@ print '<tr class="liste_titre">';
print '<td colspan="3">'.$langs->trans("Search").'</td>'; print '<td colspan="3">'.$langs->trans("Search").'</td>';
print '</tr>'; print '</tr>';
print '<tr '.$bc[0].'><td>'; print '<tr '.$bc[0].'><td>';
print $langs->trans("Name").':</td><td><input class="flat" type="text" size="20" name="catname" value="' . $_POST['catname'] . '"/></td><td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>'; print $langs->trans("Name").':</td><td><input class="flat" type="text" size="20" name="catname" value="' . $catname . '"/></td><td><input type="submit" class="button" value="'.$langs->trans("Search").'"></td></tr>';
/* /*
// faire une rech dans une sous categorie uniquement // faire une rech dans une sous categorie uniquement
print '<tr '.$bc[0].'><td>'; print '<tr '.$bc[0].'><td>';
@ -89,9 +91,9 @@ print '</td><td valign="top" width="70%">';
/* /*
* Categories found * Categories found
*/ */
if($_POST['catname'] || $id > 0) if ($catname || $id > 0)
{ {
$cats = $categstatic->rechercher($id,$_POST['catname'],$type); $cats = $categstatic->rechercher($id,$catname,$type);
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("FoundCats").'</td></tr>'; print '<tr class="liste_titre"><td colspan="2">'.$langs->trans("FoundCats").'</td></tr>';
@ -126,17 +128,10 @@ $cate_arbo = $categstatic->get_full_arbo($type);
// Define fulltree array // Define fulltree array
$fulltree=$cate_arbo; $fulltree=$cate_arbo;
print '<table class="liste" width="100%">'; print '<table class="liste" width="100%">';
print '<tr class="liste_titre"><td>'.$langs->trans("Categories").'</td><td colspan="3">'.$langs->trans("Description").'</td></tr>'; print '<tr class="liste_titre"><td>'.$langs->trans("Categories").'</td><td colspan="3">'.$langs->trans("Description").'</td></tr>';
$section=isset($_GET["section"])?$_GET["section"]:$_POST['section'];
if (! $section) $section=0;
// ----- This section will show a tree from a fulltree array ----- // ----- This section will show a tree from a fulltree array -----
// $section must also be defined // $section must also be defined
// --------------------------------------------------------------- // ---------------------------------------------------------------
@ -212,9 +207,10 @@ foreach($fulltree as $key => $val)
$showline=0; $showline=0;
// If directory is son of expanded directory, we show line // If directory is son of expanded directory, we show line
if (in_array($val['id_mere'],$expandedsectionarray)) $showline=4; if (isset($val['id_mere']) && in_array($val['id_mere'],$expandedsectionarray)) $showline=4;
// If directory is brother of selected directory, we show line // If directory is brother of selected directory, we show line
elseif ($val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3; // FIXME $ecmdirstatic not exist or not instantiate ?
//elseif (isset($val['id_mere']) && $val['id'] != $section && $val['id_mere'] == $ecmdirstatic->motherof[$section]) $showline=3;
// If directory is parent of selected directory or is selected directory, we show line // If directory is parent of selected directory or is selected directory, we show line
elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2; elseif (preg_match('/'.$val['fullpath'].'_/i',$fullpathselected.'_')) $showline=2;
// If we are level one we show line // If we are level one we show line
@ -243,7 +239,9 @@ foreach($fulltree as $key => $val)
print '<td valign="top">'; print '<td valign="top">';
//print $val['fullpath']."(".$showline.")"; //print $val['fullpath']."(".$showline.")";
$n='2'; $n='2';
if ($b == 0 || ! in_array($val['id'],$expandedsectionarray)) $n='3'; // FIXME $b not define ?
//if ($b == 0 || ! in_array($val['id'],$expandedsectionarray)) $n='3';
if (! in_array($val['id'],$expandedsectionarray)) $n='3';
if (! in_array($val['id'],$expandedsectionarray)) $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/plustop'.$n.'.gif','',1); if (! in_array($val['id'],$expandedsectionarray)) $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/plustop'.$n.'.gif','',1);
else $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop'.$n.'.gif','',1); else $ref=img_picto('',DOL_URL_ROOT.'/theme/common/treemenu/minustop'.$n.'.gif','',1);
if ($option == 'indexexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&amp;type='.$type.'&amp;sectionexpand=false">'; if ($option == 'indexexpanded') $lien = '<a href="'.$_SERVER["PHP_SELF"].'?section='.$val['id'].'&amp;type='.$type.'&amp;sectionexpand=false">';

View File

@ -63,7 +63,7 @@ if ($id > 0)
* Actions * Actions
*/ */
if ($_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC)) if (isset($_FILES['userfile']) && $_FILES['userfile']['size'] > 0 && $_POST["sendit"] && ! empty($conf->global->MAIN_UPLOAD_DOC))
{ {
if ($object->id) $result = $object->add_photo($upload_dir, $_FILES['userfile']); if ($object->id) $result = $object->add_photo($upload_dir, $_FILES['userfile']);
} }

View File

@ -173,7 +173,6 @@ else
$var=true; $var=true;
foreach ($cats as $cat) foreach ($cats as $cat)
{ {
$i++;
$var=!$var; $var=!$var;
print "\t<tr ".$bc[$var].">\n"; print "\t<tr ".$bc[$var].">\n";
print "\t\t<td nowrap=\"nowrap\">"; print "\t\t<td nowrap=\"nowrap\">";
@ -219,11 +218,9 @@ if ($object->type == 0)
if (count($prods) > 0) if (count($prods) > 0)
{ {
$i = 0;
$var=true; $var=true;
foreach ($prods as $prod) foreach ($prods as $prod)
{ {
$i++;
$var=!$var; $var=!$var;
print "\t<tr ".$bc[$var].">\n"; print "\t<tr ".$bc[$var].">\n";
print '<td nowrap="nowrap" valign="top">'; print '<td nowrap="nowrap" valign="top">';
@ -257,11 +254,9 @@ if ($object->type == 1)
if (count($socs) > 0) if (count($socs) > 0)
{ {
$i = 0;
$var=true; $var=true;
foreach ($socs as $soc) foreach ($socs as $soc)
{ {
$i++;
$var=!$var; $var=!$var;
print "\t<tr ".$bc[$var].">\n"; print "\t<tr ".$bc[$var].">\n";
@ -335,11 +330,9 @@ if ($object->type == 3)
if (count($prods) > 0) if (count($prods) > 0)
{ {
$i = 0;
$var=true; $var=true;
foreach ($prods as $key => $member) foreach ($prods as $key => $member)
{ {
$i++;
$var=!$var; $var=!$var;
print "\t<tr ".$bc[$var].">\n"; print "\t<tr ".$bc[$var].">\n";
print '<td nowrap="nowrap" valign="top">'; print '<td nowrap="nowrap" valign="top">';

View File

@ -1091,9 +1091,9 @@ function dol_set_user_param($db, $conf, &$user, $tab)
{ {
$sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,entity,param,value)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."user_param(fk_user,entity,param,value)";
$sql.= " VALUES (".$user->id.",".$conf->entity.","; $sql.= " VALUES (".$user->id.",".$conf->entity.",";
$sql.= " '".$key."','".$db->escape($value)."');"; $sql.= " '".$key."','".$db->escape($value)."')";
dol_syslog("functions2.lib::dol_set_user_param sql=".$sql, LOG_DEBUG);
dol_syslog("functions2.lib::dol_set_user_param sql=".$sql, LOG_DEBUG);
$result=$db->query($sql); $result=$db->query($sql);
if (! $result) if (! $result)
{ {

View File

@ -101,7 +101,8 @@ function tree_showpad(&$fulltree,$key,$silent=0)
if ($fulltree[$key2]['level'] > $pos) if ($fulltree[$key2]['level'] > $pos)
{ {
$nbofdirinsub++; $nbofdirinsub++;
$nbofdocinsub+=$fulltree[$key2]['cachenbofdoc']; if (! empty($fulltree[$key2]['cachenbofdoc']))
$nbofdocinsub+=$fulltree[$key2]['cachenbofdoc'];
} }
if ($fulltree[$key2]['level'] == $pos) if ($fulltree[$key2]['level'] == $pos)
{ {

View File

@ -174,12 +174,21 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
$thumbsbyrow=6; $thumbsbyrow=6;
print '<table class="noborder" width="100%">'; print '<table class="noborder" width="100%">';
$var=false;
// Title // Title
if ($foruserprofile) if ($foruserprofile)
{ {
print '<tr class="liste_titre"><th width="25%">'.$langs->trans("Parameter").'</th><th width="25%">'.$langs->trans("DefaultValue").'</th>'; print '<tr class="liste_titre"><th width="25%">'.$langs->trans("Parameter").'</th><th width="25%">'.$langs->trans("DefaultValue").'</th>';
print '<th colspan="2">&nbsp;</th>'; print '<th colspan="2">&nbsp;</th>';
print '</tr>'; print '</tr>';
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("DefaultSkin").'</td>';
print '<td>'.$conf->global->MAIN_THEME.'</td>';
print '<td align="left" nowrap="nowrap" width="20%"><input '.$bc[$var].' name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>';
print '<td>&nbsp;</td>';
print '</tr>';
} }
else else
{ {
@ -192,31 +201,16 @@ function show_theme($fuser,$edit=0,$foruserprofile=false)
print $langs->trans('DownloadMoreSkins'); print $langs->trans('DownloadMoreSkins');
print '</a>'; print '</a>';
print '</th></tr>'; print '</th></tr>';
}
$var=false; print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("ThemeDir").'</td>';
if ($foruserprofile) print '<td>';
{ foreach($dirthemes as $dirtheme)
print '<tr '.$bc[$var].'>'; {
print '<td>'.$langs->trans("DefaultSkin").'</td>'; echo '"'.$dirtheme.'" ';
print '<td>'.$conf->global->MAIN_THEME.'</td>'; }
print '<td align="left" nowrap="nowrap" width="20%"><input '.$bc[$var].' name="check_MAIN_THEME"'.($edit?'':' disabled').' type="checkbox" '.($selected_theme?" checked":"").'> '.$langs->trans("UsePersonalValue").'</td>'; print '</td>';
print '<td>&nbsp;</td>'; print '</tr>';
print '</tr>';
}
if (! $foruserprofile)
{
print '<tr '.$bc[$var].'>';
print '<td>'.$langs->trans("ThemeDir").'</td>';
print '<td>';
foreach($dirthemes as $dirtheme)
{
echo '"'.$dirtheme.'" ';
}
print '</td>';
print '</tr>';
} }
$var=!$var; $var=!$var;

View File

@ -41,7 +41,7 @@ $action = GETPOST('action','alpha');
if ($id) if ($id)
{ {
// $user est le user qui edite, $id est l'id de l'utilisateur edite // $user est le user qui edite, $id est l'id de l'utilisateur edite
$caneditfield=( (($user->id == $id) && $user->rights->user->self->creer) $caneditfield=((($user->id == $id) && $user->rights->user->self->creer)
|| (($user->id != $id) && $user->rights->user->user->creer)); || (($user->id != $id) && $user->rights->user->user->creer));
} }

View File

@ -317,7 +317,7 @@ if ($result)
print '</td>'; print '</td>';
// Permission and tick // Permission and tick
if ($fuser->admin && $objMod->rights_admin_allowed) // Permission own because admin if (! empty($fuser->admin) && ! empty($objMod->rights_admin_allowed)) // Permission own because admin
{ {
if ($caneditperms) if ($caneditperms)
{ {