use of org.olat.core.commons.services.notifications.Subscriber in project openolat by klemens.
the class DateChooserController method setSubscribers.
public void setSubscribers(List<Subscriber> subscribers) {
String selectedKey = typeSelection.isOneSelected() ? typeSelection.getSelectedKey() : null;
Set<String> types = new HashSet<String>();
for (Subscriber subscriber : subscribers) {
String type = subscriber.getPublisher().getType();
types.add(type);
}
typeKeys = new String[types.size() + 1];
typeValues = new String[types.size() + 1];
typeKeys[0] = "all";
typeValues[0] = translate("news.type.all");
int count = 1;
for (String type : types) {
String typeName = NewControllerFactory.translateResourceableTypeName(type, getLocale());
typeKeys[count] = type;
typeValues[count++] = typeName;
}
typeSelection.setKeysAndValues(typeKeys, typeValues, null);
if (selectedKey != null) {
// select the current key but check if it still exists
for (String typeKey : typeKeys) {
if (typeKey.equals(selectedKey)) {
typeSelection.select(selectedKey, true);
break;
}
}
}
if (!typeSelection.isOneSelected()) {
typeSelection.select("all", true);
}
}
use of org.olat.core.commons.services.notifications.Subscriber in project openolat by klemens.
the class NotificationNewsController method event.
/**
* @see org.olat.core.gui.control.DefaultController#event(org.olat.core.gui.UserRequest,
* org.olat.core.gui.components.Component,
* org.olat.core.gui.control.Event)
*/
@Override
protected void event(UserRequest ureq, Component source, Event event) {
if (source == emailLink) {
// send email to user with the currently visible date
NotificationsManager man = NotificationsManager.getInstance();
List<SubscriptionItem> infoList = new ArrayList<>();
List<Subscriber> subsList = new ArrayList<>();
for (Subscriber subscriber : subsInfoMap.keySet()) {
subsList.add(subscriber);
SubscriptionItem item = man.createSubscriptionItem(subscriber, getLocale(), SubscriptionInfo.MIME_HTML, SubscriptionInfo.MIME_HTML, compareDate);
if (item != null) {
infoList.add(item);
}
}
if (man.sendMailToUserAndUpdateSubscriber(subscriberIdentity, infoList, getTranslator(), subsList)) {
showInfo("email.ok");
} else {
showError("email.nok");
}
}
}
use of org.olat.core.commons.services.notifications.Subscriber in project openolat by klemens.
the class NotificationNewsController method updateNewsDataModel.
/**
* Update the new data model and refresh the GUI
*/
protected List<Subscriber> updateNewsDataModel() {
if (compareDate == null) {
// compare date is mandatory
return Collections.emptyList();
}
List<String> notiTypes = new ArrayList<>();
if (StringHelper.containsNonWhitespace(newsType) && !newsType.equals("all")) {
notiTypes.add(newsType);
}
NotificationsManager man = NotificationsManager.getInstance();
List<Subscriber> subs = man.getSubscribers(subscriberIdentity, notiTypes);
newsVC.contextPut("subs", subs);
subsInfoMap = NotificationHelper.getSubscriptionMap(getLocale(), true, compareDate, subs);
NotificationSubscriptionAndNewsFormatter subsFormatter = new NotificationSubscriptionAndNewsFormatter(getTranslator(), subsInfoMap);
newsVC.contextPut("subsFormatter", subsFormatter);
return subs;
}
use of org.olat.core.commons.services.notifications.Subscriber in project openolat by klemens.
the class NotificationSubscriptionTableDataModel method getValueAt.
/**
* @see org.olat.core.gui.components.table.DefaultTableDataModel#getValueAt(int,
* int)
*/
@Override
public Object getValueAt(int row, int col) {
Subscriber sub = getObject(row);
Publisher pub = sub.getPublisher();
switch(col) {
case 0:
return sub.getKey();
case 1:
String innerType = pub.getType();
return NewControllerFactory.translateResourceableTypeName(innerType, getLocale());
case 2:
String containerType = pub.getResName();
return NewControllerFactory.translateResourceableTypeName(containerType, getLocale());
case 3:
NotificationsHandler handler = NotificationsManager.getInstance().getNotificationsHandler(pub);
if (handler == null) {
return "";
}
String title = handler.createTitleInfo(sub, getLocale());
if (title == null) {
return "";
}
return title;
case 4:
return sub.getCreationDate();
case 5:
return sub.getLatestEmailed();
default:
return "ERROR";
}
}
use of org.olat.core.commons.services.notifications.Subscriber in project openolat by klemens.
the class NotificationsPortletRunController method event.
/**
* @see org.olat.core.gui.control.ControllerEventListener#dispatchEvent(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Controller source, Event event) {
super.event(ureq, source, event);
if (source == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
if (actionid.equals(CMD_LAUNCH)) {
int rowid = te.getRowId();
Subscriber sub = notificationListModel.getSubscriberAt(rowid);
if (actionid.equals(CMD_LAUNCH)) {
NotificationUIFactory.launchSubscriptionResource(ureq, getWindowControl(), sub);
}
}
}
}
}
Aggregations