001: /*
002: * File : $Source: /usr/local/cvs/alkacon/com.alkacon.opencms.newsletter/src/com/alkacon/opencms/newsletter/admin/CmsSubscribersList.java,v $
003: * Date : $Date: 2007-11-30 11:57:27 $
004: * Version: $Revision: 1.6 $
005: *
006: * This file is part of the Alkacon OpenCms Add-On Module Package
007: *
008: * Copyright (c) 2007 Alkacon Software GmbH (http://www.alkacon.com)
009: *
010: * The Alkacon OpenCms Add-On Module Package is free software:
011: * you can redistribute it and/or modify
012: * it under the terms of the GNU General Public License as published by
013: * the Free Software Foundation, either version 3 of the License, or
014: * (at your option) any later version.
015: *
016: * The Alkacon OpenCms Add-On Module Package is distributed
017: * in the hope that it will be useful,
018: * but WITHOUT ANY WARRANTY; without even the implied warranty of
019: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
020: * GNU General Public License for more details.
021: *
022: * You should have received a copy of the GNU General Public License
023: * along with the Alkacon OpenCms Add-On Module Package.
024: * If not, see http://www.gnu.org/licenses/.
025: *
026: * For further information about Alkacon Software GmbH, please see the
027: * company website: http://www.alkacon.com.
028: *
029: * For further information about OpenCms, please see the
030: * project website: http://www.opencms.org.
031: */
032:
033: package com.alkacon.opencms.newsletter.admin;
034:
035: import org.opencms.file.CmsUser;
036: import org.opencms.jsp.CmsJspActionElement;
037: import org.opencms.main.CmsException;
038: import org.opencms.main.OpenCms;
039: import org.opencms.util.CmsStringUtil;
040: import org.opencms.workplace.list.CmsListColumnDefinition;
041: import org.opencms.workplace.list.CmsListDefaultAction;
042: import org.opencms.workplace.list.CmsListDirectAction;
043: import org.opencms.workplace.list.CmsListItemDetails;
044: import org.opencms.workplace.list.CmsListItemDetailsFormatter;
045: import org.opencms.workplace.list.CmsListMetadata;
046: import org.opencms.workplace.list.CmsListMultiAction;
047: import org.opencms.workplace.list.CmsListSearchAction;
048: import org.opencms.workplace.list.I_CmsListDirectAction;
049: import org.opencms.workplace.tools.accounts.A_CmsUsersList;
050:
051: import java.util.List;
052:
053: import javax.servlet.http.HttpServletRequest;
054: import javax.servlet.http.HttpServletResponse;
055: import javax.servlet.jsp.PageContext;
056:
057: /**
058: * Subscribers management view.<p>
059: *
060: * @author Michael Moossen
061: * @author Andreas Zahner
062: *
063: * @version $Revision: 1.6 $
064: *
065: * @since 7.0.3
066: */
067: public class CmsSubscribersList extends A_CmsUsersList {
068:
069: /** List id constant. */
070: public static final String LIST_ID = "llu";
071:
072: /**
073: * Public constructor.<p>
074: *
075: * @param jsp an initialized JSP action element
076: */
077: public CmsSubscribersList(CmsJspActionElement jsp) {
078:
079: super (jsp, LIST_ID, Messages.get().container(
080: Messages.GUI_SUBSCRIBERS_LIST_NAME_0));
081: }
082:
083: /**
084: * Public constructor with JSP variables.<p>
085: *
086: * @param context the JSP page context
087: * @param req the JSP request
088: * @param res the JSP response
089: */
090: public CmsSubscribersList(PageContext context,
091: HttpServletRequest req, HttpServletResponse res) {
092:
093: this (new CmsJspActionElement(context, req, res));
094: }
095:
096: /**
097: * @see org.opencms.workplace.tools.accounts.A_CmsUsersList#getGroupIcon()
098: */
099: protected String getGroupIcon() {
100:
101: return "tools/newsletter/buttons/mailinglist.png";
102: }
103:
104: /**
105: * @see org.opencms.workplace.tools.accounts.A_CmsUsersList#getUsers()
106: */
107: protected List getUsers() throws CmsException {
108:
109: return OpenCms.getOrgUnitManager().getUsers(getCms(),
110: getParamOufqn(), false);
111: }
112:
113: /**
114: * @see org.opencms.workplace.tools.accounts.A_CmsUsersList#readUser(java.lang.String)
115: */
116: protected CmsUser readUser(String name) throws CmsException {
117:
118: return getCms().readUser(name);
119: }
120:
121: /**
122: * @see org.opencms.workplace.tools.accounts.A_CmsUsersList#setColumns(org.opencms.workplace.list.CmsListMetadata)
123: */
124: protected void setColumns(CmsListMetadata metadata) {
125:
126: super .setColumns(metadata);
127:
128: metadata.getColumnDefinition(LIST_COLUMN_ROLE)
129: .setVisible(false);
130: metadata.getColumnDefinition(LIST_COLUMN_LOGIN).setVisible(
131: false);
132: metadata.getColumnDefinition(LIST_COLUMN_EMAIL).setVisible(
133: false);
134: metadata.getColumnDefinition(LIST_COLUMN_LASTLOGIN).setVisible(
135: false);
136: metadata.getColumnDefinition(LIST_COLUMN_NAME)
137: .setVisible(false);
138:
139: CmsListColumnDefinition viewCol = metadata
140: .getColumnDefinition(LIST_COLUMN_EDIT);
141: viewCol.setHelpText(Messages.get().container(
142: Messages.GUI_SUBSCRIBERS_LIST_COLS_ICON_HELP_0));
143:
144: CmsListColumnDefinition deleteCol = metadata
145: .getColumnDefinition(LIST_COLUMN_DELETE);
146: deleteCol.setHelpText(Messages.get().container(
147: Messages.GUI_SUBSCRIBERS_LIST_COLS_DELETE_HELP_0));
148:
149: CmsListColumnDefinition mailinglistsCol = metadata
150: .getColumnDefinition(LIST_COLUMN_GROUPS);
151: mailinglistsCol.setName(Messages.get().container(
152: Messages.GUI_SUBSCRIBERS_LIST_COLS_MAILINGLISTS_0));
153: mailinglistsCol
154: .setHelpText(Messages
155: .get()
156: .container(
157: Messages.GUI_SUBSCRIBERS_LIST_COLS_MAILINGLISTS_HELP_0));
158:
159: I_CmsListDirectAction mailinglistsAction = mailinglistsCol
160: .getDirectAction(LIST_ACTION_GROUPS);
161: mailinglistsAction
162: .setName(Messages
163: .get()
164: .container(
165: Messages.GUI_SUBSCRIBERS_LIST_ACTION_MAILINGLISTS_NAME_0));
166: mailinglistsAction
167: .setHelpText(Messages
168: .get()
169: .container(
170: Messages.GUI_SUBSCRIBERS_LIST_ACTION_MAILINGLISTS_HELP_0));
171:
172: CmsListColumnDefinition displayCol = metadata
173: .getColumnDefinition(LIST_COLUMN_DISPLAY);
174: displayCol.setName(Messages.get().container(
175: Messages.GUI_SUBSCRIBERS_LIST_COLS_EMAIL_0));
176: displayCol.setWidth("100%");
177:
178: CmsListDefaultAction defEditAction = displayCol
179: .getDefaultAction(LIST_DEFACTION_EDIT);
180: defEditAction.setName(Messages.get().container(
181: Messages.GUI_SUBSCRIBERS_LIST_DEFACTION_EDIT_NAME_0));
182: defEditAction.setHelpText(Messages.get().container(
183: Messages.GUI_SUBSCRIBERS_LIST_DEFACTION_EDIT_HELP_0));
184:
185: CmsListColumnDefinition activateCol = metadata
186: .getColumnDefinition(LIST_COLUMN_ACTIVATE);
187: activateCol.setHelpText(Messages.get().container(
188: Messages.GUI_SUBSCRIBERS_LIST_COLS_ACTIVATE_HELP_0));
189:
190: I_CmsListDirectAction activateAction = activateCol
191: .getDirectAction(LIST_ACTION_ACTIVATE);
192: activateAction.setHelpText(Messages.get().container(
193: Messages.GUI_SUBSCRIBERS_LIST_ACTION_ACTIVATE_HELP_0));
194: activateAction.setConfirmationMessage(Messages.get().container(
195: Messages.GUI_SUBSCRIBERS_LIST_ACTION_ACTIVATE_CONF_0));
196:
197: I_CmsListDirectAction deactivateAction = activateCol
198: .getDirectAction(LIST_ACTION_DEACTIVATE);
199: deactivateAction
200: .setHelpText(Messages
201: .get()
202: .container(
203: Messages.GUI_SUBSCRIBERS_LIST_ACTION_DEACTIVATE_HELP_0));
204: deactivateAction
205: .setConfirmationMessage(Messages
206: .get()
207: .container(
208: Messages.GUI_SUBSCRIBERS_LIST_ACTION_DEACTIVATE_CONF_0));
209: }
210:
211: /**
212: * @see org.opencms.workplace.tools.accounts.A_CmsUsersList#setDeleteAction(org.opencms.workplace.list.CmsListColumnDefinition)
213: */
214: protected void setDeleteAction(CmsListColumnDefinition deleteCol) {
215:
216: CmsListDirectAction deleteAction = new CmsListDirectAction(
217: LIST_ACTION_DELETE);
218: deleteAction.setName(Messages.get().container(
219: Messages.GUI_SUBSCRIBERS_LIST_ACTION_DELETE_NAME_0));
220: deleteAction.setHelpText(Messages.get().container(
221: Messages.GUI_SUBSCRIBERS_LIST_ACTION_DELETE_HELP_0));
222: deleteAction.setConfirmationMessage(Messages.get().container(
223: Messages.GUI_SUBSCRIBERS_LIST_ACTION_DELETE_CONF_0));
224: deleteAction.setIconPath(ICON_DELETE);
225: deleteCol.addDirectAction(deleteAction);
226: }
227:
228: /**
229: * @see org.opencms.workplace.tools.accounts.A_CmsUsersList#setEditAction(org.opencms.workplace.list.CmsListColumnDefinition)
230: */
231: protected void setEditAction(CmsListColumnDefinition editCol) {
232:
233: CmsListDirectAction editAction = new CmsListDirectAction(
234: LIST_ACTION_EDIT);
235: editAction.setName(Messages.get().container(
236: Messages.GUI_SUBSCRIBERS_LIST_DEFACTION_EDIT_NAME_0));
237: editAction.setHelpText(Messages.get().container(
238: Messages.GUI_SUBSCRIBERS_LIST_DEFACTION_EDIT_HELP_0));
239: editAction
240: .setIconPath("tools/newsletter/buttons/subscriber.png");
241: editCol.addDirectAction(editAction);
242: }
243:
244: /**
245: * @see org.opencms.workplace.tools.accounts.A_CmsUsersList#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
246: */
247: protected void setIndependentActions(CmsListMetadata metadata) {
248:
249: // add mailing lists details
250: CmsListItemDetails mailinglistsDetails = new CmsListItemDetails(
251: LIST_DETAIL_GROUPS);
252: mailinglistsDetails.setAtColumn(LIST_COLUMN_DISPLAY);
253: mailinglistsDetails.setVisible(false);
254: mailinglistsDetails
255: .setShowActionName(Messages
256: .get()
257: .container(
258: Messages.GUI_SUBSCRIBERS_DETAIL_SHOW_MAILINGLISTS_NAME_0));
259: mailinglistsDetails
260: .setShowActionHelpText(Messages
261: .get()
262: .container(
263: Messages.GUI_SUBSCRIBERS_DETAIL_SHOW_MAILINGLISTS_HELP_0));
264: mailinglistsDetails
265: .setHideActionName(Messages
266: .get()
267: .container(
268: Messages.GUI_SUBSCRIBERS_DETAIL_HIDE_MAILINGLISTS_NAME_0));
269: mailinglistsDetails
270: .setHideActionHelpText(Messages
271: .get()
272: .container(
273: Messages.GUI_SUBSCRIBERS_DETAIL_HIDE_MAILINGLISTS_HELP_0));
274: mailinglistsDetails.setName(Messages.get().container(
275: Messages.GUI_SUBSCRIBERS_DETAIL_MAILINGLISTS_NAME_0));
276: mailinglistsDetails
277: .setFormatter(new CmsListItemDetailsFormatter(
278: Messages
279: .get()
280: .container(
281: Messages.GUI_SUBSCRIBERS_DETAIL_MAILINGLISTS_NAME_0)));
282: metadata.addItemDetails(mailinglistsDetails);
283:
284: // makes the list searchable
285: CmsListSearchAction searchAction = new CmsListSearchAction(
286: metadata.getColumnDefinition(LIST_COLUMN_DISPLAY));
287: searchAction.addColumn(metadata
288: .getColumnDefinition(LIST_COLUMN_NAME));
289: metadata.setSearchAction(searchAction);
290: }
291:
292: /**
293: * @see org.opencms.workplace.tools.accounts.A_CmsUsersList#setMultiActions(org.opencms.workplace.list.CmsListMetadata)
294: */
295: protected void setMultiActions(CmsListMetadata metadata) {
296:
297: // add delete multi action
298: CmsListMultiAction deleteMultiAction = new CmsListMultiAction(
299: LIST_MACTION_DELETE);
300: deleteMultiAction.setName(Messages.get().container(
301: Messages.GUI_SUBSCRIBERS_LIST_MACTION_DELETE_NAME_0));
302: deleteMultiAction.setHelpText(Messages.get().container(
303: Messages.GUI_SUBSCRIBERS_LIST_MACTION_DELETE_HELP_0));
304: deleteMultiAction
305: .setConfirmationMessage(Messages
306: .get()
307: .container(
308: Messages.GUI_SUBSCRIBERS_LIST_MACTION_DELETE_CONF_0));
309: deleteMultiAction.setIconPath(ICON_MULTI_DELETE);
310: metadata.addMultiAction(deleteMultiAction);
311:
312: // add the activate user multi action
313: CmsListMultiAction activateUser = new CmsListMultiAction(
314: LIST_MACTION_ACTIVATE);
315: activateUser.setName(Messages.get().container(
316: Messages.GUI_SUBSCRIBERS_LIST_MACTION_ACTIVATE_NAME_0));
317: activateUser.setHelpText(Messages.get().container(
318: Messages.GUI_SUBSCRIBERS_LIST_MACTION_ACTIVATE_HELP_0));
319: activateUser.setConfirmationMessage(Messages.get().container(
320: Messages.GUI_SUBSCRIBERS_LIST_MACTION_ACTIVATE_CONF_0));
321: activateUser.setIconPath(ICON_MULTI_ACTIVATE);
322: metadata.addMultiAction(activateUser);
323:
324: // add the deactivate user multi action
325: CmsListMultiAction deactivateUser = new CmsListMultiAction(
326: LIST_MACTION_DEACTIVATE);
327: deactivateUser
328: .setName(Messages
329: .get()
330: .container(
331: Messages.GUI_SUBSCRIBERS_LIST_MACTION_DEACTIVATE_NAME_0));
332: deactivateUser
333: .setHelpText(Messages
334: .get()
335: .container(
336: Messages.GUI_SUBSCRIBERS_LIST_MACTION_DEACTIVATE_HELP_0));
337: deactivateUser
338: .setConfirmationMessage(Messages
339: .get()
340: .container(
341: Messages.GUI_SUBSCRIBERS_LIST_MACTION_DEACTIVATE_CONF_0));
342: deactivateUser.setIconPath(ICON_MULTI_DEACTIVATE);
343: metadata.addMultiAction(deactivateUser);
344: }
345:
346: /**
347: * @see org.opencms.workplace.tools.accounts.A_CmsUsersList#validateParamaters()
348: */
349: protected void validateParamaters() throws Exception {
350:
351: super .validateParamaters();
352: // this is to prevent the switch to the root ou
353: // if the oufqn param get lost (by reloading for example)
354: if (CmsStringUtil.isEmptyOrWhitespaceOnly(getParamOufqn())) {
355: throw new Exception();
356: }
357: }
358: }
|