diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php
index d6ddf70528be719bdc9bd288d88356acbf7b52de..fe0539f73484c282f38902e5d2445b93edd8de75 100644
--- a/htdocs/admin/agenda_extsites.php
+++ b/htdocs/admin/agenda_extsites.php
@@ -41,7 +41,7 @@ $actiontest=GETPOST('test','alpha');
 $actionsave=GETPOST('save','alpha');
 
 if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
-$MAXAGENDA=empty($conf->global->AGENDA_EXT_NB)?5:$conf->global->AGENDA_EXT_NB;
+$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
 
 // List of aviable colors
 $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5');
diff --git a/htdocs/comm/action/index.php b/htdocs/comm/action/index.php
index 2ec95810536e64b966d8da669f17f4a293946d9c..a0ab00b9db6da63a6b9d6e142edbff71b51050eb 100644
--- a/htdocs/comm/action/index.php
+++ b/htdocs/comm/action/index.php
@@ -1,7 +1,7 @@
 <?php
 /* Copyright (C) 2001-2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
  * Copyright (C) 2003      Eric Seigne          <erics@rycks.com>
- * Copyright (C) 2004-2014 Laurent Destailleur  <eldy@users.sourceforge.net>
+ * Copyright (C) 2004-2015 Laurent Destailleur  <eldy@users.sourceforge.net>
  * Copyright (C) 2005-2012 Regis Houssin        <regis.houssin@capnetworks.com>
  * Copyright (C) 2011      Juanjo Menent        <jmenent@2byte.es>
  * Copyright (C) 2014      Cedric GROSS         <c.gross@kreiz-it.fr>
@@ -39,6 +39,9 @@ if (! empty($conf->projet->enabled)) {
 
 if (! isset($conf->global->AGENDA_MAX_EVENTS_DAY_VIEW)) $conf->global->AGENDA_MAX_EVENTS_DAY_VIEW=3;
 
+if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
+$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
+
 $filter=GETPOST("filter",'',3);
 $filtert = GETPOST("usertodo","int",3)?GETPOST("usertodo","int",3):GETPOST("filtert","int",3);
 $usergroup = GETPOST("usergroup","int",3);
@@ -170,7 +173,7 @@ $listofextcals=array();
 if (empty($conf->global->AGENDA_DISABLE_EXT))
 {
     $i=0;
-    while($i < $conf->global->AGENDA_EXT_NB)
+    while($i < $MAXAGENDA)
     {
         $i++;
         $source='AGENDA_EXT_SRC'.$i;
@@ -188,7 +191,7 @@ if (empty($conf->global->AGENDA_DISABLE_EXT))
 if (empty($user->conf->AGENDA_DISABLE_EXT))
 {
 	$i=0;
-	while($i < $conf->global->AGENDA_EXT_NB)
+	while($i < $MAXAGENDA)
 	{
 		$i++;
 		$source='AGENDA_EXT_SRC_'.$user->id.'_'.$i;
diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php
index 7dc29b5821b4de20544abde557918b861c38b81b..f2c00e2cf752a3b4e74e411d950ccf65e2f73e8c 100644
--- a/htdocs/core/lib/functions.lib.php
+++ b/htdocs/core/lib/functions.lib.php
@@ -3851,8 +3851,8 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
 
 /**
  *	This function is called to encode a string into a HTML string but differs from htmlentities because
- * 	all entities but &,<,> are converted. This permits to encode special chars to entities with no double
- *  encoding for already encoded HTML strings.
+ * 	a detection is done before to see if text is already HTML or not. Also, all entities but &,<,> are converted.
+ *  This permits to encode special chars to entities with no double encoding for already encoded HTML strings.
  * 	This function also remove last EOL or BR if $removelasteolbr=1 (default).
  *  For PDF usage, you can show text by 2 ways:
  *              - writeHTMLCell -> param must be encoded into HTML.
@@ -3869,7 +3869,7 @@ function dol_nl2br($stringtoencode,$nl2brmode=0,$forxml=false)
 function dol_htmlentitiesbr($stringtoencode,$nl2brmode=0,$pagecodefrom='UTF-8',$removelasteolbr=1)
 {
 	$newstring=$stringtoencode;
-	if (dol_textishtml($stringtoencode))
+	if (dol_textishtml($stringtoencode))	// Check if text is already HTML or not
 	{
 		$newstring=preg_replace('/<br(\s[\sa-zA-Z_="]*)?\/?>/i','<br>',$newstring);	// Replace "<br type="_moz" />" by "<br>". It's same and avoid pb with FPDF.
 		if ($removelasteolbr) $newstring=preg_replace('/<br>$/i','',$newstring);	// Remove last <br> (remove only last one)
diff --git a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
index d9d972cc25c282f3c7ebf931e3da547805b56a70..7a432a1109e408b913b8f2936358f1a5923287d8 100755
--- a/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
+++ b/htdocs/install/mysql/migration/3.6.0-3.7.0.sql
@@ -1095,8 +1095,8 @@ ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_task (fk_task);
 ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_date (task_date);
 ALTER TABLE llx_projet_task_time ADD INDEX idx_projet_task_time_datehour (task_datehour);
 
-ALTER TABLE llx_projet_task CHANGE COLUMN duration_effective real DEFAULT 0 NULL;
-ALTER TABLE llx_projet_task CHANGE COLUMN planned_workload real DEFAULT 0 NULL;
+ALTER TABLE llx_projet_task MODIFY COLUMN duration_effective real DEFAULT 0 NULL;
+ALTER TABLE llx_projet_task MODIFY COLUMN planned_workload real DEFAULT 0 NULL;
   
 
 -- add extrafield on ficheinter lines
diff --git a/htdocs/product/stock/lib/replenishment.lib.php b/htdocs/product/stock/lib/replenishment.lib.php
index 1ef993c479d350a5f4b2db08b74816b07998ca8a..486e83732558472b6d9fc01c610bb5845260f71b 100644
--- a/htdocs/product/stock/lib/replenishment.lib.php
+++ b/htdocs/product/stock/lib/replenishment.lib.php
@@ -37,7 +37,7 @@ function dolDispatchToDo($order_id)
     $dispatched = array();
     $ordered = array();
 
-    # Count nb of quantity dispatched per product
+    // Count nb of quantity dispatched per product
     $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseur_dispatch';
     $sql.= ' WHERE fk_commande = ' . $order_id;
     $sql.= ' GROUP BY fk_product';
@@ -49,7 +49,7 @@ function dolDispatchToDo($order_id)
             $dispatched[$obj->fk_product] = $obj;
     }
 
-    # Count nb of quantity to dispatch per product
+    // Count nb of quantity to dispatch per product
     $sql = 'SELECT fk_product, SUM(qty) FROM ' . MAIN_DB_PREFIX . 'commande_fournisseurdet';
     $sql.= ' WHERE fk_commande = ' . $order_id;
     $sql.= ' AND fk_product > 0';
diff --git a/htdocs/public/agenda/agendaexport.php b/htdocs/public/agenda/agendaexport.php
index 2b1d02ef493e21d5c0c16cd572206b48357beb40..3d5492dd62ce33360101fe2383fee7fce5f53adc 100644
--- a/htdocs/public/agenda/agendaexport.php
+++ b/htdocs/public/agenda/agendaexport.php
@@ -22,6 +22,10 @@
  * 				http://127.0.0.1/dolibarr/public/agenda/agendaexport.php?format=vcal&exportkey=cle
  * 				http://127.0.0.1/dolibarr/public/agenda/agendaexport.php?format=ical&type=event&exportkey=cle
  * 				http://127.0.0.1/dolibarr/public/agenda/agendaexport.php?format=rss&exportkey=cle
+ *              Other parameters into url are:
+ *              &notolderthan=99
+ *              &year=2015
+ *              &id=..., &idfrom=..., &idto=...
  */
 
 //if (! defined('NOREQUIREUSER'))  define('NOREQUIREUSER','1');
@@ -55,23 +59,26 @@ require_once DOL_DOCUMENT_ROOT.'/comm/action/class/actioncomm.class.php';
 // Security check
 if (empty($conf->agenda->enabled)) accessforbidden('',1,1,1);
 
+// Not older than
+if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100;	// default limit
+
 // Define format, type and filter
 $format='ical';
 $type='event';
 if (! empty($_GET["format"])) $format=$_GET["format"];
 if (! empty($_GET["type"]))   $type=$_GET["type"];
+
 $filters=array();
-if (! empty($_GET["year"])) 	$filters['year']=$_GET["year"];
-if (! empty($_GET["id"]))       $filters['id']=$_GET["id"];
-if (! empty($_GET["idfrom"]))   $filters['idfrom']=$_GET["idfrom"];
-if (! empty($_GET["idto"]))     $filters['idto']=$_GET["idto"];
-if (! empty($_GET["project"]))  $filters['project']=$_GET["project"];
-if (! empty($_GET["login"]))    $filters['login']=$_GET["login"];
-if (! empty($_GET["logina"]))   $filters['logina']=$_GET["logina"];
-if (! empty($_GET["logint"]))   $filters['logint']=$_GET["logint"];
-// Not older than
-if (! isset($conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY)) $conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY=100;
-$filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY;
+if (! empty($_GET["year"])) 	     $filters['year']=$_GET["year"];
+if (! empty($_GET["id"]))           $filters['id']=$_GET["id"];
+if (! empty($_GET["idfrom"]))       $filters['idfrom']=$_GET["idfrom"];
+if (! empty($_GET["idto"]))         $filters['idto']=$_GET["idto"];
+if (! empty($_GET["project"]))      $filters['project']=$_GET["project"];
+if (! empty($_GET["login"]))        $filters['login']=$_GET["login"];
+if (! empty($_GET["logina"]))       $filters['logina']=$_GET["logina"];
+if (! empty($_GET["logint"]))       $filters['logint']=$_GET["logint"];
+if (GETPOST("notolderthan")) $filters['notolderthan']=GETPOST("notolderthan","int");
+else $filters['notolderthan']=$conf->global->MAIN_AGENDA_EXPORT_PAST_DELAY;
 
 // Check config
 if (empty($conf->global->MAIN_AGENDA_XCAL_EXPORTKEY))