From ff0668e908d86e315406782e6ec8042afefa266a Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Tue, 10 Jul 2012 22:10:12 +0200 Subject: [PATCH] Fix: strict mode way --- .../actions_contactcard_common.class.php | 7 +- .../actions_contactcard_default.class.php | 14 +-- .../default/tpl/contactcard_edit.tpl.php | 2 +- .../default/tpl/contactcard_view.tpl.php | 6 +- htdocs/contact/fiche.php | 3 +- htdocs/contact/list.php | 21 ++--- htdocs/contact/perso.php | 5 +- htdocs/core/class/commonobject.class.php | 12 +-- htdocs/core/class/html.form.class.php | 15 ++-- htdocs/core/lib/ajax.lib.php | 6 +- htdocs/core/lib/company.lib.php | 90 ++++++++++++------- htdocs/core/lib/contact.lib.php | 6 +- htdocs/core/lib/functions.lib.php | 12 +-- 13 files changed, 113 insertions(+), 86 deletions(-) diff --git a/htdocs/contact/canvas/actions_contactcard_common.class.php b/htdocs/contact/canvas/actions_contactcard_common.class.php index dafb75b4e04..fb8711d7c12 100644 --- a/htdocs/contact/canvas/actions_contactcard_common.class.php +++ b/htdocs/contact/canvas/actions_contactcard_common.class.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-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 @@ -227,9 +227,10 @@ abstract class ActionsContactCardCommon * Set content of ->tpl array, to use into template * * @param string &$action Type of action + * @param int $id Id * @return string HTML output */ - function assign_values(&$action) + function assign_values(&$action, $id) { global $conf, $langs, $user, $canvas; global $form, $formcompany, $objsoc; @@ -273,7 +274,7 @@ abstract class ActionsContactCardCommon $this->tpl['select_civility'] = $formcompany->select_civility($this->object->civilite_id); // Predefined with third party - if ($objsoc->typent_code == 'TE_PRIVATE' || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) + if ((isset($objsoc->typent_code) && $objsoc->typent_code == 'TE_PRIVATE') || ! empty($conf->global->CONTACT_USE_COMPANY_ADDRESS)) { if (dol_strlen(trim($this->object->address)) == 0) $this->tpl['address'] = $objsoc->address; if (dol_strlen(trim($this->object->zip)) == 0) $this->object->zip = $objsoc->zip; diff --git a/htdocs/contact/canvas/default/actions_contactcard_default.class.php b/htdocs/contact/canvas/default/actions_contactcard_default.class.php index ed186b92348..1cb87732ddc 100644 --- a/htdocs/contact/canvas/default/actions_contactcard_default.class.php +++ b/htdocs/contact/canvas/default/actions_contactcard_default.class.php @@ -1,6 +1,6 @@ - * Copyright (C) 2011 Laurent Destailleur +/* Copyright (C) 2010-2012 Regis Houssin + * Copyright (C) 2011 Laurent Destailleur * * 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 @@ -38,15 +38,15 @@ class ActionsContactCardDefault extends ActionsContactCardCommon /** * Constructor * - * @param DoliDB $DB Handler acces base de donnees + * @param DoliDB $db Handler acces base de donnees * @param string $dirmodule Name of directory of module * @param string $targetmodule Name of directory of module where canvas is stored * @param string $canvas Name of canvas * @param string $card Name of tab (sub-canvas) */ - function __construct($DB, $dirmodule, $targetmodule, $canvas, $card) + function __construct($db, $dirmodule, $targetmodule, $canvas, $card) { - $this->db = $DB; + $this->db = $db; $this->dirmodule = $dirmodule; $this->targetmodule = $targetmodule; $this->canvas = $canvas; @@ -86,7 +86,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $ret = $this->getObject($id); - parent::assign_values($action); + parent::assign_values($action, $id); $this->tpl['title'] = $this->getTitle($action); $this->tpl['error'] = $this->error; @@ -102,7 +102,7 @@ class ActionsContactCardDefault extends ActionsContactCardCommon $this->tpl['showend']=dol_get_fiche_end(); $objsoc = new Societe($db); - $objsoc->fetch($this->object->fk_soc); + $objsoc->fetch($this->object->socid); $this->tpl['actionstodo']=show_actions_todo($conf,$langs,$db,$objsoc,$this->object,1); diff --git a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php index c4b48767f2f..34b077eac9b 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_edit.tpl.php @@ -40,7 +40,7 @@ echo $this->control->tpl['ajax_selectcountry']; -control->tpl['company_id']) { ?> +control->tpl['company_id'])) { ?> diff --git a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php index fe878bf95f0..53f29e5397e 100644 --- a/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php +++ b/htdocs/contact/canvas/default/tpl/contactcard_view.tpl.php @@ -1,5 +1,5 @@ +/* Copyright (C) 2010-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 @@ -26,8 +26,8 @@ $contact = $GLOBALS['objcanvas']->control->object; dol_htmloutput_errors($this->control->tpl['error'],$this->control->tpl['errors']); ?> -control->tpl['action_create_user']) echo $this->control->tpl['action_create_user']; ?> -control->tpl['action_delete']) echo $this->control->tpl['action_delete']; ?> +control->tpl['action_create_user'])) echo $this->control->tpl['action_create_user']; ?> +control->tpl['action_delete'])) echo $this->control->tpl['action_delete']; ?> diff --git a/htdocs/contact/fiche.php b/htdocs/contact/fiche.php index 7487bf6d06f..b13f960e9de 100644 --- a/htdocs/contact/fiche.php +++ b/htdocs/contact/fiche.php @@ -50,7 +50,8 @@ $object = new Contact($db); // Get object canvas (By default, this is not defined, so standard usage of dolibarr) $object->getCanvas($id); -$canvas = $object->canvas?$object->canvas:GETPOST("canvas"); +$objcanvas=null; +$canvas = (! empty($object->canvas)?$object->canvas:GETPOST("canvas")); if (! empty($canvas)) { require_once(DOL_DOCUMENT_ROOT."/core/class/canvas.class.php"); diff --git a/htdocs/contact/list.php b/htdocs/contact/list.php index b6723bb6623..d71dcc44225 100755 --- a/htdocs/contact/list.php +++ b/htdocs/contact/list.php @@ -31,7 +31,7 @@ $langs->load("companies"); $langs->load("suppliers"); // Security check -$contactid = isset($_GET["id"])?$_GET["id"]:''; +$contactid = GETPOST('id','int'); if ($user->societe_id) $socid=$user->societe_id; $result = restrictedArea($user, 'contact', $contactid,''); @@ -54,6 +54,8 @@ $sall=GETPOST("contactname"); $sortfield = GETPOST("sortfield"); $sortorder = GETPOST("sortorder"); $page = GETPOST("page"); +$userid=GETPOST('userid'); +$begin=GETPOST('begin'); if (! $sortorder) $sortorder="ASC"; if (! $sortfield) $sortfield="p.name"; @@ -86,9 +88,9 @@ else if ($type == "o") if ($view == 'phone') { $text=" (Vue Telephones)"; } if ($view == 'mail') { $text=" (Vue EMail)"; } if ($view == 'recent') { $text=" (Recents)"; } -$titre.= " $text"; +if (! empty($text)) $titre.= " $text"; -if ($_POST["button_removefilter"]) +if (GETPOST('button_removefilter')) { $search_nom=""; $search_prenom=""; @@ -129,9 +131,9 @@ if (!$user->rights->societe->client->voir && !$socid) //restriction { $sql .= " AND (sc.fk_user = " .$user->id." OR p.fk_soc IS NULL)"; } -if ($_GET["userid"]) // propre au commercial +if ($userid) // propre au commercial { - $sql .= " AND p.fk_user_creat=".$_GET["userid"]; + $sql .= " AND p.fk_user_creat=".$userid; } // Filter to exclude not owned private contacts @@ -205,7 +207,7 @@ if ($sall) { $sql .= " AND (p.name LIKE '%".$db->escape($sall)."%' OR p.firstname LIKE '%".$db->escape($sall)."%' OR p.email LIKE '%".$db->escape($sall)."%')"; } -if ($socid) +if (! empty($socid)) { $sql .= " AND s.rowid = ".$socid; } @@ -235,8 +237,7 @@ if ($result) { $contactstatic=new Contact($db); - $begin=$_GET["begin"]; - $param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($_GET["userid"]).'&contactname='.urlencode($sall); + $param ='&begin='.urlencode($begin).'&view='.urlencode($view).'&userid='.urlencode($userid).'&contactname='.urlencode($sall); $param.='&type='.urlencode($type).'&view='.urlencode($view).'&search_nom='.urlencode($search_nom).'&search_prenom='.urlencode($search_prenom).'&search_societe='.urlencode($search_societe).'&search_email='.urlencode($search_email); if ($search_priv == '0' || $search_priv == '1') $param.="&search_priv=".urlencode($search_priv); @@ -408,7 +409,7 @@ if ($result) print ''; - if ($num > $limit) print_barre_liste('', $page, $_SERVER["PHP_SELF"], '&begin='.$begin.'&view='.$view.'&userid='.$_GET["userid"], $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); + if ($num > $limit) print_barre_liste('', $page, $_SERVER["PHP_SELF"], '&begin='.$begin.'&view='.$view.'&userid='.$userid, $sortfield, $sortorder, '', $num, $nbtotalofrecords, ''); $db->free($result); } @@ -419,7 +420,7 @@ else print '
'; -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/contact/perso.php b/htdocs/contact/perso.php index 8cf299ec133..26a3b90ea59 100644 --- a/htdocs/contact/perso.php +++ b/htdocs/contact/perso.php @@ -131,7 +131,7 @@ if ($action == 'edit') print ''; print ''; } @@ -193,7 +193,7 @@ else // Date To Birth print ''; - if ($object->birthday != '') + if (! empty($object->birthday)) { include_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); @@ -225,7 +225,6 @@ else dol_fiche_end(); - if ($action != 'edit') { // Barre d'actions diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index aa0c71dbd45..a41aee430b8 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -772,13 +772,13 @@ abstract class CommonObject $sql = "SELECT MAX(te.".$fieldid.")"; $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as te"; - if ($this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && empty($user->rights->societe->client->voir))) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && empty($user->rights->societe->client->voir))) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; $sql.= " WHERE te.".$fieldid." < '".$this->db->escape($this->ref)."'"; if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id; if (! empty($filter)) $sql.=" AND ".$filter; - if ($this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity - if ($this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; //print $sql."
"; $result = $this->db->query($sql); @@ -793,13 +793,13 @@ abstract class CommonObject $sql = "SELECT MIN(te.".$fieldid.")"; $sql.= " FROM ".MAIN_DB_PREFIX.$this->table_element." as te"; - if ($this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ", ".MAIN_DB_PREFIX."societe as s"; // If we need to link to societe to limit select to entity if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."societe_commerciaux as sc ON ".$alias.".rowid = sc.fk_soc"; $sql.= " WHERE te.".$fieldid." > '".$this->db->escape($this->ref)."'"; if (empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir) $sql.= " AND sc.fk_user = " .$user->id; if (! empty($filter)) $sql.=" AND ".$filter; - if ($this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity - if ($this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 2 || ($this->element != 'societe' && empty($this->isnolinkedbythird) && !$user->rights->societe->client->voir)) $sql.= ' AND te.fk_soc = s.rowid'; // If we need to link to societe to limit select to entity + if (isset($this->ismultientitymanaged) && $this->ismultientitymanaged == 1) $sql.= ' AND te.entity IN ('.getEntity($this->element, 1).')'; // Rem: Bug in some mysql version: SELECT MIN(rowid) FROM llx_socpeople WHERE rowid > 1 when one row in database with rowid=1, returns 1 instead of null //print $sql."
"; diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 044fbd74443..53ab7a49ddc 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -2151,21 +2151,23 @@ class Form $inputok=array(); $inputko=array(); - if (is_array($formquestion) && count($formquestion) > 0) + if (is_array($formquestion) && ! empty($formquestion)) { $more.='
'.$langs->trans("Alert").': '; - if ($object->birthday_alert) + if (! empty($object->birthday_alert)) { print '
'."\n"; - $more.=''."\n"; + $more.=''."\n"; foreach ($formquestion as $key => $input) { - if (is_array($input)) + if (is_array($input) && ! empty($input)) { + $size=(! empty($input['size'])?' size="'.$input['size'].'"':''); + if ($input['type'] == 'text') { - $more.=''."\n"; + $more.=''."\n"; } else if ($input['type'] == 'password') { - $more.=''."\n"; + $more.=''."\n"; } else if ($input['type'] == 'select') { @@ -3087,8 +3089,9 @@ class Form if ($d) { // Show date with popup - if ($conf->use_javascript_ajax && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) + if (! empty($conf->use_javascript_ajax) && (empty($conf->global->MAIN_POPUP_CALENDAR) || $conf->global->MAIN_POPUP_CALENDAR != "none")) { + $formated_date=''; //print "e".$set_time." t ".$conf->format_date_short; if (strval($set_time) != '' && $set_time != -1) { diff --git a/htdocs/core/lib/ajax.lib.php b/htdocs/core/lib/ajax.lib.php index f433374f83c..1eec9ff53be 100644 --- a/htdocs/core/lib/ajax.lib.php +++ b/htdocs/core/lib/ajax.lib.php @@ -207,19 +207,19 @@ function ajax_dialog($title,$message,$w=350,$h=150) */ function ajax_combobox($htmlname, $event=array()) { - $msg.= '
'.$formquestion['text'].'
'.(! empty($formquestion['text'])?$formquestion['text']:'').'
'.$input['label'].'
'.$input['label'].'
'.$input['label'].'
'.$input['label'].'