Changeset 1330 for trunk

Show
Ignore:
Timestamp:
08/14/08 12:01:54 (3 years ago)
Author:
kohlhaas
Message:

closes #56

Location:
trunk/src/org/rapla
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/org/rapla/facade/QueryModule.java

    r1110 r1330  
    118118     * The User cannot change appointments.*/ 
    119119    boolean canExchangeAllocatables(Reservation reservation); 
     120     
     121    boolean canReadReservationsFromOthers(User user); 
    120122} 
    121123 
  • trunk/src/org/rapla/facade/internal/FacadeImpl.java

    r1268 r1330  
    481481        } 
    482482        removeFilteredClassifications( reservations, filters); 
     483         
     484        //Category can_see = getUserGroupsCategory().getCategory( Permission.GROUP_CAN_READ_EVENTS_FROM_OTHERS); 
    483485        Iterator it = reservations.iterator(); 
     486        boolean canSeeOthers =  canReadReservationsFromOthers(user); 
    484487        while ( it.hasNext() ) { 
    485488            Reservation r = (Reservation) it.next(); 
    486             if ( workingUser == null || r.getOwner().equals( workingUser ) || workingUser.isAdmin()) 
     489            if ( workingUser == null || r.getOwner().equals( workingUser ) || canSeeOthers) 
    487490                continue; 
    488491            Allocatable[] allocatables = r.getAllocatables(); 
     
    691694            return false; 
    692695        } 
     696    } 
     697     
     698    public boolean canReadReservationsFromOthers(User user)  
     699    { 
     700        if ( user == null) 
     701        { 
     702            return workingUser == null || workingUser.isAdmin(); 
     703        } 
     704        if ( user.isAdmin()) 
     705        { 
     706            return true; 
     707        } 
     708        try { 
     709            Category can_see = getUserGroupsCategory().getCategory( Permission.GROUP_CAN_READ_EVENTS_FROM_OTHERS); 
     710            return user.belongsTo( can_see); 
     711        } 
     712        catch (Exception ex) 
     713        { 
     714            getLogger().error("Can't get permissions!", ex); 
     715        } 
     716        return false; 
    693717    } 
    694718 
  • trunk/src/org/rapla/gui/internal/action/AppointmentAction.java

    r1234 r1330  
    1717import java.util.Date; 
    1818 
     19import org.rapla.entities.User; 
    1920import org.rapla.entities.domain.Allocatable; 
    2021import org.rapla.entities.domain.Appointment; 
     
    156157        putValue(NAME, getString("view")); 
    157158        putValue(SMALL_ICON, getIcon("icon.help")); 
     159        User owner = appointment.getReservation().getOwner(); 
     160        try  
     161        { 
     162            User user = getUser(); 
     163            boolean canView = getQuery().canReadReservationsFromOthers( user) || user.equals( owner); 
     164            setEnabled( canView); 
     165        }  
     166        catch (RaplaException ex) 
     167        { 
     168            getLogger().error( "Can't get user",ex); 
     169        } 
    158170        return this; 
    159171    } 
  • trunk/src/org/rapla/gui/internal/action/ReservationAction.java

    r1091 r1330  
    1616import java.awt.Point; 
    1717 
     18import org.rapla.entities.User; 
    1819import org.rapla.entities.domain.Reservation; 
    1920import org.rapla.entities.dynamictype.DynamicType; 
     
    8283            setEnabled( m_wizard != null); 
    8384        } 
     85 
    8486    } 
    8587 
     
    8789        m_wizard.start(parent, (CalendarModel)getService( CalendarModel.ROLE), guessType()); 
    8890    } 
     91     
     92 
    8993} 
  • trunk/src/org/rapla/gui/internal/common/CalendarModelImpl.java

    r1262 r1330  
    2929import org.rapla.components.util.DateTools; 
    3030import org.rapla.components.xmlbundle.I18nBundle; 
     31import org.rapla.entities.Category; 
    3132import org.rapla.entities.Named; 
    3233import org.rapla.entities.RaplaObject; 
     
    3738import org.rapla.entities.domain.Appointment; 
    3839import org.rapla.entities.domain.AppointmentBlockArray; 
     40import org.rapla.entities.domain.Permission; 
    3941import org.rapla.entities.domain.Reservation; 
    4042import org.rapla.entities.dynamictype.Classifiable; 
     
    517519 
    518520    public User[] getSelectedUsers()  { 
     521        User currentUser = getUser(); 
     522        if ( currentUser != null && !m_facade.canReadReservationsFromOthers( currentUser)) 
     523        { 
     524            return new User[] {currentUser}; 
     525        } 
    519526        return (User[]) getSelected(User.TYPE).toArray(User.USER_ARRAY); 
    520527   } 
     
    612619        User[] users = getSelectedUsers(); 
    613620        User currentUser = getUser(); 
     621 
     622     
     623             
    614624        return ( users.length == 1 && users[0].equals( currentUser)); 
    615625    } 
  • trunk/src/org/rapla/plugin/abstractcalendar/RaplaBuilder.java

    r1112 r1330  
    4949import org.rapla.entities.domain.Appointment; 
    5050import org.rapla.entities.domain.AppointmentBlockArray; 
    51 import org.rapla.entities.domain.Permission; 
    5251import org.rapla.entities.domain.Reservation; 
    5352import org.rapla.entities.dynamictype.Attribute; 
     
    484483        User user; 
    485484        List blocks; 
    486         Category canReadOthersGroup; 
     485        boolean canReadOthers; 
    487486         
    488487        public BuildContext(RaplaBuilder builder, List blocks) 
     
    499498            this.logger = builder.getLogger(); 
    500499            this.user = builder.editingUser; 
    501             try { 
    502                 this.canReadOthersGroup = builder.getClientFacade().getUserGroupsCategory().getCategory( Permission.GROUP_CAN_READ_EVENTS_FROM_OTHERS); 
    503             } catch (RaplaException ex) 
    504             { 
    505                 // we assume that there is no other group 
    506             } 
     500            this.canReadOthers = builder.getClientFacade().canReadReservationsFromOthers(user); 
    507501        } 
    508502 
     
    643637               return false; 
    644638           } 
    645            if ( buildContext.canReadOthersGroup == null ||  user.belongsTo( buildContext.canReadOthersGroup)) 
     639           if ( buildContext.canReadOthers ) 
    646640           { 
    647641               return false;