mirror of
https://gitea.psi.ch/ELOG/elog.git
synced 2026-09-14 20:33:48 +00:00
Added 'email attributes' option
SVN revision: 1430
This commit is contained in:
parent
b4167331ac
commit
b33477f161
@ -1541,6 +1541,7 @@ individual logbook sections, one has to log in to each logbook separately.<p>
|
|||||||
<LI><b><code>Use Email Heading Edit = <string></code></b>
|
<LI><b><code>Use Email Heading Edit = <string></code></b>
|
||||||
<LI><b><code>Omit Email To = 0|1</code></b>
|
<LI><b><code>Omit Email To = 0|1</code></b>
|
||||||
<LI><b><code>Suppress Email to users = 0|1</code></b>
|
<LI><b><code>Suppress Email to users = 0|1</code></b>
|
||||||
|
<LI><b><code>Email attributes = <list></code></b>
|
||||||
|
|
||||||
</ul>
|
</ul>
|
||||||
<p>
|
<p>
|
||||||
@ -1555,43 +1556,44 @@ contain attributes via the <b>"$"</b> substitution. If a logbook contains for
|
|||||||
example an attribute <i>name</i> which contains email names, then one can
|
example an attribute <i>name</i> which contains email names, then one can
|
||||||
put <i>$name@domain</i> to form a valid email address.<p>
|
put <i>$name@domain</i> to form a valid email address.<p>
|
||||||
|
|
||||||
Multiple <b><code>Email xxx</code></b > statements may occur in a configuration
|
Multiple <b><code>Email xxx</code></b > statements may occur in a configuration
|
||||||
file. If either the attribute or the value contains one or more blanks the string
|
file. If either the attribute or the value contains one or more blanks the
|
||||||
must be enclosed with quotation marks, as in:
|
string must be enclosed with quotation marks, as in: <p> <ul><code>Email type
|
||||||
<p>
|
"Normal routine" = ...</code></ul> <p> The statement <b><code>Email All =
|
||||||
<ul><code>Email type "Normal routine" = ...</code></ul>
|
<list></code></b> sends an email notification independent of the type and
|
||||||
<p>
|
category. The <b><code>Use Email Subject = <string></b></code> statement
|
||||||
The statement <b><code>Email All = <list></code></b> sends an
|
specifies which text is used as the email subject. The text can contain
|
||||||
email notification independent of the type and category. The <b><code>Use
|
<b><code>$<attribute> </code></b>statements which are substituted with the
|
||||||
Email Subject = <string></b></code> statement specifies which text is
|
current value of that attribute. For a full list of possible substitutions, see
|
||||||
used as the email subject. The text can contain <b><code>$<attribute>
|
the "<I>Subst <attribute></I>" option. The <b><code>Use Email Heading =
|
||||||
</code></b>statements which are substituted with the current value of that
|
<string></code></b> specifies the text for the email heading line. Default
|
||||||
attribute. For a full list of possible substitutions, see the
|
is <i>"A new entry has been submitted on [host]"</i>. The option <b><code>Use
|
||||||
"<I>Subst <attribute></I>" option. The <b><code>Use Email Heading
|
Email Heading Edit = <string></code></b> works the same way for updated
|
||||||
= <string></code></b> specifies the text for the email heading line.
|
(edited) entries.<p>
|
||||||
Default is <i>"A new entry has been submitted on [host]"</i>. The option
|
|
||||||
<b><code>Use Email Heading Edit = <string></code></b> works the same
|
|
||||||
way for updated (edited) entries.<p>
|
|
||||||
|
|
||||||
The option <b><code>Use Email From = <string>
|
The option <b><code>Use Email From = <string> </code></b> is used for the
|
||||||
</code></b> is used for the "<I>From:</I>" field in the email.
|
"<I>From:</I>" field in the email. Since more and more email servers do not
|
||||||
Since more and more email servers do not accept invalid <I>"From:"</I> addresses in
|
accept invalid <I>"From:"</I> addresses in order to reduce spam mail, it might
|
||||||
order to reduce spam mail, it might be important that a "real" email address is used in
|
be important that a "real" email address is used in the <I>"From:"</I> field. By
|
||||||
the <I>"From:"</I> field. By default, the email address of the currently logged in
|
default, the email address of the currently logged in user is used for the
|
||||||
user is used for the <I>"From:"</I> field. If no user is logged in, or the current
|
<I>"From:"</I> field. If no user is logged in, or the current user has not
|
||||||
user has not specified a email address in the password database, the setting
|
specified a email address in the password database, the setting of the option
|
||||||
of the option <b><code>Use Email From</code></b> is used for the "<I>From:</I>" field.
|
<b><code>Use Email From</code></b> is used for the "<I>From:</I>" field. Only if
|
||||||
Only if this option is not specified, a generic address <I>ELOG@<hostname></I>
|
this option is not specified, a generic address <I>ELOG@<hostname></I> is
|
||||||
is used, which might be rejected by the SMTP server however.<p>
|
used, which might be rejected by the SMTP server however.<p>
|
||||||
|
|
||||||
If the flag <b><code>
|
If the flag <b><code>Omit Email To</b></code> is set to <b>1</b>, the <i>To:</i>
|
||||||
Omit Email To</b></code> is set to <b>1</b>, the <i>To:</i> field in the email is
|
field in the email is left empty instead set to the real email address of the
|
||||||
left empty instead set to the real email address of the recipients. This can
|
recipients. This can be useful if one recipient should not see the email
|
||||||
be useful if one recipient should not see the email addresses of the other recipients.
|
addresses of the other recipients. <p> The flag <b><code>Suppress Email to
|
||||||
<p>
|
users</b></code> can be set to <b>"1"</b> if email should only be sent to the
|
||||||
The flag <b><code>Suppress Email to users</b></code> can be set to <b>"1"</b> if email should
|
recipients of the <b><code>Email <attribute> <value> =
|
||||||
only be sent to the recipients of the <b><code>Email <attribute> <value> = <list></code></b>
|
<list></code></b> statements but not to the users who have registerd for
|
||||||
statements but not to the users who have registerd for automatic email notification.<p>
|
automatic email notification.<p>
|
||||||
|
|
||||||
|
If one wants to send only some attributes but not all in an email notification,
|
||||||
|
one can use the option <b><code>Email attributes = <list></code></b>,
|
||||||
|
where a subset of the attributes can be specified as well as their order.
|
||||||
|
|
||||||
<a name="flags"><hr>
|
<a name="flags"><hr>
|
||||||
<div class=section> Flags </div>
|
<div class=section> Flags </div>
|
||||||
@ -1717,6 +1719,22 @@ 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>.
|
only for new messages. The default is <b>0</b>.
|
||||||
<p>
|
<p>
|
||||||
|
|
||||||
|
<li><b><code>Email Encoding = <n></code></b>
|
||||||
|
</br>
|
||||||
|
Specifies in which encoding an email is sent. <n> is the sum of following
|
||||||
|
flags:<br>
|
||||||
|
|
||||||
|
<ul>
|
||||||
|
<li>1 : Plain text
|
||||||
|
<li>2 : HTML in the form of the plain text, but with ELCode interpreted
|
||||||
|
<li>4 : Full HTML page as shown in elog
|
||||||
|
</ul>
|
||||||
|
|
||||||
|
So to send email in plain text and full HTML, set <n>
|
||||||
|
to <b>5</b>. Most email clients have the possibility then to switch from one view
|
||||||
|
to the other. Default is <b>2</b> (send everything).
|
||||||
|
<p>
|
||||||
|
|
||||||
<li><b><code>Back to main = 0|1</code></b>
|
<li><b><code>Back to main = 0|1</code></b>
|
||||||
</br>
|
</br>
|
||||||
If this flag is <b>1</b>, the "<I>List</I>" button takes you back to the logbook
|
If this flag is <b>1</b>, the "<I>List</I>" button takes you back to the logbook
|
||||||
|
|||||||
103
src/elogd.c
103
src/elogd.c
@ -6,6 +6,9 @@
|
|||||||
Contents: Web server program for Electronic Logbook ELOG
|
Contents: Web server program for Electronic Logbook ELOG
|
||||||
|
|
||||||
$Log$
|
$Log$
|
||||||
|
Revision 1.704 2005/07/20 18:53:00 ritt
|
||||||
|
Added 'email attributes' option
|
||||||
|
|
||||||
Revision 1.703 2005/07/16 10:18:17 ritt
|
Revision 1.703 2005/07/16 10:18:17 ritt
|
||||||
Added '\' as escape character for HTML and ELCode tags
|
Added '\' as escape character for HTML and ELCode tags
|
||||||
|
|
||||||
@ -3442,7 +3445,7 @@ void check_config_file(BOOL force)
|
|||||||
parse_config_file(config_file);
|
parse_config_file(config_file);
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
eprintf("Cannot stat() config file; %s\n", strerror(errno));
|
eprintf("Cannot stat() config file \"%s\": %s\n", config_file, strerror(errno));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*-------------------------------------------------------------------*/
|
/*-------------------------------------------------------------------*/
|
||||||
@ -18162,9 +18165,9 @@ void show_elog_thread(LOGBOOK * lbs, int message_id)
|
|||||||
void format_email_text(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], int old_mail,
|
void format_email_text(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], int old_mail,
|
||||||
char *url, char *mail_text)
|
char *url, char *mail_text)
|
||||||
{
|
{
|
||||||
int j, k, flags;
|
int i, j, k, flags, n_email_attr, attr_index[MAX_N_ATTR];
|
||||||
char str[NAME_LENGTH + 100], str2[256], mail_from[256], format[256];
|
char str[NAME_LENGTH + 100], str2[256], mail_from[256], format[256],
|
||||||
char comment[256];
|
list[MAX_N_ATTR][NAME_LENGTH], comment[256];
|
||||||
time_t ltime;
|
time_t ltime;
|
||||||
struct tm *pts;
|
struct tm *pts;
|
||||||
|
|
||||||
@ -18198,33 +18201,53 @@ void format_email_text(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], int
|
|||||||
sprintf(mail_text + strlen(mail_text), "%s : %s\r\n", loc("Logbook"), lbs->name);
|
sprintf(mail_text + strlen(mail_text), "%s : %s\r\n", loc("Logbook"), lbs->name);
|
||||||
|
|
||||||
if (flags & 2) {
|
if (flags & 2) {
|
||||||
for (j = 0; j < lbs->n_attr; j++) {
|
|
||||||
|
if (getcfg(lbs->name, "Email attributes", str, sizeof(str))) {
|
||||||
|
n_email_attr = strbreak(str, list, MAX_N_ATTR, ",");
|
||||||
|
for (i = 0; i < n_email_attr; i++) {
|
||||||
|
for (j = 0; j < lbs->n_attr; j++)
|
||||||
|
if (strieq(attr_list[j], list[i]))
|
||||||
|
break;
|
||||||
|
if (!strieq(attr_list[j], list[i]))
|
||||||
|
/* attribute not found */
|
||||||
|
j = 0;
|
||||||
|
attr_index[i] = j;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < lbs->n_attr; i++)
|
||||||
|
attr_index[i] = i;
|
||||||
|
n_email_attr = lbs->n_attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < n_email_attr; j++) {
|
||||||
|
|
||||||
|
i = attr_index[j];
|
||||||
strcpy(str, " ");
|
strcpy(str, " ");
|
||||||
memcpy(str, attr_list[j], strlen(attr_list[j]));
|
memcpy(str, attr_list[i], strlen(attr_list[i]));
|
||||||
|
|
||||||
comment[0] = 0;
|
comment[0] = 0;
|
||||||
if (attr_flags[j] & AF_ICON) {
|
if (attr_flags[i] & AF_ICON) {
|
||||||
|
|
||||||
sprintf(str2, "Icon comment %s", attrib[j]);
|
sprintf(str2, "Icon comment %s", attrib[i]);
|
||||||
getcfg(lbs->name, str2, comment, sizeof(comment));
|
getcfg(lbs->name, str2, comment, sizeof(comment));
|
||||||
|
|
||||||
} else if (attr_flags[j] & AF_DATE) {
|
} else if (attr_flags[i] & AF_DATE) {
|
||||||
|
|
||||||
if (!getcfg(lbs->name, "Date format", format, sizeof(format)))
|
if (!getcfg(lbs->name, "Date format", format, sizeof(format)))
|
||||||
strcpy(format, DEFAULT_DATE_FORMAT);
|
strcpy(format, DEFAULT_DATE_FORMAT);
|
||||||
|
|
||||||
ltime = atoi(attrib[j]);
|
ltime = atoi(attrib[i]);
|
||||||
pts = localtime(<ime);
|
pts = localtime(<ime);
|
||||||
if (ltime == 0)
|
if (ltime == 0)
|
||||||
strcpy(comment, "-");
|
strcpy(comment, "-");
|
||||||
else
|
else
|
||||||
my_strftime(comment, sizeof(str), format, pts);
|
my_strftime(comment, sizeof(str), format, pts);
|
||||||
} else if (attr_flags[j] & AF_DATETIME) {
|
} else if (attr_flags[i] & AF_DATETIME) {
|
||||||
|
|
||||||
if (!getcfg(lbs->name, "Time format", format, sizeof(format)))
|
if (!getcfg(lbs->name, "Time format", format, sizeof(format)))
|
||||||
strcpy(format, DEFAULT_TIME_FORMAT);
|
strcpy(format, DEFAULT_TIME_FORMAT);
|
||||||
|
|
||||||
ltime = atoi(attrib[j]);
|
ltime = atoi(attrib[i]);
|
||||||
pts = localtime(<ime);
|
pts = localtime(<ime);
|
||||||
if (ltime == 0)
|
if (ltime == 0)
|
||||||
strcpy(comment, "-");
|
strcpy(comment, "-");
|
||||||
@ -18233,10 +18256,10 @@ void format_email_text(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], int
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!comment[0])
|
if (!comment[0])
|
||||||
strcpy(comment, attrib[j]);
|
strcpy(comment, attrib[i]);
|
||||||
|
|
||||||
if (strieq(attr_options[j][0], "boolean"))
|
if (strieq(attr_options[i][0], "boolean"))
|
||||||
strcpy(comment, atoi(attrib[j]) ? loc("Yes") : loc("No"));
|
strcpy(comment, atoi(attrib[i]) ? loc("Yes") : loc("No"));
|
||||||
|
|
||||||
for (k = strlen(str) - 1; k > 0; k--)
|
for (k = strlen(str) - 1; k > 0; k--)
|
||||||
if (str[k] != ' ')
|
if (str[k] != ' ')
|
||||||
@ -18267,9 +18290,9 @@ void format_email_text(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], int
|
|||||||
void format_email_html(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], int old_mail,
|
void format_email_html(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], int old_mail,
|
||||||
char *encoding, char *url, char *mail_text)
|
char *encoding, char *url, char *mail_text)
|
||||||
{
|
{
|
||||||
int j, k, flags;
|
int i, j, k, flags, n_email_attr, attr_index[MAX_N_ATTR];
|
||||||
char str[NAME_LENGTH + 100], str2[256], mail_from[256], format[256];
|
char str[NAME_LENGTH + 100], str2[256], mail_from[256], format[256],
|
||||||
char comment[256];
|
list[MAX_N_ATTR][NAME_LENGTH], comment[256];
|
||||||
time_t ltime;
|
time_t ltime;
|
||||||
struct tm *pts;
|
struct tm *pts;
|
||||||
|
|
||||||
@ -18310,33 +18333,53 @@ void format_email_html(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], int
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (flags & 2) {
|
if (flags & 2) {
|
||||||
for (j = 0; j < lbs->n_attr; j++) {
|
|
||||||
|
if (getcfg(lbs->name, "Email attributes", str, sizeof(str))) {
|
||||||
|
n_email_attr = strbreak(str, list, MAX_N_ATTR, ",");
|
||||||
|
for (i = 0; i < n_email_attr; i++) {
|
||||||
|
for (j = 0; j < lbs->n_attr; j++)
|
||||||
|
if (strieq(attr_list[j], list[i]))
|
||||||
|
break;
|
||||||
|
if (!strieq(attr_list[j], list[i]))
|
||||||
|
/* attribute not found */
|
||||||
|
j = 0;
|
||||||
|
attr_index[i] = j;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (i = 0; i < lbs->n_attr; i++)
|
||||||
|
attr_index[i] = i;
|
||||||
|
n_email_attr = lbs->n_attr;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (j = 0; j < n_email_attr; j++) {
|
||||||
|
|
||||||
|
i = attr_index[j];
|
||||||
strcpy(str, " ");
|
strcpy(str, " ");
|
||||||
memcpy(str, attr_list[j], strlen(attr_list[j]));
|
memcpy(str, attr_list[i], strlen(attr_list[i]));
|
||||||
|
|
||||||
comment[0] = 0;
|
comment[0] = 0;
|
||||||
if (attr_flags[j] & AF_ICON) {
|
if (attr_flags[i] & AF_ICON) {
|
||||||
|
|
||||||
sprintf(str2, "Icon comment %s", attrib[j]);
|
sprintf(str2, "Icon comment %s", attrib[i]);
|
||||||
getcfg(lbs->name, str2, comment, sizeof(comment));
|
getcfg(lbs->name, str2, comment, sizeof(comment));
|
||||||
|
|
||||||
} else if (attr_flags[j] & AF_DATE) {
|
} else if (attr_flags[i] & AF_DATE) {
|
||||||
|
|
||||||
if (!getcfg(lbs->name, "Date format", format, sizeof(format)))
|
if (!getcfg(lbs->name, "Date format", format, sizeof(format)))
|
||||||
strcpy(format, DEFAULT_DATE_FORMAT);
|
strcpy(format, DEFAULT_DATE_FORMAT);
|
||||||
|
|
||||||
ltime = atoi(attrib[j]);
|
ltime = atoi(attrib[i]);
|
||||||
pts = localtime(<ime);
|
pts = localtime(<ime);
|
||||||
if (ltime == 0)
|
if (ltime == 0)
|
||||||
strcpy(comment, "-");
|
strcpy(comment, "-");
|
||||||
else
|
else
|
||||||
my_strftime(comment, sizeof(str), format, pts);
|
my_strftime(comment, sizeof(str), format, pts);
|
||||||
} else if (attr_flags[j] & AF_DATETIME) {
|
} else if (attr_flags[i] & AF_DATETIME) {
|
||||||
|
|
||||||
if (!getcfg(lbs->name, "Time format", format, sizeof(format)))
|
if (!getcfg(lbs->name, "Time format", format, sizeof(format)))
|
||||||
strcpy(format, DEFAULT_TIME_FORMAT);
|
strcpy(format, DEFAULT_TIME_FORMAT);
|
||||||
|
|
||||||
ltime = atoi(attrib[j]);
|
ltime = atoi(attrib[i]);
|
||||||
pts = localtime(<ime);
|
pts = localtime(<ime);
|
||||||
if (ltime == 0)
|
if (ltime == 0)
|
||||||
strcpy(comment, "-");
|
strcpy(comment, "-");
|
||||||
@ -18345,16 +18388,16 @@ void format_email_html(LOGBOOK * lbs, char attrib[MAX_N_ATTR][NAME_LENGTH], int
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!comment[0])
|
if (!comment[0])
|
||||||
strcpy(comment, attrib[j]);
|
strcpy(comment, attrib[i]);
|
||||||
|
|
||||||
if (strieq(attr_options[j][0], "boolean"))
|
if (strieq(attr_options[i][0], "boolean"))
|
||||||
strcpy(comment, atoi(attrib[j]) ? loc("Yes") : loc("No"));
|
strcpy(comment, atoi(attrib[i]) ? loc("Yes") : loc("No"));
|
||||||
|
|
||||||
for (k = strlen(str) - 1; k > 0; k--)
|
for (k = strlen(str) - 1; k > 0; k--)
|
||||||
if (str[k] != ' ')
|
if (str[k] != ' ')
|
||||||
break;
|
break;
|
||||||
|
|
||||||
sprintf(mail_text + strlen(mail_text), "<tr><td bgcolor=\"#CCCCFF\">%s</td>", attr_list[j]);
|
sprintf(mail_text + strlen(mail_text), "<tr><td bgcolor=\"#CCCCFF\">%s</td>", attr_list[i]);
|
||||||
sprintf(mail_text + strlen(mail_text), "<td bgcolor=\"#DDEEBB\">%s</td></tr>\r\n", comment);
|
sprintf(mail_text + strlen(mail_text), "<td bgcolor=\"#DDEEBB\">%s</td></tr>\r\n", comment);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user