2011-04-22 10:50:25 +02:00
|
|
|
<?php
|
2015-06-30 21:50:24 +02:00
|
|
|
/* Copyright (C) 2008-2015 Laurent Destailleur <eldy@users.sourceforge.net>
|
2015-05-09 13:25:40 +02:00
|
|
|
* Copyright (C) 2011-2015 Juanjo Menent <jmenent@2byte.es>
|
2015-04-18 19:47:09 +02:00
|
|
|
* Copyright (C) 2015 Jean-François Ferry <jfefe@aternatik.fr>
|
2016-01-08 14:47:46 +01:00
|
|
|
* Copyright (C) 2016 Raphaël Doursenaud <rdoursenaud@gpcsolutions.fr>
|
2011-04-22 10:50:25 +02:00
|
|
|
*
|
|
|
|
|
* 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
|
2013-01-16 15:36:08 +01:00
|
|
|
* the Free Software Foundation; either version 3 of the License, or
|
2011-04-22 10:50:25 +02:00
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2011-08-01 00:21:57 +02:00
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-04-22 10:50:25 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* \file htdocs/admin/agenda_extsites.php
|
|
|
|
|
* \ingroup agenda
|
|
|
|
|
* \brief Page to setup external calendars for agenda module
|
|
|
|
|
*/
|
|
|
|
|
|
2012-08-22 23:24:21 +02:00
|
|
|
require '../main.inc.php';
|
2012-08-22 23:11:24 +02:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/admin.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formadmin.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/class/html.formother.class.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/agenda.lib.php';
|
|
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/date.lib.php';
|
2014-03-22 13:00:23 +01:00
|
|
|
require_once DOL_DOCUMENT_ROOT.'/core/lib/files.lib.php';
|
2011-04-22 10:50:25 +02:00
|
|
|
|
2014-05-27 10:45:58 +02:00
|
|
|
if (!$user->admin) accessforbidden();
|
2011-04-22 10:50:25 +02:00
|
|
|
|
2018-05-26 18:41:16 +02:00
|
|
|
// Load translation files required by the page
|
|
|
|
|
$langs->loadLangs(array('agenda', 'admin', 'other'));
|
2011-04-22 10:50:25 +02:00
|
|
|
|
2011-05-19 19:29:44 +02:00
|
|
|
$def = array();
|
2012-03-29 12:41:11 +02:00
|
|
|
$actiontest=GETPOST('test','alpha');
|
|
|
|
|
$actionsave=GETPOST('save','alpha');
|
2011-04-22 10:50:25 +02:00
|
|
|
|
2011-05-19 19:29:44 +02:00
|
|
|
if (empty($conf->global->AGENDA_EXT_NB)) $conf->global->AGENDA_EXT_NB=5;
|
2015-03-02 17:34:50 +01:00
|
|
|
$MAXAGENDA=$conf->global->AGENDA_EXT_NB;
|
2011-04-22 10:50:25 +02:00
|
|
|
|
2011-06-07 13:05:20 +02:00
|
|
|
// List of aviable colors
|
2011-06-08 09:53:05 +02:00
|
|
|
$colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5');
|
2011-05-19 19:29:44 +02:00
|
|
|
|
2018-03-04 19:39:46 +01:00
|
|
|
|
2011-05-19 19:29:44 +02:00
|
|
|
/*
|
|
|
|
|
* Actions
|
|
|
|
|
*/
|
2018-03-04 19:39:46 +01:00
|
|
|
|
2011-05-19 19:29:44 +02:00
|
|
|
if ($actionsave)
|
|
|
|
|
{
|
|
|
|
|
$db->begin();
|
|
|
|
|
|
2012-03-29 12:41:11 +02:00
|
|
|
$disableext=GETPOST('AGENDA_DISABLE_EXT','alpha');
|
2013-03-13 23:05:34 +01:00
|
|
|
$res=dolibarr_set_const($db,'AGENDA_DISABLE_EXT',$disableext,'chaine',0,'',$conf->entity);
|
2011-05-19 19:29:44 +02:00
|
|
|
|
2013-03-01 18:10:19 +01:00
|
|
|
$i=1; $errorsaved=0;
|
2011-05-19 19:29:44 +02:00
|
|
|
$error=0;
|
|
|
|
|
|
|
|
|
|
// Save agendas
|
|
|
|
|
while ($i <= $MAXAGENDA)
|
|
|
|
|
{
|
2014-08-15 17:08:05 +02:00
|
|
|
$name=trim(GETPOST('AGENDA_EXT_NAME'.$i,'alpha'));
|
|
|
|
|
$src=trim(GETPOST('AGENDA_EXT_SRC'.$i,'alpha'));
|
2015-07-28 18:12:45 +02:00
|
|
|
$offsettz=trim(GETPOST('AGENDA_EXT_OFFSETTZ'.$i,'alpha'));
|
2014-08-15 17:08:05 +02:00
|
|
|
$color=trim(GETPOST('AGENDA_EXT_COLOR'.$i,'alpha'));
|
2013-03-30 14:27:13 +01:00
|
|
|
if ($color=='-1') $color='';
|
2014-08-15 17:08:05 +02:00
|
|
|
$enabled=trim(GETPOST('AGENDA_EXT_ENABLED'.$i,'alpha'));
|
2013-03-13 23:05:34 +01:00
|
|
|
|
2014-02-08 01:16:20 +01:00
|
|
|
if (! empty($src) && ! dol_is_url($src))
|
2013-03-01 18:10:19 +01:00
|
|
|
{
|
2015-10-23 12:58:30 +02:00
|
|
|
setEventMessages($langs->trans("ErrorParamMustBeAnUrl"), null, 'errors');
|
2013-03-01 18:10:19 +01:00
|
|
|
$error++;
|
|
|
|
|
$errorsaved++;
|
|
|
|
|
break;
|
|
|
|
|
}
|
2013-03-13 23:05:34 +01:00
|
|
|
|
2014-05-23 04:28:57 +02:00
|
|
|
//print '-name='.$name.'-color='.$color;
|
2013-03-13 23:05:34 +01:00
|
|
|
$res=dolibarr_set_const($db,'AGENDA_EXT_NAME'.$i,$name,'chaine',0,'',$conf->entity);
|
2011-05-19 19:29:44 +02:00
|
|
|
if (! $res > 0) $error++;
|
2013-03-13 23:05:34 +01:00
|
|
|
$res=dolibarr_set_const($db,'AGENDA_EXT_SRC'.$i,$src,'chaine',0,'',$conf->entity);
|
2011-05-19 19:29:44 +02:00
|
|
|
if (! $res > 0) $error++;
|
2015-07-28 18:12:45 +02:00
|
|
|
$res=dolibarr_set_const($db,'AGENDA_EXT_OFFSETTZ'.$i,$offsettz,'chaine',0,'',$conf->entity);
|
|
|
|
|
if (! $res > 0) $error++;
|
2013-03-13 23:05:34 +01:00
|
|
|
$res=dolibarr_set_const($db,'AGENDA_EXT_COLOR'.$i,$color,'chaine',0,'',$conf->entity);
|
2011-05-19 19:29:44 +02:00
|
|
|
if (! $res > 0) $error++;
|
2014-08-15 17:08:05 +02:00
|
|
|
$res=dolibarr_set_const($db,'AGENDA_EXT_ENABLED'.$i,$enabled,'chaine',0,'',$conf->entity);
|
|
|
|
|
if (! $res > 0) $error++;
|
2011-05-19 19:29:44 +02:00
|
|
|
$i++;
|
|
|
|
|
}
|
2013-03-13 23:05:34 +01:00
|
|
|
|
2011-05-19 19:29:44 +02:00
|
|
|
// Save nb of agenda
|
2013-03-01 18:10:19 +01:00
|
|
|
if (! $error)
|
|
|
|
|
{
|
2016-01-08 06:42:28 +01:00
|
|
|
$res=dolibarr_set_const($db,'AGENDA_EXT_NB',trim(GETPOST('AGENDA_EXT_NB','int')),'chaine',0,'',$conf->entity);
|
2013-03-01 18:10:19 +01:00
|
|
|
if (! $res > 0) $error++;
|
|
|
|
|
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;
|
|
|
|
|
}
|
2013-03-13 23:05:34 +01:00
|
|
|
|
2011-05-19 19:29:44 +02:00
|
|
|
if (! $error)
|
|
|
|
|
{
|
|
|
|
|
$db->commit();
|
2015-10-23 12:58:30 +02:00
|
|
|
setEventMessages($langs->trans("SetupSaved"), null, 'mesgs');
|
2011-05-19 19:29:44 +02:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
$db->rollback();
|
2015-10-23 12:58:30 +02:00
|
|
|
if (empty($errorsaved)) setEventMessages($langs->trans("Error"), null, 'errors');
|
2011-05-19 19:29:44 +02:00
|
|
|
}
|
|
|
|
|
}
|
2011-04-22 10:50:25 +02:00
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* View
|
|
|
|
|
*/
|
|
|
|
|
|
2011-05-19 19:29:44 +02:00
|
|
|
$form=new Form($db);
|
|
|
|
|
$formadmin=new FormAdmin($db);
|
|
|
|
|
$formother=new FormOther($db);
|
|
|
|
|
|
2011-06-11 04:25:05 +02:00
|
|
|
$arrayofjs=array();
|
|
|
|
|
$arrayofcss=array();
|
|
|
|
|
|
2017-08-22 08:12:30 +02:00
|
|
|
$wikihelp='EN:Module_Agenda_En|FR:Module_Agenda|ES:Módulo_Agenda';
|
|
|
|
|
llxHeader('',$langs->trans("AgendaSetup"),$wikihelp,'',0,0,$arrayofjs,$arrayofcss);
|
2011-04-22 10:50:25 +02:00
|
|
|
|
2018-02-26 09:20:05 +01:00
|
|
|
$linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php?restore_lastsearch_values=1">'.$langs->trans("BackToModuleList").'</a>';
|
2015-09-24 18:33:48 +02:00
|
|
|
print load_fiche_titre($langs->trans("AgendaSetup"),$linkback,'title_setup');
|
2011-04-22 10:50:25 +02:00
|
|
|
|
2015-06-30 21:50:24 +02:00
|
|
|
print '<form name="extsitesconfig" action="'.$_SERVER["PHP_SELF"].'" method="post">';
|
|
|
|
|
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
|
|
|
|
|
print '<input type="hidden" name="action" value="save">';
|
|
|
|
|
|
2011-04-22 10:50:25 +02:00
|
|
|
$head=agenda_prepare_head();
|
|
|
|
|
|
2017-04-30 04:32:03 +02:00
|
|
|
dol_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action');
|
2011-04-22 10:50:25 +02:00
|
|
|
|
2013-03-13 23:05:34 +01:00
|
|
|
print $langs->trans("AgendaExtSitesDesc")."<br>\n";
|
|
|
|
|
print "<br>\n";
|
|
|
|
|
|
2011-05-19 19:29:44 +02:00
|
|
|
|
2013-03-13 23:05:34 +01:00
|
|
|
$selectedvalue=$conf->global->AGENDA_DISABLE_EXT;
|
2011-06-11 00:05:07 +02:00
|
|
|
if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1;
|
2011-05-19 19:29:44 +02:00
|
|
|
|
|
|
|
|
print "<table class=\"noborder\" width=\"100%\">";
|
2011-04-22 10:50:25 +02:00
|
|
|
|
2011-05-19 19:29:44 +02:00
|
|
|
print "<tr class=\"liste_titre\">";
|
2013-03-13 23:05:34 +01:00
|
|
|
print '<td>'.$langs->trans("Parameter")."</td>";
|
|
|
|
|
print '<td align="center">'.$langs->trans("Value")."</td>";
|
2011-05-19 19:29:44 +02:00
|
|
|
print "</tr>";
|
|
|
|
|
|
2013-03-13 23:05:34 +01:00
|
|
|
// Show external agenda
|
2017-04-14 11:22:48 +02:00
|
|
|
|
|
|
|
|
print '<tr class="oddeven">';
|
2013-03-13 23:05:34 +01:00
|
|
|
print "<td>".$langs->trans("ExtSitesEnableThisTool")."</td>";
|
|
|
|
|
print '<td align="center">';
|
2013-03-30 14:27:13 +01:00
|
|
|
if ($conf->use_javascript_ajax)
|
|
|
|
|
{
|
|
|
|
|
print ajax_constantonoff('AGENDA_DISABLE_EXT',array('enabled'=>array(0=>'.hideifnotset')),null,1);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2015-05-09 13:25:40 +02:00
|
|
|
if (empty($conf->global->AGENDA_DISABLE_EXT))
|
2013-03-30 14:27:13 +01:00
|
|
|
{
|
|
|
|
|
print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=1">'.img_picto($langs->trans("Enabled"),'on').'</a>';
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
print '<a href="'.$_SERVER['PHP_SELF'].'?save=1&AGENDA_DISABLE_EXT=0">'.img_picto($langs->trans("Disabled"),'off').'</a>';
|
|
|
|
|
}
|
|
|
|
|
}
|
2011-05-19 19:29:44 +02:00
|
|
|
print "</td>";
|
|
|
|
|
print "</tr>";
|
|
|
|
|
|
2013-03-13 23:05:34 +01:00
|
|
|
// Nb of agenda
|
2017-04-14 11:22:48 +02:00
|
|
|
|
|
|
|
|
print '<tr class="oddeven">';
|
2013-03-30 14:27:13 +01:00
|
|
|
print "<td>".$langs->trans("ExtSitesNbOfAgenda")."</td>";
|
|
|
|
|
print '<td align="center">';
|
|
|
|
|
print '<input class="flat hideifnotset" type="text" size="2" id="AGENDA_EXT_NB" name="AGENDA_EXT_NB" value="'.$conf->global->AGENDA_EXT_NB.'">';
|
|
|
|
|
print "</td>";
|
|
|
|
|
print "</tr>";
|
2013-03-13 23:05:34 +01:00
|
|
|
|
2011-05-19 19:29:44 +02:00
|
|
|
print "</table>";
|
|
|
|
|
print "<br>";
|
|
|
|
|
|
|
|
|
|
print "<table class=\"noborder\" width=\"100%\">";
|
|
|
|
|
|
|
|
|
|
print "<tr class=\"liste_titre\">";
|
|
|
|
|
print "<td>".$langs->trans("Parameter")."</td>";
|
|
|
|
|
print "<td>".$langs->trans("Name")."</td>";
|
2011-06-08 22:45:09 +02:00
|
|
|
print "<td>".$langs->trans("ExtSiteUrlAgenda")." (".$langs->trans("Example").': http://yoursite/agenda/agenda.ics)</td>';
|
2016-03-25 15:24:57 +01:00
|
|
|
print "<td>".$form->textwithpicto($langs->trans("FixTZ"), $langs->trans("FillFixTZOnlyIfRequired"), 1).'</td>';
|
2013-03-13 23:05:34 +01:00
|
|
|
print '<td align="right">'.$langs->trans("Color").'</td>';
|
2011-05-19 19:29:44 +02:00
|
|
|
print "</tr>";
|
|
|
|
|
|
|
|
|
|
$i=1;
|
|
|
|
|
while ($i <= $MAXAGENDA)
|
|
|
|
|
{
|
|
|
|
|
$key=$i;
|
|
|
|
|
$name='AGENDA_EXT_NAME'.$key;
|
|
|
|
|
$src='AGENDA_EXT_SRC'.$key;
|
2015-07-28 18:12:45 +02:00
|
|
|
$offsettz='AGENDA_EXT_OFFSETTZ'.$key;
|
2011-05-19 19:29:44 +02:00
|
|
|
$color='AGENDA_EXT_COLOR'.$key;
|
2014-08-15 17:08:05 +02:00
|
|
|
$enabled='AGENDA_EXT_ENABLED'.$key;
|
2013-03-13 23:05:34 +01:00
|
|
|
|
2017-08-22 08:12:30 +02:00
|
|
|
|
2017-04-14 11:22:48 +02:00
|
|
|
print '<tr class="oddeven">';
|
2013-03-01 18:10:19 +01:00
|
|
|
// Nb
|
2013-04-25 01:13:13 +02:00
|
|
|
print '<td width="180" class="nowrap">'.$langs->trans("AgendaExtNb",$key)."</td>";
|
2013-03-01 18:10:19 +01:00
|
|
|
// Name
|
2016-01-08 14:45:53 +01:00
|
|
|
print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_NAME'.$key.'" value="'. (GETPOST('AGENDA_EXT_NAME'.$key)?GETPOST('AGENDA_EXT_NAME'.$key, 'alpha'):$conf->global->$name) . '" size="28"></td>';
|
2013-03-01 18:10:19 +01:00
|
|
|
// URL
|
2016-01-08 14:45:53 +01:00
|
|
|
print '<td><input type="url" class="flat hideifnotset" name="AGENDA_EXT_SRC'.$key.'" value="'. (GETPOST('AGENDA_EXT_SRC'.$key)?GETPOST('AGENDA_EXT_SRC'.$key, 'alpha'):$conf->global->$src) . '" size="60"></td>';
|
2015-07-28 18:12:45 +02:00
|
|
|
// Offset TZ
|
|
|
|
|
print '<td><input type="text" class="flat hideifnotset" name="AGENDA_EXT_OFFSETTZ'.$key.'" value="'. (GETPOST('AGENDA_EXT_OFFSETTZ'.$key)?GETPOST('AGENDA_EXT_OFFSETTZ'.$key):$conf->global->$offsettz) . '" size="2"></td>';
|
2013-03-01 18:10:19 +01:00
|
|
|
// Color (Possible colors are limited by Google)
|
2013-04-25 01:13:13 +02:00
|
|
|
print '<td class="nowrap" align="right">';
|
2013-03-13 23:05:34 +01:00
|
|
|
//print $formadmin->selectColor($conf->global->$color, "google_agenda_color".$key, $colorlist);
|
2014-08-15 17:08:05 +02:00
|
|
|
print $formother->selectColor((GETPOST("AGENDA_EXT_COLOR".$key)?GETPOST("AGENDA_EXT_COLOR".$key):$conf->global->$color), "AGENDA_EXT_COLOR".$key, 'extsitesconfig', 1, '', 'hideifnotset');
|
2011-05-19 19:29:44 +02:00
|
|
|
print '</td>';
|
|
|
|
|
print "</tr>";
|
|
|
|
|
$i++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
print '</table>';
|
2015-06-30 21:50:24 +02:00
|
|
|
|
|
|
|
|
dol_fiche_end();
|
2011-05-19 19:29:44 +02:00
|
|
|
|
2014-11-25 20:13:43 +01:00
|
|
|
print '<div class="center">';
|
|
|
|
|
print '<input type="submit" id="save" name="save" class="button hideifnotset" value="'.$langs->trans("Save").'">';
|
|
|
|
|
print '</div>';
|
2011-04-22 10:50:25 +02:00
|
|
|
|
|
|
|
|
print "</form>\n";
|
|
|
|
|
|
2018-07-28 14:29:28 +02:00
|
|
|
// End of page
|
2011-08-27 16:24:16 +02:00
|
|
|
llxFooter();
|
2013-03-01 18:10:19 +01:00
|
|
|
$db->close();
|