From 79023cddb0031afb69b3d4cf621735cd8239d619 Mon Sep 17 00:00:00 2001
From: Laurent Destailleur <eldy@destailleur.fr>
Date: Mon, 2 Mar 2015 17:34:50 +0100
Subject: [PATCH] Fix external calendar for users were not visible if no global
 calendar was set.

---
 htdocs/admin/agenda_extsites.php | 2 +-
 htdocs/comm/action/index.php     | 9 ++++++---
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php
index 6b683c8b52b..b49c82c5b84 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 f41dbc50d3a..6baa03ba87e 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;
-- 
GitLab