Hi,
it seems that by default when a user is created the delivery option for receiving announcements by email isn't active.
I would like to configuration Liferay so that by default all users get announcements by email.
1st Method
You can add a ModelListener to Liferay and then you get informed when a new user is created.
With the Plugins SDK it's very simple to achieve.
All you have to do is (also consider tutorials about hooks and how to build them):
<hook>
<model-listener>
<model-listener-class>my.class.path.UserListener</model-listener-class>
<model-name>com.liferay.portal.model.User</model-name>
</model-listener>
</hook>
public class UserListener extends BaseModelListener<User> {
@Override
public void onAfterCreate(User user) throws ModelListenerException {
super.onAfterCreate(user);
final long userId = user.getUserId();
AnnouncementsDeliveryLocalService adls = AnnouncementsDeliveryLocalServiceUtil.getService();
try {
adls.updateDelivery(userId, "general", true, false, true);
adls.updateDelivery(userId, "news", true, false, true);
adls.updateDelivery(userId, "test", false, false, true);
} catch (PortalException e) {
throw new ModelListenerException("Could not update announcement delivery.", e);
} catch (SystemException e) {
throw new ModelListenerException("Could not update announcement delivery.", e);
}
}
}
2nd Method
Edit the below syntex given in tomcat/webapps/root/html/portlet/user_admin/user/announcement_cheakbox.jsp
<aui:input disabled="<%= disabled %>" label="" name="<%= param %>" type="checkbox" value="<%= defaultValue %>" />
into
<aui:input disabled="<%= disabled %>" label="" name="<%= param %>" type="checkbox" value="true" />
it seems that by default when a user is created the delivery option for receiving announcements by email isn't active.
I would like to configuration Liferay so that by default all users get announcements by email.
1st Method
You can add a ModelListener to Liferay and then you get informed when a new user is created.
With the Plugins SDK it's very simple to achieve.
All you have to do is (also consider tutorials about hooks and how to build them):
1. Create the file liferay-hooks.xml indocroot/WEB_INF
<hook>
<model-listener>
<model-listener-class>my.class.path.UserListener</model-listener-class>
<model-name>com.liferay.portal.model.User</model-name>
</model-listener>
</hook>
2. Create the class UserListener.java in docroot/WEB-INF/src/my/class/path
public class UserListener extends BaseModelListener<User> {
@Override
public void onAfterCreate(User user) throws ModelListenerException {
super.onAfterCreate(user);
final long userId = user.getUserId();
AnnouncementsDeliveryLocalService adls = AnnouncementsDeliveryLocalServiceUtil.getService();
try {
adls.updateDelivery(userId, "general", true, false, true);
adls.updateDelivery(userId, "news", true, false, true);
adls.updateDelivery(userId, "test", false, false, true);
} catch (PortalException e) {
throw new ModelListenerException("Could not update announcement delivery.", e);
} catch (SystemException e) {
throw new ModelListenerException("Could not update announcement delivery.", e);
}
}
}
2nd Method
Edit the below syntex given in tomcat/webapps/root/html/portlet/user_admin/user/announcement_cheakbox.jsp
<aui:input disabled="<%= disabled %>" label="" name="<%= param %>" type="checkbox" value="<%= defaultValue %>" />
into
<aui:input disabled="<%= disabled %>" label="" name="<%= param %>" type="checkbox" value="true" />
No comments:
Post a Comment