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,24 +38,31 @@ $action = GETPOST('action','aZ09');
/* /*
* Actions * Action
*/ */
if (preg_match('/set_([a-z0-9_\-]+)/i',$action,$reg))
// Action activation d'un sous module du module adherent
if ($action == 'set')
{ {
$result=dolibarr_set_const($db, $_GET["name"], $_GET["value"], '', 0, '', $conf->entity); $code=$reg[1];
if ($result < 0) if (dolibarr_set_const($db, $code, 1, 'chaine', 0, '', $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{ {
dol_print_error($db); dol_print_error($db);
} }
} }
// Action desactivation d'un sous module du module adherent if (preg_match('/del_([a-z0-9_\-]+)/i',$action,$reg))
if ($action == 'unset')
{ {
$result=dolibarr_del_const($db, $_GET["name"], $conf->entity); $code=$reg[1];
if ($result < 0) if (dolibarr_del_const($db, $code, $conf->entity) > 0)
{
header("Location: ".$_SERVER["PHP_SELF"]);
exit;
}
else
{ {
dol_print_error($db); dol_print_error($db);
} }
@ -94,21 +101,13 @@ $arrayofsocialnetworks=array('jabber'=>'Jabber', 'skype'=>'Skype', 'twitter'=>'T
foreach($arrayofsocialnetworks as $snkey => $snlabel) foreach($arrayofsocialnetworks as $snkey => $snlabel)
{ {
$consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey); $consttocheck = 'SOCIALNETWORKS_'.strtoupper($snkey);
if (! empty($conf->global->$consttocheck)) if ($conf->use_javascript_ajax) {
{ $link = ajax_constantonoff($consttocheck);
//$link=img_picto($langs->trans("Active"),'tick').' '; } else {
$link='<a href="'.$_SERVER["PHP_SELF"].'?action=unset&value=0&name='.$consttocheck.'">'; $arrval = array('0' => $langs->trans("No"), '1' => $langs->trans("Yes"));
//$link.=$langs->trans("Disable"); $link = $form->selectarray($consttocheck, $arrval, $conf->global->$consttocheck);
$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>';
}
print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'<br><br>'; print $langs->trans('EnableFeatureFor', $snlabel).' '.$link.'<br><br>';
} }