Index: trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/BwPreferences.java =================================================================== --- trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/BwPreferences.java (revision 375) +++ trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/BwPreferences.java (revision 408) @@ -93,5 +93,5 @@ * asking */ - public static final int extraSimpleMode = 0; + public static final int basicMode = 0; /** Value identifying a simple user mode - we hide some stuff but make Index: trunk/calendar3/webcommon/src/org/bedework/webcommon/calendars/UpdateCalendarAction.java =================================================================== --- trunk/calendar3/webcommon/src/org/bedework/webcommon/calendars/UpdateCalendarAction.java (revision 256) +++ trunk/calendar3/webcommon/src/org/bedework/webcommon/calendars/UpdateCalendarAction.java (revision 408) @@ -56,4 +56,7 @@ import org.bedework.calfacade.BwCalendar; +import org.bedework.calfacade.CalFacadeException; +import org.bedework.calfacade.svc.BwPreferences; +import org.bedework.calfacade.svc.BwSubscription; import org.bedework.calsvci.CalSvcI; import org.bedework.webcommon.BwAbstractAction; @@ -124,6 +127,28 @@ } - if (cal.getCalendarCollection()) { - updateAuthPrefs(form, null, null, null, cal); + if (getPublicAdmin(form)) { + if (cal.getCalendarCollection()) { + updateAuthPrefs(form, null, null, null, cal); + } + } else if (svci.getUserPrefs().getUserMode() == BwPreferences.basicMode) { + // Auto subscribe. + // XXX name should be derived from path. + BwSubscription sub = BwSubscription.makeSubscription(cal, cal.getName(), + true, true, false); + try { + svci.addSubscription(sub); + } catch (CalFacadeException cfe) { + if (CalFacadeException.duplicateSubscription.equals(cfe.getMessage())) { + form.getErr().emit(cfe.getMessage()); + return "success"; // User will see message and we'll stay on page + } + + throw cfe; + } + + // Add it to the default view + svci.addViewSubscription(null, sub); + + form.setSubscriptions(svci.getSubscriptions()); } @@ -168,5 +193,5 @@ } } - + cal.setCalendarCollection(newCC); } Index: trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/SubscribeAction.java =================================================================== --- trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/SubscribeAction.java (revision 336) +++ trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/SubscribeAction.java (revision 408) @@ -102,7 +102,7 @@ return "noAccess"; // First line of defence } - + if (getReqPar(request, "delete") != null) { - return unsubscribe(request, form); + return unsubscribe(request, form); } @@ -183,5 +183,5 @@ return true; } - + private String unsubscribe(HttpServletRequest request, BwActionFormBase form) throws Throwable { @@ -202,18 +202,18 @@ return "notFound"; } - + if (sub.getUnremoveable() && !form.getUserAuth().isSuperUser()) { return "noAccess"; // Only super user can remove the unremovable } - + /* Check for references in views. For user extra simple mode only we will * automatically remove the subscription. For others we list the references */ - + Iterator it = svc.getViews().iterator(); boolean reffed = false; boolean autoRemove = !getPublicAdmin(form) && - (svc.getUserPrefs().getUserMode() == BwPreferences.extraSimpleMode); - + (svc.getUserPrefs().getUserMode() == BwPreferences.basicMode); + while (it.hasNext()) { BwView v = (BwView)it.next(); @@ -221,10 +221,10 @@ if (autoRemove) { if (!svc.removeViewSubscription(v.getName(), sub)) { - form.getErr().emit("org.bedework.client.error.viewnotfound", + form.getErr().emit("org.bedework.client.error.viewnotfound", v.getName()); return "error"; } } else { - form.getErr().emit("org.bedework.client.error.subscription.reffed", + form.getErr().emit("org.bedework.client.error.subscription.reffed", v.getName()); reffed = true; @@ -232,5 +232,5 @@ } } - + if (reffed) { return "reffed"; @@ -239,5 +239,5 @@ svc.removeSubscription(sub); form.getMsg().emit("org.bedework.client.message.subscription.removed"); - + /* Refetch to tidy up */ form.setSubscriptions(svc.getSubscriptions());