mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-08 17:13:56 +00:00
Implemented "suppress email on edit"
SVN revision: 1722
This commit is contained in:
parent
9fd0c17b55
commit
1618bb2cec
@ -2182,6 +2182,11 @@ Options Location = Main Building{a}, New Building{b}, Old Building{c}
|
|||||||
notification is always produced. If this value is set to <b>3</b>, the
|
notification is always produced. If this value is set to <b>3</b>, the
|
||||||
email notification is always suppressed. The default is <b>0</b>.
|
email notification is always suppressed. The default is <b>0</b>.
|
||||||
</li>
|
</li>
|
||||||
|
<li>
|
||||||
|
<b><code>Suppress Email on edit = 0|1|2|3</code></b><br>
|
||||||
|
This is the same as <b><code>Suppress default</code></b>, but just for
|
||||||
|
edited entries. The default is <b>0</b>.
|
||||||
|
</li>
|
||||||
<li>
|
<li>
|
||||||
<b><code>Resubmit default = 0|1|2</code></b><br>
|
<b><code>Resubmit default = 0|1|2</code></b><br>
|
||||||
This specifies the default state of the "<i>Resubmit as new entry</i>"
|
This specifies the default state of the "<i>Resubmit as new entry</i>"
|
||||||
@ -2227,11 +2232,6 @@ Options Location = Main Building{a}, New Building{b}, Old Building{c}
|
|||||||
</ul>So to send for example only the attributes and the URL, set
|
</ul>So to send for example only the attributes and the URL, set
|
||||||
<n> to <b>6</b>. Default is <b>63</b> (send everything).
|
<n> to <b>6</b>. Default is <b>63</b> (send everything).
|
||||||
</li>
|
</li>
|
||||||
<li>
|
|
||||||
<b><code>Suppress Email on edit = 0|1</code></b><br>
|
|
||||||
If this flag is <b>1</b>, no email notifications are sent for edited
|
|
||||||
messages, only for new messages. The default is <b>0</b>.
|
|
||||||
</li>
|
|
||||||
<li>
|
<li>
|
||||||
<b><code>Email Encoding = <n></code></b><br>
|
<b><code>Email Encoding = <n></code></b><br>
|
||||||
Specifies in which encoding an email is sent. <n> is the sum of
|
Specifies in which encoding an email is sent. <n> is the sum of
|
||||||
|
|||||||
196
src/elogd.c
196
src/elogd.c
@ -10021,21 +10021,21 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Suppress email check box */
|
/* Suppress email check box */
|
||||||
if (!(bedit && !breedit && !bupload && getcfg(lbs->name, "Suppress Email on edit", str, sizeof(str))
|
if (bedit)
|
||||||
&& atoi(str) == 1)) {
|
getcfg(lbs->name, "Suppress Email on edit", str, sizeof(str));
|
||||||
if (getcfg(lbs->name, "Suppress default", str, sizeof(str))) {
|
else
|
||||||
if (atoi(str) == 0) {
|
getcfg(lbs->name, "Suppress default", str, sizeof(str));
|
||||||
rsprintf("<input type=\"checkbox\" name=\"suppress\" id=\"suppress\" value=\"1\">");
|
|
||||||
rsprintf("<label for=\"suppress\">%s</label>\n", loc("Suppress Email notification"));
|
|
||||||
} else if (atoi(str) == 1) {
|
|
||||||
rsprintf("<input type=\"checkbox\" checked name=\"suppress\" id=\"suppress\" value=\"1\">");
|
|
||||||
rsprintf("<label for=\"suppress\">%s</label>\n", loc("Suppress Email notification"));
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
if (atoi(str) == 0) {
|
||||||
rsprintf("<input type=\"checkbox\" name=\"suppress\" id=\"suppress\" value=\"1\">");
|
rsprintf("<input type=\"checkbox\" name=\"suppress\" id=\"suppress\" value=\"1\">");
|
||||||
rsprintf("<label for=\"suppress\">%s</label>\n", loc("Suppress Email notification"));
|
rsprintf("<label for=\"suppress\">%s</label>\n", loc("Suppress Email notification"));
|
||||||
}
|
} else if (atoi(str) == 1) {
|
||||||
|
rsprintf("<input type=\"checkbox\" checked name=\"suppress\" id=\"suppress\" value=\"1\">");
|
||||||
|
rsprintf("<label for=\"suppress\">%s</label>\n", loc("Suppress Email notification"));
|
||||||
|
} else if (atoi(str) == 2) {
|
||||||
|
rsprintf("<input type=\"hidden\" name=\"suppress\" id=\"suppress\" value=\"2\">");
|
||||||
|
} else if (atoi(str) == 3) {
|
||||||
|
rsprintf("<input type=\"hidden\" name=\"suppress\" id=\"suppress\" value=\"3\">");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Suppress execute shell check box */
|
/* Suppress execute shell check box */
|
||||||
@ -19602,8 +19602,6 @@ void submit_elog(LOGBOOK * lbs)
|
|||||||
/*---- email notifications ----*/
|
/*---- email notifications ----*/
|
||||||
|
|
||||||
suppress = isparam("suppress") ? atoi(getparam("suppress")) : 0;
|
suppress = isparam("suppress") ? atoi(getparam("suppress")) : 0;
|
||||||
if (getcfg(lbs->name, "Suppress default", str, sizeof(str)) && atoi(str) == 3)
|
|
||||||
suppress = 3;
|
|
||||||
|
|
||||||
/* check for mail submissions */
|
/* check for mail submissions */
|
||||||
mail_param[0] = 0;
|
mail_param[0] = 0;
|
||||||
@ -19614,111 +19612,107 @@ void submit_elog(LOGBOOK * lbs)
|
|||||||
rcpt_to[0] = 0;
|
rcpt_to[0] = 0;
|
||||||
rcpt_to_size = 256;
|
rcpt_to_size = 256;
|
||||||
|
|
||||||
if (suppress) {
|
if (suppress == 1 || suppress == 3) {
|
||||||
if (suppress != 3)
|
if (suppress == 1)
|
||||||
strcpy(mail_param, "?suppress=1");
|
strcpy(mail_param, "?suppress=1");
|
||||||
} else {
|
} else {
|
||||||
if (!(isparam("edit_id")
|
/* go throuch "Email xxx" in configuration file */
|
||||||
&& getcfg(lbs->name, "Suppress Email on edit", str, sizeof(str))
|
for (index = mindex = 0; index <= n_attr; index++) {
|
||||||
&& atoi(str) == 1)) {
|
|
||||||
/* go throuch "Email xxx" in configuration file */
|
|
||||||
for (index = mindex = 0; index <= n_attr; index++) {
|
|
||||||
|
|
||||||
strcpy(ua, attr_list[index]);
|
strcpy(ua, attr_list[index]);
|
||||||
btou(ua);
|
btou(ua);
|
||||||
dtou(ua);
|
dtou(ua);
|
||||||
|
|
||||||
if (index < n_attr) {
|
if (index < n_attr) {
|
||||||
strcpy(str, "Email ");
|
strcpy(str, "Email ");
|
||||||
if (strchr(attr_list[index], ' '))
|
if (strchr(attr_list[index], ' '))
|
||||||
sprintf(str + strlen(str), "\"%s\"", attr_list[index]);
|
sprintf(str + strlen(str), "\"%s\"", attr_list[index]);
|
||||||
|
else
|
||||||
|
strlcat(str, attr_list[index], sizeof(str));
|
||||||
|
strcat(str, " ");
|
||||||
|
|
||||||
|
if (attr_flags[index] & AF_MULTI) {
|
||||||
|
sprintf(str2, "%s_%d", ua, mindex);
|
||||||
|
|
||||||
|
mindex++;
|
||||||
|
if (mindex == MAX_N_LIST)
|
||||||
|
mindex = 0;
|
||||||
else
|
else
|
||||||
strlcat(str, attr_list[index], sizeof(str));
|
index--; /* repeat this loop */
|
||||||
strcat(str, " ");
|
|
||||||
|
|
||||||
if (attr_flags[index] & AF_MULTI) {
|
|
||||||
sprintf(str2, "%s_%d", ua, mindex);
|
|
||||||
|
|
||||||
mindex++;
|
|
||||||
if (mindex == MAX_N_LIST)
|
|
||||||
mindex = 0;
|
|
||||||
else
|
|
||||||
index--; /* repeat this loop */
|
|
||||||
} else
|
|
||||||
strcpy(str2, ua);
|
|
||||||
|
|
||||||
if (isparam(str2)) {
|
|
||||||
if (strchr(getparam(str2), ' '))
|
|
||||||
sprintf(str + strlen(str), "\"%s\"", getparam(str2));
|
|
||||||
else
|
|
||||||
strlcat(str, getparam(str2), sizeof(str));
|
|
||||||
}
|
|
||||||
} else
|
} else
|
||||||
sprintf(str, "Email ALL");
|
strcpy(str2, ua);
|
||||||
|
|
||||||
if (getcfg(lbs->name, str, list, sizeof(list))) {
|
if (isparam(str2)) {
|
||||||
i = build_subst_list(lbs, slist, svalue, attrib, TRUE);
|
if (strchr(getparam(str2), ' '))
|
||||||
strsubst_list(list, sizeof(list), slist, svalue, i);
|
sprintf(str + strlen(str), "\"%s\"", getparam(str2));
|
||||||
|
else
|
||||||
|
strlcat(str, getparam(str2), sizeof(str));
|
||||||
|
}
|
||||||
|
} else
|
||||||
|
sprintf(str, "Email ALL");
|
||||||
|
|
||||||
n = strbreak(list, mail_list, MAX_N_LIST, ",");
|
if (getcfg(lbs->name, str, list, sizeof(list))) {
|
||||||
|
i = build_subst_list(lbs, slist, svalue, attrib, TRUE);
|
||||||
|
strsubst_list(list, sizeof(list), slist, svalue, i);
|
||||||
|
|
||||||
if (verbose)
|
n = strbreak(list, mail_list, MAX_N_LIST, ",");
|
||||||
eprintf("\n%s to %s\n\n", str, list);
|
|
||||||
|
|
||||||
for (i = 0; i < n; i++) {
|
if (verbose)
|
||||||
/* remove possible 'mailto:' */
|
eprintf("\n%s to %s\n\n", str, list);
|
||||||
if ((p = strstr(mail_list[i], "mailto:")) != NULL)
|
|
||||||
strcpy(p, p + 7);
|
|
||||||
|
|
||||||
if ((int) strlen(mail_to) + (int) strlen(mail_list[i]) >= mail_to_size) {
|
for (i = 0; i < n; i++) {
|
||||||
mail_to_size += 256;
|
/* remove possible 'mailto:' */
|
||||||
mail_to = xrealloc(mail_to, mail_to_size);
|
if ((p = strstr(mail_list[i], "mailto:")) != NULL)
|
||||||
}
|
strcpy(p, p + 7);
|
||||||
strcat(mail_to, mail_list[i]);
|
|
||||||
strcat(mail_to, ",");
|
|
||||||
|
|
||||||
if ((int) strlen(rcpt_to) + (int) strlen(mail_list[i]) >= rcpt_to_size) {
|
if ((int) strlen(mail_to) + (int) strlen(mail_list[i]) >= mail_to_size) {
|
||||||
rcpt_to_size += 256;
|
mail_to_size += 256;
|
||||||
rcpt_to = xrealloc(rcpt_to, rcpt_to_size);
|
mail_to = xrealloc(mail_to, mail_to_size);
|
||||||
}
|
|
||||||
strcat(rcpt_to, mail_list[i]);
|
|
||||||
strcat(rcpt_to, ",");
|
|
||||||
}
|
}
|
||||||
|
strcat(mail_to, mail_list[i]);
|
||||||
|
strcat(mail_to, ",");
|
||||||
|
|
||||||
|
if ((int) strlen(rcpt_to) + (int) strlen(mail_list[i]) >= rcpt_to_size) {
|
||||||
|
rcpt_to_size += 256;
|
||||||
|
rcpt_to = xrealloc(rcpt_to, rcpt_to_size);
|
||||||
|
}
|
||||||
|
strcat(rcpt_to, mail_list[i]);
|
||||||
|
strcat(rcpt_to, ",");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!getcfg(lbs->name, "Suppress Email to users", str, sizeof(str))
|
if (!getcfg(lbs->name, "Suppress Email to users", str, sizeof(str))
|
||||||
|| atoi(str) == 0) {
|
|| atoi(str) == 0) {
|
||||||
/* go through password file */
|
/* go through password file */
|
||||||
for (index = 0;; index++) {
|
for (index = 0;; index++) {
|
||||||
if (!enum_user_line(lbs, index, user, sizeof(user)))
|
if (!enum_user_line(lbs, index, user, sizeof(user)))
|
||||||
|
break;
|
||||||
|
|
||||||
|
get_user_line(lbs, user, NULL, full_name, user_email, email_notify, NULL);
|
||||||
|
|
||||||
|
for (i = 0; lb_list[i].name[0] && i < 1000; i++)
|
||||||
|
if (strieq(lb_list[i].name, lbs->name))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
get_user_line(lbs, user, NULL, full_name, user_email, email_notify, NULL);
|
if (email_notify[i]) {
|
||||||
|
/* check if user has access to this logbook */
|
||||||
|
if (!check_login_user(lbs, user))
|
||||||
|
continue;
|
||||||
|
|
||||||
for (i = 0; lb_list[i].name[0] && i < 1000; i++)
|
sprintf(str, "\"%s\" <%s>,\r\n\t", full_name, user_email);
|
||||||
if (strieq(lb_list[i].name, lbs->name))
|
if ((int) strlen(mail_to) + (int) strlen(str) >= mail_to_size) {
|
||||||
break;
|
mail_to_size += 256;
|
||||||
|
mail_to = xrealloc(mail_to, mail_to_size);
|
||||||
if (email_notify[i]) {
|
|
||||||
/* check if user has access to this logbook */
|
|
||||||
if (!check_login_user(lbs, user))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
sprintf(str, "\"%s\" <%s>,\r\n\t", full_name, user_email);
|
|
||||||
if ((int) strlen(mail_to) + (int) strlen(str) >= mail_to_size) {
|
|
||||||
mail_to_size += 256;
|
|
||||||
mail_to = xrealloc(mail_to, mail_to_size);
|
|
||||||
}
|
|
||||||
strcat(mail_to, str);
|
|
||||||
|
|
||||||
sprintf(str, "%s,", user_email);
|
|
||||||
if ((int) strlen(rcpt_to) + (int) strlen(str) >= rcpt_to_size) {
|
|
||||||
rcpt_to_size += 256;
|
|
||||||
rcpt_to = xrealloc(rcpt_to, rcpt_to_size);
|
|
||||||
}
|
|
||||||
strcat(rcpt_to, str);
|
|
||||||
}
|
}
|
||||||
|
strcat(mail_to, str);
|
||||||
|
|
||||||
|
sprintf(str, "%s,", user_email);
|
||||||
|
if ((int) strlen(rcpt_to) + (int) strlen(str) >= rcpt_to_size) {
|
||||||
|
rcpt_to_size += 256;
|
||||||
|
rcpt_to = xrealloc(rcpt_to, rcpt_to_size);
|
||||||
|
}
|
||||||
|
strcat(rcpt_to, str);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user