Foren

Home » Liferay Portal » English » 3. Development

Kombinierte Ansicht Flache Ansicht Baumansicht
Threads [ Zurück | Nächste ]
toggle
Tor-Einar Jarnbjo
Expiration date for messages (message board)
4. Mai 2012 03:53
Antwort

Tor-Einar Jarnbjo

Rang: New Member

Nachrichten: 1

Eintrittsdatum: 4. Mai 2012

Neue Beiträge

Am I just missing something obvious, or is there no reasonable or halfway feasible way to add an expiration date to messages in Liferay's message board?

The first problem is how to enter the expiration date in the message editor. The most obvious solution is perhaps an expando attribute, but there seem to be no expando data type for dates (only date & time) and I find no way to set a calculated default value in the expando attribute (e.g. today + 6 months). Even without a default value, a date+time attribute defaults to Jan 1st 1970, 0:00GMT and using the date picker to enter a real expiration date is rather tedious. After entering the expiration date, there is no obvious way to validate it (e.g. restrict it to dates between today and today + 6 months) and when the date is displayed in the message view, the current locale is not used to format the date and time.

Even if I would somehow manage to squeeze the expiration date into an expando attribute, there is further no obvious way to evaluate the expiration date.

It would have been acceptable that the messages are still persisted, but not counted and shown in the MB portlet. The methods in MBThreadServiceUtil to access the messages does however not offer any additional filtering criterias, so I either have to load all messages and do the count/filter operations in Java code (hardly a very clever solution) or I would have to rewrite the entire service stack "bottom-up" and add get or search methods, which are able to forward the filtering to the database.

The preferred solution would be to have a scheduled task, which regularly deletes expired messages completely. Since the MB portlet is supporting scopes (the messages are related to the portlet's scope) and the scheduled task is not run within a portlet context, I would have to get access to the scope id somehow. If I understand the documentation and available discussions on this topic, the default scope should be the community, to which the page belongs. Our "message board page" is on the other hand added on the organization level, and the messages' scope id does not match either the organization id, nor any of the ids of the communities in the organization. Anyone with an idea on how to determine the scope id in this case?
Amos Fong
RE: Expiration date for messages (message board)
8. Mai 2012 23:26
Antwort

Amos Fong

LIFERAY STAFF

Rang: Liferay Legend

Nachrichten: 1844

Eintrittsdatum: 7. Oktober 2008

Neue Beiträge

If I understand the documentation and available discussions on this topic, the default scope should be the community, to which the page belongs. Our "message board page" is on the other hand added on the organization level, and the messages' scope id does not match either the organization id, nor any of the ids of the communities in the organization. Anyone with an idea on how to determine the scope id in this case?


Your understanding is correct. To get the scopeGroupId of the organization, you should get the organization's Group's Id. (ie organization.getGroup().getGroupId()).

Don't think you can do this straight OOTB, this will take some customizing to do what you want. I would create jsp hook, that would calculate a default expiration date (probably through javascript). For validation, you'll need to override either the MBMessageLocalServiceImpl or the EditMessageAction struts action and check it there.

For searching, this field should be indexed by Lucene so you should be able to create a lucene query that will give you the range you need.