diff --git a/htdocs/admin/ihm.php b/htdocs/admin/ihm.php
index 48362cbc5f77a..3fa267ece7026 100644
--- a/htdocs/admin/ihm.php
+++ b/htdocs/admin/ihm.php
@@ -58,6 +58,7 @@
dolibarr_set_const($db, "MAIN_SIZE_LISTE_LIMIT", $_POST["main_size_liste_limit"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_DISABLE_JAVASCRIPT", $_POST["main_disable_javascript"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_USE_PREVIEW_TABS", $_POST["main_use_preview_tabs"],'chaine',0,'',$conf->entity);
+ dolibarr_set_const($db, "MAIN_BUTTON_HIDE_UNAUTHORIZED", $_POST["MAIN_BUTTON_HIDE_UNAUTHORIZED"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_START_WEEK", $_POST["MAIN_START_WEEK"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_SHOW_LOGO", $_POST["MAIN_SHOW_LOGO"],'chaine',0,'',$conf->entity);
dolibarr_set_const($db, "MAIN_FIRSTNAME_NAME_POSITION", $_POST["MAIN_FIRSTNAME_NAME_POSITION"],'chaine',0,'',$conf->entity);
@@ -207,6 +208,14 @@
print '';
print '
';
print '';
+
+ // Hide unauthorized button
+ $var=!$var;
+ print ''.$langs->trans("ButtonHideUnauthorized").' ';
+ print $form->selectyesno('MAIN_BUTTON_HIDE_UNAUTHORIZED',isset($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED)?$conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED:0,1);
+ print ' ';
+ print ' ';
+ print ' ';
// Hide helpcenter link on login page
$var=!$var;
@@ -357,6 +366,12 @@
print '';
print ' ';
print '';
+
+ // Hide unauthorized button
+ $var=!$var;
+ print ''.$langs->trans("ButtonHideUnauthorized").' ';
+ print yn($conf->global->MAIN_BUTTON_HIDE_UNAUTHORIZED,1);
+ print ' ';
// Link to help center
$var=!$var;
diff --git a/htdocs/comm/mailing/fiche.php b/htdocs/comm/mailing/fiche.php
index 296fda46d2963..7f668a021e619 100644
--- a/htdocs/comm/mailing/fiche.php
+++ b/htdocs/comm/mailing/fiche.php
@@ -40,7 +40,13 @@
$action=GETPOST('action','alpha');
$confirm=GETPOST('confirm','alpha');
$urlfrom=GETPOST('urlfrom');
-$message = '';
+
+$mesg='';
+if (isset($_SESSION['DolMessage']))
+{
+ $mesg=$_SESSION['DolMessage'];
+ unset($_SESSION['DolMessage']);
+}
$object=new Mailing($db);
$result=$object->fetch($id);
@@ -140,14 +146,14 @@
{
// Pour des raisons de securite, on ne permet pas cette fonction via l'IHM,
// on affiche donc juste un message
- $message=''.$langs->trans("MailingNeedCommand").'
';
- $message.=' ';
- $message.=''.$langs->trans("MailingNeedCommand2").'
';
+ $mesg=''.$langs->trans("MailingNeedCommand").'
';
+ $mesg.=' ';
+ $mesg.=''.$langs->trans("MailingNeedCommand2").'
';
$action='';
}
else if ($conf->global->MAILING_LIMIT_SENDBYWEB < 0)
{
- $message=''.$langs->trans("NotEnoughPermissions").'
';
+ $mesg=''.$langs->trans("NotEnoughPermissions").'
';
$action='';
}
else
@@ -363,9 +369,8 @@
dol_syslog($db->error());
dol_print_error($db);
}
- $message='';
+
$action = '';
-
}
}
@@ -379,7 +384,7 @@
$object->sendto = $_POST["sendto"];
if (! $object->sendto)
{
- $message=''.$langs->trans("ErrorFieldRequired",$langs->trans("MailTo")).'
';
+ $mesg=''.$langs->trans("ErrorFieldRequired",$langs->trans("MailTo")).'
';
$error++;
}
@@ -387,7 +392,7 @@
{
// Le message est-il en html
$msgishtml=-1; // Inconnu par defaut
- if (preg_match('/[\s\t]*/i',$message)) $msgishtml=1;
+ if (preg_match('/[\s\t]*/i',$object->body)) $msgishtml=1;
// Pratique les substitutions sur le sujet et message
$object->sujet=make_substitutions($object->sujet,$object->substitutionarrayfortest);
@@ -419,11 +424,11 @@
$result=$mailfile->sendfile();
if ($result)
{
- $message=''.$langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)).'
';
+ $mesg=''.$langs->trans("MailSuccessfulySent",$mailfile->getValidAddress($object->email_from,2),$mailfile->getValidAddress($object->sendto,2)).'
';
}
else
{
- $message=''.$langs->trans("ResultKo").' '.$mailfile->error.' '.$result.'
';
+ $mesg=''.$langs->trans("ResultKo").' '.$mailfile->error.' '.$result.'
';
}
$action='';
@@ -433,8 +438,6 @@
// Action add emailing
if ($action == 'add')
{
- $message='';
-
$object->email_from = trim($_POST["from"]);
$object->email_replyto = trim($_POST["replyto"]);
$object->email_errorsto = trim($_POST["errorsto"]);
@@ -444,21 +447,21 @@
$object->bgcolor = trim($_POST["bgcolor"]);
$object->bgimage = trim($_POST["bgimage"]);
- if (! $object->titre) $message.=($message?' ':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTitle"));
- if (! $object->sujet) $message.=($message?' ':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic"));
- if (! $object->body) $message.=($message?' ':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailBody"));
+ if (! $object->titre) $mesg.=($mesg?' ':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTitle"));
+ if (! $object->sujet) $mesg.=($mesg?' ':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic"));
+ if (! $object->body) $mesg.=($mesg?' ':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailBody"));
- if (! $message)
+ if (! $mesg)
{
if ($object->create($user) >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
- $message=$object->error;
+ $mesg=$object->error;
}
- $message=''.$message.'
';
+ $mesg=''.$mesg.'
';
$action="create";
}
@@ -472,20 +475,20 @@
else if ($action == 'setemail_replyto') $object->email_replyto = trim(GETPOST('email_replyto','alpha'));
else if ($action == 'setemail_errorsto') $object->email_errorsto = trim(GETPOST('email_errorsto','alpha'));
- else if ($action == 'settitre' && empty($object->titre)) $message.=($message?' ':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle"));
- else if ($action == 'setfrom' && empty($object->email_from)) $message.=($message?' ':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailFrom"));
+ else if ($action == 'settitre' && empty($object->titre)) $mesg.=($mesg?' ':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailTitle"));
+ else if ($action == 'setfrom' && empty($object->email_from)) $mesg.=($mesg?' ':'').$langs->trans("ErrorFieldRequired",$langs->transnoentities("MailFrom"));
- if (! $message)
+ if (! $mesg)
{
if ($object->update($user) >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
- $message=$object->error;
+ $mesg=$object->error;
}
- $message=''.$message.'
';
+ $mesg=''.$mesg.'
';
$action="";
}
@@ -504,7 +507,7 @@
$action="edit";
}
-// Action update emailing
+// Action remove file
if (! empty($_POST["removedfile"]))
{
$upload_dir = $conf->mailing->dir_output . "/" . get_exdir($object->id,2,0,1);
@@ -530,20 +533,20 @@
$object->bgcolor = trim($_POST["bgcolor"]);
$object->bgimage = trim($_POST["bgimage"]);
- if (! $object->sujet) $message.=($message?' ':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic"));
- if (! $object->body) $message.=($message?' ':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailBody"));
+ if (! $object->sujet) $mesg.=($mesg?' ':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailTopic"));
+ if (! $object->body) $mesg.=($mesg?' ':'').$langs->trans("ErrorFieldRequired",$langs->trans("MailBody"));
- if (! $message)
+ if (! $mesg)
{
if ($object->update($user) >= 0)
{
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
}
- $message=$object->error;
+ $mesg=$object->error;
}
- $message=''.$message.'
';
+ $mesg=''.$mesg.'
';
$action="edit";
}
else
@@ -557,7 +560,9 @@
{
if ($object->id > 0)
{
- $object->valid($user);
+ $object->valid($user);
+
+ $_SESSION['DolMessage']=''.$langs->trans("MailingSuccessfullyValidated").'
';
Header("Location: ".$_SERVER['PHP_SELF']."?id=".$object->id);
exit;
@@ -639,7 +644,7 @@
print_fiche_titre($langs->trans("NewMailing"));
- dol_htmloutput_mesg($message);
+ dol_htmloutput_mesg($mesg);
print '';
print ''.$langs->trans("MailTitle").' ';
@@ -697,8 +702,6 @@
dol_fiche_head($head, 'card', $langs->trans("Mailing"), 0, 'email');
- dol_htmloutput_mesg($message);
-
// Confirmation de la validation du mailing
if ($action == 'valid')
{
@@ -914,7 +917,14 @@
if (($object->statut <= 1 && $user->rights->mailing->creer) || $user->rights->mailing->supprimer)
{
- print ''.$langs->trans("DeleteMailing").' ';
+ if ($object->statut > 0 && (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->delete))
+ {
+ print ''.$langs->trans("DeleteMailing").' ';
+ }
+ else
+ {
+ print ''.$langs->trans("DeleteMailing").' ';
+ }
}
print ' ';
@@ -1001,10 +1011,7 @@
* Mailing en mode edition
*/
- $mesgs=array();
- if ($mesg) $mesgs[]=$mesg;
- if ($message) $message[]=$message;
- dol_htmloutput_mesg('',$mesgs);
+ dol_htmloutput_mesg($mesg);
print '';
diff --git a/htdocs/core/lib/emailing.lib.php b/htdocs/core/lib/emailing.lib.php
index d6df5f0804e45..da677daf1b47d 100644
--- a/htdocs/core/lib/emailing.lib.php
+++ b/htdocs/core/lib/emailing.lib.php
@@ -29,7 +29,7 @@
*/
function emailing_prepare_head($object)
{
- global $langs, $conf;
+ global $user, $langs, $conf;
$h = 0;
$head = array();
@@ -38,6 +38,10 @@ function emailing_prepare_head($object)
$head[$h][1] = $langs->trans("MailCard");
$head[$h][2] = 'card';
$h++;
+
+ if (! empty($conf->global->MAIN_USE_ADVANCED_PERMS) && ! $user->rights->mailing->mailing_advance->recipient) {
+ return $head;
+ }
$head[$h][0] = DOL_URL_ROOT."/comm/mailing/cibles.php?id=".$object->id;
$head[$h][1] = $langs->trans("MailRecipients");
diff --git a/htdocs/core/modules/modMailing.class.php b/htdocs/core/modules/modMailing.class.php
index 9f7f337e5bbb3..3044dbfd7eb8f 100644
--- a/htdocs/core/modules/modMailing.class.php
+++ b/htdocs/core/modules/modMailing.class.php
@@ -97,20 +97,36 @@ function modMailing($db)
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'valider';
- $r++;
- $this->rights[$r][0] = 228;
- $this->rights[$r][1] = 'Envoyer les mailings';
- $this->rights[$r][2] = 'w';
- $this->rights[$r][3] = 0;
- $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
- $this->rights[$r][5] = 'send';
-
$r++;
$this->rights[$r][0] = 229;
$this->rights[$r][1] = 'Supprimer les mailings';
$this->rights[$r][2] = 'd';
$this->rights[$r][3] = 0;
$this->rights[$r][4] = 'supprimer';
+
+ $r++;
+ $this->rights[$r][0] = 237;
+ $this->rights[$r][1] = 'View recipients and info';
+ $this->rights[$r][2] = 'r';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][5] = 'recipient';
+
+ $r++;
+ $this->rights[$r][0] = 238;
+ $this->rights[$r][1] = 'Manually send mailings';
+ $this->rights[$r][2] = 'w';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][5] = 'send';
+
+ $r++;
+ $this->rights[$r][0] = 239;
+ $this->rights[$r][1] = 'Delete mailings after validation and/or sent';
+ $this->rights[$r][2] = 'd';
+ $this->rights[$r][3] = 0;
+ $this->rights[$r][4] = 'mailing_advance'; // Visible if option MAIN_USE_ADVANCED_PERMS is on
+ $this->rights[$r][5] = 'delete';
}
diff --git a/htdocs/langs/en_US/admin.lang b/htdocs/langs/en_US/admin.lang
index d9505beb39152..17203d54f0644 100644
--- a/htdocs/langs/en_US/admin.lang
+++ b/htdocs/langs/en_US/admin.lang
@@ -327,6 +327,7 @@ UrlGenerationParameters=Parameters to secure URLs
SecurityTokenIsUnique=Use a unique securekey parameter for each URL
EnterRefToBuildUrl=Enter reference for object %s
GetSecuredUrl=Get calculated URL
+ButtonHideUnauthorized=Hide buttons unauthorized (instead of seeing gray)
# Modules
Module0Name=Users & groups
@@ -553,11 +554,9 @@ Permission221=Read emailings
Permission222=Create/modify emailings (topic, recipients...)
Permission223=Validate emailings (allows sending)
Permission229=Delete emailings
-Permission231=Define mode of payment
-Permission232=Create/modify supplier invoices
-Permission233=Validate supplier invoices
-Permission234=Delete supplier invoices
-Permission236=Export supplier invoices
+Permission237=View recipients and info
+Permission238=Manually send mailings
+Permission239=Delete mailings after validation or sent
Permission241=Read categories
Permission242=Create/modify categories
Permission243=Delete categories
diff --git a/htdocs/langs/fr_FR/admin.lang b/htdocs/langs/fr_FR/admin.lang
index 06cad77935545..79aac5a7cf4fe 100644
--- a/htdocs/langs/fr_FR/admin.lang
+++ b/htdocs/langs/fr_FR/admin.lang
@@ -328,6 +328,7 @@ UrlGenerationParameters=Sécurisation des URLs
SecurityTokenIsUnique=Utiliser un paramètre securekey unique pour chaque URL ?
EnterRefToBuildUrl=Entrez la référence pour l'objet %s
GetSecuredUrl=Obtenir l'URL calculée
+ButtonHideUnauthorized=Cacher les boutons non autorisés (au lieu de les voir grisés)
# Modules= undefined
Module0Name= Utilisateurs & groupes
@@ -551,11 +552,9 @@ Permission221= Consulter les mailings
Permission222= Créer/modifier les mailings (sujet, destinataires, etc.)
Permission223= Valider les mailings (permet leur envoi)
Permission229= Supprimer les mailings
-Permission231= Définir le mode de règlement
-Permission232= Créer/modifier les factures fournisseurs
-Permission233= Valider les factures fournisseurs
-Permission234= Supprimer les factures fournisseurs
-Permission236= Exporter les factures fournisseurs et attributs
+Permission237= Visualiser les destinataires et les infos
+Permission238= Envoyer les mailings manuellement
+Permission239= Supprimer les mailings après leur validation ou leur envoi
Permission241= Lire les catégories
Permission242= Créer/modifier les catégories
Permission243= Supprimer les catégories
diff --git a/htdocs/theme/amarok/style.css.php b/htdocs/theme/amarok/style.css.php
index f717370c4b9f0..82be342dd0d71 100644
--- a/htdocs/theme/amarok/style.css.php
+++ b/htdocs/theme/amarok/style.css.php
@@ -144,6 +144,12 @@
color-stop(0, rgba(0,0,0,.3))
);
}
+
+global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?>
+.butActionRefused {
+ display: none;
+}
+
.tabsAction {margin-top:12px !important; text-align:center;}
.menu_titre img{padding-bottom:2px;}
diff --git a/htdocs/theme/auguria/style.css.php b/htdocs/theme/auguria/style.css.php
index 2d4f81cf60279..7566629af5724 100644
--- a/htdocs/theme/auguria/style.css.php
+++ b/htdocs/theme/auguria/style.css.php
@@ -1094,6 +1094,12 @@
cursor: not-allowed;
}
+global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?>
+.butActionRefused {
+ display: none;
+}
+
+
span.butAction, span.butActionDelete {
cursor: pointer;
}
diff --git a/htdocs/theme/bureau2crea/style.css.php b/htdocs/theme/bureau2crea/style.css.php
index dbc5f2dd2b4d1..6183a246a837a 100644
--- a/htdocs/theme/bureau2crea/style.css.php
+++ b/htdocs/theme/bureau2crea/style.css.php
@@ -1257,6 +1257,12 @@
cursor: not-allowed;
}
+global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?>
+.butActionRefused {
+ display: none;
+}
+
+
span.butAction, span.butActionDelete {
cursor: pointer;
}
diff --git a/htdocs/theme/cameleo/style.css.php b/htdocs/theme/cameleo/style.css.php
index 969588eeb921c..a63f1e0463630 100644
--- a/htdocs/theme/cameleo/style.css.php
+++ b/htdocs/theme/cameleo/style.css.php
@@ -1230,6 +1230,12 @@
color: #666;
}
+global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?>
+.butActionRefused {
+ display: none;
+}
+
+
span.butAction, span.butActionDelete {
cursor: pointer;
}
diff --git a/htdocs/theme/eldy/style.css.php b/htdocs/theme/eldy/style.css.php
index f87802ecbd27f..4477acd75fae2 100644
--- a/htdocs/theme/eldy/style.css.php
+++ b/htdocs/theme/eldy/style.css.php
@@ -1368,6 +1368,12 @@
box-shadow: 4px 4px 4px #CCC;
}
+global->MAIN_BUTTON_HIDE_UNAUTHORIZED)) { ?>
+.butActionRefused {
+ display: none;
+}
+
+
span.butAction, span.butActionDelete {
cursor: pointer;
}