Skip to content

Commit

Permalink
Uniformize code
Browse files Browse the repository at this point in the history
  • Loading branch information
Juanjo Menent committed Sep 2, 2011
1 parent 7ced92a commit 64f4ad4
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
47 changes: 32 additions & 15 deletions htdocs/adherents/admin/adherent.php
Expand Up @@ -5,7 +5,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr>
*
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
*
* 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
Expand Down Expand Up @@ -40,32 +40,43 @@

$typeconst=array('yesno','texte','chaine');

$action = getpost("action");


// Action mise a jour ou ajout d'une constante
if ($_POST["action"] == 'update' || $_POST["action"] == 'add')
if ($action == 'update' || $action == 'add')
{
if (($_POST["constname"]=='ADHERENT_CARD_TYPE' || $_POST["constname"]=='ADHERENT_ETIQUETTE_TYPE')
&& $_POST["constvalue"] == -1) $_POST["constvalue"]='';
if ($_POST["constname"]=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
$const=GETPOST("constname");
$value=GETPOST("constvalue");

if (($const=='ADHERENT_CARD_TYPE' || $const=='ADHERENT_ETIQUETTE_TYPE')
&& $value == -1) $value='';
if ($const=='ADHERENT_LOGIN_NOT_REQUIRED') // Invert choice
{
if ($_POST["constvalue"]) $_POST["constvalue"]=0;
else $_POST["constvalue"]=1;
if ($value) $value=0;
else $value=1;
}

$const=$_POST["constname"];
$value=$_POST["constvalue"];

if (in_array($const,array('ADHERENT_MAIL_VALID','ADHERENT_MAIL_COTIS','ADHERENT_MAIL_RESIL'))) $value=$_POST["constvalue".$const];
$type=$_POST["consttype"];
$constnote=isset($_POST["constnote"])?$_POST["constnote"]:'';
$result=dolibarr_set_const($db,$const,$value,$typeconst[$type],0,$constnote,$conf->entity);
if ($result < 0)
$constnote=GETPOST("constnote");
$res=dolibarr_set_const($db,$const,$value,$typeconst[$type],0,$constnote,$conf->entity);

if (! $res > 0) $error++;

if (! $error)
{
print $db->error();
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
}

// Action activation d'un sous module du module adherent
if ($_GET["action"] == 'set')
if ($action == 'set')
{
$result=dolibarr_set_const($db, $_GET["name"],$_GET["value"],'',0,'',$conf->entity);
if ($result < 0)
Expand All @@ -75,7 +86,7 @@
}

// Action desactivation d'un sous module du module adherent
if ($_GET["action"] == 'unset')
if ($action == 'unset')
{
$result=dolibarr_del_const($db,$_GET["name"],$conf->entity);
if ($result < 0)
Expand Down Expand Up @@ -466,4 +477,10 @@ function form_constantes($tableau)
print '</table>';
}

dol_htmloutput_mesg($mesg);

$db->close();

llxFooter();

?>
2 changes: 1 addition & 1 deletion htdocs/adherents/admin/public.php
Expand Up @@ -44,7 +44,7 @@
$res=dolibarr_set_const($db, "MEMBER_ENABLE_PUBLIC",$_POST["MEMBER_ENABLE_PUBLIC"],'chaine',0,'',$conf->entity);
$res=dolibarr_set_const($db, "MEMBER_NEWFORM_AMOUNT",$_POST["MEMBER_NEWFORM_AMOUNT"],'chaine',0,'',$conf->entity);
$res=dolibarr_set_const($db, "MEMBER_NEWFORM_EDITAMOUNT",$_POST["MEMBER_NEWFORM_EDITAMOUNT"],'chaine',0,'',$conf->entity);
$$res=dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE",$_POST["MEMBER_NEWFORM_PAYONLINE"],'chaine',0,'',$conf->entity);
$res=dolibarr_set_const($db, "MEMBER_NEWFORM_PAYONLINE",$_POST["MEMBER_NEWFORM_PAYONLINE"],'chaine',0,'',$conf->entity);

if (! $res > 0) $error++;

Expand Down

0 comments on commit 64f4ad4

Please sign in to comment.