From 9a8a953e47bbebc7cc0b49722c12762c9428ad98 Mon Sep 17 00:00:00 2001 From: Regis Houssin Date: Mon, 4 May 2009 14:58:40 +0000 Subject: [PATCH] New: only superadmin access for common constant --- htdocs/admin/mails.php | 193 ++++++++++++++++++++++++----------- htdocs/html.form.class.php | 15 +++ htdocs/lib/functions.lib.php | 17 +++ htdocs/user/group/fiche.php | 2 +- 4 files changed, 164 insertions(+), 63 deletions(-) diff --git a/htdocs/admin/mails.php b/htdocs/admin/mails.php index 7d1777a8a38..c8b8b6020d0 100644 --- a/htdocs/admin/mails.php +++ b/htdocs/admin/mails.php @@ -1,5 +1,6 @@ + * Copyright (C) 2009 Regis Houssin * * 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 @@ -48,11 +49,11 @@ $substitutionarrayfortest=array( if (isset($_POST["action"]) && $_POST["action"] == 'update') { dolibarr_set_const($db, "MAIN_DISABLE_ALL_MAILS", $_POST["MAIN_DISABLE_ALL_MAILS"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", $_POST["MAIN_MAIL_SENDMODE"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", $_POST["MAIN_MAIL_SMTP_PORT"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", $_POST["MAIN_MAIL_SMTP_SERVER"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", $_POST["MAIN_MAIL_SMTPS_ID"],'chaine',0,'',$conf->entity); - dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", $_POST["MAIN_MAIL_SMTPS_PW"],'chaine',0,'',$conf->entity); + if ($_POST["MAIN_MAIL_SENDMODE"]) dolibarr_set_const($db, "MAIN_MAIL_SENDMODE", $_POST["MAIN_MAIL_SENDMODE"],'chaine',0,'',0); + if ($_POST["MAIN_MAIL_SMTP_PORT"]) dolibarr_set_const($db, "MAIN_MAIL_SMTP_PORT", $_POST["MAIN_MAIL_SMTP_PORT"],'chaine',0,'',0); + if ($_POST["MMAIN_MAIL_SMTP_SERVER"]) dolibarr_set_const($db, "MAIN_MAIL_SMTP_SERVER", $_POST["MAIN_MAIL_SMTP_SERVER"],'chaine',0,'',0); + if ($_POST["MAIN_MAIL_SMTPS_ID"]) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_ID", $_POST["MAIN_MAIL_SMTPS_ID"],'chaine',0,'',0); + if ($_POST["MAIN_MAIL_SMTPS_PW"]) dolibarr_set_const($db, "MAIN_MAIL_SMTPS_PW", $_POST["MAIN_MAIL_SMTPS_PW"],'chaine',0,'',0); dolibarr_set_const($db, "MAIN_MAIL_EMAIL_FROM", $_POST["MAIN_MAIL_EMAIL_FROM"],'chaine',0,'',$conf->entity); Header("Location: ".$_SERVER["PHP_SELF"]."?mainmenu=home&leftmenu=setup"); @@ -202,79 +203,147 @@ if ($message) print $message.'
'; if (isset($_GET["action"]) && $_GET["action"] == 'edit') { $html=new Form($db); + + print '
'; + print ''; - print ''; - print ''; + clearstatcache(); + $var=true; - clearstatcache(); - $var=true; + print ''; + print ''; - print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'; - print ''; - - // Disable - $var=!$var; + // Disable + $var=!$var; print ''; + print ''; - // Method - $var=!$var; + // Method + $var=!$var; print ''; + // SuperAdministrator access only + if ((!$conf->global->MAIN_MODULE_MULTICOMPANY) || ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->admin && !$user->entity)) + { + print $html->select_array('MAIN_MAIL_SENDMODE',$listofmethods,$conf->global->MAIN_MAIL_SENDMODE); + } + else + { + if ($conf->global->MAIN_MAIL_SENDMODE == 'mail') $text = 'PHP mail function'; + elseif ($conf->global->MAIN_MAIL_SENDMODE == 'smtps') $text = 'SMTPS library'; + else { $text = $langs->trans("Undefined"); } + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $html->textwithredstar($text,$htmltext); + } + print ''; + + // Server + $var=!$var; + print ''; - // Server - $var=!$var; - if ($linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') - { - print ''; - } - else - { - print ''; - } + // Port + $var=!$var; + print ''; + + // ID + if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps') + { + $var=!$var; + print ''; + } - // Port - $var=!$var; - if ($linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') - { - print ''; - } - else - { - print ''; - } + // PW + if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps') + { + $var=!$var; + print ''; + } - // ID - if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps') - { - $var=!$var; - print ''; - } + // From + $var=!$var; + print ''; - // PW - if ($conf->global->MAIN_MAIL_SENDMODE == 'smtps') - { - $var=!$var; - print ''; - } + print '
'.$langs->trans("Parameter").''.$langs->trans("Value").'
'.$langs->trans("MAIN_DISABLE_ALL_MAILS").''; print $html->selectyesno('MAIN_DISABLE_ALL_MAILS',$conf->global->MAIN_DISABLE_ALL_MAILS,1); - print '
'.$langs->trans("MAIN_MAIL_SENDMODE").''; $listofmethods=array(); $listofmethods['mail']='PHP mail function'; $listofmethods['smtps']='SMTP/SMTPS socket library'; - print $html->select_array('MAIN_MAIL_SENDMODE',$listofmethods,$conf->global->MAIN_MAIL_SENDMODE); - print '
'; + if ($linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') + { + print $langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike"); + print ''; + print $langs->trans("SeeLocalSendMailSetup"); + } + else + { + $smtpserver = ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined"); + print $langs->trans("MAIN_MAIL_SMTP_SERVER",$smtpserver); + print ''; + // SuperAdministrator access only + if ((!$conf->global->MAIN_MODULE_MULTICOMPANY) || ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->admin && !$user->entity)) + { + print ''; + } + else + { + $text = $conf->global->MAIN_MAIL_SMTP_SERVER ? $conf->global->MAIN_MAIL_SMTP_SERVER : $smtpserver; + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $html->textwithredstar($conf->global->MAIN_MAIL_SMTP_SERVER,$htmltext); + } + } + print '
'.$langs->trans("MAIN_MAIL_SMTP_SERVER_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_SERVER",ini_get('SMTP')?ini_get('SMTP'):$langs->transnoentities("Undefined")).'
'; + if ($linuxlike && $conf->global->MAIN_MAIL_SENDMODE == 'mail') + { + print $langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike"); + print ''; + print $langs->trans("SeeLocalSendMailSetup"); + } + else + { + $smtpport = ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined"); + print $langs->trans("MAIN_MAIL_SMTP_PORT",$smtpport); + print ''; + // SuperAdministrator access only + if ((!$conf->global->MAIN_MODULE_MULTICOMPANY) || ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->admin && !$user->entity)) + { + print ''; + } + else + { + $text = $conf->global->MAIN_MAIL_SMTP_PORT ? $conf->global->MAIN_MAIL_SMTP_PORT : $smtpport; + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $html->textwithredstar($text,$htmltext); + } + } + print '
'.$langs->trans("MAIN_MAIL_SMTPS_ID").''; + // SuperAdministrator access only + if ((!$conf->global->MAIN_MODULE_MULTICOMPANY) || ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->admin && !$user->entity)) + { + print ''; + } + else + { + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $html->textwithredstar($conf->global->MAIN_MAIL_SMTPS_ID,$htmltext); + } + print '
'.$langs->trans("MAIN_MAIL_SMTP_PORT_NotAvailableOnLinuxLike").''.$langs->trans("SeeLocalSendMailSetup").'
'.$langs->trans("MAIN_MAIL_SMTP_PORT",ini_get('smtp_port')?ini_get('smtp_port'):$langs->transnoentities("Undefined")).'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").''; + // SuperAdministrator access only + if ((!$conf->global->MAIN_MODULE_MULTICOMPANY) || ($conf->global->MAIN_MODULE_MULTICOMPANY && $user->admin && !$user->entity)) + { + print ''; + } + else + { + $htmltext = $langs->trans("ContactSuperAdminForChange"); + print $html->textwithredstar($conf->global->MAIN_MAIL_SMTPS_PW,$htmltext); + } + print '
'.$langs->trans("MAIN_MAIL_SMTPS_ID").'
'.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).'
'.$langs->trans("MAIN_MAIL_SMTPS_PW").'
'; - // From - $var=!$var; - print ''.$langs->trans("MAIN_MAIL_EMAIL_FROM",ini_get('sendmail_from')?ini_get('sendmail_from'):$langs->transnoentities("Undefined")).''; + print '
'; + print ''; + print '
'; - print ''; - - print '
'; - print ''; - print '
'; - - print '
'; - print '
'; + print ''; + print '
'; } else { diff --git a/htdocs/html.form.class.php b/htdocs/html.form.class.php index 930fe6b2d2a..0d1e5868526 100644 --- a/htdocs/html.form.class.php +++ b/htdocs/html.form.class.php @@ -174,6 +174,21 @@ class Form if (empty($conf->use_javascript_ajax)) $alt='Help disabled (javascript disabled)'; return $this->textwithtooltip($text,$htmltext,2,$direction,img_warning($alt)); } + + /** + * \brief Affiche un texte avec picto redstar qui affiche un tooltip + * \param text Texte à afficher + * \param htmltooltip Contenu html du tooltip + * \param direction 1=Le picto est après, -1=le picto est avant + * \return string Code html du texte,picto + */ + function textwithredstar($text,$htmltext,$direction=1) + { + global $conf; + $alt=''; + if (empty($conf->use_javascript_ajax)) $alt='Help disabled (javascript disabled)'; + return $this->textwithtooltip($text,$htmltext,2,$direction,img_redstar($alt)); + } /** diff --git a/htdocs/lib/functions.lib.php b/htdocs/lib/functions.lib.php index ff3082d8b2b..53c7910f2d7 100644 --- a/htdocs/lib/functions.lib.php +++ b/htdocs/lib/functions.lib.php @@ -1125,6 +1125,23 @@ function img_warning($alt = "default",$float=0) return $img; } +/** + * \brief Affiche logo redstar + * \param alt Texte sur le alt de l'image + * \param float Si il faut afficher le style "float: right" + * \return string Retourne tag img + */ +function img_redstar($alt = "default",$float=0) +{ + global $conf,$langs; + if ($alt=="default") $alt=$langs->trans("SuperAdministrator"); + $img=''.$alt.'load("users"); $langs->load("other"); // Security check -$result = restrictedArea($user, 'user', $_GET["id"], '', 'user'); +$result = restrictedArea($user, 'user', $_GET["id"], 'usergroup', 'user'); $action=isset($_GET["action"])?$_GET["action"]:$_POST["action"];