FIX: Ajax on socialnetworks.php

This commit is contained in:
ptibogxiv 2018-12-30 19:48:04 +01:00 committed by GitHub
parent 2225d0a41e
commit 511579a24b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name='.$consttocheck.'">';
//$link.=$langs->trans("Disable");
$link.=img_picto($langs->trans("Activated"),'switch_on');
$link.='</a>';
}
else
{
$link='<a href="'.$_SERVER["PHP_SELF"].'?action=set&value=1&name='.$consttocheck.'">';
//$link.=img_$langs->trans("Activate")
$link.=img_picto($langs->trans("Disabled"),'switch_off');
$link.='</a>';
}
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.'<br><br>';
}