Changeset 408

Show
Ignore:
Timestamp:
04/21/06 10:32:11
Author:
douglm
Message:

Auto subscribe new calendars in basic mode

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/calendar3/calFacade/src/org/bedework/calfacade/svc/BwPreferences.java

    r375 r408  
    9393   * asking 
    9494   */ 
    95   public static final int extraSimpleMode = 0; 
     95  public static final int basicMode = 0; 
    9696 
    9797  /** Value identifying a simple user mode - we hide some stuff but make 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/calendars/UpdateCalendarAction.java

    r256 r408  
    5656 
    5757import org.bedework.calfacade.BwCalendar; 
     58import org.bedework.calfacade.CalFacadeException; 
     59import org.bedework.calfacade.svc.BwPreferences; 
     60import org.bedework.calfacade.svc.BwSubscription; 
    5861import org.bedework.calsvci.CalSvcI; 
    5962import org.bedework.webcommon.BwAbstractAction; 
     
    124127    } 
    125128 
    126     if (cal.getCalendarCollection()) { 
    127       updateAuthPrefs(form, null, null, null, cal); 
     129    if (getPublicAdmin(form)) { 
     130      if (cal.getCalendarCollection()) { 
     131        updateAuthPrefs(form, null, null, null, cal); 
     132      } 
     133    } else if (svci.getUserPrefs().getUserMode() == BwPreferences.basicMode) { 
     134      // Auto subscribe. 
     135      // XXX name should be derived from path. 
     136      BwSubscription sub = BwSubscription.makeSubscription(cal, cal.getName(), 
     137                                                           true, true, false); 
     138      try { 
     139        svci.addSubscription(sub); 
     140      } catch (CalFacadeException cfe) { 
     141        if (CalFacadeException.duplicateSubscription.equals(cfe.getMessage())) { 
     142          form.getErr().emit(cfe.getMessage()); 
     143          return "success"; // User will see message and we'll stay on page 
     144        } 
     145 
     146        throw cfe; 
     147      } 
     148 
     149      // Add it to the default view 
     150      svci.addViewSubscription(null, sub); 
     151 
     152      form.setSubscriptions(svci.getSubscriptions()); 
    128153    } 
    129154 
     
    168193          } 
    169194        } 
    170          
     195 
    171196        cal.setCalendarCollection(newCC); 
    172197      } 
  • trunk/calendar3/webcommon/src/org/bedework/webcommon/subs/SubscribeAction.java

    r336 r408  
    102102      return "noAccess"; // First line of defence 
    103103    } 
    104      
     104 
    105105    if (getReqPar(request, "delete") != null) { 
    106        return unsubscribe(request, form); 
     106      return unsubscribe(request, form); 
    107107    } 
    108108 
     
    183183    return true; 
    184184  } 
    185    
     185 
    186186  private String unsubscribe(HttpServletRequest request, 
    187187                             BwActionFormBase form) throws Throwable { 
     
    202202      return "notFound"; 
    203203    } 
    204      
     204 
    205205    if (sub.getUnremoveable() && !form.getUserAuth().isSuperUser()) { 
    206206      return "noAccess"; // Only super user can remove the unremovable 
    207207    } 
    208      
     208 
    209209    /* Check for references in views. For user extra simple mode only we will 
    210210     * automatically remove the subscription. For others we list the references 
    211211     */ 
    212      
     212 
    213213    Iterator it = svc.getViews().iterator(); 
    214214    boolean reffed = false; 
    215215    boolean autoRemove = !getPublicAdmin(form) && 
    216       (svc.getUserPrefs().getUserMode() == BwPreferences.extraSimpleMode); 
    217      
     216      (svc.getUserPrefs().getUserMode() == BwPreferences.basicMode); 
     217 
    218218    while (it.hasNext()) { 
    219219      BwView v = (BwView)it.next(); 
     
    221221        if (autoRemove) { 
    222222          if (!svc.removeViewSubscription(v.getName(), sub)) { 
    223             form.getErr().emit("org.bedework.client.error.viewnotfound",  
     223            form.getErr().emit("org.bedework.client.error.viewnotfound", 
    224224                               v.getName()); 
    225225            return "error"; 
    226226          } 
    227227        } else { 
    228           form.getErr().emit("org.bedework.client.error.subscription.reffed",  
     228          form.getErr().emit("org.bedework.client.error.subscription.reffed", 
    229229                             v.getName()); 
    230230          reffed = true; 
     
    232232      } 
    233233    } 
    234      
     234 
    235235    if (reffed) { 
    236236      return "reffed"; 
     
    239239    svc.removeSubscription(sub); 
    240240    form.getMsg().emit("org.bedework.client.message.subscription.removed"); 
    241      
     241 
    242242    /* Refetch to tidy up */ 
    243243    form.setSubscriptions(svc.getSubscriptions());