From 320fe741cb639c90fc517b9a65f32fac49607c2f Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Sun, 8 Jul 2012 22:43:06 +0200 Subject: [PATCH] Fix: avoid warning with php 5.4 and strict mode --- htdocs/comm/action/class/actioncomm.class.php | 6 +++ .../default/tpl/contactcard_edit.tpl.php | 3 +- htdocs/contact/fiche.php | 3 +- htdocs/core/ajax/ajaxdirpreview.php | 18 +++---- htdocs/core/ajax/ajaxdirtree.php | 2 +- htdocs/core/boxes/box_activity.php | 2 +- htdocs/core/class/html.form.class.php | 9 ++-- htdocs/core/lib/functions.lib.php | 16 +++---- htdocs/core/lib/product.lib.php | 2 +- htdocs/core/lib/security.lib.php | 8 +++- htdocs/main.inc.php | 47 ++++++++++--------- htdocs/product/class/product.class.php | 1 + htdocs/product/class/service.class.php | 2 +- htdocs/product/fiche.php | 36 +++++++------- htdocs/product/index.php | 6 +-- htdocs/societe/class/address.class.php | 32 ++++++------- htdocs/user/class/user.class.php | 3 ++ 17 files changed, 108 insertions(+), 88 deletions(-) diff --git a/htdocs/comm/action/class/actioncomm.class.php b/htdocs/comm/action/class/actioncomm.class.php index c982bfbcdbd..ed54057f962 100644 --- a/htdocs/comm/action/class/actioncomm.class.php +++ b/htdocs/comm/action/class/actioncomm.class.php @@ -287,19 +287,25 @@ class ActionComm extends CommonObject $this->note = $obj->note; $this->percentage = $obj->percentage; + $this->author = (object) array(); $this->author->id = $obj->fk_user_author; $this->author->firstname = $obj->firstname; $this->author->lastname = $obj->lastname; + $this->usermod = (object) array(); $this->usermod->id = $obj->fk_user_mod; + $this->usertodo = (object) array(); $this->usertodo->id = $obj->fk_user_action; + $this->userdone = (object) array(); $this->userdone->id = $obj->fk_user_done; $this->priority = $obj->priority; $this->fulldayevent = $obj->fulldayevent; $this->location = $obj->location; $this->socid = $obj->fk_soc; // To have fetch_thirdparty method working + $this->societe = (object) array(); $this->societe->id = $obj->fk_soc; + $this->contact = (object) array(); $this->contact->id = $obj->fk_contact; $this->fk_project = $obj->fk_project; diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index c8629f185e8..c4b48767f2f 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -133,12 +133,13 @@ echo $this->control->tpl['ajax_selectcountry']; +control->tpl['contact_element'])) { ?> control->tpl['contact_element'] as $element) { ?> - + trans("DolibarrLogin"); ?> diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 4c47d13805c..7487bf6d06f 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -540,10 +540,11 @@ else print ''; print ''; print ''; - print ''; print ''; print ''; print ''; + if (! empty($backtopage)) print ''; + print ''; // Ref diff --git a/htdocs/core/ajax/ajaxdirpreview.php b/htdocs/core/ajax/ajaxdirpreview.php index 05f667be112..4205c9c24ac 100644 --- a/htdocs/core/ajax/ajaxdirpreview.php +++ b/htdocs/core/ajax/ajaxdirpreview.php @@ -45,15 +45,15 @@ if (! isset($mode) || $mode != 'noajax') // For ajax call $module=GETPOST("module"); $urlsource=GETPOST("urlsource"); - $sortfield = GETPOST("sortfield",'alpha'); - $sortorder = GETPOST("sortorder",'alpha'); - $page = GETPOST("page",'int'); - if ($page == -1) { $page = 0; } - $offset = $conf->liste_limit * $page; - $pageprev = $page - 1; - $pagenext = $page + 1; - if (! $sortorder) $sortorder="ASC"; - if (! $sortfield) $sortfield="name"; + $sortfield = GETPOST("sortfield",'alpha'); + $sortorder = GETPOST("sortorder",'alpha'); + $page = GETPOST("page",'int'); + if ($page == -1) { $page = 0; } + $offset = $conf->liste_limit * $page; + $pageprev = $page - 1; + $pagenext = $page + 1; + if (! $sortorder) $sortorder="ASC"; + if (! $sortfield) $sortfield="name"; $upload_dir = dirname(str_replace("../","/", $conf->ecm->dir_output.'/'.$file)); diff --git a/htdocs/core/ajax/ajaxdirtree.php b/htdocs/core/ajax/ajaxdirtree.php index b33161a0d55..60952f4961f 100644 --- a/htdocs/core/ajax/ajaxdirtree.php +++ b/htdocs/core/ajax/ajaxdirtree.php @@ -72,7 +72,7 @@ if ($modulepart == 'ecm') * View */ -top_httphead(); +top_httphead(); $userstatic=new User($db); $form=new Form($db); diff --git a/htdocs/core/boxes/box_activity.php b/htdocs/core/boxes/box_activity.php index c437a9f2fdf..d26f4f8fdfc 100644 --- a/htdocs/core/boxes/box_activity.php +++ b/htdocs/core/boxes/box_activity.php @@ -85,7 +85,7 @@ class box_activity extends ModeleBoxes if ($result) { $num = $db->num_rows($result); - $now=gmmktime(); + $now=dol_now(); $i = 0; while ($i < $num) diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 63a31c85483..42a6119c611 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -91,7 +91,7 @@ class Form if ($perm) { $tmp=explode(':',$typeofdata); - $ret.= '
'; + $ret.= '
'; $ret.= $langs->trans($text); $ret.= '
'."\n"; } @@ -267,7 +267,8 @@ class Form if (preg_match('/^(string|email|numeric)/',$inputType)) { $tmp=explode(':',$inputType); - $inputType=$tmp[0]; $inputOption=$tmp[1]; + $inputType=$tmp[0]; + if (! empty($tmp[1])) $inputOption=$tmp[1]; if (! empty($tmp[2])) $savemethod=$tmp[2]; } else if (preg_match('/^datepicker/',$inputType)) @@ -2237,8 +2238,8 @@ class Form { foreach ($formquestion as $key => $input) { - array_push($inputok,$input['name']); - if ($input['inputko'] == 1) array_push($inputko,$input['name']); + if (isset($input['name'])) array_push($inputok,$input['name']); + if (isset($input['inputko']) && $input['inputko'] == 1) array_push($inputko,$input['name']); } } diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 455758b6148..4503d8e9192 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -821,12 +821,12 @@ function dol_print_date($time,$format='',$tzoutput='tzserver',$outputlangs='',$e // This part of code should not be used. dol_syslog("Functions.lib::dol_print_date function call with deprecated value of time in page ".$_SERVER["PHP_SELF"], LOG_WARNING); // Date has format 'YYYY-MM-DD' or 'YYYY-MM-DD HH:MM:SS' or 'YYYYMMDDHHMMSS' - $syear = $reg[1]; - $smonth = $reg[2]; - $sday = $reg[3]; - $shour = $reg[4]; - $smin = $reg[5]; - $ssec = $reg[6]; + $syear = (! empty($reg[1]) ? $reg[1] : ''); + $smonth = (! empty($reg[2]) ? $reg[2] : ''); + $sday = (! empty($reg[3]) ? $reg[3] : ''); + $shour = (! empty($reg[4]) ? $reg[4] : ''); + $smin = (! empty($reg[5]) ? $reg[5] : ''); + $ssec = (! empty($reg[6]) ? $reg[6] : ''); $time=dol_mktime($shour,$smin,$ssec,$smonth,$sday,$syear,true); $ret=adodb_strftime($format,$time+$offsettz+$offsetdst,$to_gmt); @@ -966,7 +966,7 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) else $localtz = new DateTimeZone('UTC'); $dt = new DateTime(null,$localtz); $dt->setDate($year,$month,$day); - $dt->setTime($hour,$minute,$second); + $dt->setTime((int) $hour, (int) $minute, (int) $second); $date=$dt->getTimestamp(); } else @@ -3852,7 +3852,7 @@ function picto_from_langcode($codelang) */ function complete_head_from_modules($conf,$langs,$object,&$head,&$h,$type,$mode='add') { - if (is_array($conf->tabs_modules[$type])) + if (isset($conf->tabs_modules[$type]) && is_array($conf->tabs_modules[$type])) { foreach ($conf->tabs_modules[$type] as $value) { diff --git a/htdocs/core/lib/product.lib.php b/htdocs/core/lib/product.lib.php index e13c7dbdc64..d811a3edfd1 100644 --- a/htdocs/core/lib/product.lib.php +++ b/htdocs/core/lib/product.lib.php @@ -123,7 +123,7 @@ function product_prepare_head($object, $user) // More tabs from canvas - if (is_array($object->onglets)) + if (isset($object->onglets) && is_array($object->onglets)) { foreach ($object->onglets as $onglet) { diff --git a/htdocs/core/lib/security.lib.php b/htdocs/core/lib/security.lib.php index b1047350a89..95cdb171a1d 100644 --- a/htdocs/core/lib/security.lib.php +++ b/htdocs/core/lib/security.lib.php @@ -115,10 +115,14 @@ function restrictedArea($user, $features, $objectid=0, $dbtablename='', $feature if ($dbt_select != 'rowid') $objectid = "'".$objectid."'"; // More features to check - $features = explode("&",$features); + if (! empty($features)) { + $features = explode("&", $features); + } // More parameters - list($dbtablename, $sharedelement) = explode('&', $dbtablename); + if (! empty($dbtablename)) { + list($dbtablename, $sharedelement) = explode('&', $dbtablename); + } // Check read permission from module // TODO Replace "feature" param into caller by first level of permission diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 31f22ef81b6..2936da5720d 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -669,7 +669,7 @@ if (! defined('NOREQUIRETRAN')) } // Use php template engine -if ($conf->global->MAIN_USE_TEMPLATE_ENGINE && ! defined('NOTEMPLATEENGINE')) +if (! empty($conf->global->MAIN_USE_TEMPLATE_ENGINE) && ! defined('NOTEMPLATEENGINE')) { require_once(DOL_DOCUMENT_ROOT.'/includes/savant/Savant3.php'); @@ -893,14 +893,17 @@ function top_htmlhead($head, $title='', $disablejs=0, $disablehead=0, $arrayofjs //print 'themepath='.$themepath.' themeparam='.$themeparam;exit; print ''."\n"; // CSS forced by modules (relative url starting with /) - $dircss=(array) $conf->modules_parts['css']; - foreach($dircss as $key => $cssfile) + if (isset($conf->modules_parts['css'])) { - // cssfile is a relative path - print ''."\n"; + $dircss=(array) $conf->modules_parts['css']; + foreach($dircss as $key => $cssfile) + { + // cssfile is a relative path + print ''."\n"; + } } // CSS forced by page in top_htmlhead call (relative url starting with /) if (is_array($arrayofcss)) @@ -1207,7 +1210,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print "\n".''."\n"; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print '
'."\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'."\n"; print '
'."\n"; @@ -1241,7 +1244,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a $loginhtmltext.='
'.$langs->trans("IPAddress").': '.$_SERVER["REMOTE_ADDR"]; $loginhtmltext.='
'; $loginhtmltext.='
'.$langs->trans("Connection").''; - if ($conf->global->MAIN_MODULE_MULTICOMPANY) $loginhtmltext.='
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; + if (! empty($conf->global->MAIN_MODULE_MULTICOMPANY)) $loginhtmltext.='
'.$langs->trans("ConnectedOnMultiCompany").': '.$conf->entity.' (user entity '.$user->entity.')'; $loginhtmltext.='
'.$langs->trans("ConnectedSince").': '.dol_print_date($user->datelastlogin,"dayhour"); $loginhtmltext.='
'.$langs->trans("PreviousConnexion").': '.dol_print_date($user->datepreviouslogin,"dayhour"); $loginhtmltext.='
'.$langs->trans("AuthenticationMode").': '.$_SESSION["dol_authmode"]; @@ -1253,7 +1256,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a if (! empty($_SESSION["disablemodules"])) $loginhtmltext.='
'.$langs->trans("DisabledModules").':
'.join(', ',explode(',',$_SESSION["disablemodules"])); $appli='Dolibarr'; - if (!empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; + if (! empty($conf->global->MAIN_APPLICATION_TITLE)) $appli=$conf->global->MAIN_APPLICATION_TITLE; // Link info $logouttext=''; @@ -1281,7 +1284,7 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print '
'; - if (! is_object($form)) $form=new Form($db); + $form=new Form($db); $toprightmenu.=$form->textwithtooltip('',$loginhtmltext,2,1,$logintext,'',1); @@ -1308,11 +1311,11 @@ function top_menu($head, $title='', $target='', $disablejs=0, $disablehead=0, $a print '
'."\n"; print "\n"; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n"; print "\n"; - if (! $conf->use_javascript_ajax || ! $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print ''; + if (empty($conf->use_javascript_ajax) || empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print '
'; } @@ -1347,32 +1350,32 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me } $hookmanager->initHooks(array('searchform','leftblock')); - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print "\n".'
'."\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print "\n".'
'."\n"; else print '
'; print "\n"; @@ -1527,7 +1530,7 @@ function main_area($title='') { global $conf, $langs; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) { print '
'."\n"; print '
'; print "\n"; // Define $searchform - if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_SOCIETE && $user->rights->societe->lire) + if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_SOCIETE) && $user->rights->societe->lire) { $langs->load("companies"); $searchform.=printSearchForm(DOL_URL_ROOT.'/societe/societe.php', DOL_URL_ROOT.'/societe/societe.php', img_object('','company').' '.$langs->trans("ThirdParties"), 'soc', 'socname'); } - if ($conf->societe->enabled && $conf->global->MAIN_SEARCHFORM_CONTACT && $user->rights->societe->lire) + if (! empty($conf->societe->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_CONTACT) && $user->rights->societe->lire) { $langs->load("companies"); $searchform.=printSearchForm(DOL_URL_ROOT.'/contact/list.php', DOL_URL_ROOT.'/contact/list.php', img_object('','contact').' '.$langs->trans("Contacts"), 'contact', 'contactname'); } - if ((($conf->product->enabled && $user->rights->produit->lire) || ($conf->service->enabled && $user->rights->service->lire)) - && $conf->global->MAIN_SEARCHFORM_PRODUITSERVICE) + if (((! empty($conf->product->enabled) && $user->rights->produit->lire) || (! empty($conf->service->enabled) && $user->rights->service->lire)) + && ! empty($conf->global->MAIN_SEARCHFORM_PRODUITSERVICE)) { $langs->load("products"); $searchform.=printSearchForm(DOL_URL_ROOT.'/product/liste.php', DOL_URL_ROOT.'/product/liste.php', img_object('','product').' '.$langs->trans("Products")."/".$langs->trans("Services"), 'products', 'sall'); } - if ($conf->adherent->enabled && $conf->global->MAIN_SEARCHFORM_ADHERENT && $user->rights->adherent->lire) + if (! empty($conf->adherent->enabled) && ! empty($conf->global->MAIN_SEARCHFORM_ADHERENT) && $user->rights->adherent->lire) { $langs->load("members"); $searchform.=printSearchForm(DOL_URL_ROOT.'/adherents/liste.php', DOL_URL_ROOT.'/adherents/liste.php', img_object('','user').' '.$langs->trans("Members"), 'member', 'sall'); @@ -1504,7 +1507,7 @@ function left_menu($menu_array_before, $helppagename='', $moresearchform='', $me $leftblock=$hookmanager->executeHooks('printLeftBlock',$parameters); // Note that $action and $object may have been modified by some hooks print $leftblock; - if ($conf->use_javascript_ajax && $conf->global->MAIN_MENU_USE_JQUERY_LAYOUT) print ' '."\n"; + if (! empty($conf->use_javascript_ajax) && ! empty($conf->global->MAIN_MENU_USE_JQUERY_LAYOUT)) print ' '."\n"; else print '
'; diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index fe6fa3395a9..409a0f775b0 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2423,6 +2423,7 @@ class Product extends CommonObject while ($i < $num) { $row = $this->db->fetch_object($result); + $this->stock_warehouse[$row->fk_entrepot] = (object) array(); $this->stock_warehouse[$row->fk_entrepot]->real = $row->reel; $this->stock_warehouse[$row->fk_entrepot]->pmp = $row->pmp; $this->stock_reel+=$row->reel; diff --git a/htdocs/product/class/service.class.php b/htdocs/product/class/service.class.php index a2780e88b91..8d12267ea0b 100644 --- a/htdocs/product/class/service.class.php +++ b/htdocs/product/class/service.class.php @@ -66,7 +66,7 @@ class Service extends CommonObject $sql = "SELECT count(p.rowid) as nb"; $sql.= " FROM ".MAIN_DB_PREFIX."product as p"; - $sql.= ' WHERE p.entity IN ('.getEntity($this->element, 1).')'; + $sql.= ' WHERE p.entity IN ('.getEntity('product', 1).')'; $sql.= " AND p.fk_product_type = 1"; $resql=$this->db->query($sql); diff --git a/htdocs/product/fiche.php b/htdocs/product/fiche.php index 11121edf567..03d6dad9356 100644 --- a/htdocs/product/fiche.php +++ b/htdocs/product/fiche.php @@ -668,7 +668,7 @@ $helpurl=''; if (GETPOST("type") == '0') $helpurl='EN:Module_Products|FR:Module_Produits|ES:Módulo_Productos'; if (GETPOST("type") == '1') $helpurl='EN:Module_Services_En|FR:Module_Services|ES:Módulo_Servicios'; -llxHeader('',$langs->trans("CardProduct".$_GET["type"]),$helpurl); +llxHeader('',$langs->trans("CardProduct".GETPOST("type")),$helpurl); $form = new Form($db); $formproduct = new FormProduct($db); @@ -1047,7 +1047,7 @@ else dol_fiche_head($head, 'card', $titre, 0, $picto); $showphoto=$object->is_photo_available($conf->product->multidir_output[$object->entity]); - $showbarcode=$conf->barcode->enabled && $user->rights->barcode->lire; + $showbarcode=(! empty($conf->barcode->enabled) && $user->rights->barcode->lire); // En mode visu print '
'; @@ -1137,13 +1137,13 @@ else } // Accountancy sell code - print ''; // Accountancy buy code - print ''; // Status (to sell) @@ -1179,7 +1179,7 @@ else { $dur=array("h"=>$langs->trans("Hour"),"d"=>$langs->trans("Day"),"w"=>$langs->trans("Week"),"m"=>$langs->trans("Month"),"y"=>$langs->trans("Year")); } - print $langs->trans($dur[$object->duration_unit])." "; + print (! empty($object->duration_unit) && isset($dur[$object->duration_unit]) ? $langs->trans($dur[$object->duration_unit]) : '')." "; print ''; } @@ -1302,11 +1302,11 @@ if ($action == '' || $action == 'view') { if ($user->rights->produit->creer || $user->rights->service->creer) { - if ($object->no_button_edit <> 1) print 'id.'">'.$langs->trans("Modify").''; + if (isset($object->no_button_edit) && $object->no_button_edit <> 1) print 'id.'">'.$langs->trans("Modify").''; - if ($object->no_button_copy <> 1) + if (isset($object->no_button_copy) && $object->no_button_copy <> 1) { - if ($conf->use_javascript_ajax) + if (! empty($conf->use_javascript_ajax)) { print ''.$langs->trans('ToClone').''."\n"; print $form->formconfirm($_SERVER["PHP_SELF"].'?id='.$object->id,$langs->trans('CloneProduct'),$langs->trans('ConfirmCloneProduct',$object->ref),'confirm_clone',$formquestionclone,'yes','action-clone',230,600); @@ -1322,9 +1322,9 @@ if ($action == '' || $action == 'view') if (($object->type == 0 && $user->rights->produit->supprimer) || ($object->type == 1 && $user->rights->service->supprimer)) { - if (! $object_is_used && $object->no_button_delete <> 1) + if (! $object_is_used && isset($object->no_button_delete) && $object->no_button_delete <> 1) { - if ($conf->use_javascript_ajax) + if (! empty($conf->use_javascript_ajax)) { print ''.$langs->trans('Delete').''."\n"; print $form->formconfirm("fiche.php?id=".$object->id,$langs->trans("DeleteProduct"),$langs->trans("ConfirmDeleteProduct"),"confirm_delete",'',0,"action-delete"); @@ -1357,7 +1357,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) print '
'.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer).''; - print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer); + print '
'.$form->editfieldkey("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').''; + print $form->editfieldval("ProductAccountancySellCode",'accountancy_code_sell',$object->accountancy_code_sell,$object,$user->rights->produit->creer||$user->rights->service->creer,'string'); print '
'.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer).''; - print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer); + print '
'.$form->editfieldkey("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string').''; + print $form->editfieldval("ProductAccountancyBuyCode",'accountancy_code_buy',$object->accountancy_code_buy,$object,$user->rights->produit->creer||$user->rights->service->creer,'string'); print '
'; // Propals - if($conf->propal->enabled && $user->rights->propale->creer) + if (! empty($conf->propal->enabled) && $user->rights->propale->creer) { $propal = new Propal($db); @@ -1413,7 +1413,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) print ''; @@ -1474,7 +1474,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) } // Commande - if($conf->commande->enabled && $user->rights->commande->creer) + if (! empty($conf->commande->enabled) && $user->rights->commande->creer) { $commande = new Commande($db); @@ -1530,7 +1530,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) print ''; @@ -1592,7 +1592,7 @@ if ($id && ($action == '' || $action == 'view') && $object->status) } // Factures - if ($conf->facture->enabled && $user->rights->facture->creer) + if (! empty($conf->facture->enabled) && $user->rights->facture->creer) { print ''; @@ -1743,6 +1743,6 @@ if ($id && ($action == '' || $action == 'view') && $object->status) } -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/product/index.php b/htdocs/product/index.php index bfd666fad2b..8703283e460 100644 --- a/htdocs/product/index.php +++ b/htdocs/product/index.php @@ -1,7 +1,7 @@ * Copyright (C) 2004-2011 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -74,7 +74,7 @@ print '
'; print ''.$langs->trans("ReductionShort"); print '%'; - print " ".$object->stock_proposition; + if (isset($object->stock_proposition)) print " ".$object->stock_proposition; print ''; print ''; print ''; print ''.$langs->trans("ReductionShort"); print '%'; - print " ".$object->stock_proposition; + if (isset($object->stock_proposition)) print " ".$object->stock_proposition; print ''; print ''; print '
'; print $langs->trans("AddToMyBills").'
'; * Zone recherche produit/service */ $rowspan=2; -if ($conf->barcode->enabled) $rowspan++; +if (! empty($conf->barcode->enabled)) $rowspan++; print '
'; print ''; print ''; @@ -83,7 +83,7 @@ print ''; print "'; print ''; -if ($conf->barcode->enabled) +if (! empty($conf->barcode->enabled)) { print "'; diff --git a/htdocs/societe/class/address.class.php b/htdocs/societe/class/address.class.php index f1a0815b4c7..a8360e52968 100644 --- a/htdocs/societe/class/address.class.php +++ b/htdocs/societe/class/address.class.php @@ -86,7 +86,7 @@ class Address if ($result >= 0) { $now=dol_now(); - + $sql = "INSERT INTO ".MAIN_DB_PREFIX."societe_address (label, fk_soc, name, datec, fk_user_creat) "; $sql .= " VALUES ('".$this->db->escape($this->label)."', '".$socid."', '".$this->db->escape($this->name)."', ".$this->db->idate($now).", '".$user->id."')"; @@ -188,7 +188,7 @@ class Address if ($result >= 0) { dol_syslog(get_class($this)."::Update verify ok"); - + $this->db->begin(); $sql = "UPDATE ".MAIN_DB_PREFIX."societe_address"; @@ -203,7 +203,7 @@ class Address $sql.= ", fax = ".($this->fax?"'".$this->db->escape($this->fax)."'":"null"); if ($user) $sql .= ",fk_user_modif = '".$user->id."'"; $sql .= " WHERE fk_soc = '" . $socid ."' AND rowid = '" . $id ."'"; - + dol_syslog(get_class($this)."::Update sql=".$sql, LOG_DEBUG); $resql=$this->db->query($sql); if ($resql) @@ -216,7 +216,7 @@ class Address { if ($this->db->errno() == 'DB_ERROR_RECORD_ALREADY_EXISTS') { - + $this->error=$langs->trans("ErrorDuplicateField",$this->name); $result=-1; } @@ -302,7 +302,7 @@ class Address $line->phone = $objp->tel; $line->fax = $objp->fax; $line->note = $objp->note; - + // deprecated $line->cp = $line->zip; $line->ville = $line->town; @@ -381,14 +381,14 @@ class Address $this->phone = $obj->tel; $this->fax = $obj->fax; $this->note = $obj->note; - + // deprecated - $line->cp = $line->zip; - $line->ville = $line->town; - $line->pays_id = $line->country_id; - $line->pays_code = $line->country_code; - $line->pays = $line->country; - $line->tel = $line->phone; + $this->cp = $this->zip; + $this->ville = $this->town; + $this->pays_id = $this->country_id; + $this->pays_code = $this->country_code; + $this->pays = $this->country; + $this->tel = $this->phone; $result = 1; } @@ -435,7 +435,7 @@ class Address print $this->db->error() . '
' . $sql; } } - + /** * Return name of address with link (and eventually picto) * Use $this->id, $this->label, $this->socid @@ -447,12 +447,12 @@ class Address function getNomUrl($withpicto=0,$option='') { global $langs; - + $result=''; - + $lien = ''; $lienfin=''; - + if ($withpicto) $result.=($lien.img_object($langs->trans("ShowAddress").': '.$this->label,'address').$lienfin.' '); $result.=$lien.$this->label.$lienfin; return $result; diff --git a/htdocs/user/class/user.class.php b/htdocs/user/class/user.class.php index d0ee57086e0..f3cad67cd4a 100644 --- a/htdocs/user/class/user.class.php +++ b/htdocs/user/class/user.class.php @@ -578,8 +578,11 @@ class User extends CommonObject if ($perms) { + if (! is_object($this->rights)) $this->rights = (object) array(); // For avoid error + if (! is_object($this->rights->$module)) $this->rights->$module = (object) array(); if ($subperms) { + if (! is_object($this->rights->$module->$perms)) $this->rights->$module->$perms = (object) array(); $this->rights->$module->$perms->$subperms = 1; } else
'.$langs->trans("Search").'
"; print $langs->trans("Ref").':
"; print $langs->trans("BarCode").':