- added method isNotificationEnabled() that does a basic check if email notification is enabled for a site

- simplified level checks in sendNotification(), removed commented out code
This commit is contained in:
Robert Gaggl 2003-10-11 10:40:03 +00:00
parent 6e147b0e32
commit 45fd91573a

View file

@ -230,6 +230,17 @@ function processHref(href) {
} }
/**
* basic check if email notification is enabled for a site
* @param Obj site object
* @return Boolean true if notification is enabled, false otherwise
*/
function isNotificationEnabled() {
if (root.sys_allowEmails == 1 || root.sys_allowEmails == 2 && this.trusted)
return true;
return false;
}
/** /**
* send e-mail notification if necessary * send e-mail notification if necessary
* @param String type of changes (e.g. createStory) * @param String type of changes (e.g. createStory)
@ -244,9 +255,9 @@ function sendNotification(type, obj) {
var m = this.members.get(i); var m = this.members.get(i);
if ((type != "update" && m.user == obj.creator) || (type == "update" && m.user == obj.modifier)) if ((type != "update" && m.user == obj.creator) || (type == "update" && m.user == obj.modifier))
continue; continue;
if (notify == 1 && (m.level == ADMIN || m.level == CONTENTMANAGER) ) if (notify == 1 && m.level >= CONTENTMANAGER)
recipients.push(m.user.email); recipients.push(m.user.email);
if (notify == 2 && (m.level == ADMIN || m.level == CONTENTMANAGER || m.level == CONTRIBUTOR)) else if (notify == 2 && m.level >= CONTRIBUTOR)
recipients.push(m.user.email); recipients.push(m.user.email);
} }
if (recipients.length > 0) { if (recipients.length > 0) {
@ -259,15 +270,6 @@ function sendNotification(type, obj) {
var subject = getMessage("mail.notification"); var subject = getMessage("mail.notification");
var body = this.renderSkinAsString("notificationMail", param); var body = this.renderSkinAsString("notificationMail", param);
sendMail(sender, recipients, subject, body); sendMail(sender, recipients, subject, body);
/*
var mail = new Mail();
mail.setFrom(root.sys_title + "<" + root.sys_email + ">");
mail.setSubject("Notification of site changes");
mail.setText();
for (var i in recipients)
mail.addBCC(recipients[i]);
mail.queue();
*/
} }
return; return;
} }