diff --git a/build/debian/apache/dolibarr.conf b/build/debian/apache/dolibarr.conf
index 95eaae21190..bdbb6e1b4c3 100644
--- a/build/debian/apache/dolibarr.conf
+++ b/build/debian/apache/dolibarr.conf
@@ -15,7 +15,7 @@ Alias /dolibarr /usr/share/dolibarr/htdocs
# Require all granted
#
#
-# Order allow, deny
+# Order allow,deny
# Allow from all
#
#
@@ -27,7 +27,7 @@ Alias /dolibarr /usr/share/dolibarr/htdocs
Require all granted
- Order allow, deny
+ Order allow,deny
Allow from all
diff --git a/build/makepack-dolibarr.pl b/build/makepack-dolibarr.pl
index 2b31d1f26a6..99ec7b3543a 100755
--- a/build/makepack-dolibarr.pl
+++ b/build/makepack-dolibarr.pl
@@ -467,6 +467,7 @@ if ($nboftargetok) {
# Removed known external modules to avoid any error when packaging from env where external modules are tested
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/custom/*`; # For custom we want to keep dir
+ $ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/allscreens*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/ancotec*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/cabinetmed*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/calling*`;
@@ -481,8 +482,8 @@ if ($nboftargetok) {
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/pos*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/teclib*`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/timesheet*`;
- # Removed other test files
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/oblyon*`;
+ # Removed other test files
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/themes/eldy/*.new`;
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/api/explorer`; # This is a dev tool
$ret=`rm -fr $BUILDROOT/$PROJECT/htdocs/public/test`;
diff --git a/htdocs/.gitignore b/htdocs/.gitignore
index 0b4d7b82790..b0b84be129e 100644
--- a/htdocs/.gitignore
+++ b/htdocs/.gitignore
@@ -1,7 +1,11 @@
+/allscreens*
/ancot*
/bootstrap*
+/dolimed*
+/ecommerce*
/extensions*
/google*
+/lead
/multicompany*
/ndf*
/numberingpack*
@@ -11,5 +15,3 @@
/teclib*
/test.php
/ultimatepdf*
-/lead
-/dolimed*
diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 20e05482685..f3260070fd7 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -343,7 +343,7 @@ else // Show
print ($conf->global->MAIN_LANG_DEFAULT=='auto'?$langs->trans("AutoDetectLang"):$langs->trans("Language_".$conf->global->MAIN_LANG_DEFAULT));
print '';
print '
';
- if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation",$conf->global->MAIN_LANG_DEFAULT),1);
+ if ($user->admin && $conf->global->MAIN_LANG_DEFAULT!='auto') print info_admin($langs->trans("SubmitTranslation".($conf->global->MAIN_LANG_DEFAULT=='en_US'?'ENUS':''),$conf->global->MAIN_LANG_DEFAULT),1);
print ' | ';
print "";
diff --git a/htdocs/admin/system/perf.php b/htdocs/admin/system/perf.php
index b53c666f2af..a5865b29eac 100644
--- a/htdocs/admin/system/perf.php
+++ b/htdocs/admin/system/perf.php
@@ -108,6 +108,14 @@ if (! $foundcache && $test)
$foundcache++;
print img_picto('','tick.png').' '.$langs->trans("EAcceleratorInstalled");
}
+$test=function_exists('opcache_get_status');
+if (! $foundcache && $test)
+{
+ $foundcache++;
+ print img_picto('','tick.png').' '.$langs->trans("ZendOPCacheInstalled"); // Should be by defautl starting with PHP 5.5
+ //$tmp=opcache_get_status();
+ //var_dump($tmp);
+}
$test=function_exists('apc_cache_info');
if (! $foundcache && $test)
{
diff --git a/htdocs/api/class/api_access.class.php b/htdocs/api/class/api_access.class.php
index 027c9dcf5f4..3a130fe35d2 100644
--- a/htdocs/api/class/api_access.class.php
+++ b/htdocs/api/class/api_access.class.php
@@ -60,7 +60,8 @@ class DolibarrApiAccess implements iAuthenticate
$userClass = Defaults::$userIdentifierClass;
- if (isset($_GET['api_key'])) {
+ if (isset($_GET['api_key']))
+ {
$sql = "SELECT u.login, u.datec, u.api_key, ";
$sql.= " u.tms as date_modification, u.entity";
$sql.= " FROM ".MAIN_DB_PREFIX."user as u";
@@ -100,7 +101,9 @@ class DolibarrApiAccess implements iAuthenticate
}
else
{
- return false;
+ throw new RestException(401, "Failed to login to API. No parameter 'api_key' provided");
+ //dol_syslog("Failed to login to API. No parameter key provided", LOG_DEBUG);
+ //return false;
}
$userClass::setCacheIdentifier(static::$role);
diff --git a/htdocs/categories/categorie.php b/htdocs/categories/categorie.php
index 083edbf6b7e..43803d045bb 100644
--- a/htdocs/categories/categorie.php
+++ b/htdocs/categories/categorie.php
@@ -419,7 +419,7 @@ else if ($id || $ref)
// Ref
print '| '.$langs->trans("Ref").' | ';
print '';
- print $form->showrefnav($member,'id');
+ print $form->showrefnav($member,'id','','1','rowid','ref','','&type=3');
print ' |
';
// Login
diff --git a/htdocs/categories/edit.php b/htdocs/categories/edit.php
index 83d3547d1b8..28a97d3d89d 100644
--- a/htdocs/categories/edit.php
+++ b/htdocs/categories/edit.php
@@ -86,21 +86,15 @@ if ($action == 'update' && $user->rights->categorie->creer)
if (empty($categorie->label))
{
$error++;
- $action = 'create';
+ $action = 'edit';
setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Label")), 'errors');
}
- if (empty($categorie->description))
- {
- $error++;
- $action = 'create';
- setEventMessage($langs->trans("ErrorFieldRequired",$langs->transnoentities("Description")), 'errors');
- }
if (! $error && empty($categorie->error))
{
$ret = $extrafields->setOptionalsFromPost($extralabels,$categorie);
if ($ret < 0) $error++;
- if ($categorie->update($user) > 0)
+ if (! $error && $categorie->update($user) > 0)
{
header('Location: '.DOL_URL_ROOT.'/categories/viewcat.php?id='.$categorie->id.'&type='.$type);
exit;
@@ -151,7 +145,7 @@ print '';
// Description
print '';
-print '| '.$langs->trans("Description").' | ';
+print ''.$langs->trans("Description").' | ';
print '';
require_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php';
$doleditor=new DolEditor('description',$object->description,'',200,'dolibarr_notes','',false,true,$conf->fckeditor->enabled,ROWS_6,50);
diff --git a/htdocs/comm/card.php b/htdocs/comm/card.php
index d6ff35f8af5..a9164676716 100644
--- a/htdocs/comm/card.php
+++ b/htdocs/comm/card.php
@@ -965,25 +965,25 @@ if ($id > 0)
print '';
- if (! empty($conf->propal->enabled) && $user->rights->propal->creer)
+ if (! empty($conf->propal->enabled) && $user->rights->propal->creer && $object->status==1)
{
$langs->load("propal");
print ' ';
}
- if (! empty($conf->commande->enabled) && $user->rights->commande->creer)
+ if (! empty($conf->commande->enabled) && $user->rights->commande->creer && $object->status==1)
{
$langs->load("orders");
print ' ';
}
- if ($user->rights->contrat->creer)
+ if ($user->rights->contrat->creer && $object->status==1)
{
$langs->load("contracts");
print ' ';
}
- if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer)
+ if (! empty($conf->ficheinter->enabled) && $user->rights->ficheinter->creer && $object->status==1)
{
$langs->load("fichinter");
print ' ';
@@ -992,7 +992,7 @@ if ($id > 0)
// Add invoice
if ($user->societe_id == 0)
{
- if (! empty($conf->deplacement->enabled))
+ if (! empty($conf->deplacement->enabled) && $object->status==1)
{
$langs->load("trips");
print ' ';
@@ -1000,7 +1000,7 @@ if ($id > 0)
if (! empty($conf->facture->enabled))
{
- if ($user->rights->facture->creer)
+ if ($user->rights->facture->creer && $object->status==1)
{
$langs->load("bills");
$langs->load("orders");
diff --git a/htdocs/comm/propal.php b/htdocs/comm/propal.php
index 3549b122baa..24b7ab16d69 100644
--- a/htdocs/comm/propal.php
+++ b/htdocs/comm/propal.php
@@ -195,22 +195,18 @@ if (empty($reshook))
{
if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
{
- // Define output language
- if (empty($conf->global->MAIN_DISABLE_PDF_AUTOUPDATE))
- {
- $outputlangs = $langs;
- $newlang = '';
- if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
- if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
- if (! empty($newlang)) {
- $outputlangs = new Translate("", $conf);
- $outputlangs->setDefaultLang($newlang);
- }
- $model=$object->modelpdf;
- $ret = $object->fetch($id); // Reload to get new records
-
- $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
+ $outputlangs = $langs;
+ $newlang = '';
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang) && GETPOST('lang_id')) $newlang = GETPOST('lang_id','alpha');
+ if ($conf->global->MAIN_MULTILANGS && empty($newlang)) $newlang = $object->thirdparty->default_lang;
+ if (! empty($newlang)) {
+ $outputlangs = new Translate("", $conf);
+ $outputlangs->setDefaultLang($newlang);
}
+ $model=$object->modelpdf;
+ $ret = $object->fetch($id); // Reload to get new records
+
+ $object->generateDocument($model, $outputlangs, $hidedetails, $hidedesc, $hideref);
}
} else {
$langs->load("errors");
@@ -1290,7 +1286,7 @@ if ($action == 'create')
print ' | ';
} else {
print '';
- print $form->select_company('', 'socid', 's.client = 1 OR s.client = 2 OR s.client = 3', 1);
+ print $form->select_company('', 'socid', '(s.client = 1 OR s.client = 2 OR s.client = 3) AND status=1', 1);
print ' | ';
}
print '
' . "\n";
@@ -1414,11 +1410,7 @@ if ($action == 'create')
print '';
print '| ' . $langs->trans('NotePublic') . ' | ';
print '';
- $note_public = '';
- if (is_object($objectsrc)) // Take value from source object
- {
- $note_public = $objectsrc->note_public;
- }
+ $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc)?$objectsrc->note_public:null));
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
@@ -1428,11 +1420,7 @@ if ($action == 'create')
print ' |
';
print '| ' . $langs->trans('NotePrivate') . ' | ';
print '';
- $note_private = '';
- if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) // Take value from source object
- {
- $note_private = $objectsrc->note_private;
- }
+ $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null));
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// print '
diff --git a/htdocs/commande/card.php b/htdocs/commande/card.php
index 1d418ac295c..83b86ee5525 100644
--- a/htdocs/commande/card.php
+++ b/htdocs/commande/card.php
@@ -1292,8 +1292,8 @@ if ($action == 'create' && $user->rights->commande->creer)
$datedelivery = (! empty($objectsrc->date_livraison) ? $objectsrc->date_livraison : '');
- $note_private = (! empty($objectsrc->note_private) ? $objectsrc->note_private : (! empty($objectsrc->note_private) ? $objectsrc->note_private : ''));
- $note_public = (! empty($objectsrc->note_public) ? $objectsrc->note_public : '');
+ $note_private = $object->getDefaultCreateValueFor('note_private', (! empty($objectsrc->note_private) ? $objectsrc->note_private : null));
+ $note_public = $object->getDefaultCreateValueFor('note_public', (! empty($objectsrc->note_public) ? $objectsrc->note_public : null));
// Object source contacts list
$srccontactslist = $objectsrc->liste_contact(- 1, 'external', 1);
@@ -1311,6 +1311,9 @@ if ($action == 'create' && $user->rights->commande->creer)
$remise_absolue = 0;
$dateorder = empty($conf->global->MAIN_AUTOFILL_DATE_ORDER)?-1:'';
$projectid = 0;
+
+ $note_private = $object->getDefaultCreateValueFor('note_private');
+ $note_public = $object->getDefaultCreateValueFor('note_public');
}
$absolute_discount=$soc->getAvailableDiscounts();
diff --git a/htdocs/compta/facture.php b/htdocs/compta/facture.php
index 5f324712ab7..6b0af5f7043 100644
--- a/htdocs/compta/facture.php
+++ b/htdocs/compta/facture.php
@@ -2285,11 +2285,7 @@ if ($action == 'create')
print ' |
';
print '| ' . $langs->trans('NotePublic') . ' | ';
print '';
- $note_public = '';
- if (is_object($objectsrc)) // Take value from source object
- {
- $note_public = $objectsrc->note_public;
- }
+ $note_public = $object->getDefaultCreateValueFor('note_public', (is_object($objectsrc)?$objectsrc->note_public:null));
$doleditor = new DolEditor('note_public', $note_public, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
@@ -2299,11 +2295,7 @@ if ($action == 'create')
print ' |
';
print '| ' . $langs->trans('NotePrivate') . ' | ';
print '';
- $note_private = '';
- if (! empty($origin) && ! empty($originid) && is_object($objectsrc)) // Take value from source object
- {
- $note_private = $objectsrc->note_private;
- }
+ $note_private = $object->getDefaultCreateValueFor('note_private', ((! empty($origin) && ! empty($originid) && is_object($objectsrc))?$objectsrc->note_private:null));
$doleditor = new DolEditor('note_private', $note_private, '', 80, 'dolibarr_notes', 'In', 0, false, true, ROWS_3, '90%');
print $doleditor->Create(1);
// print '
diff --git a/htdocs/core/boxes/box_contacts.php b/htdocs/core/boxes/box_contacts.php
index dde2a559cd3..18a09af6ace 100644
--- a/htdocs/core/boxes/box_contacts.php
+++ b/htdocs/core/boxes/box_contacts.php
@@ -82,7 +82,8 @@ class box_contacts extends ModeleBoxes
$societestatic=new Societe($db);
$line = 0;
- while ($line < $num) {
+ while ($line < $num)
+ {
$objp = $db->fetch_object($result);
$datec=$db->jdate($objp->datec);
$datem=$db->jdate($objp->tms);
@@ -92,7 +93,6 @@ class box_contacts extends ModeleBoxes
$contactstatic->firstname=$objp->firstname;
$contactstatic->civility_id=$objp->civility_id;
$contactstatic->statut=$objp->status;
-
$societestatic->id = $objp->fk_soc;
$societestatic->code_client = $objp->code_client;
$societestatic->name = $objp->socname;
diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php
index 135635ed94d..2a7834473dc 100644
--- a/htdocs/core/class/commonobject.class.php
+++ b/htdocs/core/class/commonobject.class.php
@@ -389,7 +389,7 @@ abstract class CommonObject
*
* @param Translate $langs Language object for translation of civility
* @param int $option 0=No option, 1=Add civility
- * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname
+ * @param int $nameorder -1=Auto, 0=Lastname+Firstname, 1=Firstname+Lastname, 2=Firstname
* @param int $maxlen Maximum length
* @return string String with full name
*/
@@ -3549,7 +3549,47 @@ abstract class CommonObject
/* Functions common to commonobject and commonobjectline */
+ /* For default values */
+ /**
+ * Return the default value to use for a field when showing the create form of object.
+ * Return values in this order:
+ * 1) If parameter is available into POST, we return it first.
+ * 2) If not but an alternate value was provided as parameter of function, we return it.
+ * 3) If not but a constant $conf->global->OBJECTELEMENT_FIELDNAME is set, we return it (It is better to use the dedicated table).
+ * 4) Return value found into database (TODO No yet implemented)
+ *
+ * @param string $fieldname Name of field
+ * @param string $alternatevalue Alternate value to use
+ * @return string Default value
+ **/
+ function getDefaultCreateValueFor($fieldname, $alternatevalue=null)
+ {
+ global $conf, $_POST;
+
+ // If param is has been posted with use this value first.
+ if (isset($_POST[$fieldname])) return GETPOST($fieldname, 2);
+
+ if (isset($alternatevalue)) return $alternatevalue;
+
+ $newelement=$this->element;
+ if ($newelement == 'facture') $newelement='invoice';
+ if ($newelement == 'commande') $newelement='order';
+ if (empty($newelement))
+ {
+ dol_syslog("Ask a default value using common method getDefaultCreateValueForField on an object with no property ->element defined. Return empty string.", LOG_WARNING);
+ return '';
+ }
+
+ $keyforfieldname=strtoupper($newelement.'_DEFAULT_'.$fieldname);
+ //var_dump($keyforfieldname);
+ if (isset($conf->global->$keyforfieldname)) return $conf->global->$keyforfieldname;
+
+ // TODO Ad here a scan into table llx_overwrite_default with a filter on $this->element and $fieldname
+
+ }
+
+
/* For triggers */
diff --git a/htdocs/core/db/mysqli.class.php b/htdocs/core/db/mysqli.class.php
index 4033dc01117..068cd410326 100644
--- a/htdocs/core/db/mysqli.class.php
+++ b/htdocs/core/db/mysqli.class.php
@@ -31,6 +31,8 @@ require_once DOL_DOCUMENT_ROOT .'/core/db/DoliDB.class.php';
*/
class DoliDBMysqli extends DoliDB
{
+ /** @var mysqli Database object */
+ public $db;
//! Database type
public $type='mysqli';
//! Database label
@@ -81,29 +83,26 @@ class DoliDBMysqli extends DoliDB
$this->connected = false;
$this->ok = false;
$this->error=$langs->trans("ErrorWrongHostParameter");
- dol_syslog(get_class($this)."::DoliDBMysqli : Erreur Connect, wrong host parameters",LOG_ERR);
+ dol_syslog(get_class($this)."::DoliDBMysqli : Connect error, wrong host parameters",LOG_ERR);
return $this->ok;
}
- // Essai connexion serveur
- // We do not try to connect to database, only to server. Connect to database is done later in constrcutor
- $this->db = $this->connect($host, $user, $pass, '', $port);
+ // Try server connection
+ // We do not try to connect to database, only to server. Connect to database is done later in constrcutor
+ $this->db = $this->connect($host, $user, $pass, '', $port);
- if ($this->db)
- {
- $this->connected = true;
- $this->ok = true;
- }
- else
- {
- // host, login ou password incorrect
- $this->connected = false;
- $this->ok = false;
- $this->error=mysqli_connect_error();
- dol_syslog(get_class($this)."::DoliDBMysqli : Erreur Connect mysqli_connect_error=".$this->error,LOG_ERR);
- }
+ if ($this->db->connect_errno) {
+ $this->connected = false;
+ $this->ok = false;
+ $this->error = $this->db->connect_error;
+ dol_syslog(get_class($this) . "::DoliDBMysqli Connect error: " . $this->error, LOG_ERR);
+ return $this->ok;
+ } else {
+ $this->connected = true;
+ $this->ok = true;
+ }
- // Si connexion serveur ok et si connexion base demandee, on essaie connexion base
+ // If server connection is ok, we try to connect to the database
if ($this->connected && $name)
{
if ($this->select_db($name))
@@ -116,7 +115,7 @@ class DoliDBMysqli extends DoliDB
$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_character_set_name($this->db) != $clientmustbe)
+ if ($this->db->character_set_name() != $clientmustbe)
{
$this->query("SET NAMES '".$clientmustbe."'", $this->db);
//$this->query("SET CHARACTER SET ". $this->forcecharset);
@@ -128,7 +127,7 @@ class DoliDBMysqli extends DoliDB
$this->database_name = '';
$this->ok = false;
$this->error=$this->error();
- dol_syslog(get_class($this)."::DoliDBMysqli : Erreur Select_db ".$this->error,LOG_ERR);
+ dol_syslog(get_class($this)."::DoliDBMysqli : Select_db error ".$this->error,LOG_ERR);
}
}
else
@@ -142,7 +141,7 @@ class DoliDBMysqli extends DoliDB
$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_character_set_name($this->db) != $clientmustbe)
+ if ($this->db->character_set_name() != $clientmustbe)
{
$this->query("SET NAMES '".$clientmustbe."'", $this->db);
//$this->query("SET CHARACTER SET ". $this->forcecharset);
@@ -175,36 +174,27 @@ class DoliDBMysqli extends DoliDB
function select_db($database)
{
dol_syslog(get_class($this)."::select_db database=".$database, LOG_DEBUG);
- return mysqli_select_db($this->db,$database);
+ return $this->db->select_db($database);
}
- /**
- * Connexion to server
+ /**
+ * Connect to server
*
- * @param string $host database server host
- * @param string $login login
- * @param string $passwd password
- * @param string $name name of database (not used for mysql, used for pgsql)
- * @param integer $port Port of database server
- * @return mysqli Database access handler
- * @see close
- */
- function connect($host, $login, $passwd, $name, $port=0)
- {
- dol_syslog(get_class($this)."::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name",LOG_DEBUG);
+ * @param string $host database server host
+ * @param string $login login
+ * @param string $passwd password
+ * @param string $name name of database (not used for mysql, used for pgsql)
+ * @param integer $port Port of database server
+ * @return mysqli Database access object
+ * @see close
+ */
+ function connect($host, $login, $passwd, $name, $port = 0)
+ {
+ dol_syslog(get_class($this) . "::connect host=$host, port=$port, login=$login, passwd=--hidden--, name=$name", LOG_DEBUG);
- $newhost=$host;
- $newport=$port;
-
- // With mysqli, port must be in connect parameters
- if (! $newport) $newport=3306;
-
- $this->db = @mysqli_connect($newhost, $login, $passwd, $name, $newport);
-
- //print "Resultat fonction connect: ".$this->db;
- return $this->db;
- }
+ return new mysqli($host, $login, $passwd, $name, $port);
+ }
/**
* Return version of database server
@@ -213,7 +203,7 @@ class DoliDBMysqli extends DoliDB
*/
function getVersion()
{
- return mysqli_get_server_info($this->db);
+ return $this->db->get_server_info();
}
/**
@@ -221,10 +211,10 @@ class DoliDBMysqli extends DoliDB
*
* @return string Version string
*/
- function getDriverInfo()
- {
- return mysqli_get_client_info($this->db);
- }
+ function getDriverInfo()
+ {
+ return $this->db->get_client_info();
+ }
/**
@@ -239,7 +229,7 @@ class DoliDBMysqli extends DoliDB
{
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=false;
- return mysqli_close($this->db);
+ return $this->db->close();
}
return false;
}
@@ -264,11 +254,11 @@ class DoliDBMysqli extends DoliDB
if (! $this->database_name)
{
// Ordre SQL ne necessitant pas de connexion a une base (exemple: CREATE DATABASE)
- $ret = mysqli_query($this->db,$query);
+ $ret = $this->db->query($query);
}
else
{
- $ret = mysqli_query($this->db,$query);
+ $ret = $this->db->query($query);
}
if (! preg_match("/^COMMIT/i",$query) && ! preg_match("/^ROLLBACK/i",$query))
@@ -300,7 +290,7 @@ class DoliDBMysqli extends DoliDB
{
// Si le resultset n'est pas fourni, on prend le dernier utilise sur cette connexion
if (! is_object($resultset)) { $resultset=$this->_results; }
- return mysqli_fetch_object($resultset);
+ return $resultset->fetch_object();
}
@@ -314,7 +304,7 @@ class DoliDBMysqli extends DoliDB
{
// If resultset not provided, we take the last used by connexion
if (! is_object($resultset)) { $resultset=$this->_results; }
- return mysqli_fetch_array($resultset);
+ return $resultset->fetch_array();
}
/**
@@ -329,7 +319,7 @@ class DoliDBMysqli extends DoliDB
if (! is_bool($resultset))
{
if (! is_object($resultset)) { $resultset=$this->_results; }
- return mysqli_fetch_row($resultset);
+ return $resultset->fetch_row();
}
else
{
@@ -349,7 +339,7 @@ class DoliDBMysqli extends DoliDB
{
// If resultset not provided, we take the last used by connexion
if (! is_object($resultset)) { $resultset=$this->_results; }
- return mysqli_num_rows($resultset);
+ return $resultset->num_rows;
}
/**
@@ -365,7 +355,7 @@ class DoliDBMysqli extends DoliDB
if (! is_object($resultset)) { $resultset=$this->_results; }
// mysql necessite un link de base pour cette fonction contrairement
// a pqsql qui prend un resultset
- return mysqli_affected_rows($this->db);
+ return $this->db->affected_rows;
}
@@ -380,7 +370,7 @@ class DoliDBMysqli extends DoliDB
// If resultset not provided, we take the last used by connexion
if (! is_object($resultset)) { $resultset=$this->_results; }
// Si resultset en est un, on libere la memoire
- if (is_object($resultset)) mysqli_free_result($resultset);
+ if (is_object($resultset)) $resultset->free_result();
}
/**
@@ -436,10 +426,10 @@ class DoliDBMysqli extends DoliDB
1451 => 'DB_ERROR_CHILD_EXISTS'
);
- if (isset($errorcode_map[mysqli_errno($this->db)])) {
- return $errorcode_map[mysqli_errno($this->db)];
+ if (isset($errorcode_map[$this->db->errno])) {
+ return $errorcode_map[$this->db->errno];
}
- $errno=mysqli_errno($this->db);
+ $errno=$this->db->errno;
return ($errno?'DB_ERROR_'.$errno:'0');
}
}
@@ -456,7 +446,7 @@ class DoliDBMysqli extends DoliDB
return 'Not connected. Check setup parameters in conf/conf.php file and your mysql client and server versions';
}
else {
- return mysqli_error($this->db);
+ return $this->db->error;
}
}
@@ -469,7 +459,7 @@ class DoliDBMysqli extends DoliDB
*/
function last_insert_id($tab,$fieldid='rowid')
{
- return mysqli_insert_id($this->db);
+ return $this->db->insert_id;
}
/**
diff --git a/htdocs/core/lib/files.lib.php b/htdocs/core/lib/files.lib.php
index 8f6471f4af0..c1b68d0f1b7 100644
--- a/htdocs/core/lib/files.lib.php
+++ b/htdocs/core/lib/files.lib.php
@@ -950,7 +950,7 @@ function dol_move($srcfile, $destfile, $newmask=0, $overwriteifexists=1)
else dol_syslog("files.lib.php::dol_move failed", LOG_WARNING);
}
if (empty($newmask) && ! empty($conf->global->MAIN_UMASK)) $newmask=$conf->global->MAIN_UMASK;
- @chmod($newpathofsrcfile, octdec($newmask));
+ @chmod($newpathofdestfile, octdec($newmask));
}
return $result;
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 8649528d883..acdb6d24efe 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -4297,12 +4297,16 @@ function dolGetFirstLastname($firstname,$lastname,$nameorder=-1)
$ret='';
// If order not defined, we use the setup
if ($nameorder < 0) $nameorder=(empty($conf->global->MAIN_FIRSTNAME_NAME_POSITION));
- if ($nameorder)
+ if ($nameorder && ((string) $nameorder != '2'))
{
- $ret.=$firstname;
+ $ret.=$firstname;
if ($firstname && $lastname) $ret.=' ';
$ret.=$lastname;
}
+ else if ($nameorder == 2)
+ {
+ $ret.=$firstname;
+ }
else
{
$ret.=$lastname;
diff --git a/htdocs/core/lib/xcal.lib.php b/htdocs/core/lib/xcal.lib.php
index 5927bf97674..14cda539291 100644
--- a/htdocs/core/lib/xcal.lib.php
+++ b/htdocs/core/lib/xcal.lib.php
@@ -59,12 +59,14 @@ function build_calfile($format,$title,$desc,$events_array,$outputfile)
fwrite($calfileh,"CALSCALE:GREGORIAN\n");
fwrite($calfileh,"X-WR-CALNAME:".$encoding.format_cal($format,$title)."\n");
fwrite($calfileh,"X-WR-CALDESC:".$encoding.format_cal($format,$desc)."\n");
- $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour');
- $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min');
- $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec');
//fwrite($calfileh,"X-WR-TIMEZONE:Europe/Paris\n");
if (! empty($conf->global->MAIN_AGENDA_EXPORT_CACHE)
- && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60) fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
+ && $conf->global->MAIN_AGENDA_EXPORT_CACHE > 60){
+ $hh=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'hour');
+ $mm=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'min');
+ $ss=convertSecondToTime($conf->global->MAIN_AGENDA_EXPORT_CACHE,'sec');
+ fwrite($calfileh,"X-PUBLISHED-TTL: P".$hh."H".$mm."M".$ss."S\n");
+ }
foreach ($events_array as $date => $event)
{
diff --git a/htdocs/core/menus/standard/auguria.lib.php b/htdocs/core/menus/standard/auguria.lib.php
index 9624bf66341..1cafd091521 100644
--- a/htdocs/core/menus/standard/auguria.lib.php
+++ b/htdocs/core/menus/standard/auguria.lib.php
@@ -235,7 +235,7 @@ function print_left_auguria_menu($db,$menu_array_before,$menu_array_after,&$tabM
}
$title=$langs->trans("GoIntoSetupToChangeLogo");
print "\n".''."\n";
- print ' |