Qual: Uniformize code

This commit is contained in:
Juanjo Menent 2011-09-06 10:52:42 +00:00
parent b6dac11cc3
commit 113562747f
4 changed files with 57 additions and 36 deletions

View File

@ -1,6 +1,7 @@
<?php <?php
/* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org> /* Copyright (C) 2004 Rodolphe Quiedeville <rodolphe@quiedeville.org>
* Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.org> * Copyright (C) 2005-2011 Laurent Destailleur <eldy@users.sourceforge.org>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -30,24 +31,27 @@ $langs->load("admin");
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$action = getpost("action");
if ($_POST["action"] == 'setvalue' && $user->admin) /*
* Actions
*/
if ($action == 'setvalue' && $user->admin)
{ {
$result=dolibarr_set_const($db, "CLICKTODIAL_URL",$_POST["url"],'chaine',0,'',$conf->entity); $result=dolibarr_set_const($db, "CLICKTODIAL_URL",GETPOST("url"),'chaine',0,'',$conf->entity);
if ($result >= 0) if ($result >= 0)
{ {
$mesg='<div class="ok">'.$langs->trans("RecordModifiedSuccessfully").'</div>'; $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
} }
else else
{ {
dol_print_error($db); $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
} }
} }
/* /*
* * View
*
*/ */
$wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es'; $wikihelp='EN:Module_ClickToDial_En|FR:Module_ClickToDial|ES:Módulo_ClickTodial_Es';
@ -58,9 +62,6 @@ print_fiche_titre($langs->trans("ClickToDialSetup"),$linkback,'setup');
print $langs->trans("ClickToDialDesc")."<br>\n"; print $langs->trans("ClickToDialDesc")."<br>\n";
if ($mesg) print '<br>'.$mesg;
print '<br>'; print '<br>';
print '<form method="post" action="clicktodial.php">'; print '<form method="post" action="clicktodial.php">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
@ -92,6 +93,8 @@ print '</table></form>';
} }
*/ */
dol_htmloutput_mesg($mesg);
$db->close(); $db->close();
llxFooter(); llxFooter();

View File

@ -5,6 +5,7 @@
* Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org> * Copyright (C) 2004 Sebastien Di Cintio <sdicintio@ressource-toi.org>
* Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be> * Copyright (C) 2004 Benoit Mortier <benoit.mortier@opensides.be>
* Copyright (C) 2005-2011 Regis Houssin <regis@dolibarr.fr> * 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 * 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 * it under the terms of the GNU General Public License as published by
@ -59,10 +60,10 @@ else
dol_print_error($db); dol_print_error($db);
} }
if ($action == 'add' || $_POST["modify"]) if ($action == 'add' || GETPOST("modify"))
{ {
$external_rss_title = "external_rss_title_" . $_POST["norss"]; $external_rss_title = "external_rss_title_" . GETPOST("norss");
$external_rss_urlrss = "external_rss_urlrss_" . $_POST["norss"]; $external_rss_urlrss = "external_rss_urlrss_" . GETPOST("norss");
if (! empty($_POST[$external_rss_urlrss])) if (! empty($_POST[$external_rss_urlrss]))
{ {
@ -90,7 +91,7 @@ if ($action == 'add' || $_POST["modify"])
{ {
// Ajoute boite box_external_rss dans definition des boites // Ajoute boite box_external_rss dans definition des boites
$sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)"; $sql = "INSERT INTO ".MAIN_DB_PREFIX."boxes_def (file, note)";
$sql.= " VALUES ('box_external_rss.php','".$db->escape($_POST["norss"].' ('.$_POST[$external_rss_title]).")')"; $sql.= " VALUES ('box_external_rss.php','".$db->escape(GETPOST("norss").' ('.GETPOST($external_rss_title)).")')";
if (! $db->query($sql)) if (! $db->query($sql))
{ {
dol_print_error($db); dol_print_error($db);
@ -98,8 +99,8 @@ if ($action == 'add' || $_POST["modify"])
} }
} }
$result1=dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_" . $_POST["norss"],$_POST[$external_rss_title],'chaine',0,'',$conf->entity); $result1=dolibarr_set_const($db, "EXTERNAL_RSS_TITLE_" . GETPOST("norss"),GETPOST($external_rss_title),'chaine',0,'',$conf->entity);
if ($result1) $result2=dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_" . $_POST["norss"],$_POST[$external_rss_urlrss],'chaine',0,'',$conf->entity); if ($result1) $result2=dolibarr_set_const($db, "EXTERNAL_RSS_URLRSS_" . GETPOST("norss"),GETPOST($external_rss_urlrss),'chaine',0,'',$conf->entity);
if ($result1 && $result2) if ($result1 && $result2)
{ {
@ -118,13 +119,13 @@ if ($action == 'add' || $_POST["modify"])
if ($_POST["delete"]) if ($_POST["delete"])
{ {
if(isset($_POST["norss"])) if(GETPOST("norss"))
{ {
$db->begin(); $db->begin();
// Supprime boite box_external_rss de definition des boites // Supprime boite box_external_rss de definition des boites
$sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes_def"; $sql = "SELECT rowid FROM ".MAIN_DB_PREFIX."boxes_def";
$sql.= " WHERE file = 'box_external_rss.php' AND note LIKE '".$_POST["norss"]." %'"; $sql.= " WHERE file = 'box_external_rss.php' AND note LIKE '".GETPOST("norss")." %'";
$resql=$db->query($sql); $resql=$db->query($sql);
if ($resql) if ($resql)
@ -163,8 +164,8 @@ if ($_POST["delete"])
} }
$result1=dolibarr_del_const($db,"EXTERNAL_RSS_TITLE_" . $_POST["norss"],$conf->entity); $result1=dolibarr_del_const($db,"EXTERNAL_RSS_TITLE_" . GETPOST("norss"),$conf->entity);
if ($result1) $result2=dolibarr_del_const($db,"EXTERNAL_RSS_URLRSS_" . $_POST["norss"],$conf->entity); if ($result1) $result2=dolibarr_del_const($db,"EXTERNAL_RSS_URLRSS_" . GETPOST("norss"),$conf->entity);
if ($result1 && $result2) if ($result1 && $result2)
{ {

View File

@ -1,5 +1,6 @@
<?php <?php
/* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.net> /* Copyright (C) 2009 Laurent Destailleur <eldy@users.sourceforge.org>
* Copyright (C) 2011 Juanjo Menent <jmenent@2byte.es>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
@ -32,21 +33,36 @@ accessforbidden();
$langs->load("admin"); $langs->load("admin");
$langs->load("errors"); $langs->load("errors");
$action = GETPOST("action");
/* /*
* Actions * Actions
*/ */
if ($_POST["action"] == 'set') if ($action == 'set')
{ {
$error=0; $error=0;
if (! empty($_POST["GEOIPMAXMIND_COUNTRY_DATAFILE"]) && ! file_exists($_POST["GEOIPMAXMIND_COUNTRY_DATAFILE"]))
$gimcdf= getpost("GEOIPMAXMIND_COUNTRY_DATAFILE");
if (! $gimcdf && ! file_exists($gimcdf))
{ {
$mesg='<div class="error">'.$langs->trans("ErrorFileNotFound",$_POST["GEOIPMAXMIND_COUNTRY_DATAFILE"]).'</div>'; $mesg='<div class="error">'.$langs->trans("ErrorFileNotFound",$gimcdf).'</div>';
$error++; $error++;
} }
if (! $error) if (! $error)
{ {
dolibarr_set_const($db,"GEOIPMAXMIND_COUNTRY_DATAFILE",$_POST["GEOIPMAXMIND_COUNTRY_DATAFILE"],'chaine',0,'',$conf->entity); $res = dolibarr_set_const($db,"GEOIPMAXMIND_COUNTRY_DATAFILE",$gimcdf,'chaine',0,'',$conf->entity);
if (! $res > 0) $error++;
if (! $error)
{
$mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
}
else
{
$mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
}
} }
} }
@ -64,8 +80,6 @@ $linkback='<a href="'.DOL_URL_ROOT.'/admin/modules.php">'.$langs->trans("BackToM
print_fiche_titre($langs->trans("GeoIPMaxmindSetup"),$linkback,'setup'); print_fiche_titre($langs->trans("GeoIPMaxmindSetup"),$linkback,'setup');
print '<br>'; print '<br>';
if ($mesg) print $mesg;
$version=''; $version='';
$geoip=''; $geoip='';
if (! empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE)) if (! empty($conf->global->GEOIPMAXMIND_COUNTRY_DATAFILE))
@ -126,5 +140,9 @@ if ($geoip)
$geoip->close(); $geoip->close();
} }
dol_htmloutput_mesg($mesg);
$db->close();
llxFooter(); llxFooter();
?> ?>

View File

@ -27,27 +27,28 @@ require_once(DOL_DOCUMENT_ROOT."/lib/admin.lib.php");
require_once(DOL_DOCUMENT_ROOT."/includes/triggers/interface_modNotification_Notification.class.php"); require_once(DOL_DOCUMENT_ROOT."/includes/triggers/interface_modNotification_Notification.class.php");
$langs->load("admin"); $langs->load("admin");
$langs->load("mails"); $langs->load("other");
// Security check // Security check
if (!$user->admin) if (!$user->admin)
accessforbidden(); accessforbidden();
$action = GETPOST("action");
/* /*
* Actions * Actions
*/ */
if ($_POST["action"] == 'setvalue' && $user->admin) if ($action == 'setvalue' && $user->admin)
{ {
$result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM",$_POST["email_from"],'chaine',0,'',$conf->entity); $result=dolibarr_set_const($db, "NOTIFICATION_EMAIL_FROM",$_POST["email_from"],'chaine',0,'',$conf->entity);
if ($result >= 0) if ($result >= 0)
{ {
$mesg='<div class="ok">'.$langs->trans("Success").'</div>'; $mesg = "<font class=\"ok\">".$langs->trans("SetupSaved")."</font>";
} }
else else
{ {
dol_print_error($db); $mesg = "<font class=\"error\">".$langs->trans("Error")."</font>";
} }
} }
@ -64,8 +65,6 @@ print_fiche_titre($langs->trans("NotificationSetup"),$linkback,'setup');
print $langs->trans("NotificationsDesc").'<br><br>'; print $langs->trans("NotificationsDesc").'<br><br>';
dol_htmloutput_mesg($mesg);
print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">'; print '<form method="post" action="'.$_SERVER["PHP_SELF"].'">';
print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">'; print '<input type="hidden" name="token" value="'.$_SESSION['newtoken'].'">';
print '<input type="hidden" name="action" value="setvalue">'; print '<input type="hidden" name="action" value="setvalue">';
@ -109,7 +108,7 @@ $listofnotifiedevents=$notificationtrigger->getListOfManagedEvents();
foreach($listofnotifiedevents as $notifiedevent) foreach($listofnotifiedevents as $notifiedevent)
{ {
$var=!$var; $var=!$var;
$label=$langs->trans("Notify_".$notifiedevent['code'])!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label']; $label=$langs->trans("Notify_".$notifiedevent['code']); //!=$langs->trans("Notify_".$notifiedevent['code'])?$langs->trans("Notify_".$notifiedevent['code']):$notifiedevent['label'];
print '<tr '.$bc[$var].'>'; print '<tr '.$bc[$var].'>';
print '<td>'.$notifiedevent['elementtype'].'</td>'; print '<td>'.$notifiedevent['elementtype'].'</td>';
print '<td>'.$notifiedevent['code'].'</td>'; print '<td>'.$notifiedevent['code'].'</td>';
@ -118,9 +117,9 @@ foreach($listofnotifiedevents as $notifiedevent)
} }
print '</table>'; print '</table>';
dol_htmloutput_mesg($mesg);
$db->close(); $db->close();
llxFooter(); llxFooter();
?> ?>