* Copyright (C) 2011-2012 Juanjo Menent * * 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 * the Free Software Foundation; either version 3 of the License, or * (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 * along with this program. If not, see . */ /** * \file htdocs/admin/agenda_extsites.php * \ingroup agenda * \brief Page to setup external calendars for agenda module */ require '../main.inc.php'; 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'; if (!$user->admin) accessforbidden(); $langs->load("agenda"); $langs->load("admin"); $langs->load("other"); $def = array(); $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; // List of aviable colors $colorlist=array('BECEDD','DDBECE','BFDDBE','F598B4','F68654','CBF654','A4A4A5'); /* * Actions */ if ($actionsave) { $db->begin(); $disableext=GETPOST('AGENDA_DISABLE_EXT','alpha'); if ($disableext) $disableext=0; else $disableext=1; $res=dolibarr_set_const($db,'AGENDA_DISABLE_EXT',$disableext,'chaine',0); $i=1; $error=0; // Save agendas while ($i <= $MAXAGENDA) { $color=trim(GETPOST('agenda_ext_color'.$i,'alpha')); if ($color=='-1') $color=''; //print 'color='.$color; $res=dolibarr_set_const($db,'AGENDA_EXT_NAME'.$i,trim(GETPOST('agenda_ext_name'.$i),'alpha'),'chaine',0); if (! $res > 0) $error++; $res=dolibarr_set_const($db,'AGENDA_EXT_SRC'.$i,trim(GETPOST('agenda_ext_src'.$i,'alpha')),'chaine',0); if (! $res > 0) $error++; $res=dolibarr_set_const($db,'AGENDA_EXT_COLOR'.$i,$color,'chaine',0); if (! $res > 0) $error++; $i++; } // Save nb of agenda $res=dolibarr_set_const($db,'AGENDA_EXT_NB',trim(GETPOST('AGENDA_EXT_NB','alpha')),'chaine',0); 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; if (! $error) { $db->commit(); $mesg = "".$langs->trans("SetupSaved").""; } else { $db->rollback(); $mesg = "".$langs->trans("Error").""; } } /* * View */ $form=new Form($db); $formadmin=new FormAdmin($db); $formother=new FormOther($db); $arrayofjs=array(); $arrayofcss=array(); llxHeader('',$langs->trans("AgendaSetup"),'','',0,0,$arrayofjs,$arrayofcss); $linkback=''.$langs->trans("BackToModuleList").''; print_fiche_titre($langs->trans("AgendaSetup"),$linkback,'setup'); print '
'; print $langs->trans("AgendaExtSitesDesc")."
\n"; print "
\n"; $head=agenda_prepare_head(); dol_fiche_head($head, 'extsites', $langs->trans("Agenda")); print '
'; $selectedvalue=(GETPOST('AGENDA_DISABLE_AGENDA','alpha'))?GETPOST('AGENDA_DISABLE_EXT','alpha'):$conf->global->AGENDA_DISABLE_EXT; if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1; print $langs->trans("ExtSitesEnableThisTool").' '.$form->selectyesno("AGENDA_DISABLE_EXT",$selectedvalue,1).'

'; $var=false; print ""; print ""; print '"; print ""; print ""; // Nb of agenda print ""; print ""; print ""; print ""; print "
'.$langs->trans("Parameter")."".$langs->trans("Value")."
".$langs->trans("ExtSitesNbOfAgenda").""; print ''; print "
"; print "
"; print ""; print ""; print ""; print ""; print "'; print ''; print ""; $i=1; $var=true; while ($i <= $MAXAGENDA) { $key=$i; $var=!$var; print ""; print '"; $name='AGENDA_EXT_NAME'.$key; $src='AGENDA_EXT_SRC'.$key; $color='AGENDA_EXT_COLOR'.$key; print ""; print ""; print ''; print ""; $i++; } print '
".$langs->trans("Parameter")."".$langs->trans("Name")."".$langs->trans("ExtSiteUrlAgenda")." (".$langs->trans("Example").': http://yoursite/agenda/agenda.ics)'.$langs->trans("Color").'
'.$langs->trans("AgendaExtNb",$key)."global->$name . "\" size=\"28\">global->$src . "\" size=\"60\">'; // Possible colors are limited by Google //print $formadmin->select_colors($conf->global->$color, "google_agenda_color".$key, $colorlist); print $formother->select_color($conf->global->$color, "agenda_ext_color".$key, 'extsitesconfig', 1, ''); print '
'; print '
'; print '
'; print "trans("Save")."\">"; print "
"; print "
\n"; dol_fiche_end(); dol_htmloutput_mesg($mesg); $db->close(); llxFooter(); ?>