Merge branch 'develop' of ssh://git@github.com/Dolibarr/dolibarr.git into develop

This commit is contained in:
Laurent Destailleur 2012-02-10 23:24:19 +01:00
commit ad44bc5e7e
11 changed files with 228 additions and 79 deletions

View File

@ -1,6 +1,6 @@
<?php
/* Copyright (C) 2001-2005 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2004-2010 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2005-2010 Regis Houssin <regis@dolibarr.fr>
*
* This program is free software; you can redistribute it and/or modify
@ -74,6 +74,7 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can
if (isset($_POST["MAIN_MENUFRONT_SMARTPHONE"])) $listofmenuhandler[preg_replace('/((_back|_front)office)?\.php/i','',$_POST["MAIN_MENUFRONT_SMARTPHONE"])]=1;
// Initialize menu handlers
$error=0; $errmsgs=array();
foreach ($listofmenuhandler as $key => $val)
{
// Load sql init_menu_handler.sql file
@ -83,13 +84,30 @@ if (isset($_POST["action"]) && $_POST["action"] == 'update' && empty($_POST["can
if (file_exists($fullpath))
{
$result=run_sql($fullpath,1,'',1,$key);
$db->begin();
$result=run_sql($fullpath,1,'',1,$key,'none');
if ($result > 0)
{
$db->commit();
}
else
{
$error++;
$errmsgs[]='Failed to initialize menu '.$key.'.';
$db->rollback();
}
}
}
// We make a header redirect because we need to change menu NOW.
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
if (! $error)
{
$db->close();
// We make a header redirect because we need to change menu NOW.
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
}
@ -238,6 +256,9 @@ else
print '</div>';
dol_htmloutput_errors('',$errmsgs);
if (! isset($_GET["action"]) || $_GET["action"] != 'edit')
{
print '<div class="tabsAction">';
@ -245,7 +266,8 @@ if (! isset($_GET["action"]) || $_GET["action"] != 'edit')
print '</div>';
}
$db->close();
llxFooter();
$db->close();
?>

View File

@ -53,7 +53,7 @@ class DoliDBMssql
var $database_name;
//! Nom user base
var $database_user;
//! 1 si une transaction est en cours, 0 sinon
//! >=1 if a transaction is opened, 0 otherwise
var $transaction_opened;
//! Derniere requete executee
var $lastquery;
@ -242,7 +242,7 @@ class DoliDBMssql
{
if ($this->db)
{
//dol_syslog(get_class($this)."::disconnect",LOG_DEBUG);
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
return mssql_close($this->db);
}

View File

@ -53,7 +53,7 @@ class DoliDBMysql
var $database_name;
//! Nom user base
var $database_user;
//! 1 si une transaction est en cours, 0 sinon
//! >=1 if a transaction is opened, 0 otherwise
var $transaction_opened;
//! Last executed request
var $lastquery;
@ -269,7 +269,7 @@ class DoliDBMysql
{
if ($this->db)
{
//dol_syslog(get_class($this)."::disconnect",LOG_DEBUG);
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
return mysql_close($this->db);
}

View File

@ -53,7 +53,7 @@ class DoliDBMysqli
var $database_name;
//! Nom user base
var $database_user;
//! 1 si une transaction est en cours, 0 sinon
//! >=1 if a transaction is opened, 0 otherwise
var $transaction_opened;
//! Last executed request
var $lastquery;
@ -273,7 +273,7 @@ class DoliDBMysqli
{
if ($this->db)
{
//dol_syslog(get_class($this)."::disconnect",LOG_DEBUG);
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
return mysqli_close($this->db);
}

View File

@ -51,7 +51,8 @@ class DoliDBPgsql
var $database_selected; // 1 si base selectionne, 0 sinon
var $database_name; //! Nom base selectionnee
var $database_user; //! Nom user base
var $transaction_opened; // 1 si une transaction est en cours, 0 sinon
//! >=1 if a transaction is opened, 0 otherwise
var $transaction_opened;
var $lastquery;
var $lastqueryerror; // Ajout d'une variable en cas d'erreur
@ -439,7 +440,7 @@ class DoliDBPgsql
{
if ($this->db)
{
//dol_syslog(get_class($this)."::disconnect",LOG_DEBUG);
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
return pg_close($this->db);
}

View File

@ -53,7 +53,7 @@ class DoliDBSqlite
var $database_name;
//! Nom user base
var $database_user;
//! 1 si une transaction est en cours, 0 sinon
//! >=1 if a transaction is opened, 0 otherwise
var $transaction_opened;
//! Last executed request
var $lastquery;
@ -393,7 +393,7 @@ class DoliDBSqlite
{
if ($this->db)
{
//dol_syslog(get_class($this)."::disconnect",LOG_DEBUG);
if ($this->transaction_opened > 0) dol_syslog(get_class($this)."::close Closing a connection with an opened transaction depth=".$this->transaction_opened,LOG_ERR);
$this->connected=0;
$this->db=null; // Clean this->db
return true;

View File

@ -108,13 +108,14 @@ function versiondolibarrarray()
* @param int $entity Entity targeted for multicompany module
* @param int $usesavepoint 1=Run a savepoint before each request and a rollback to savepoint if error (this allow to have some request with errors inside global transactions).
* @param string $handler Handler targeted for menu
* @param string $okerror Family of errors we accept ('default', 'none')
* @return int <=0 if KO, >0 if OK
*/
function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='')
function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='',$okerror='default')
{
global $db, $conf, $langs, $user;
dol_syslog("Admin.lib::run_sql run sql file ".$sqlfile." silent=".$silent." entity=".$entity." usesavepoint=".$usesavepoint." handler=".$handler, LOG_DEBUG);
dol_syslog("Admin.lib::run_sql run sql file ".$sqlfile." silent=".$silent." entity=".$entity." usesavepoint=".$usesavepoint." handler=".$handler." okerror=".$okerror, LOG_DEBUG);
$ok=0;
$error=0;
@ -317,24 +318,25 @@ function run_sql($sqlfile,$silent=1,$entity='',$usesavepoint=1,$handler='')
$errno=$db->errno();
if (! $silent) print '<!-- Result = '.$errno.' -->'."\n";
$okerror=array( 'DB_ERROR_TABLE_ALREADY_EXISTS',
'DB_ERROR_COLUMN_ALREADY_EXISTS',
'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS', // PgSql use same code for table and key already exist
'DB_ERROR_RECORD_ALREADY_EXISTS',
'DB_ERROR_NOSUCHTABLE',
'DB_ERROR_NOSUCHFIELD',
'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
'DB_ERROR_NO_INDEX_TO_DROP',
'DB_ERROR_CANNOT_CREATE', // Qd contrainte deja existante
'DB_ERROR_CANT_DROP_PRIMARY_KEY',
'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS'
// Define list of errors we accept (array $okerrors)
$okerrors=array( // By default
'DB_ERROR_TABLE_ALREADY_EXISTS',
'DB_ERROR_COLUMN_ALREADY_EXISTS',
'DB_ERROR_KEY_NAME_ALREADY_EXISTS',
'DB_ERROR_TABLE_OR_KEY_ALREADY_EXISTS', // PgSql use same code for table and key already exist
'DB_ERROR_RECORD_ALREADY_EXISTS',
'DB_ERROR_NOSUCHTABLE',
'DB_ERROR_NOSUCHFIELD',
'DB_ERROR_NO_FOREIGN_KEY_TO_DROP',
'DB_ERROR_NO_INDEX_TO_DROP',
'DB_ERROR_CANNOT_CREATE', // Qd contrainte deja existante
'DB_ERROR_CANT_DROP_PRIMARY_KEY',
'DB_ERROR_PRIMARY_KEY_ALREADY_EXISTS'
);
if (in_array($errno,$okerror))
{
//if (! $silent) print $langs->trans("OK");
}
else
if ($okerror == 'none') $okerrors=array();
// Is it an error we accept
if (! in_array($errno,$okerrors))
{
if (! $silent) print '<tr><td valign="top" colspan="2">';
if (! $silent) print '<div class="error">'.$langs->trans("Error")." ".$db->errno().": ".$newsql."<br>".$db->error()."</div></td>";

View File

@ -1,7 +1,7 @@
<?php
/* Copyright (C) 2000-2007 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2003 Jean-Louis Bergamo <jlb@j1b.org>
* Copyright (C) 2004-2011 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004-2012 Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2004 Christophe Combelles <ccomb@free.fr>
@ -229,9 +229,9 @@ function getEntity($element=false, $shared=false)
function dol_shutdown()
{
global $conf,$user,$langs,$db;
$disconnectdone=false;
if (is_object($db) && ! empty($db->connected)) $disconnectdone=$db->close();
dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].($disconnectdone?' (Warn: db disconnection forced)':''), ($disconnectdone?LOG_WARNING:LOG_DEBUG));
$disconnectdone=false; $depth=0;
if (is_object($db) && ! empty($db->connected)) { $depth=$db->transaction_opened; $disconnectdone=$db->close(); }
dol_syslog("--- End access to ".$_SERVER["PHP_SELF"].($disconnectdone?' (Warn: db disconnection forced, transaction depth was '.$depth.')':''), ($disconnectdone?LOG_WARNING:LOG_DEBUG));
}

View File

@ -3,7 +3,6 @@
-- This file is loaded when a menu handler base is activated (auguria, etc..)
--
-- V4.1 delete from llx_menu_const where fk_menu in (select rowid from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__);
delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__;
--

View File

@ -3,7 +3,6 @@
-- This file is loaded when a menu handler base is activated (auguria, etc..)
--
-- V4.1 delete from llx_menu_const where fk_menu in (select rowid from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__);
delete from llx_menu where menu_handler=__HANDLER__ and entity=__ENTITY__;
--

View File

@ -706,21 +706,14 @@ function migrate_paiements_orphelins_2($db,$langs,$conf)
print '</td></tr>';
}
function migrate_paiements_orphelins_3($db,$langs,$conf)
{
/*
select p.rowid from llx_paiement as p left join llx_paiement_facture as pf on pf.fk_paiement=p.rowid WHERE pf.rowid IS NULL AND (p.fk_facture = 0 OR p.fk_facture IS NULL)
Poru chaque rep, test si
select count(*) from llx_bank where rowid = obj->fk_bank
select count(*) from llx_bank_url where url_id = 128 and type='payment'
Si partout 0, on efface ligne de llx_paiement
*/
}
/*
/**
* Mise a jour des contrats (gestion du contrat + detail de contrat)
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_contracts_det($db,$langs,$conf)
{
@ -812,6 +805,13 @@ function migrate_contracts_det($db,$langs,$conf)
print '</td></tr>';
}
/**
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_links_transfert($db,$langs,$conf)
{
print '<tr><td colspan="4">';
@ -888,8 +888,13 @@ function migrate_links_transfert($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Mise a jour des date de contrats non renseignees
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_contracts_date1($db,$langs,$conf)
{
@ -983,8 +988,13 @@ function migrate_contracts_date2($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Mise a jour des dates de creation de contrat
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_contracts_date3($db,$langs,$conf)
{
@ -1005,8 +1015,13 @@ function migrate_contracts_date3($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Reouverture des contrats qui ont au moins une ligne non fermee
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_contracts_open($db,$langs,$conf)
{
@ -1176,8 +1191,13 @@ function migrate_paiementfourn_facturefourn($db,$langs,$conf)
}
}
/*
/**
* Mise a jour des totaux lignes de facture
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_price_facture($db,$langs,$conf)
{
@ -1287,8 +1307,13 @@ function migrate_price_facture($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Mise a jour des totaux lignes de propal
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_price_propal($db,$langs,$conf)
{
@ -1387,8 +1412,13 @@ function migrate_price_propal($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Mise a jour des totaux lignes de propal
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_price_contrat($db,$langs,$conf)
{
@ -1488,8 +1518,13 @@ function migrate_price_contrat($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Mise a jour des totaux lignes de commande
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_price_commande($db,$langs,$conf)
{
@ -1597,8 +1632,13 @@ function migrate_price_commande($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Mise a jour des totaux lignes de commande fournisseur
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_price_commande_fournisseur($db,$langs,$conf)
{
@ -1706,8 +1746,13 @@ function migrate_price_commande_fournisseur($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Mise a jour des modeles selectionnes
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_modeles($db,$langs,$conf)
{
@ -1759,8 +1804,13 @@ function migrate_modeles($db,$langs,$conf)
}
/*
/**
* Correspondance des expeditions et des commandes clients dans la table llx_co_exp
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_commande_expedition($db,$langs,$conf)
{
@ -1831,8 +1881,13 @@ function migrate_commande_expedition($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Correspondance des livraisons et des commandes clients dans la table llx_co_liv
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_commande_livraison($db,$langs,$conf)
{
@ -1919,8 +1974,13 @@ function migrate_commande_livraison($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migration des details commandes dans les details livraisons
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_detail_livraison($db,$langs,$conf)
{
@ -2036,8 +2096,13 @@ function migrate_detail_livraison($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migration du champ stock dans produits
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_stocks($db,$langs,$conf)
{
@ -2105,8 +2170,14 @@ function migrate_stocks($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migration of menus (use only 1 table instead of 3)
* 2.6 -> 2.7
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_menus($db,$langs,$conf)
{
@ -2181,9 +2252,14 @@ function migrate_menus($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migration du champ fk_adresse_livraison dans expedition
* 2.6 -> 2.7
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_commande_deliveryaddress($db,$langs,$conf)
{
@ -2260,9 +2336,14 @@ function migrate_commande_deliveryaddress($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migration du champ fk_remise_except dans llx_facturedet doit correspondre a
* lien dans llx_societe_remise_except vers llx_facturedet
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_restore_missing_links($db,$langs,$conf)
{
@ -2414,8 +2495,13 @@ function migrate_restore_missing_links($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migration du champ fk_user_resp de llx_projet vers llx_element_contact
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_project_user_resp($db,$langs,$conf)
{
@ -2506,8 +2592,13 @@ function migrate_project_user_resp($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migration de la table llx_projet_task_actors vers llx_element_contact
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_project_task_actors($db,$langs,$conf)
{
@ -2593,8 +2684,13 @@ function migrate_project_task_actors($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migration des tables de relation
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_relationship_tables($db,$langs,$conf,$table,$fk_source,$sourcetype,$fk_target,$targettype)
{
@ -2684,8 +2780,13 @@ function migrate_relationship_tables($db,$langs,$conf,$table,$fk_source,$sourcet
print '</td></tr>';
}
/*
/**
* Migrate duration in seconds
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_project_task_time($db,$langs,$conf)
{
@ -2800,8 +2901,13 @@ function migrate_project_task_time($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migrate order ref_customer and date_delivery fields to llx_expedition
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_customerorder_shipping($db,$langs,$conf)
{
@ -2896,8 +3002,13 @@ function migrate_customerorder_shipping($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migrate link stored into fk_expedition into llx_element_element
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_shipping_delivery($db,$langs,$conf)
{
@ -3002,9 +3113,14 @@ function migrate_shipping_delivery($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* We try to complete field ref_customer and date_delivery that are empty into llx_livraison.
* We set them with value from llx_expedition.
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_shipping_delivery2($db,$langs,$conf)
{
@ -3082,8 +3198,13 @@ function migrate_shipping_delivery2($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migrate link stored into fk_xxxx into fk_element and elementtype
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_actioncomm_element($db,$langs,$conf)
{
@ -3143,8 +3264,13 @@ function migrate_actioncomm_element($db,$langs,$conf)
print '</td></tr>';
}
/*
/**
* Migrate link stored into fk_mode_reglement
*
* @param DoliDB $db Database handler
* @param Translate $langs Object langs
* @param Conf $conf Object conf
* @return void
*/
function migrate_mode_reglement($db,$langs,$conf)
{