diff --git a/build.xml b/build.xml index 2c2dfb0c64c..fbfd6c3f4f6 100644 --- a/build.xml +++ b/build.xml @@ -97,5 +97,5 @@ - + \ No newline at end of file diff --git a/htdocs/admin/system/database.php b/htdocs/admin/system/database.php index 395011ee2b9..8231d9c2e90 100644 --- a/htdocs/admin/system/database.php +++ b/htdocs/admin/system/database.php @@ -44,7 +44,7 @@ print_fiche_titre($langs->trans("DatabaseConfiguration"),'','setup'); // Database print ''; print ''."\n"; -print ''."\n"; +print ''."\n"; print ''."\n"; print ''."\n"; print ''."\n"; diff --git a/htdocs/admin/system/index.php b/htdocs/admin/system/index.php index 0ce5fb86190..5c11f595f94 100644 --- a/htdocs/admin/system/index.php +++ b/htdocs/admin/system/index.php @@ -86,7 +86,7 @@ print "
\n"; // Database print '
'.$langs->trans("Database").'
'.$langs->trans("Version").''.$db->getLabel().' '.$db->getVersion().'
'.$langs->trans("Version").''.getStaticMember(get_class($db),'label').' '.$db->getVersion().'
'.$langs->trans("DatabaseServer").''.$conf->db->host.'
'.$langs->trans("DatabasePort").''.(empty($conf->db->port)?$langs->trans("Default"):$conf->db->port).'
'.$langs->trans("DatabaseName").''.$conf->db->name.'
'; print "\n"; -$dblabel=$db->getLabel(); +$dblabel=getStaticMember(get_class($db),'label'); $dbversion=$db->getVersion(); print "\n"; print '
".$langs->trans("Database")."
".$langs->trans("Version")."" .$dblabel." ".$dbversion."
'; diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php index 1a159d03257..e6d334965c4 100644 --- a/htdocs/categories/categorie.php +++ b/htdocs/categories/categorie.php @@ -1,7 +1,7 @@ * Copyright (C) 2005 Brice Davoleau - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * Copyright (C) 2010 Juanjo Menent @@ -38,6 +38,8 @@ $ref = GETPOST('ref'); $type = GETPOST('type'); $mesg = GETPOST('mesg'); +$removecat = GETPOST('removecat','int'); + $dbtablename = ''; @@ -65,6 +67,7 @@ if ($id || $ref) $elementtype = 'societe'; $objecttype = 'societe&categorie'; $objectid = isset($id)?$id:(isset($socid)?$socid:''); + $dbtablename = '&societe'; $fieldid = 'rowid'; } if ($type == 3) { @@ -86,7 +89,7 @@ $result = restrictedArea($user,$objecttype,$objectid,$dbtablename,'','',$fieldid */ //Suppression d'un objet d'une categorie -if ($_REQUEST["removecat"]) +if ($removecat > 0) { if ($type==0 && ($user->rights->produit->creer || $user->rights->service->creer)) { @@ -112,7 +115,7 @@ if ($_REQUEST["removecat"]) $result = $object->fetch($objectid); } $cat = new Categorie($db); - $result=$cat->fetch($_REQUEST["removecat"]); + $result=$cat->fetch($removecat); $result=$cat->del_type($object,$elementtype); } @@ -269,11 +272,11 @@ if ($socid) dol_htmloutput_mesg($mesg); - if ($soc->client) formCategory($db,$soc,2); + if ($soc->client) formCategory($db,$soc,2,$socid); if ($soc->client && $soc->fournisseur) print '

'; - if ($soc->fournisseur) formCategory($db,$soc,1); + if ($soc->fournisseur) formCategory($db,$soc,1,$socid); } else if ($id || $ref) { @@ -423,7 +426,7 @@ else if ($id || $ref) * @param int $typeid Type of category (0, 1, 2, 3) * @return int 0 */ -function formCategory($db,$object,$typeid) +function formCategory($db,$object,$typeid,$socid=0) { global $user,$langs,$form,$bc; @@ -498,7 +501,7 @@ function formCategory($db,$object,$typeid) if ($typeid == 3) $permission=$user->rights->adherent->creer; if ($permission) { - print ""; + print ""; print img_delete($langs->trans("DeleteFromCat")).' '; print $langs->trans("DeleteFromCat").""; } @@ -529,7 +532,7 @@ function formCategory($db,$object,$typeid) return 0; } -$db->close(); llxFooter(); -?> +$db->close(); +?> \ No newline at end of file diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 7a7cc186a6d..2a8e52e7cad 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2005 Davoleau Brice * Copyright (C) 2005 Rodolphe Quiedeville - * Copyright (C) 2006-2011 Regis Houssin + * Copyright (C) 2006-2012 Regis Houssin * Copyright (C) 2006-2012 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin * @@ -125,6 +125,7 @@ class Categorie * @return int -1 : erreur SQL * -2 : nouvel ID inconnu * -3 : categorie invalide + * -4 : category already exists */ function create($user='') { @@ -141,8 +142,10 @@ class Categorie { $this->error=$langs->trans("ImpossibleAddCat"); $this->error.=" : ".$langs->trans("CategoryExistsAtSameLevel"); - return -1; + return -4; } + + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie (label, description,"; if ($conf->global->CATEGORY_ASSIGNED_TO_A_CUSTOMER) @@ -176,7 +179,8 @@ class Categorie if($this->add_fille() < 0) { $this->error=$langs->trans("ImpossibleAssociateCategory"); - return -1; + $this->db->rollback(); + return -3; } } @@ -186,17 +190,21 @@ class Categorie $result=$interface->run_triggers('CATEGORY_CREATE',$this,$user,$langs,$conf); if ($result < 0) { $error++; $this->errors=$interface->errors; } // Fin appel triggers - + + $this->db->commit(); return $id; } else { + $this->db->rollback(); return -2; } } else { - dol_print_error($this->db); + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::create error ".$this->error." sql=".$sql, LOG_ERR); + $this->db->rollback(); return -1; } } @@ -589,11 +597,11 @@ class Categorie */ function get_desc($cate) { - $sql = "SELECT description FROM ".MAIN_DB_PREFIX."categorie "; - $sql .= "WHERE rowid = ".$cate; + $sql = "SELECT description FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE rowid = ".$cate; - $res = $this->db->query($sql); - $n = $this->db->fetch_array($res); + $res = $this->db->query($sql); + $n = $this->db->fetch_array($res); return($n[0]); } @@ -632,8 +640,6 @@ class Categorie */ function get_full_arbo($type,$markafterid=0) { - global $conf; - $this->cats = array(); // Charge tableau des meres @@ -641,7 +647,7 @@ class Categorie $sql.= " FROM ".MAIN_DB_PREFIX."categorie_association ca"; $sql.= ", ".MAIN_DB_PREFIX."categorie as c"; $sql.= " WHERE ca.fk_categorie_mere = c.rowid"; - $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; // Load array this->motherof dol_syslog("Categorie::get_full_arbo build motherof array sql=".$sql, LOG_DEBUG); @@ -665,7 +671,7 @@ class Categorie $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie_association as ca"; $sql.= " ON c.rowid = ca.fk_categorie_mere"; $sql.= " WHERE c.type = ".$type; - $sql.= " AND c.entity = ".$conf->entity; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; $sql.= " ORDER BY c.label, c.rowid"; dol_syslog("Categorie::get_full_arbo get category list sql=".$sql, LOG_DEBUG); @@ -811,6 +817,7 @@ class Categorie function get_all_categories () { $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE entity IN (".getEntity('category',1).")"; $res = $this->db->query($sql); if ($res) @@ -839,6 +846,7 @@ class Categorie { $sql = "SELECT count(rowid)"; $sql.= " FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE entity IN (".getEntity('category',1).")"; $res = $this->db->query($sql); if ($res) { @@ -870,6 +878,7 @@ class Categorie $sql.= " ON c.rowid=ca.fk_categorie_fille"; $sql.= " WHERE ca.fk_categorie_mere=".$this->id_mere; $sql.= " AND c.label='".$this->db->escape($this->label)."'"; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; } else // mother_id undefined (so it's root) { @@ -883,8 +892,9 @@ class Categorie $sql.= " ON c.rowid!=ca.fk_categorie_fille"; $sql.= " WHERE c.type=".$this->type; $sql.= " AND c.label='".$this->db->escape($this->label)."'"; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; } - dol_syslog("Categorie::already_exists sql=".$sql); + dol_syslog(get_class($this)."::already_exists sql=".$sql, LOG_DEBUG); $resql = $this->db->query($sql); if ($resql) { @@ -896,13 +906,19 @@ class Categorie * So if the result have the same id, update is not for label, and if result have an other one, * update may be for label. */ - if($obj[0] > 0 && $obj[0] != $this->id) return 1; + if($obj[0] > 0 && $obj[0] != $this->id) + { + dol_syslog(get_class($this)."::already_exists category with name=".$this->label." exist rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG); + return 1; + } } + dol_syslog(get_class($this)."::already_exists no category with same name=".$this->label." rowid=".$obj[0]." current_id=".$this->id, LOG_DEBUG); return 0; } else { - dol_print_error($this->db); + $this->error=$this->db->error(); + dol_syslog(get_class($this)."::already_exists error ".$this->error." sql=".$sql, LOG_ERR); return -1; } } @@ -1101,6 +1117,7 @@ class Categorie $sql.= " FROM ".MAIN_DB_PREFIX."categorie_".$type." as ct"; $sql.= " LEFT JOIN ".MAIN_DB_PREFIX."categorie as c ON ct.fk_categorie = c.rowid"; $sql.= " WHERE ct.fk_".$table." = ".$id." AND c.type = ".$typeid; + $sql.= " AND c.entity IN (".getEntity('category',1).")"; $res = $this->db->query($sql); if ($res) @@ -1135,8 +1152,9 @@ class Categorie $cats = array (); // Generation requete recherche - $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie "; - $sql .= "WHERE type = ".$type." "; + $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."categorie"; + $sql.= " WHERE type = ".$type." "; + $sql.= " AND entity IN (".getEntity('category',1).")"; if ($nom) { if (! $exact) diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php index ca82944a32a..015b964d452 100644 --- a/htdocs/categories/edit.php +++ b/htdocs/categories/edit.php @@ -1,7 +1,7 @@ * Copyright (C) 2006-2010 Laurent Destailleur - * Copyright (C) 2005-2011 Regis Houssin + * Copyright (C) 2005-2012 Regis Houssin * Copyright (C) 2007 Patrick Raguin * * This program is free software; you can redistribute it and/or modify @@ -41,7 +41,7 @@ if ($id == "") } // Security check -$result = restrictedArea($user, 'categorie', $id); +$result = restrictedArea($user, 'categorie', $id, '&category'); diff --git a/htdocs/categories/index.php b/htdocs/categories/index.php index 8dc601e996f..de8d727c657 100644 --- a/htdocs/categories/index.php +++ b/htdocs/categories/index.php @@ -3,7 +3,7 @@ * Copyright (C) 2005 Eric Seigne * Copyright (C) 2006-2011 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin - * 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 @@ -29,12 +29,13 @@ require("../main.inc.php"); require_once(DOL_DOCUMENT_ROOT."/categories/class/categorie.class.php"); require_once(DOL_DOCUMENT_ROOT."/core/lib/treeview.lib.php"); -$type=(GETPOST('type') ? GETPOST('type') : 0); - -if (!$user->rights->categorie->lire) accessforbidden(); - $langs->load("categories"); +if (! $user->rights->categorie->lire) accessforbidden(); + +$id=GETPOST('id','int'); +$type=(GETPOST('type') ? GETPOST('type') : 0); + /* * View @@ -88,9 +89,9 @@ print ''; /* * Categories found */ -if($_POST['catname'] || $_REQUEST['id']) +if($_POST['catname'] || $id > 0) { - $cats = $categstatic->rechercher($_REQUEST['id'],$_POST['catname'],$_POST['type']); + $cats = $categstatic->rechercher($id,$_POST['catname'],$type); print ''; print ''; @@ -309,7 +310,7 @@ if ($nbofentries == 0) print "
'.$langs->trans("FoundCats").'
"; -$db->close(); llxFooter(); +$db->close(); ?> diff --git a/htdocs/categories/photos.php b/htdocs/categories/photos.php index 747d2c92a5b..7730347f286 100644 --- a/htdocs/categories/photos.php +++ b/htdocs/categories/photos.php @@ -2,7 +2,7 @@ /* Copyright (C) 2001-2007 Rodolphe Quiedeville * Copyright (C) 2004-2010 Laurent Destailleur * Copyright (C) 2005 Eric Seigne - * 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 @@ -48,7 +48,7 @@ if ($id == "") } // Security check -$result = restrictedArea($user, 'categorie', $id); +$result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); diff --git a/htdocs/categories/viewcat.php b/htdocs/categories/viewcat.php index 5efa8c9ecec..bcf8fd65675 100644 --- a/htdocs/categories/viewcat.php +++ b/htdocs/categories/viewcat.php @@ -2,7 +2,7 @@ /* Copyright (C) 2005 Matthieu Valleton * Copyright (C) 2006-2010 Laurent Destailleur * Copyright (C) 2007 Patrick Raguin - * 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 @@ -44,7 +44,7 @@ if ($id == "") } // Security check -$result = restrictedArea($user, 'categorie', $id); +$result = restrictedArea($user, 'categorie', $id, '&category'); $object = new Categorie($db); $result=$object->fetch($id); diff --git a/htdocs/commande/class/commande.class.php b/htdocs/commande/class/commande.class.php index 0f80894cb2b..8c4a8b6f06e 100644 --- a/htdocs/commande/class/commande.class.php +++ b/htdocs/commande/class/commande.class.php @@ -2111,7 +2111,7 @@ class Commande extends CommonObject * @param double $pu Prix unitaire * @param double $qty Quantity * @param double $remise_percent Pourcentage de remise de la ligne - * @param double $tva_tx Taux TVA + * @param double $txtva Taux TVA * @param double $txlocaltax1 Local tax 1 rate * @param double $txlocaltax2 Local tax 2 rate * @param string $price_base_type HT or TTC diff --git a/htdocs/core/class/conf.class.php b/htdocs/core/class/conf.class.php index dbff136ff30..cca1ce2e0ad 100644 --- a/htdocs/core/class/conf.class.php +++ b/htdocs/core/class/conf.class.php @@ -85,12 +85,46 @@ class Conf function Conf() { // Avoid warnings when filling this->xxx - $this->file=(object) array(); - $this->db=(object) array(); - $this->global=(object) array(); - $this->mycompany=(object) array(); - $this->admin=(object) array(); - $this->user=(object) array(); + $this->file = (object) array(); + $this->db = (object) array(); + $this->global = (object) array(); + $this->mycompany = (object) array(); + $this->admin = (object) array(); + $this->user = (object) array(); + $this->syslog = (object) array(); + $this->browser = (object) array(); + $this->multicompany = (object) array(); + + $this->expedition_bon = (object) array(); + $this->livraison_bon = (object) array(); + $this->fournisseur = (object) array(); + $this->fournisseur->commande = (object) array(); + $this->fournisseur->facture = (object) array(); + $this->product = (object) array(); + $this->service = (object) array(); + $this->contrat = (object) array(); + $this->actions = (object) array(); + $this->commande = (object) array(); + $this->commande->client = (object) array(); + $this->commande->fournisseur = (object) array(); + $this->propal = (object) array(); + $this->propal->cloture = (object) array(); + $this->propal->facturation = (object) array(); + $this->facture = (object) array(); + $this->facture->client = (object) array(); + $this->facture->fournisseur = (object) array(); + $this->contrat = (object) array(); + $this->contrat->services = (object) array(); + $this->contrat->services->inactifs = (object) array(); + $this->contrat->services->expires = (object) array(); + $this->adherent = (object) array(); + $this->adherent->cotisation = (object) array(); + $this->bank = (object) array(); + $this->bank->rappro = (object) array(); + $this->bank->cheque = (object) array(); + $this->notification = (object) array(); + $this->mailing = (object) array(); + //! Charset for HTML output and for storing data in memory $this->file->character_set_client='UTF-8'; // UTF-8, ISO-8859-1 } @@ -185,19 +219,7 @@ class Conf } $i++; } - - // Object $mc - if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) - { - global $mc; - - $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); - if ($ret) - { - $mc = new ActionsMulticompany($db); - $mc->setValues($this); - } - } + $db->free($resql); } //var_dump($this->modules); @@ -237,6 +259,7 @@ class Conf // For backward compatibility // TODO Replace this->xxx->enabled by this->modulename->enabled to remove this code if (isset($this->propale->enabled)) $this->propal->enabled=$this->propale->enabled; + if (isset($this->categorie->enabled)) $this->category->enabled=$this->categorie->enabled; // Define default dir_output and dir_temp for directories of modules foreach($this->modules as $module) @@ -261,7 +284,7 @@ class Conf // for backward compatibility. // Sous module bons d'expedition - $this->expedition_bon->enabled=defined("MAIN_SUBMODULE_EXPEDITION")?MAIN_SUBMODULE_EXPEDITION:0; + $this->expedition_bon->enabled= defined("MAIN_SUBMODULE_EXPEDITION")?MAIN_SUBMODULE_EXPEDITION:0; // Sous module bons de livraison $this->livraison_bon->enabled=defined("MAIN_SUBMODULE_LIVRAISON")?MAIN_SUBMODULE_LIVRAISON:0; @@ -358,13 +381,13 @@ class Conf // Delay before warnings $this->actions->warning_delay=(isset($this->global->MAIN_DELAY_ACTIONS_TODO)?$this->global->MAIN_DELAY_ACTIONS_TODO:7)*24*60*60; $this->commande->client->warning_delay=(isset($this->global->MAIN_DELAY_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_ORDERS_TO_PROCESS:2)*24*60*60; - $this->commande->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS:7)*24*60*60; - $this->propal->cloture->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE)?$this->global->MAIN_DELAY_PROPALS_TO_CLOSE:0)*24*60*60; - $this->propal->facturation->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_BILL)?$this->global->MAIN_DELAY_PROPALS_TO_BILL:0)*24*60*60; + $this->commande->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS)?$this->global->MAIN_DELAY_SUPPLIER_ORDERS_TO_PROCESS:7)*24*60*60; + $this->propal->cloture->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_CLOSE)?$this->global->MAIN_DELAY_PROPALS_TO_CLOSE:0)*24*60*60; + $this->propal->facturation->warning_delay=(isset($this->global->MAIN_DELAY_PROPALS_TO_BILL)?$this->global->MAIN_DELAY_PROPALS_TO_BILL:0)*24*60*60; $this->facture->client->warning_delay=(isset($this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED)?$this->global->MAIN_DELAY_CUSTOMER_BILLS_UNPAYED:0)*24*60*60; - $this->facture->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY)?$this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY:0)*24*60*60; - $this->contrat->services->inactifs->warning_delay=(isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES)?$this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES:0)*24*60*60; - $this->contrat->services->expires->warning_delay=(isset($this->global->MAIN_DELAY_RUNNING_SERVICES)?$this->global->MAIN_DELAY_RUNNING_SERVICES:0)*24*60*60; + $this->facture->fournisseur->warning_delay=(isset($this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY)?$this->global->MAIN_DELAY_SUPPLIER_BILLS_TO_PAY:0)*24*60*60; + $this->contrat->services->inactifs->warning_delay=(isset($this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES)?$this->global->MAIN_DELAY_NOT_ACTIVATED_SERVICES:0)*24*60*60; + $this->contrat->services->expires->warning_delay=(isset($this->global->MAIN_DELAY_RUNNING_SERVICES)?$this->global->MAIN_DELAY_RUNNING_SERVICES:0)*24*60*60; $this->adherent->cotisation->warning_delay=(isset($this->global->MAIN_DELAY_MEMBERS)?$this->global->MAIN_DELAY_MEMBERS:0)*24*60*60; $this->bank->rappro->warning_delay=(isset($this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE)?$this->global->MAIN_DELAY_TRANSACTIONS_TO_CONCILIATE:0)*24*60*60; $this->bank->cheque->warning_delay=(isset($this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT)?$this->global->MAIN_DELAY_CHEQUES_TO_DEPOSIT:0)*24*60*60; @@ -387,6 +410,19 @@ class Conf // For backward compatibility if ($this->top_menu == 'eldy.php') $this->top_menu='eldy_backoffice.php'; elseif ($this->top_menu == 'rodolphe.php') $this->top_menu='eldy_backoffice.php'; + + // Object $mc + if (! defined('NOREQUIREMC') && ! empty($this->multicompany->enabled)) + { + global $mc; + + $ret = @dol_include_once('/multicompany/class/actions_multicompany.class.php'); + if ($ret) + { + $mc = new ActionsMulticompany($db); + $mc->setValues($this); + } + } } } diff --git a/htdocs/core/class/ldap.class.php b/htdocs/core/class/ldap.class.php index 3598497a3a9..8ed2d0cbbb6 100644 --- a/htdocs/core/class/ldap.class.php +++ b/htdocs/core/class/ldap.class.php @@ -1011,8 +1011,8 @@ class Ldap * Converts a little-endian hex-number to one, that 'hexdec' can convert * Required by Active Directory * - * @param string $hex - * @return string little endian + * @param string $hex Hex value + * @return string Little endian */ function littleEndian($hex) { diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php index 55cf0168bf4..3fbda6c3613 100644 --- a/htdocs/core/db/mysqli.class.php +++ b/htdocs/core/db/mysqli.class.php @@ -83,9 +83,10 @@ class DoliDBMysqli function DoliDBMysqli($type, $host, $user, $pass, $name='', $port=0) { global $conf,$langs; - - if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set; - if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation; + + // TODO error in strict mode (static property for "$forcecharset" and "$forcecollate") + //if (! empty($conf->db->character_set)) $this->forcecharset=$conf->db->character_set; + //if (! empty($conf->db->dolibarr_main_db_collation)) $this->forcecollate=$conf->db->dolibarr_main_db_collation; $this->database_user=$user; @@ -142,7 +143,7 @@ class DoliDBMysqli $clientmustbe=''; if (preg_match('/UTF-8/i',$conf->file->character_set_client)) $clientmustbe='utf8'; if (preg_match('/ISO-8859-1/i',$conf->file->character_set_client)) $clientmustbe='latin1'; - if (mysqli_client_encoding($this->db) != $clientmustbe) + if (mysqli_character_set_name($this->db) != $clientmustbe) { $this->query("SET NAMES '".$clientmustbe."'", $this->db); //$this->query("SET CHARACTER SET ". $this->forcecharset); @@ -168,7 +169,7 @@ class DoliDBMysqli $clientmustbe=''; if (preg_match('/UTF-8/i',$conf->file->character_set_client)) $clientmustbe='utf8'; if (preg_match('/ISO-8859-1/i',$conf->file->character_set_client)) $clientmustbe='latin1'; - if (mysqli_client_encoding($this->db) != $clientmustbe) + if (mysqli_character_set_name($this->db) != $clientmustbe) { $this->query("SET NAMES '".$clientmustbe."'", $this->db); //$this->query("SET CHARACTER SET ". $this->forcecharset); @@ -232,16 +233,6 @@ class DoliDBMysqli return $this->db; } - /** - * Return label of manager - * - * @return string Label - */ - function getLabel() - { - return $this->label; - } - /** * Return version of database server * diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 59d6adf5771..5bdbc3ad554 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -1101,8 +1101,8 @@ function dol_mktime($hour,$minute,$second,$month,$day,$year,$gm=false,$check=1) function dol_now($mode='gmt') { // Note that gmmktime and mktime return same value (GMT) whithout parameters - if ($mode == 'gmt') $ret=gmmktime(); // Time for now at greenwich. - else if ($mode == 'tzserver') // Time for now with PHP server timezone added + if ($mode == 'gmt') $ret=time(); // Time for now at greenwich. + else if ($mode == 'tzserver') // Time for now with PHP server timezone added { require_once(DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php'); $tzsecond=getServerTimeZoneInt(); // Contains tz+dayling saving time diff --git a/htdocs/core/lib/ws.lib.php b/htdocs/core/lib/ws.lib.php index 7145f0c2aff..babe8609f6b 100755 --- a/htdocs/core/lib/ws.lib.php +++ b/htdocs/core/lib/ws.lib.php @@ -65,6 +65,12 @@ function check_authentication($authentication,&$error,&$errorcode,&$errorlabel) $errorcode='BAD_CREDENTIALS'; $errorlabel='Bad value for login or password'; } + if (! $error && $fuser->statut == 0) + { + $error++; + $errorcode='ERROR_USER_DISABLED'; $errorlabel='This user has been locked or disabled'; + } + // Validation of login if (! $error) { diff --git a/htdocs/core/modules/DolibarrModules.class.php b/htdocs/core/modules/DolibarrModules.class.php index 5d60c70c4e6..9fcb2a89f69 100644 --- a/htdocs/core/modules/DolibarrModules.class.php +++ b/htdocs/core/modules/DolibarrModules.class.php @@ -373,7 +373,7 @@ abstract class DolibarrModules $sql.= $this->numero; $sql.= ", ".$conf->entity; $sql.= ", 1"; - $sql.= ", '".$this->db->idate(gmmktime())."'"; + $sql.= ", '".$this->db->idate(dol_now())."'"; $sql.= ", '".$this->version."'"; $sql.= ")"; diff --git a/htdocs/install/etape1.php b/htdocs/install/etape1.php index 96292a89b52..b57b0e8a1c3 100644 --- a/htdocs/install/etape1.php +++ b/htdocs/install/etape1.php @@ -236,8 +236,8 @@ if (! $error && $db->connected) { if (! empty($_POST["db_create_database"])) // If we create database, we force default value { - $defaultCharacterSet=$db->forcecharset; - $defaultCollationConnection=$db->forcecollate; + $defaultCharacterSet=getStaticMember(get_class($db),'forcecharset'); + $defaultCollationConnection=getStaticMember(get_class($db),'forcecollate'); } else // If already created, we take current value { diff --git a/htdocs/install/inc.php b/htdocs/install/inc.php index 8dd1b140d6c..3ee0e363d1a 100644 --- a/htdocs/install/inc.php +++ b/htdocs/install/inc.php @@ -43,6 +43,13 @@ require_once(ADODB_PATH.'adodb-time.inc.php'); error_reporting(E_ALL); // To have all errors without disabled E_STRICT +// IMPORTANT with strict mode E_STRICT +$conf = new stdClass(); // instantiate $conf explicitely +$conf->global = (object) array(); +$conf->file = (object) array(); +$conf->db = (object) array(); +$conf->syslog = (object) array(); + // Define $_REQUEST["logtohtml"] $_REQUEST["logtohtml"]=1; @@ -134,7 +141,7 @@ if (! defined('DONOTLOADCONF') && file_exists($conffile)) $includeconferror='ErrorBadFormatForConfFile'; } } -$conf->global->MAIN_LOGTOHTML=1; +$conf->global->MAIN_LOGTOHTML = 1; // Define prefix if (! isset($dolibarr_main_db_prefix) || ! $dolibarr_main_db_prefix) $dolibarr_main_db_prefix='llx_'; @@ -222,7 +229,7 @@ if (! defined('SYSLOG_FILE')) // To avoid warning on systems with constant alrea if (! defined('SYSLOG_FILE_NO_ERROR')) define('SYSLOG_FILE_NO_ERROR',1); // Removed magic_quotes -if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP6 +if (function_exists('get_magic_quotes_gpc')) // magic_quotes_* removed in PHP 5.4 { if (get_magic_quotes_gpc()) { diff --git a/htdocs/user/fiche.php b/htdocs/user/fiche.php index f8f6489903c..bac58616bce 100644 --- a/htdocs/user/fiche.php +++ b/htdocs/user/fiche.php @@ -1222,7 +1222,7 @@ else /* - * Barre d'actions + * Buttons actions */ print '
'; @@ -1247,13 +1247,21 @@ else // Si on a un gestionnaire de generation de mot de passe actif if ($conf->global->USER_PASSWORD_GENERATED != 'none') { - if (($user->id != $id && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && + if ($fuser->statut == 0) + { + print ''.$langs->trans("ReinitPassword").''; + } + elseif (($user->id != $id && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1))) { print ''.$langs->trans("ReinitPassword").''; } - if (($user->id != $id && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && + if ($fuser->statut == 0) + { + print ''.$langs->trans("SendNewPassword").''; + } + else if (($user->id != $id && $caneditpassword) && $fuser->login && !$fuser->ldap_sid && (empty($conf->multicompany->enabled) || ($fuser->entity == $conf->entity) || ($conf->multicompany->transverse_mode && $conf->entity == 1)) ) { if ($fuser->email) print ''.$langs->trans("SendNewPassword").''; diff --git a/quickbuild.xml b/quickbuild.xml index 09bed28b867..7378a201028 100644 --- a/quickbuild.xml +++ b/quickbuild.xml @@ -88,5 +88,5 @@ - + \ No newline at end of file diff --git a/test/phpunit/CategorieTest.php b/test/phpunit/CategorieTest.php index 24693fdac20..3cdd14463fe 100755 --- a/test/phpunit/CategorieTest.php +++ b/test/phpunit/CategorieTest.php @@ -129,15 +129,26 @@ class CategorieTest extends PHPUnit_Framework_TestCase $localobject=new Categorie($this->savdb); $localobject->initAsSpecimen(); - $result=$localobject->create($user); - $this->assertLessThan($result, 0); - print __METHOD__." result=".$result."\n"; + // We create category + $resultFirstCreate=$localobject->create($user); + print __METHOD__." resultFirstCreate=".$resultFirstCreate."\n"; + $this->assertGreaterThan(0, $resultFirstCreate); + + //Unset $this->id for good check test + unset($localobject->id); + + // We check if exist + $resultCheck=$localobject->already_exists(); + print __METHOD__." resultCheck=".$resultCheck."\n"; + $this->assertGreaterThan(0, $resultCheck); - // TODO Add test on error when creating duplicate + // We try to create same category again + $resultSecondCreate=$localobject->create($user); + print __METHOD__." result=".$resultSecondCreate."\n"; + $this->assertEquals(-4, $resultSecondCreate); - - return $result; + return $resultFirstCreate; } /** @@ -164,7 +175,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase $catid=$localobjecttmp->create($user); print __METHOD__." catid=".$catid."\n"; - $this->assertLessThanOrEqual($catid, 0); + $this->assertGreaterThan(0, $catid); // Category $localobject2=new Product($this->savdb); @@ -175,7 +186,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase $result=$localobject2->create($user); print __METHOD__." result=".$result."\n"; - $this->assertLessThanOrEqual($result, 0); + $this->assertGreaterThan(0, $result); return $id; } @@ -199,9 +210,9 @@ class CategorieTest extends PHPUnit_Framework_TestCase $localobject=new Categorie($this->savdb); $result=$localobject->fetch($id); - - $this->assertLessThan($result, 0); + print __METHOD__." id=".$id." result=".$result."\n"; + $this->assertGreaterThan(0, $result); return $localobject; } @@ -226,7 +237,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase $result=$localobject->update($user); print __METHOD__." id=".$localobject->id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); return $localobject; } @@ -287,7 +298,7 @@ class CategorieTest extends PHPUnit_Framework_TestCase $result=$localobject->delete($id); print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertLessThan($result, 0); + $this->assertGreaterThan(0, $result); return $result; } diff --git a/test/phpunit/jenkins_phpunittest.xml b/test/phpunit/jenkins_phpunittest.xml index 81aa2c40dad..8c9b93179f8 100644 --- a/test/phpunit/jenkins_phpunittest.xml +++ b/test/phpunit/jenkins_phpunittest.xml @@ -8,7 +8,7 @@ convertWarningsToExceptions="true" colors="true" processIsolation="false" - stopOnFailure="false" + stopOnFailure="true" syntaxCheck="true">