diff --git a/htdocs/admin/agenda_extsites.php b/htdocs/admin/agenda_extsites.php
index 272da835741..bf6c8bdee2a 100644
--- a/htdocs/admin/agenda_extsites.php
+++ b/htdocs/admin/agenda_extsites.php
@@ -41,8 +41,7 @@ if (!$user->admin) {
$langs->loadLangs(array('agenda', 'admin', 'other'));
$def = array();
-$actiontest = GETPOST('test', 'alpha');
-$actionsave = GETPOST('save', 'alpha');
+$action = GETPOST('action', 'alpha');
if (empty($conf->global->AGENDA_EXT_NB)) {
$conf->global->AGENDA_EXT_NB = 5;
@@ -57,14 +56,57 @@ $colorlist = array('BECEDD', 'DDBECE', 'BFDDBE', 'F598B4', 'F68654', 'CBF654', '
* Actions
*/
-if ($actionsave) {
+$error = 0;
+$errors = array();
+
+if (preg_match('/set_(.*)/', $action,$reg)) {
+ $db->begin();
+
+ $code=$reg[1];
+ $value=(GETPOST($code) ? GETPOST($code) : 1);
+
+ $res = dolibarr_set_const($db, $code, $value, 'chaine', 0, '', $conf->entity);
+ if (!$res > 0) {
+ $error++;
+ $errors[] = $db->lasterror();
+ }
+
+ if ($error) {
+ $db->rollback();
+ setEventMessages('', $errors, 'errors');
+ } else {
+ $db->commit();
+ setEventMessage($langs->trans('SetupSaved'));
+ header('Location: ' . $_SERVER["PHP_SELF"]);
+ exit();
+ }
+} elseif (preg_match('/del_(.*)/', $action,$reg)) {
+ $db->begin();
+
+ $code = $reg[1];
+
+ $res = dolibarr_del_const($db, $code, $conf->entity);
+ if (!$res > 0) {
+ $error++;
+ $errors[] = $db->lasterror();
+ }
+
+ if ($error) {
+ $db->rollback();
+ setEventMessages('', $errors, 'errors');
+ } else {
+ $db->commit();
+ setEventMessage($langs->trans('SetupSaved'));
+ header('Location: ' . $_SERVER["PHP_SELF"]);
+ exit();
+ }
+} elseif ($action == 'save') {
$db->begin();
$disableext = GETPOST('AGENDA_DISABLE_EXT', 'alpha');
$res = dolibarr_set_const($db, 'AGENDA_DISABLE_EXT', $disableext, 'chaine', 0, '', $conf->entity);
$i = 1; $errorsaved = 0;
- $error = 0;
// Save agendas
while ($i <= $MAXAGENDA) {
@@ -159,6 +201,10 @@ print dol_get_fiche_head($head, 'extsites', $langs->trans("Agenda"), -1, 'action
print ''.$langs->trans("AgendaExtSitesDesc")."
\n";
print "
\n";
+
+$selectedvalue=$conf->global->AGENDA_DISABLE_EXT;
+if ($selectedvalue==1) $selectedvalue=0; else $selectedvalue=1;
+
print "
| ".$langs->trans("Name")." | "; print "".$langs->trans("ExtSiteUrlAgenda")." (".$langs->trans("Example").': http://yoursite/agenda/agenda.ics) | '; print "".$form->textwithpicto($langs->trans("FixTZ"), $langs->trans("FillFixTZOnlyIfRequired"), 1).' | '; print ''.$langs->trans("Color").' | '; +print ''.$langs->trans("ActiveByDefault").' | '; print "
| '; + if ($conf->use_javascript_ajax) { + print ajax_constantonoff('AGENDA_EXT_ACTIVEBYDEFAULT'.$key); + } else { + if (empty($conf->global->{$default})) { + print ''.img_picto($langs->trans("Enabled"), 'on').''; + } else { + print ''.img_picto($langs->trans("Disabled"), 'off').''; + } + } + print ' | '; print "