001: /*
002: * File : $Source: /usr/local/cvs/alkacon/com.alkacon.opencms.newsletter/src/com/alkacon/opencms/newsletter/admin/CmsOrgUnitsAdminList.java,v $
003: * Date : $Date: 2007-11-30 11:57:27 $
004: * Version: $Revision: 1.7 $
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 com.alkacon.opencms.newsletter.CmsNewsletterManager;
036:
037: import org.opencms.file.CmsObject;
038: import org.opencms.file.CmsProject;
039: import org.opencms.jsp.CmsJspActionElement;
040: import org.opencms.main.CmsException;
041: import org.opencms.main.OpenCms;
042: import org.opencms.security.CmsOrganizationalUnit;
043: import org.opencms.workplace.list.CmsListColumnDefinition;
044: import org.opencms.workplace.list.CmsListDefaultAction;
045: import org.opencms.workplace.list.CmsListDirectAction;
046: import org.opencms.workplace.list.CmsListItemDetails;
047: import org.opencms.workplace.list.CmsListItemDetailsFormatter;
048: import org.opencms.workplace.list.CmsListMetadata;
049: import org.opencms.workplace.list.CmsListSearchAction;
050: import org.opencms.workplace.list.I_CmsListDirectAction;
051:
052: import java.util.Iterator;
053: import java.util.List;
054:
055: import javax.servlet.http.HttpServletRequest;
056: import javax.servlet.http.HttpServletResponse;
057: import javax.servlet.jsp.PageContext;
058:
059: /**
060: * Newsletter organization units management view.<p>
061: *
062: * @author Michael Moossen
063: * @author Andreas Zahner
064: *
065: * @version $Revision: 1.7 $
066: *
067: * @since 7.0.3
068: */
069: public class CmsOrgUnitsAdminList extends
070: org.opencms.workplace.tools.accounts.CmsOrgUnitsAdminList {
071:
072: /** Parth to the newsletter buttons. */
073: public static final String PATH_NL_BUTTONS = "tools/newsletter/buttons/";
074:
075: /**
076: * Public constructor.<p>
077: *
078: * @param jsp an initialized JSP action element
079: */
080: public CmsOrgUnitsAdminList(CmsJspActionElement jsp) {
081:
082: super (jsp);
083: getList()
084: .setName(
085: Messages
086: .get()
087: .container(
088: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_NAME_0));
089: }
090:
091: /**
092: * Public constructor with JSP variables.<p>
093: *
094: * @param context the JSP page context
095: * @param req the JSP request
096: * @param res the JSP response
097: */
098: public CmsOrgUnitsAdminList(PageContext context,
099: HttpServletRequest req, HttpServletResponse res) {
100:
101: this (new CmsJspActionElement(context, req, res));
102: }
103:
104: /**
105: * @see org.opencms.workplace.tools.accounts.A_CmsOrgUnitsList#getGroupIcon()
106: */
107: public String getGroupIcon() {
108:
109: return PATH_NL_BUTTONS + "mailinglist.png";
110: }
111:
112: /**
113: * @see org.opencms.workplace.tools.accounts.CmsOrgUnitsAdminList#getOverviewIcon()
114: */
115: public String getOverviewIcon() {
116:
117: return PATH_NL_BUTTONS + "newsletter_overview.png";
118: }
119:
120: /**
121: * @see org.opencms.workplace.tools.accounts.A_CmsOrgUnitsList#getUserIcon()
122: */
123: public String getUserIcon() {
124:
125: return PATH_NL_BUTTONS + "subscriber.png";
126: }
127:
128: /**
129: * @see org.opencms.workplace.tools.accounts.CmsOrgUnitsAdminList#hasMoreAdminOUs()
130: */
131: public boolean hasMoreAdminOUs() throws CmsException {
132:
133: boolean result = super .hasMoreAdminOUs();
134:
135: // delete default group "Users"
136: Iterator it = CmsNewsletterManager.getOrgUnits(getCms())
137: .iterator();
138: while (it.hasNext()) {
139: CmsOrganizationalUnit ou = (CmsOrganizationalUnit) it
140: .next();
141: String groupName = ou.getName()
142: + OpenCms.getDefaultUsers().getGroupUsers();
143: try {
144: getCms().readGroup(groupName);
145: // in order to delete a group, we have to switch to an offline project
146: CmsObject cms = OpenCms.initCmsObject(getCms());
147: String projectName = OpenCms
148: .getModuleManager()
149: .getModule(CmsNewsletterManager.MODULE_NAME)
150: .getParameter(
151: CmsNewsletterManager.MODULE_PARAM_PROJECT_NAME,
152: "Offline");
153: CmsProject project = cms.readProject(projectName);
154: cms.getRequestContext().setCurrentProject(project);
155: getCms().deleteGroup(groupName);
156: } catch (Exception e) {
157: // ok
158: }
159: }
160: return result;
161: }
162:
163: /**
164: * @see org.opencms.workplace.tools.accounts.CmsOrgUnitsAdminList#getForwardToolPath()
165: */
166: protected String getForwardToolPath() {
167:
168: return "/newsletter/orgunit";
169: }
170:
171: /**
172: * @see org.opencms.workplace.tools.accounts.CmsOrgUnitsAdminList#getGroupsToolPath()
173: */
174: protected String getGroupsToolPath() {
175:
176: return getCurrentToolPath() + "/orgunit/mailinglists";
177: }
178:
179: /**
180: * @see org.opencms.workplace.tools.accounts.A_CmsOrgUnitsList#getOrgUnits()
181: */
182: protected List getOrgUnits() throws CmsException {
183:
184: return CmsNewsletterManager.getOrgUnits(getCms());
185: }
186:
187: /**
188: * @see org.opencms.workplace.tools.accounts.CmsOrgUnitsAdminList#getUsersToolPath()
189: */
190: protected String getUsersToolPath() {
191:
192: return getCurrentToolPath() + "/orgunit/subscribers";
193: }
194:
195: /**
196: * @see org.opencms.workplace.tools.accounts.CmsOrgUnitsAdminList#setColumns(org.opencms.workplace.list.CmsListMetadata)
197: */
198: protected void setColumns(CmsListMetadata metadata) {
199:
200: super .setColumns(metadata);
201:
202: CmsListColumnDefinition overviewCol = metadata
203: .getColumnDefinition(LIST_COLUMN_OVERVIEW);
204: overviewCol
205: .setName(Messages
206: .get()
207: .container(
208: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_COLS_OVERVIEW_0));
209: overviewCol
210: .setHelpText(Messages
211: .get()
212: .container(
213: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_COLS_OVERVIEW_HELP_0));
214: overviewCol.removeDirectAction(LIST_ACTION_OVERVIEW);
215: I_CmsListDirectAction overviewAction = new CmsListDirectAction(
216: LIST_ACTION_OVERVIEW);
217: overviewAction
218: .setName(Messages
219: .get()
220: .container(
221: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_ACTION_OVERVIEW_NAME_0));
222: overviewAction
223: .setHelpText(Messages
224: .get()
225: .container(
226: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_COLS_OVERVIEW_HELP_0));
227: overviewAction.setIconPath(getOverviewIcon());
228: overviewCol.addDirectAction(overviewAction);
229:
230: CmsListColumnDefinition subscribersCol = metadata
231: .getColumnDefinition(LIST_COLUMN_USER);
232: subscribersCol.setName(Messages.get().container(
233: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_COLS_USER_0));
234: subscribersCol
235: .setHelpText(Messages
236: .get()
237: .container(
238: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_COLS_USER_HELP_0));
239: I_CmsListDirectAction subscribersAction = subscribersCol
240: .getDirectAction(LIST_ACTION_USER);
241: subscribersAction
242: .setName(Messages
243: .get()
244: .container(
245: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_ACTION_USER_NAME_0));
246: subscribersAction
247: .setHelpText(Messages
248: .get()
249: .container(
250: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_COLS_USER_HELP_0));
251:
252: CmsListColumnDefinition mailinglistsCol = metadata
253: .getColumnDefinition(LIST_COLUMN_GROUP);
254: mailinglistsCol
255: .setName(Messages
256: .get()
257: .container(
258: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_COLS_GROUP_0));
259: mailinglistsCol
260: .setHelpText(Messages
261: .get()
262: .container(
263: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_COLS_GROUP_HELP_0));
264: I_CmsListDirectAction mailinglistsAction = mailinglistsCol
265: .getDirectAction(LIST_ACTION_GROUP);
266: mailinglistsAction
267: .setName(Messages
268: .get()
269: .container(
270: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_ACTION_GROUP_NAME_0));
271: mailinglistsAction
272: .setHelpText(Messages
273: .get()
274: .container(
275: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_COLS_GROUP_HELP_0));
276:
277: CmsListColumnDefinition descriptionCol = metadata
278: .getColumnDefinition(LIST_COLUMN_DESCRIPTION);
279: CmsListDefaultAction defAction = descriptionCol
280: .getDefaultAction(LIST_DEFACTION_OVERVIEW);
281: defAction
282: .setName(Messages
283: .get()
284: .container(
285: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_DEFACTION_OVERVIEW_NAME_0));
286: defAction
287: .setHelpText(Messages
288: .get()
289: .container(
290: Messages.GUI_ALK_NEWSLETTER_ORGUNITS_LIST_COLS_OVERVIEW_HELP_0));
291: }
292:
293: /**
294: * @see org.opencms.workplace.tools.accounts.A_CmsOrgUnitsList#setIndependentActions(org.opencms.workplace.list.CmsListMetadata)
295: */
296: protected void setIndependentActions(CmsListMetadata metadata) {
297:
298: // add mailing lists details
299: CmsListItemDetails mailinglistsDetails = new CmsListItemDetails(
300: LIST_DETAIL_GROUPS);
301: mailinglistsDetails.setAtColumn(LIST_COLUMN_DESCRIPTION);
302: mailinglistsDetails.setVisible(false);
303: mailinglistsDetails
304: .setShowActionName(Messages
305: .get()
306: .container(
307: Messages.GUI_ORGUNITS_DETAIL_SHOW_ALK_MAILINGLISTS_NAME_0));
308: mailinglistsDetails
309: .setShowActionHelpText(Messages
310: .get()
311: .container(
312: Messages.GUI_ORGUNITS_DETAIL_SHOW_ALK_MAILINGLISTS_HELP_0));
313: mailinglistsDetails
314: .setHideActionName(Messages
315: .get()
316: .container(
317: Messages.GUI_ORGUNITS_DETAIL_HIDE_ALK_MAILINGLISTS_NAME_0));
318: mailinglistsDetails
319: .setHideActionHelpText(Messages
320: .get()
321: .container(
322: Messages.GUI_ORGUNITS_DETAIL_HIDE_ALK_MAILINGLISTS_HELP_0));
323: mailinglistsDetails.setName(Messages.get().container(
324: Messages.GUI_ORGUNITS_DETAIL_ALK_MAILINGLISTS_NAME_0));
325: mailinglistsDetails
326: .setFormatter(new CmsListItemDetailsFormatter(
327: Messages
328: .get()
329: .container(
330: Messages.GUI_ORGUNITS_DETAIL_ALK_MAILINGLISTS_NAME_0)));
331: metadata.addItemDetails(mailinglistsDetails);
332:
333: // makes the list searchable
334: CmsListSearchAction searchAction = new CmsListSearchAction(
335: metadata.getColumnDefinition(LIST_COLUMN_NAME));
336: searchAction.addColumn(metadata
337: .getColumnDefinition(LIST_COLUMN_DESCRIPTION));
338: metadata.setSearchAction(searchAction);
339: }
340:
341: }
|