diff --git a/htdocs/admin/socialnetworks.php b/htdocs/admin/socialnetworks.php index 959dd91f339..d25becaac4f 100644 --- a/htdocs/admin/socialnetworks.php +++ b/htdocs/admin/socialnetworks.php @@ -38,27 +38,34 @@ $action = GETPOST('action','aZ09'); /* - * Actions + * Action */ - -// Action activation d'un sous module du module adherent -if ($action == 'set') +if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg)) { - $result=dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); - if ($result < 0) - { - dol_print_error($db); - } + $code=$reg[1]; + if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } } -// Action desactivation d'un sous module du module adherent -if ($action == 'unset') +if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg)) { - $result=dolibarr_del_const($db, $_GET["name"], $conf->entity); - if ($result < 0) - { - dol_print_error($db); - } + $code=$reg[1]; + if (dolibarr_del_const($db, $code, $conf->entity) > 0) + { + header("Location: ".$_SERVER["PHP_SELF"]); + exit; + } + else + { + dol_print_error($db); + } } @@ -94,21 +101,13 @@ $arrayofsocialnetworks=array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'T foreach($arrayofsocialnetworks as $snkey => $snlabel) { $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); - if (! empty($conf->global->$consttocheck)) - { - //$link=img_picto($langs->trans("Active"),'tick').' '; - $link=''; - //$link.=$langs->trans("Disable"); - $link.=img_picto($langs->trans("Activated"),'switch_on'); - $link.=''; - } - else - { - $link=''; - //$link.=img_$langs->trans("Activate") - $link.=img_picto($langs->trans("Disabled"),'switch_off'); - $link.=''; - } + if ($conf->use_javascript_ajax) { + $link = ajax_constantonoff($consttocheck); +} else { + $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes")); + $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck); +} + print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'

'; }