You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@roller.apache.org by sn...@apache.org on 2006/07/24 22:10:54 UTC
svn commit: r425173 - in /incubator/roller/branches/roller_3.0:
src/org/apache/roller/ui/authoring/struts/actions/
src/org/apache/roller/ui/authoring/struts/formbeans/
src/org/apache/roller/ui/core/struts/actions/ web/WEB-INF/
web/WEB-INF/classes/ web/...
Author: snoopdave
Date: Mon Jul 24 13:10:53 2006
New Revision: 425173
URL: http://svn.apache.org/viewvc?rev=425173&view=rev
Log:
Added invitation management page for listing and revoking outstating invitations
Added:
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/InvitationsAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/formbeans/InvitationsForm.java
incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/authoring/Invitations.jsp
Modified:
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/InviteMemberAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/MemberPermissionsAction.java
incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/struts/actions/YourWebsitesAction.java
incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties
incubator/roller/branches/roller_3.0/web/WEB-INF/editor-menu.xml
incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/authoring/MemberPermissionsSidebar.jsp
incubator/roller/branches/roller_3.0/web/WEB-INF/tiles-defs.xml
Added: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/InvitationsAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/InvitationsAction.java?rev=425173&view=auto
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/InvitationsAction.java (added)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/InvitationsAction.java Mon Jul 24 13:10:53 2006
@@ -0,0 +1,223 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.roller.ui.authoring.struts.actions;
+
+import java.net.MalformedURLException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.ResourceBundle;
+import javax.mail.MessagingException;
+import javax.mail.Session;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.struts.action.ActionForm;
+import org.apache.struts.action.ActionForward;
+import org.apache.struts.action.ActionMapping;
+import org.apache.struts.actions.DispatchAction;
+import org.apache.struts.util.RequestUtils;
+import org.apache.roller.RollerException;
+import org.apache.roller.config.RollerRuntimeConfig;
+import org.apache.roller.model.Roller;
+import org.apache.roller.model.RollerFactory;
+import org.apache.roller.model.UserManager;
+import org.apache.roller.pojos.PermissionsData;
+import org.apache.roller.pojos.UserData;
+import org.apache.roller.pojos.WebsiteData;
+import org.apache.roller.ui.authoring.struts.formbeans.InvitationsForm;
+import org.apache.roller.ui.core.BasePageModel;
+import org.apache.roller.ui.core.RollerContext;
+import org.apache.roller.ui.core.RollerRequest;
+import org.apache.roller.ui.core.RollerSession;
+import org.apache.roller.util.MailUtil;
+import org.apache.struts.action.ActionError;
+import org.apache.struts.action.ActionErrors;
+import org.apache.struts.action.ActionMessage;
+import org.apache.struts.action.ActionMessages;
+
+/**
+ * Allow viewing and deletion of invitations.
+ *
+ * @struts.action path="/roller-ui/authoring/invitations" parameter="method" name="invitationsForm"
+ * @struts.action-forward name="invitations.page" path=".Invitations"
+ */
+public class InvitationsAction extends DispatchAction {
+ private static Log mLogger =
+ LogFactory.getFactory().getInstance(InvitationsAction.class);
+
+ /** If method param is not specified, use HTTP verb to pick method to call */
+ public ActionForward unspecified(
+ ActionMapping mapping,
+ ActionForm actionForm,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+ return view(mapping, actionForm, request, response);
+ }
+
+ public ActionForward view(
+ ActionMapping mapping,
+ ActionForm actionForm,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+ InvitationsPageModel pageModel =
+ new InvitationsPageModel(request, response, mapping);
+ RollerSession rses = RollerSession.getRollerSession(request);
+ if (pageModel.getWebsite() != null &&
+ rses.isUserAuthorizedToAdmin(pageModel.getWebsite())) {
+ request.setAttribute("model", pageModel);
+ return mapping.findForward("invitations.page");
+ }
+ return mapping.findForward("access-denied");
+ }
+
+ /** Forwads back to the member permissions page */
+ public ActionForward cancel(
+ ActionMapping mapping,
+ ActionForm actionForm,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+ return mapping.findForward("memberPermissions");
+ }
+
+ public ActionForward revoke(
+ ActionMapping mapping,
+ ActionForm actionForm,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
+
+ InvitationsForm invitationForm = (InvitationsForm)actionForm;
+ Roller roller = RollerFactory.getRoller();
+ UserManager umgr = roller.getUserManager();
+ PermissionsData perms = umgr.getPermissions(invitationForm.getPermissionId());
+ if (perms == null) {
+ ActionErrors errors = new ActionErrors();
+ errors.add(null, new ActionError("invitations.error.notFound"));
+ saveErrors(request, errors);
+ return view(mapping, actionForm, request, response);
+ }
+ RollerSession rses = RollerSession.getRollerSession(request);
+ if (rses.isUserAuthorizedToAdmin(perms.getWebsite())) {
+ umgr.removePermissions(perms);
+ roller.flush();
+ notifyInvitee(request, perms.getWebsite(), perms.getUser());
+ ActionMessages msgs = new ActionMessages();
+ msgs.add(ActionMessages.GLOBAL_MESSAGE,
+ new ActionMessage("invitations.revoked"));
+ saveMessages(request, msgs);
+ return view(mapping, actionForm, request, response);
+ }
+ return mapping.findForward("access-denied");
+ }
+
+ /**
+ * Inform invitee that invitation has been revoked.
+ */
+ private void notifyInvitee(
+ HttpServletRequest request, WebsiteData website, UserData user)
+ throws RollerException {
+ try {
+ Roller roller = RollerFactory.getRoller();
+ UserManager umgr = roller.getUserManager();
+ javax.naming.Context ctx = (javax.naming.Context)
+ new InitialContext().lookup("java:comp/env");
+ Session mailSession =
+ (Session)ctx.lookup("mail/Session");
+ if (mailSession != null) {
+ String userName = user.getUserName();
+ String from = website.getEmailAddress();
+ String cc[] = new String[] {from};
+ String bcc[] = new String[0];
+ String to[] = new String[] {user.getEmailAddress()};
+ String subject;
+ String content;
+
+ // Figure URL to entry edit page
+ RollerContext rc = RollerContext.getRollerContext();
+ String rootURL = RollerRuntimeConfig.getAbsoluteContextURL();
+ if (rootURL == null || rootURL.trim().length()==0) {
+ rootURL = RequestUtils.serverURL(request)
+ + request.getContextPath();
+ }
+
+ ResourceBundle resources = ResourceBundle.getBundle(
+ "ApplicationResources",
+ website.getLocaleInstance());
+ StringBuffer sb = new StringBuffer();
+ sb.append(MessageFormat.format(
+ resources.getString("invitations.revokationSubject"),
+ new Object[] {
+ website.getName(),
+ website.getHandle()})
+ );
+ subject = sb.toString();
+ sb = new StringBuffer();
+ sb.append(MessageFormat.format(
+ resources.getString("invitations.revokationContent"),
+ new Object[] {
+ website.getName(),
+ website.getHandle(),
+ user.getUserName()
+ }));
+ content = sb.toString();
+ MailUtil.sendTextMessage(
+ mailSession, from, to, cc, bcc, subject, content);
+ }
+ } catch (NamingException e) {
+ throw new RollerException("ERROR: Revokation email(s) not sent, "
+ + "Roller's mail session not properly configured", e);
+ } catch (MessagingException e) {
+ throw new RollerException("ERROR: Revokation email(s) not sent, "
+ + "due to Roller configuration or mail server problem.", e);
+ } catch (MalformedURLException e) {
+ throw new RollerException("ERROR: Revokation email(s) not sent, "
+ + "Roller site URL is malformed?", e);
+ } catch (RollerException e) {
+ throw new RuntimeException(
+ "FATAL ERROR: unable to find Roller object", e);
+ }
+ }
+
+ public static class InvitationsPageModel extends BasePageModel {
+ private List pendings = new ArrayList();
+
+ public InvitationsPageModel(HttpServletRequest request,
+ HttpServletResponse response, ActionMapping mapping) throws RollerException {
+ super("invitations.title", request, response, mapping);
+ Roller roller = RollerFactory.getRoller();
+ RollerSession rollerSession = RollerSession.getRollerSession(request);
+ RollerRequest rreq = RollerRequest.getRollerRequest(request);
+ WebsiteData website = rreq.getWebsite();
+ pendings = roller.getUserManager().getPendingPermissions(website);
+ }
+ public List getPendings() {
+ return pendings;
+ }
+ public void setPendings(List pendings) {
+ this.pendings = pendings;
+ }
+ }
+}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/InviteMemberAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/InviteMemberAction.java?rev=425173&r1=425172&r2=425173&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/InviteMemberAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/InviteMemberAction.java Mon Jul 24 13:10:53 2006
@@ -1,20 +1,20 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
package org.apache.roller.ui.authoring.struts.actions;
import java.net.MalformedURLException;
@@ -56,64 +56,58 @@
/**
* Allows website admin to invite new members to website.
- *
+ *
* @struts.action path="/roller-ui/authoring/inviteMember" parameter="method" name="inviteMemberForm"
* @struts.action-forward name="inviteMember.page" path=".InviteMember"
*/
-public class InviteMemberAction extends DispatchAction
-{
+public class InviteMemberAction extends DispatchAction {
private static Log mLogger =
- LogFactory.getFactory().getInstance(InviteMemberAction.class);
-
+ LogFactory.getFactory().getInstance(InviteMemberAction.class);
+
/** If method param is not specified, use HTTP verb to pick method to call */
public ActionForward unspecified(
ActionMapping mapping,
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
- throws Exception
- {
- if (request.getMethod().equals("GET"))
- {
+ throws Exception {
+ if (request.getMethod().equals("GET")) {
return edit(mapping, actionForm, request, response);
}
return send(mapping, actionForm, request, response);
}
- /** If method param is not specified, use HTTP verb to pick method to call */
public ActionForward cancel(
ActionMapping mapping,
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
- throws Exception
- {
+ throws Exception {
return mapping.findForward("memberPermissions");
}
public ActionForward edit(
- ActionMapping mapping,
- ActionForm actionForm,
- HttpServletRequest request,
- HttpServletResponse response)
- throws Exception
- {
+ ActionMapping mapping,
+ ActionForm actionForm,
+ HttpServletRequest request,
+ HttpServletResponse response)
+ throws Exception {
// if group blogging is disabled then you can't change permissions
if (!RollerConfig.getBooleanProperty("groupblogging.enabled")) {
return mapping.findForward("access-denied");
}
-
+
BasePageModel pageModel = new BasePageModel(
- "inviteMember.title", request, response, mapping);
+ "inviteMember.title", request, response, mapping);
RollerSession rses = RollerSession.getRollerSession(request);
// Ensure use has admin perms for this weblog
- if (pageModel.getWebsite() != null && rses.isUserAuthorizedToAdmin(pageModel.getWebsite())) {
- request.setAttribute("model", pageModel);
+ if (pageModel.getWebsite() != null && rses.isUserAuthorizedToAdmin(pageModel.getWebsite())) {
+ request.setAttribute("model", pageModel);
InviteMemberForm form = (InviteMemberForm)actionForm;
form.setWebsiteId(pageModel.getWebsite().getId());
ActionForward forward = mapping.findForward("inviteMember.page");
- return forward;
+ return forward;
} else {
return mapping.findForward("access-denied");
}
@@ -124,8 +118,7 @@
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
- throws Exception
- {
+ throws Exception {
// if group blogging is disabled then you can't change permissions
if (!RollerConfig.getBooleanProperty("groupblogging.enabled")) {
return mapping.findForward("access-denied");
@@ -139,59 +132,48 @@
UserData user = umgr.getUserByUserName(form.getUserName());
BasePageModel pageModel = new BasePageModel(
- "inviteMember.title", request, response, mapping);
+ "inviteMember.title", request, response, mapping);
RollerSession rses = RollerSession.getRollerSession(request);
// Ensure use has admin perms for this weblog
if (pageModel.getWebsite() != null && rses.isUserAuthorizedToAdmin(pageModel.getWebsite())) {
-
- if (user == null)
- {
- errors.add(ActionErrors.GLOBAL_ERROR,
- new ActionError("inviteMember.error.userNotFound"));
- }
- else
- {
+
+ if (user == null) {
+ errors.add(ActionErrors.GLOBAL_ERROR,
+ new ActionError("inviteMember.error.userNotFound"));
+ } else {
RollerRequest rreq = RollerRequest.getRollerRequest(request);
WebsiteData website = rreq.getWebsite();
PermissionsData perms = umgr.getPermissions(website, user);
- if (perms != null && perms.isPending())
- {
- errors.add(ActionErrors.GLOBAL_ERROR,
- new ActionError("inviteMember.error.userAlreadyInvited"));
+ if (perms != null && perms.isPending()) {
+ errors.add(ActionErrors.GLOBAL_ERROR,
+ new ActionError("inviteMember.error.userAlreadyInvited"));
request.setAttribute("model", new BasePageModel(
- "inviteMember.title", request, response, mapping));
- }
- else if (perms != null)
- {
- errors.add(ActionErrors.GLOBAL_ERROR,
- new ActionError("inviteMember.error.userAlreadyMember"));
+ "inviteMember.title", request, response, mapping));
+ } else if (perms != null) {
+ errors.add(ActionErrors.GLOBAL_ERROR,
+ new ActionError("inviteMember.error.userAlreadyMember"));
request.setAttribute("model", new BasePageModel(
- "inviteMember.title", request, response, mapping));
- }
- else
- {
+ "inviteMember.title", request, response, mapping));
+ } else {
String mask = request.getParameter("permissionsMask");
umgr.inviteUser(website, user, Short.parseShort(mask));
RollerFactory.getRoller().flush();
request.setAttribute("user", user);
- try
- {
+ try {
notifyInvitee(request, website, user);
+ } catch (RollerException e) {
+ errors.add(ActionErrors.GLOBAL_ERROR,
+ new ActionError("error.untranslated", e.getMessage()));
}
- catch (RollerException e)
- {
- errors.add(ActionErrors.GLOBAL_ERROR,
- new ActionError("error.untranslated", e.getMessage()));
- }
- msgs.add(ActionMessages.GLOBAL_MESSAGE,
- new ActionMessage("inviteMember.userInvited"));
-
+ msgs.add(ActionMessages.GLOBAL_MESSAGE,
+ new ActionMessage("inviteMember.userInvited"));
+
request.setAttribute("model", new BasePageModel(
- "inviteMemberDone.title", request, response, mapping));
-
- forward = mapping.findForward("memberPermissions");
+ "inviteMemberDone.title", request, response, mapping));
+
+ forward = mapping.findForward("memberPermissions");
}
}
saveErrors(request, errors);
@@ -200,26 +182,23 @@
} else {
return mapping.findForward("access-denied");
}
- return forward;
+ return forward;
}
/**
* Inform invitee of new invitation.
*/
private void notifyInvitee(
- HttpServletRequest request, WebsiteData website, UserData user)
- throws RollerException
- {
- try
- {
+ HttpServletRequest request, WebsiteData website, UserData user)
+ throws RollerException {
+ try {
Roller roller = RollerFactory.getRoller();
UserManager umgr = roller.getUserManager();
javax.naming.Context ctx = (javax.naming.Context)
- new InitialContext().lookup("java:comp/env");
- Session mailSession =
- (Session)ctx.lookup("mail/Session");
- if (mailSession != null)
- {
+ new InitialContext().lookup("java:comp/env");
+ Session mailSession =
+ (Session)ctx.lookup("mail/Session");
+ if (mailSession != null) {
String userName = user.getUserName();
String from = website.getEmailAddress();
String cc[] = new String[] {from};
@@ -231,59 +210,50 @@
// Figure URL to entry edit page
RollerContext rc = RollerContext.getRollerContext();
String rootURL = RollerRuntimeConfig.getAbsoluteContextURL();
- if (rootURL == null || rootURL.trim().length()==0)
- {
- rootURL = RequestUtils.serverURL(request)
- + request.getContextPath();
- }
+ if (rootURL == null || rootURL.trim().length()==0) {
+ rootURL = RequestUtils.serverURL(request)
+ + request.getContextPath();
+ }
String url = rootURL + "/roller-ui/yourWebsites.do";
ResourceBundle resources = ResourceBundle.getBundle(
- "ApplicationResources",
- website.getLocaleInstance());
+ "ApplicationResources",
+ website.getLocaleInstance());
StringBuffer sb = new StringBuffer();
sb.append(MessageFormat.format(
- resources.getString("inviteMember.notificationSubject"),
- new Object[] {
- website.getName(),
- website.getHandle()})
- );
+ resources.getString("inviteMember.notificationSubject"),
+ new Object[] {
+ website.getName(),
+ website.getHandle()})
+ );
subject = sb.toString();
sb = new StringBuffer();
sb.append(MessageFormat.format(
- resources.getString("inviteMember.notificationContent"),
- new Object[] {
- website.getName(),
- website.getHandle(),
- user.getUserName(),
- url
+ resources.getString("inviteMember.notificationContent"),
+ new Object[] {
+ website.getName(),
+ website.getHandle(),
+ user.getUserName(),
+ url
}));
content = sb.toString();
MailUtil.sendTextMessage(
mailSession, from, to, cc, bcc, subject, content);
}
- }
- catch (NamingException e)
- {
+ } catch (NamingException e) {
throw new RollerException("ERROR: Notification email(s) not sent, "
+ "Roller's mail session not properly configured", e);
- }
- catch (MessagingException e)
- {
+ } catch (MessagingException e) {
throw new RollerException("ERROR: Notification email(s) not sent, "
- + "due to Roller configuration or mail server problem.", e);
- }
- catch (MalformedURLException e)
- {
+ + "due to Roller configuration or mail server problem.", e);
+ } catch (MalformedURLException e) {
throw new RollerException("ERROR: Notification email(s) not sent, "
+ "Roller site URL is malformed?", e);
- }
- catch (RollerException e)
- {
+ } catch (RollerException e) {
throw new RuntimeException(
"FATAL ERROR: unable to find Roller object", e);
}
}
-
-
+
+
}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/MemberPermissionsAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/MemberPermissionsAction.java?rev=425173&r1=425172&r2=425173&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/MemberPermissionsAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/actions/MemberPermissionsAction.java Mon Jul 24 13:10:53 2006
@@ -1,20 +1,20 @@
/*
-* Licensed to the Apache Software Foundation (ASF) under one or more
-* contributor license agreements. The ASF licenses this file to You
-* under the Apache License, Version 2.0 (the "License"); you may not
-* use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License. For additional information regarding
-* copyright in this work, please see the NOTICE file in the top level
-* directory of this distribution.
-*/
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
package org.apache.roller.ui.authoring.struts.actions;
import java.util.ArrayList;
@@ -48,14 +48,13 @@
/**
* Allows website admin to change website member permissions.
- *
+ *
* @struts.action path="/roller-ui/authoring/memberPermissions" parameter="method" name="memberPermissionsForm"
* @struts.action-forward name="memberPermissions.page" path=".MemberPermissions"
*/
-public class MemberPermissionsAction extends DispatchAction
-{
+public class MemberPermissionsAction extends DispatchAction {
private static Log mLogger =
- LogFactory.getFactory().getInstance(MemberPermissionsAction.class);
+ LogFactory.getFactory().getInstance(MemberPermissionsAction.class);
/** If method param is not specified, use HTTP verb to pick method to call */
public ActionForward unspecified(
@@ -63,10 +62,8 @@
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
- throws Exception
- {
- if (request.getMethod().equals("GET"))
- {
+ throws Exception {
+ if (request.getMethod().equals("GET")) {
return edit(mapping, actionForm, request, response);
}
return save(mapping, actionForm, request, response);
@@ -78,8 +75,7 @@
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
- throws Exception
- {
+ throws Exception {
return edit(mapping, actionForm, request, response);
}
@@ -88,8 +84,7 @@
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
- throws Exception
- {
+ throws Exception {
return edit(mapping, actionForm, request, response);
}
@@ -98,10 +93,10 @@
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
- throws Exception
- {
- MemberPermissionsPageModel pageModel =
- new MemberPermissionsPageModel(request, response, mapping);
+ throws Exception {
+
+ MemberPermissionsPageModel pageModel =
+ new MemberPermissionsPageModel(request, response, mapping);
request.setAttribute("model", pageModel);
RollerSession rses = RollerSession.getRollerSession(request);
@@ -121,45 +116,36 @@
ActionForm actionForm,
HttpServletRequest request,
HttpServletResponse response)
- throws Exception
- {
+ throws Exception {
ActionErrors errors = new ActionErrors();
ActionMessages msgs = new ActionMessages();
RollerSession rses = RollerSession.getRollerSession(request);
- MemberPermissionsPageModel model =
- new MemberPermissionsPageModel(request, response, mapping);
+ MemberPermissionsPageModel model =
+ new MemberPermissionsPageModel(request, response, mapping);
// Ensure use has admin perms for this weblog
if (model.getWebsite() != null && rses.isUserAuthorizedToAdmin(model.getWebsite())) {
-
+
UserManager userMgr = RollerFactory.getRoller().getUserManager();
Iterator iter = model.getPermissions().iterator();
int removed = 0;
int changed = 0;
- while (iter.hasNext())
- {
+ while (iter.hasNext()) {
PermissionsData perms = (PermissionsData)iter.next();
String sval = request.getParameter("perm-" + perms.getId());
- if (sval != null)
- {
+ if (sval != null) {
short val = Short.parseShort(sval);
UserData user = rses.getAuthenticatedUser();
- if (perms.getUser().getId().equals(user.getId())
- && val < perms.getPermissionMask())
- {
+ if (perms.getUser().getId().equals(user.getId())
+ && val < perms.getPermissionMask()) {
errors.add(null,new ActionError(
- "memberPermissions.noSelfDemotions"));
- }
- else if (val != perms.getPermissionMask())
- {
- if (val == -1)
- {
+ "memberPermissions.noSelfDemotions"));
+ } else if (val != perms.getPermissionMask()) {
+ if (val == -1) {
userMgr.removePermissions(perms);
removed++;
- }
- else
- {
+ } else {
perms.setPermissionMask(val);
userMgr.savePermissions(perms);
changed++;
@@ -167,24 +153,21 @@
}
}
}
- if (removed > 0 || changed > 0)
- {
+ if (removed > 0 || changed > 0) {
RollerFactory.getRoller().flush();
}
- if (removed > 0)
- {
+ if (removed > 0) {
msgs.add(null,new ActionMessage(
- "memberPermissions.membersRemoved", new Integer(removed)));
+ "memberPermissions.membersRemoved", new Integer(removed)));
}
- if (changed > 0)
- {
+ if (changed > 0) {
msgs.add(null,new ActionMessage(
- "memberPermissions.membersChanged", new Integer(changed)));
+ "memberPermissions.membersChanged", new Integer(changed)));
}
saveErrors(request, errors);
saveMessages(request, msgs);
- MemberPermissionsPageModel updatedModel =
- new MemberPermissionsPageModel(request, response, mapping);
+ MemberPermissionsPageModel updatedModel =
+ new MemberPermissionsPageModel(request, response, mapping);
request.setAttribute("model", updatedModel);
ActionForward forward = mapping.findForward("memberPermissions.page");
return forward;
@@ -194,12 +177,10 @@
}
}
- public static class MemberPermissionsPageModel extends BasePageModel
- {
+ public static class MemberPermissionsPageModel extends BasePageModel {
private List permissions = new ArrayList();
public MemberPermissionsPageModel(HttpServletRequest request,
- HttpServletResponse response, ActionMapping mapping) throws RollerException
- {
+ HttpServletResponse response, ActionMapping mapping) throws RollerException {
super("memberPermissions.title", request, response, mapping);
Roller roller = RollerFactory.getRoller();
RollerRequest rreq = RollerRequest.getRollerRequest(request);
@@ -207,13 +188,11 @@
WebsiteData website = rreq.getWebsite();
permissions = roller.getUserManager().getAllPermissions(website);
}
- public List getPermissions()
- {
+ public List getPermissions() {
return permissions;
}
- public void setWebsites(List permissions)
- {
+ public void setWebsites(List permissions) {
this.permissions = permissions;
}
- }
+ }
}
Added: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/formbeans/InvitationsForm.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/formbeans/InvitationsForm.java?rev=425173&view=auto
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/formbeans/InvitationsForm.java (added)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/authoring/struts/formbeans/InvitationsForm.java Mon Jul 24 13:10:53 2006
@@ -0,0 +1,40 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. The ASF licenses this file to You
+ * under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License. For additional information regarding
+ * copyright in this work, please see the NOTICE file in the top level
+ * directory of this distribution.
+ */
+package org.apache.roller.ui.authoring.struts.formbeans;
+
+import org.apache.struts.action.ActionForm;
+
+/**
+ * @struts.form name="invitationsForm"
+ */
+public class InvitationsForm extends ActionForm {
+ private String weblog;
+ private String permissionId;
+ public String getWeblog() {
+ return weblog;
+ }
+ public void setWeblog(String weblog) {
+ this.weblog = weblog;
+ }
+ public String getPermissionId() {
+ return permissionId;
+ }
+ public void setPermissionId(String permissionId) {
+ this.permissionId = permissionId;
+ }
+}
Modified: incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/struts/actions/YourWebsitesAction.java
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/struts/actions/YourWebsitesAction.java?rev=425173&r1=425172&r2=425173&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/struts/actions/YourWebsitesAction.java (original)
+++ incubator/roller/branches/roller_3.0/src/org/apache/roller/ui/core/struts/actions/YourWebsitesAction.java Mon Jul 24 13:10:53 2006
@@ -42,6 +42,8 @@
import org.apache.roller.ui.core.RollerRequest;
import org.apache.roller.ui.core.RollerSession;
import org.apache.roller.ui.authoring.struts.formbeans.YourWebsitesForm;
+import org.apache.struts.action.ActionError;
+import org.apache.struts.action.ActionErrors;
/**
@@ -89,21 +91,26 @@
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
- YourWebsitesForm form = (YourWebsitesForm)actionForm;
+ YourWebsitesForm form = (YourWebsitesForm)actionForm;
UserManager userMgr = RollerFactory.getRoller().getUserManager();
PermissionsData perms = userMgr.getPermissions(form.getInviteId());
-
- // TODO ROLLER_2.0: notify inviter that invitee has accepted invitation
- // TODO EXCEPTIONS: better exception handling
- perms.setPending(false);
- userMgr.savePermissions(perms);
- RollerFactory.getRoller().flush();
-
- ActionMessages msgs = new ActionMessages();
- msgs.add(null, new ActionMessage(
- "yourWebsites.accepted", perms.getWebsite().getHandle()));
- saveMessages(request, msgs);
+ if (perms != null) {
+ // TODO ROLLER_2.0: notify inviter that invitee has accepted invitation
+ // TODO EXCEPTIONS: better exception handling
+ perms.setPending(false);
+ userMgr.savePermissions(perms);
+ RollerFactory.getRoller().flush();
+
+ ActionMessages msgs = new ActionMessages();
+ msgs.add(null, new ActionMessage(
+ "yourWebsites.accepted", perms.getWebsite().getHandle()));
+ saveMessages(request, msgs);
+ } else {
+ ActionErrors errs = new ActionErrors();
+ errs.add(null, new ActionError("yourWebsites.permNotFound"));
+ saveMessages(request, errs);
+ }
request.setAttribute("model",
new YourWebsitesPageModel(request, response, mapping));
@@ -118,20 +125,25 @@
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
- YourWebsitesForm form = (YourWebsitesForm)actionForm;
-
+
+ YourWebsitesForm form = (YourWebsitesForm)actionForm;
UserManager userMgr = RollerFactory.getRoller().getUserManager();
PermissionsData perms = userMgr.getPermissions(form.getInviteId());
-
- // TODO ROLLER_2.0: notify inviter that invitee has declined invitation
- // TODO EXCEPTIONS: better exception handling here
- userMgr.removePermissions(perms);
- RollerFactory.getRoller().flush();
-
- ActionMessages msgs = new ActionMessages();
- msgs.add(null, new ActionMessage(
- "yourWebsites.declined", perms.getWebsite().getHandle()));
- saveMessages(request, msgs);
+ if (perms != null) {
+ // TODO ROLLER_2.0: notify inviter that invitee has declined invitation
+ // TODO EXCEPTIONS: better exception handling here
+ userMgr.removePermissions(perms);
+ RollerFactory.getRoller().flush();
+
+ ActionMessages msgs = new ActionMessages();
+ msgs.add(null, new ActionMessage(
+ "yourWebsites.declined", perms.getWebsite().getHandle()));
+ saveMessages(request, msgs);
+ } else {
+ ActionErrors errs = new ActionErrors();
+ errs.add(null, new ActionError("yourWebsites.permNotFound"));
+ saveMessages(request, errs);
+ }
request.setAttribute("model",
new YourWebsitesPageModel(request, response, mapping));
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties?rev=425173&r1=425172&r2=425173&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/classes/ApplicationResources.properties Mon Jul 24 13:10:53 2006
@@ -534,14 +534,36 @@
folderForm.save.exception=ERROR saving folder, perhaps name is not unique? \
The error message is: {0}
-# ----------------------------------------------------------------------- Footer
+# ---------------------------------------------------------------------- Footer
footer.reportIssue=Report an Issue
footer.userGuide=User Guide
footer.macros=Macros
footer.mailingLists=Mailing Lists
-# ----------------------------------------------------------------- Invite member
+# ------------------------------------------------------ Invitations management
+
+invitations.title=Manage invitations
+
+invitations.subtitle=Manage invitations in weblog <span>{0}</span>
+invitations.prompt=This page lists the outstanding invitations in this weblog. \
+You may choose to cancel invitations and if email notification is enabled the \
+uninvited party will receive a invitation revoked message.
+
+invitations.revokationSubject=Roller: invitation to join weblog "{0}" ({1}) \
+REVOKED
+invitations.revokationContent=Your invitation to join weblog "{0}" ({1}) has \
+been revoked.
+
+invitations.weblog=Weblog
+invitations.user=User
+invitations.permission=Permission
+invitations.action=Action
+invitations.revoked=Invitation successfully revoked.
+
+invitations.error.notFound=Invitation already revoked.
+
+# --------------------------------------------------------------- Invite member
inviteMember.title=Invite New Member
@@ -719,7 +741,6 @@
memberPermissions.author=Author
memberPermissions.limited=Limited
memberPermissions.remove=Remove
-memberPermissions.inviteMember=Invite new member
memberPermissions.noSelfDemotions=You're not allowed to demote yourself
memberPermissions.membersRemoved=Removed {0} user(s)
@@ -730,8 +751,12 @@
memberPermissions.button.save=Save
+memberPermissions.inviteMember=Invite new member
memberPermissions.whyInvite=Invite somebody to help you write your weblog.
+memberPermissions.manageInvitations=Manage invitations
+memberPermissions.whyManageInvitations=View existing invitations, with option to revoke.
+
memberPermissions.permissionsHelpTitle=What are permissions?
memberPermissions.permissionHelp=\
<b>Admin</b> permission allows user to post entries, manage weblog and its users<br /> \
@@ -1702,4 +1727,4 @@
yourWebsites.declined=You have declined an invitation to join weblog [{0}]
yourWebsites.accepted=You are now a member of weblog [{0}]
yourWebsites.resigned=You have resigned from weblog [{0}]
-
+yourWebsites.permNotFound=Sorry, that invitation was just revoked.
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/editor-menu.xml
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/editor-menu.xml?rev=425173&r1=425172&r2=425173&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/editor-menu.xml (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/editor-menu.xml Mon Jul 24 13:10:53 2006
@@ -49,7 +49,7 @@
<menu-item forward="memberPermissions" enabledProperty="groupblogging.enabled"
name="tabbedmenu.website.members"
perms="admin"
- subforwards="inviteMember" />
+ subforwards="inviteMember,invitations" />
<menu-item forward="pingSetup" name="tabbedmenu.weblog.pingSetup"
disabledProperty="pings.disablePingUsage"
perms="admin" />
Added: incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/authoring/Invitations.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/authoring/Invitations.jsp?rev=425173&view=auto
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/authoring/Invitations.jsp (added)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/authoring/Invitations.jsp Mon Jul 24 13:10:53 2006
@@ -0,0 +1,98 @@
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. The ASF licenses this file to You
+ under the Apache License, Version 2.0 (the "License"); you may not
+ use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License. For additional information regarding
+ copyright in this work, please see the NOTICE file in the top level
+ directory of this distribution.
+-->
+<%@ include file="/taglibs.jsp" %>
+
+<script type="text/javascript">
+// <!--
+function revokeInvite(id) {
+ if (confirm("Revoke selected invitation?")) {
+ document.invitationsForm.method.value="revoke";
+ document.invitationsForm.permissionId.value=id;
+ document.invitationsForm.submit();
+ }
+}
+function done() {
+ document.invitationsForm.method.value="cancel";
+ document.invitationsForm.submit();
+}
+// -->
+</script>
+
+<p class="subtitle">
+ <fmt:message key="invitations.subtitle" >
+ <fmt:param value="${model.website.handle}" />
+ </fmt:message>
+</p>
+<p><fmt:message key="invitations.prompt" /></p>
+
+<html:form action="/roller-ui/authoring/invitations" method="post" focus="userName">
+ <html:hidden property="weblog" />
+ <html:hidden property="permissionId" />
+ <input type="hidden" name="method" value="view" />
+
+ <c:choose>
+ <c:when test="${empty model.pendings}">
+ No invitations
+ </c:when>
+ <c:when test="${!empty model.pendings}">
+ <table class="rollertable">
+ <tr class="rHeaderTr">
+ <th class="rollertable" width="20%">
+ <fmt:message key="invitations.weblog" />
+ </th>
+ <th class="rollertable" width="20%">
+ <fmt:message key="invitations.user" />
+ </th>
+ <th class="rollertable" width="20%">
+ <fmt:message key="invitations.permission" />
+ </th>
+ <th class="rollertable" width="20%">
+ <fmt:message key="invitations.action" />
+ </th>
+ </tr>
+ <c:forEach var="invite" items="${model.pendings}">
+ <roller:row oddStyleClass="rollertable_odd" evenStyleClass="rollertable_even">
+ <td class="rollertable">
+ <c:out value="${invite.website.handle}" />
+ </td>
+ <td class="rollertable">
+ <c:out value="${invite.user.userName}" />
+ </td>
+ <td class="rollertable">
+ <c:if test="${invite.permissionMask == 0}" >LIMITED</c:if>
+ <c:if test="${invite.permissionMask == 1}" >AUTHOR</c:if>
+ <c:if test="${invite.permissionMask == 3}" >ADMIN</c:if>
+ </td>
+ <td class="rollertable">
+ <a hrerf="#" onclick="revokeInvite('<c:out value="${invite.id}" />')">Revoke</a>
+ </td>
+ </roller:row>
+ </c:forEach>
+ </table>
+ </c:when>
+ </c:choose>
+
+ <br />
+ <br />
+ <input type="button" value='<fmt:message key="application.done" />' onclick="done()"></input>
+
+</html:form>
+
+
+
+
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/authoring/MemberPermissionsSidebar.jsp
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/authoring/MemberPermissionsSidebar.jsp?rev=425173&r1=425172&r2=425173&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/authoring/MemberPermissionsSidebar.jsp (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/jsps/authoring/MemberPermissionsSidebar.jsp Mon Jul 24 13:10:53 2006
@@ -23,8 +23,9 @@
<div class="sidebarInner">
- <h3><fmt:message key="mainPage.actions" /></h3>
+ <h3><fmt:message key="mainPage.actions" /></h3>
<hr size="1" noshade="noshade" />
+
<img src='<c:url value="/images/email_edit.png"/>' alt="mail-icon" align="bottom" />
<c:url value="/roller-ui/authoring/inviteMember.do" var="inviteUrl">
<c:param name="weblog" value="${model.website.handle}" />
@@ -34,9 +35,22 @@
</a>
<br />
<fmt:message key="memberPermissions.whyInvite" />
- <br />
- <br />
- </div>
+ <br />
+ <br />
+
+ <img src='<c:url value="/images/email_edit.png"/>' alt="mail-icon" align="bottom" />
+ <c:url value="/roller-ui/authoring/invitations.do" var="invitationsUrl">
+ <c:param name="weblog" value="${model.website.handle}" />
+ </c:url>
+ <a href='<c:out value="${invitationsUrl}" />'>
+ <fmt:message key="memberPermissions.manageInvitations" />
+ </a>
+ <br />
+ <fmt:message key="memberPermissions.whyManageInvitations" />
+ <br />
+ <br />
+
+ </div>
</div>
</div>
</div>
Modified: incubator/roller/branches/roller_3.0/web/WEB-INF/tiles-defs.xml
URL: http://svn.apache.org/viewvc/incubator/roller/branches/roller_3.0/web/WEB-INF/tiles-defs.xml?rev=425173&r1=425172&r2=425173&view=diff
==============================================================================
--- incubator/roller/branches/roller_3.0/web/WEB-INF/tiles-defs.xml (original)
+++ incubator/roller/branches/roller_3.0/web/WEB-INF/tiles-defs.xml Mon Jul 24 13:10:53 2006
@@ -235,6 +235,10 @@
<put name="content" value="/WEB-INF/jsps/authoring/remove-page.jsp" />
<put name="styles" value="/WEB-INF/jsps/tiles/css-nosidebar.jsp" />
</definition>
+<definition name=".Invitations" extends=".tiles-editorpage" >
+ <put name="content" value="/WEB-INF/jsps/authoring/Invitations.jsp" />
+ <put name="styles" value="/WEB-INF/jsps/tiles/css-nosidebar.jsp" />
+</definition>
<!-- global admin pages (and associates) -->