Changeset 3074


Ignore:
Timestamp:
Jan 22, 2007, 11:16:43 AM (16 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #476: "Import" button is not shown even if the user has permission to use an
import plugin in a given context

Location:
trunk/src/core
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/core/common-queries.xml

    r3050 r3074  
    17861786      JOIN plg.guiContexts gcx
    17871787      LEFT JOIN plg.configurations cfg
    1788         WITH cfg.owner.id = :owner OR cfg.itemKey.id IN (:itemKeys) OR cfg.projectKey.id IN (:projectKeys)
     1788      WITH true = :hasConfigPermission OR cfg.owner.id = :owner
     1789        OR cfg.itemKey.id IN (:itemKeys) OR cfg.projectKey.id IN (:projectKeys)
    17891790      WHERE
    1790       (plg.owner.id = :owner OR plg.itemKey.id IN (:itemKeys) OR plg.projectKey.id IN (:projectKeys))
     1791        (true = :hasPluginPermission OR plg.owner.id = :owner
     1792        OR plg.itemKey.id IN (:itemKeys) OR plg.projectKey.id IN (:projectKeys))
    17911793      AND gcx.itemType = :itemType AND gcx.contextType = :contextType
    17921794      AND (
  • trunk/src/core/net/sf/basedb/core/PluginDefinition.java

    r3052 r3074  
    266266    throws BaseException
    267267  {
     268    SessionControl sc = dc.getSessionControl();
     269    boolean hasConfigPermission = sc.hasPermission(Permission.USE, Item.PLUGINCONFIGURATION);
     270    boolean hasPluginPermission = sc.hasPermission(Permission.USE, Item.PLUGINDEFINITION);
     271   
    268272    org.hibernate.Session session = dc.getHibernateSession();
    269273    org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, "COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT");
     
    273277      JOIN plg.guiContexts gcx
    274278      LEFT JOIN plg.configurations cfg
    275         WITH cfg.owner.id = :owner OR cfg.itemKey.id IN (:itemKeys) OR cfg.projectKey.id IN (:projectKeys)
     279      WITH true = :hasConfigPermission OR cfg.owner.id = :owner
     280        OR cfg.itemKey.id IN (:itemKeys) OR cfg.projectKey.id IN (:projectKeys)
    276281      WHERE
    277       (plg.owner.id = :owner OR plg.itemKey.id IN (:itemKeys) OR plg.projectKey.id IN (:projectKeys))
     282        (true = :hasPluginPermission OR plg.owner.id = :owner
     283        OR plg.itemKey.id IN (:itemKeys) OR plg.projectKey.id IN (:projectKeys))
    278284      AND gcx.itemType = :itemType AND gcx.contextType = :contextType
    279285      AND (
     
    284290      GROUP BY plg.mainType
    285291    */
     292   
     293    // Context
    286294    query.setInteger("itemType", gc.getItem().getValue());
    287295    query.setInteger("contextType", gc.getType().getValue());
    288296
    289     SessionControl sc = dc.getSessionControl();
     297    // Role permissions
     298    query.setBoolean("hasConfigPermission", hasConfigPermission);
     299    query.setBoolean("hasPluginPermission", hasPluginPermission);
     300   
    290301    // Owner
    291302    query.setInteger("owner", sc.getLoggedInUserId());
Note: See TracChangeset for help on using the changeset viewer.