Implemented "suppress email on edit"

SVN revision: 1722
This commit is contained in:
2006-10-09 20:31:10 +00:00
parent 9fd0c17b55
commit 1618bb2cec
2 changed files with 100 additions and 106 deletions
+5 -5
View File
@@ -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
email notification is always suppressed. The default is <b>0</b>.
</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>
<b><code>Resubmit default = 0|1|2</code></b><br>
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
&lt;n&gt; to <b>6</b>. Default is <b>63</b> (send everything).
</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>
<b><code>Email Encoding = &lt;n&gt;</code></b><br>
Specifies in which encoding an email is sent. &lt;n&gt; is the sum of
+95 -101
View File
@@ -10021,21 +10021,21 @@ void show_edit_form(LOGBOOK * lbs, int message_id, BOOL breply, BOOL bedit, BOOL
}
/* Suppress email check box */
if (!(bedit && !breedit && !bupload && getcfg(lbs->name, "Suppress Email on edit", str, sizeof(str))
&& atoi(str) == 1)) {
if (getcfg(lbs->name, "Suppress default", str, sizeof(str))) {
if (atoi(str) == 0) {
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"));
}
if (bedit)
getcfg(lbs->name, "Suppress Email on edit", str, sizeof(str));
else
getcfg(lbs->name, "Suppress default", str, sizeof(str));
} else {
rsprintf("<input type=\"checkbox\" name=\"suppress\" id=\"suppress\" value=\"1\">");
rsprintf("<label for=\"suppress\">%s</label>\n", loc("Suppress Email notification"));
}
if (atoi(str) == 0) {
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) == 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 */
@@ -19602,8 +19602,6 @@ void submit_elog(LOGBOOK * lbs)
/*---- email notifications ----*/
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 */
mail_param[0] = 0;
@@ -19614,111 +19612,107 @@ void submit_elog(LOGBOOK * lbs)
rcpt_to[0] = 0;
rcpt_to_size = 256;
if (suppress) {
if (suppress != 3)
if (suppress == 1 || suppress == 3) {
if (suppress == 1)
strcpy(mail_param, "?suppress=1");
} else {
if (!(isparam("edit_id")
&& getcfg(lbs->name, "Suppress Email on edit", str, sizeof(str))
&& atoi(str) == 1)) {
/* go throuch "Email xxx" in configuration file */
for (index = mindex = 0; index <= n_attr; index++) {
/* go throuch "Email xxx" in configuration file */
for (index = mindex = 0; index <= n_attr; index++) {
strcpy(ua, attr_list[index]);
btou(ua);
dtou(ua);
strcpy(ua, attr_list[index]);
btou(ua);
dtou(ua);
if (index < n_attr) {
strcpy(str, "Email ");
if (strchr(attr_list[index], ' '))
sprintf(str + strlen(str), "\"%s\"", attr_list[index]);
if (index < n_attr) {
strcpy(str, "Email ");
if (strchr(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
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
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));
}
index--; /* repeat this loop */
} else
sprintf(str, "Email ALL");
strcpy(str2, ua);
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 (isparam(str2)) {
if (strchr(getparam(str2), ' '))
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)
eprintf("\n%s to %s\n\n", str, list);
n = strbreak(list, mail_list, MAX_N_LIST, ",");
for (i = 0; i < n; i++) {
/* remove possible 'mailto:' */
if ((p = strstr(mail_list[i], "mailto:")) != NULL)
strcpy(p, p + 7);
if (verbose)
eprintf("\n%s to %s\n\n", str, list);
if ((int) strlen(mail_to) + (int) strlen(mail_list[i]) >= mail_to_size) {
mail_to_size += 256;
mail_to = xrealloc(mail_to, mail_to_size);
}
strcat(mail_to, mail_list[i]);
strcat(mail_to, ",");
for (i = 0; i < n; i++) {
/* remove possible 'mailto:' */
if ((p = strstr(mail_list[i], "mailto:")) != NULL)
strcpy(p, p + 7);
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 ((int) strlen(mail_to) + (int) strlen(mail_list[i]) >= mail_to_size) {
mail_to_size += 256;
mail_to = xrealloc(mail_to, mail_to_size);
}
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))
|| atoi(str) == 0) {
/* go through password file */
for (index = 0;; index++) {
if (!enum_user_line(lbs, index, user, sizeof(user)))
if (!getcfg(lbs->name, "Suppress Email to users", str, sizeof(str))
|| atoi(str) == 0) {
/* go through password file */
for (index = 0;; index++) {
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;
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++)
if (strieq(lb_list[i].name, lbs->name))
break;
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);
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);
}
}
}