diff --git a/src/main/java/org/olat/admin/user/imp/_i18n/LocalStrings_fr.properties b/src/main/java/org/olat/admin/user/imp/_i18n/LocalStrings_fr.properties index 0cd1c280592e33299ed3fecc562b7fac2a9ea9df..96cc5b7c5f1e7806a33ee309ef8bc3570b2890b7 100644 --- a/src/main/java/org/olat/admin/user/imp/_i18n/LocalStrings_fr.properties +++ b/src/main/java/org/olat/admin/user/imp/_i18n/LocalStrings_fr.properties @@ -19,7 +19,7 @@ formatexplanation.part2.cancreatepassword=<li>Les colonnes suivantes sont obliga formatexplanation.part2.cannotcreatepassword=<li>Les colonnes suivantes sont obligatoires\: Login, mot de passe. </li> formatexplanation.part2a=<li>Les champs suivants sont \u00E0 remplir (obligatoirement ceux avec *)\: formatexplanation.part3=<li>Si la langue manque, la langue standard de l'installation OLAT.</li><li>Les autres colonnes d\u00E9pendent de la configuration et doivent correspondre \u00E0 la mod\u00E8le Excell.</li></ul> -import.confirm={0} utilisateurs dans le tableau\: {1} nouvel utilisateur et {2} utilisateur d\u00E9j\u00E0 existant. <br>Voulez-vous importer { 1 } nouvel utilisateur dans OLAT? +import.confirm={0} utilisateurs dans le tableau\: {1} nouvel utilisateur et {2} utilisateur d\u00E9j\u00E0 existant. <br>Voulez-vous importer {1} nouvel utilisateur dans OLAT? import.description0=Guid\u00E9 par un assistant, vous pouvez importer plusieurs utilisateurs en une fois. Vous n\u00E9cessiterez une liste de valeurs s\u00E9par\u00E9es par des tabulateurs. import.description1=Ce qui vous attend pendant l'assistant\: import.description2=<i>Exemple de donn\u00E9es\:</i> Gr\u00E2ce \u00E0 cet exemple, vous voyez comment le fichier Excel peut \u00EAtre rempli. En plus, un fichier-exemple excel est pr\u00EAt pour \u00EAtre t\u00E9l\u00E9charg\u00E9. diff --git a/src/main/java/org/olat/core/gui/control/generic/portal/PortalImpl.java b/src/main/java/org/olat/core/gui/control/generic/portal/PortalImpl.java index 5574f8ad01a4e96c5430c83f895058a22fdf64a9..2b4afb8948703ec13f465a0129e243a374261f21 100644 --- a/src/main/java/org/olat/core/gui/control/generic/portal/PortalImpl.java +++ b/src/main/java/org/olat/core/gui/control/generic/portal/PortalImpl.java @@ -74,6 +74,7 @@ public class PortalImpl extends DefaultController implements Portal, ControllerE private Map<String, PortletContainer> portletContainers; // map of all portlet containers (defined in portal columns + inactive portlets) private List<String> inactivePortlets; // list containing the names of inactive portlets private String name; + private boolean editModeEnabled = false; /** * Do use PortalFactory for create new Portals @@ -251,15 +252,11 @@ public class PortalImpl extends DefaultController implements Portal, ControllerE } if (isActive) { // initialize portlet container for active portlets only - pc.initializeRunComponent(ureq); - log.debug("initPortlets: add to inacitve portlets portletName=" + portlet.getName()); + pc.initializeRunComponent(ureq, editModeEnabled); } else { // add it to inacitve portlets list if not active inactivePortlets.add(portlet.getName()); - log.debug("initPortlets: add to inacitve portlets portletName=" + portlet.getName()); } - } else { - log.debug("Portlet disabled portletName=" + portlet.getName()); } } // update links on visible portlets @@ -273,15 +270,15 @@ public class PortalImpl extends DefaultController implements Portal, ControllerE if (source instanceof Link && portalVC.contains(source)) { Link tmp = (Link)source; String portletName = (String)tmp.getUserObject(); - List<String> firstColumn = this.portalColumns.get(0); - PortletContainer pc = this.portletContainers.get(portletName); + List<String> firstColumn = portalColumns.get(0); + PortletContainer pc = portletContainers.get(portletName); if (pc == null) throw new AssertException("trying to add portlet with name::" + portletName + " to portal, but portlet container did not exist. Could be a user modifying the URL..."); // add to users portlet list firstColumn.add(portletName); // remove from inactive portlets list - this.inactivePortlets.remove(portletName); + inactivePortlets.remove(portletName); // initialize portlet run component - pc.initializeRunComponent(ureq); + pc.initializeRunComponent(ureq, editModeEnabled); // save user config in db saveUserPortalColumnsConfiguration(ureq, portalColumns); // update possible links in gui @@ -295,21 +292,22 @@ public class PortalImpl extends DefaultController implements Portal, ControllerE * Enable/disable the edit mode of the portal * @param editModeEnabled true: enabled, false: disabled */ - public void setIsEditMode(UserRequest ureq, Boolean editModeEnabled) { + public void setIsEditMode(UserRequest ureq, boolean editModeEnabled) { + this.editModeEnabled = editModeEnabled; updatePorletContainerEditMode(ureq, editModeEnabled); - this.portalVC.contextPut(MODE_EDIT, editModeEnabled); + portalVC.contextPut(MODE_EDIT, editModeEnabled); } /** * Updates all portles using the given mode * @param editMode true: edit mode activated, false: deactivated */ - private void updatePorletContainerEditMode(UserRequest ureq, Boolean editMode) { - Iterator<String> portletsIter = PortletFactory.getPortlets().keySet().iterator(); - while (portletsIter.hasNext()) { - String portletName = (String) portletsIter.next(); - PortletContainer pc = this.portletContainers.get(portletName); - if (pc != null ) pc.setIsEditMode(ureq, editMode); + private void updatePorletContainerEditMode(UserRequest ureq, boolean editMode) { + for (String portletName : PortletFactory.getPortlets().keySet()) { + PortletContainer pc = portletContainers.get(portletName); + if (pc != null ) { + pc.setIsEditMode(ureq, editMode); + } } } @@ -318,7 +316,6 @@ public class PortalImpl extends DefaultController implements Portal, ControllerE */ @Override public void event(UserRequest ureq, Controller source, Event event) { - log.debug("PortalImpl event=" + event); if (source instanceof PortletContainer) { PortletContainer pc = (PortletContainer) source; String cmd = event.getCommand(); @@ -432,7 +429,7 @@ public class PortalImpl extends DefaultController implements Portal, ControllerE * @return Name of portal */ public String getName(){ - return this.name; + return name; } } diff --git a/src/main/java/org/olat/core/gui/control/generic/portal/PortletContainer.java b/src/main/java/org/olat/core/gui/control/generic/portal/PortletContainer.java index 875fb4dfa5dbbc98cf42f982308c4105b6b25ad4..92617c670afcef570f7c6ce50b6a0722676cccb9 100644 --- a/src/main/java/org/olat/core/gui/control/generic/portal/PortletContainer.java +++ b/src/main/java/org/olat/core/gui/control/generic/portal/PortletContainer.java @@ -106,16 +106,16 @@ public class PortletContainer extends BasicController implements PortletContaine close.setCustomEnabledLinkCSS("b_portlet_edit_delete"); portletContainerVC.put("toolbox", toolboxContainer); - } /** * Initializes the portlet runtime view * @param ureq */ - protected void initializeRunComponent(UserRequest ureq) { - this.runComponent = this.portlet.getInitialRunComponent(getWindowControl(), ureq); - this.portletContainerVC.put("portlet", runComponent); + protected void initializeRunComponent(UserRequest ureq, boolean editModeEnabled) { + runComponent = portlet.getInitialRunComponent(getWindowControl(), ureq); + portletContainerVC.put("portlet", runComponent); + addAdditonalTools(ureq, editModeEnabled); } /** @@ -135,7 +135,7 @@ public class PortletContainer extends BasicController implements PortletContaine * @param value Boolean value */ protected void contextPut(String name, Boolean value) { - this.portletContainerVC.contextPut(name, value); + portletContainerVC.contextPut(name, value); } /** @@ -166,18 +166,20 @@ public class PortletContainer extends BasicController implements PortletContaine /** * @param editModeEnabled true: portal is in edit mode, false in run mode */ - protected void setIsEditMode(UserRequest ureq, Boolean editModeEnabled) { - this.portletContainerVC.contextPut(MODE_EDIT, editModeEnabled); - + protected void setIsEditMode(UserRequest ureq, boolean editModeEnabled) { + portletContainerVC.contextPut(MODE_EDIT, editModeEnabled); //only create sorting and moving stuff if switching to edit mode otherwise lots or memory is wasted! - if (editModeEnabled) { - Controller additionalPortletTools = portlet.getTools(ureq, getWindowControl()); - if(additionalPortletTools!=null) { - toolboxContainer.contextPut("hasAdditional", Boolean.TRUE); - toolboxContainer.put("additionalTools", additionalPortletTools.getInitialComponent()); - } - } + addAdditonalTools(ureq, editModeEnabled); + } + + private void addAdditonalTools(UserRequest ureq, boolean editModeEnabled) { + if(!editModeEnabled) return; + Controller additionalPortletTools = portlet.getTools(ureq, getWindowControl()); + if(additionalPortletTools!=null) { + toolboxContainer.contextPut("hasAdditional", Boolean.TRUE); + toolboxContainer.put("additionalTools", additionalPortletTools.getInitialComponent()); + } } public void setCanMoveDown(boolean canMoveDown) { diff --git a/src/main/java/org/olat/core/util/cache/infinispan/InfinispanCacheWrapper.java b/src/main/java/org/olat/core/util/cache/infinispan/InfinispanCacheWrapper.java index f30214c32c93af6b4d6d6789ab79fb7d45996214..ae9c1f93ec053edc48ef3be33f6ed2dadf07dbd5 100644 --- a/src/main/java/org/olat/core/util/cache/infinispan/InfinispanCacheWrapper.java +++ b/src/main/java/org/olat/core/util/cache/infinispan/InfinispanCacheWrapper.java @@ -30,7 +30,6 @@ import java.util.ArrayList; import java.util.List; import org.infinispan.Cache; -import org.infinispan.CacheException; import org.olat.core.logging.OLATRuntimeException; import org.olat.core.util.cache.CacheWrapper; @@ -76,7 +75,7 @@ public class InfinispanCacheWrapper<U,V extends Serializable> implements CacheWr elem = cache.get(key); } catch (IllegalStateException e) { throw new OLATRuntimeException("cache state error for cache " + cache.getName(), e); - } catch (CacheException e) { + } catch (Exception e) {//don't catch CacheException to be compatible with infinispan 5.2 to 6.0 throw new OLATRuntimeException("cache error for cache " + cache.getName(), e); } return elem; diff --git a/src/main/java/org/olat/course/auditing/UserNodeAuditManagerImpl.java b/src/main/java/org/olat/course/auditing/UserNodeAuditManagerImpl.java index a57441599dec7b2f7cb691681d71e5e5dc6965ec..db58d52d9e9871bba24b86165c4e4236c0a3092a 100644 --- a/src/main/java/org/olat/course/auditing/UserNodeAuditManagerImpl.java +++ b/src/main/java/org/olat/course/auditing/UserNodeAuditManagerImpl.java @@ -26,7 +26,6 @@ package org.olat.course.auditing; import java.text.SimpleDateFormat; import java.util.Date; -import java.util.List; import org.olat.core.id.Identity; import org.olat.core.id.OLATResourceable; @@ -102,17 +101,19 @@ public class UserNodeAuditManagerImpl extends UserNodeAuditManager { /** * @see org.olat.course.auditing.AuditManager#hasUserNodeLogs(org.olat.course.nodes.CourseNode) */ + @Override public boolean hasUserNodeLogs(CourseNode node) { ICourse course = CourseFactory.loadCourse(ores); CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager(); - List<?> logsProperties = cpm.listCourseNodeProperties(node, null, null, LOG_IDENTIFYER); - return logsProperties.size() == 0 ? false : true; + int numOfProperties = cpm.countCourseNodeProperties(node, null, null, LOG_IDENTIFYER); + return numOfProperties > 0; } /** * @see org.olat.course.auditing.AuditManager#getUserNodeLog(org.olat.course.nodes.CourseNode, * org.olat.core.id.Identity) */ + @Override public String getUserNodeLog(CourseNode courseNode, Identity identity) { ICourse course = CourseFactory.loadCourse(ores); CoursePropertyManager cpm = course.getCourseEnvironment().getCoursePropertyManager(); diff --git a/src/main/java/org/olat/course/properties/CoursePropertyManager.java b/src/main/java/org/olat/course/properties/CoursePropertyManager.java index fcd5a442580d5e3db8df6546099d9cae5a74a23e..58eae4067d70655c2346401e459c6d8e11f332b6 100644 --- a/src/main/java/org/olat/course/properties/CoursePropertyManager.java +++ b/src/main/java/org/olat/course/properties/CoursePropertyManager.java @@ -87,6 +87,16 @@ public interface CoursePropertyManager extends IdentityAnonymizerCallback { */ public List<Property> listCourseNodeProperties(CourseNode node, Identity identity, BusinessGroup grp, String name); + /** + * Same as above but only count the properties + * @param node + * @param identity + * @param grp + * @param name + * @return + */ + public int countCourseNodeProperties(CourseNode node, Identity identity, BusinessGroup grp, String name); + /** * Find course node properties (exact match. I.e. null values are taken into account) * @param node diff --git a/src/main/java/org/olat/course/properties/PersistingCoursePropertyManager.java b/src/main/java/org/olat/course/properties/PersistingCoursePropertyManager.java index aecac3a8dc47c4b3190e306f05a4b4a23fa2916c..81619b54a12e87572485dcab87f2b4b3e78a06b3 100644 --- a/src/main/java/org/olat/course/properties/PersistingCoursePropertyManager.java +++ b/src/main/java/org/olat/course/properties/PersistingCoursePropertyManager.java @@ -125,11 +125,18 @@ public class PersistingCoursePropertyManager extends BasicManager implements Cou * org.olat.core.id.Identity, org.olat.group.BusinessGroup, * java.lang.String) */ + @Override public List<Property> listCourseNodeProperties(CourseNode node, Identity identity, BusinessGroup grp, String name) { String myCategory = buildCourseNodePropertyCategory(node); return pm.listProperties(identity, grp, myCategory, name); } + @Override + public int countCourseNodeProperties(CourseNode node, Identity identity, BusinessGroup grp, String name) { + String myCategory = buildCourseNodePropertyCategory(node); + return pm.countProperties(identity, grp, myCategory, name); + } + /** * @see org.olat.course.properties.CoursePropertyManager#findCourseNodeProperties(org.olat.course.nodes.CourseNode, * org.olat.core.id.Identity, org.olat.group.BusinessGroup, diff --git a/src/main/java/org/olat/course/run/preview/PreviewCoursePropertyManager.java b/src/main/java/org/olat/course/run/preview/PreviewCoursePropertyManager.java index fda347cd63edfb0ce2798b0b383d4c776c541f7e..a7c41451a64e795a614425d082d467aff14424ca 100644 --- a/src/main/java/org/olat/course/run/preview/PreviewCoursePropertyManager.java +++ b/src/main/java/org/olat/course/run/preview/PreviewCoursePropertyManager.java @@ -124,6 +124,11 @@ final class PreviewCoursePropertyManager extends BasicManager implements CourseP throw new AssertException("Not implemented for preview."); } + @Override + public int countCourseNodeProperties(CourseNode node, Identity identity, BusinessGroup grp, String name) { + return 0; + } + /** * @see org.olat.course.properties.CoursePropertyManager#findCourseNodeProperties(org.olat.course.nodes.CourseNode, org.olat.core.id.Identity, org.olat.group.BusinessGroup, java.lang.String) */ diff --git a/src/main/java/org/olat/course/site/CourseSiteDef.java b/src/main/java/org/olat/course/site/CourseSiteDef.java index d1d781c049d7cabc66668149c4471b798fae3e64..4487d7e0ed329c5a9581af0bede6f51a9754a35e 100644 --- a/src/main/java/org/olat/course/site/CourseSiteDef.java +++ b/src/main/java/org/olat/course/site/CourseSiteDef.java @@ -105,7 +105,7 @@ public class CourseSiteDef extends AbstractSiteDefinition implements SiteDefinit protected LanguageConfiguration getLanguageConfiguration(UserRequest ureq, CourseSiteConfiguration config) { if(config == null || config.getConfigurations() == null) return null; String language = ureq.getUserSession().getLocale().getLanguage(); - + LanguageConfiguration myLangConfig = null; LanguageConfiguration defaultLangConfig = null; for(LanguageConfiguration langConfig:config.getConfigurations()) { diff --git a/src/main/java/org/olat/home/controllerCreators/HomePortalControllerCreator.java b/src/main/java/org/olat/home/controllerCreators/HomePortalControllerCreator.java index be3077a6e3b07d6a4463140e66ef48345e8a7109..b6dd307f90f51094713230c977b09ac3deb760cb 100644 --- a/src/main/java/org/olat/home/controllerCreators/HomePortalControllerCreator.java +++ b/src/main/java/org/olat/home/controllerCreators/HomePortalControllerCreator.java @@ -135,10 +135,10 @@ public class HomePortalControllerCreator extends AutoCreator { @Override public void event(UserRequest ureq, Component source, Event event) { if (source == portalBackButton){ - this.myPortal.setIsEditMode(ureq, Boolean.FALSE); + myPortal.setIsEditMode(ureq, false); welcome.contextPut("portalEditMode", Boolean.FALSE); } else if (source == portalEditButton){ - this.myPortal.setIsEditMode(ureq, Boolean.TRUE); + myPortal.setIsEditMode(ureq, true); welcome.contextPut("portalEditMode", Boolean.TRUE); } } diff --git a/src/main/java/org/olat/note/NotesPortletRunController.java b/src/main/java/org/olat/note/NotesPortletRunController.java index f02fd60f73ff90e75d16b9fd5f0ffd3e7a954fce..aed0e44dc61160d6e5b9b60910aadbe8657532b9 100644 --- a/src/main/java/org/olat/note/NotesPortletRunController.java +++ b/src/main/java/org/olat/note/NotesPortletRunController.java @@ -248,6 +248,7 @@ public class NotesPortletRunController extends AbstractPortletRunController<Note protected void doDispose() { CoordinatorManager.getInstance().getCoordinator().getEventBus().deregisterFor(this, eventBusThisIdentityOres); super.doDispose(); + portletToolsController = null; } /** diff --git a/src/main/java/org/olat/portfolio/ui/structel/_content/multiMaps.html b/src/main/java/org/olat/portfolio/ui/structel/_content/multiMaps.html index 6d4665214b60e0ecf934777666cb80d6f0c568b3..b9a373c6e503ec64ed5260f6f4829f9cdcf297c3 100644 --- a/src/main/java/org/olat/portfolio/ui/structel/_content/multiMaps.html +++ b/src/main/java/org/olat/portfolio/ui/structel/_content/multiMaps.html @@ -23,7 +23,7 @@ #if($map.getClass().getSimpleName() == "EPStructuredMapTemplate") #set($addTempStamp = "template") #end <li class="$!mapStyles.get($index) $!addTempStamp"> <h4>$r.escapeHtml($map.title)</h4> - <div class="b_map_descr">$r.escapeHtml($map.shortenedDescription)</div> + <div class="b_map_descr">$r.xssScan($map.shortenedDescription)</div> <div class="b_map_info"> #if ($owners.get($index)) <p>$r.translate("map.owners", $r.escapeHtml($owners.get($index))) </p> #end <p>$amounts.get($index) diff --git a/src/main/java/org/olat/properties/NarrowedPropertyManager.java b/src/main/java/org/olat/properties/NarrowedPropertyManager.java index 58099d16644109890530650bdbcf6cba58e70fde..5aed655591929cb7c45d1105ced1a9e45307a606 100644 --- a/src/main/java/org/olat/properties/NarrowedPropertyManager.java +++ b/src/main/java/org/olat/properties/NarrowedPropertyManager.java @@ -118,6 +118,10 @@ public class NarrowedPropertyManager { return pm.listProperties(identity, grp, resourceable, category, name); } + public int countProperties(Identity identity, BusinessGroup grp, String category, String name) { + return pm.countProperties(identity, grp, resourceable, category, name); + } + /** * Generic find method. Returns a list of Property objects. This is an exact match i.e. if you pass-on null values, * null values will be included in the query. diff --git a/src/main/java/org/olat/properties/PropertyManager.java b/src/main/java/org/olat/properties/PropertyManager.java index a8ae2569dfb631e0184705774eddbec73fd6ec6b..b049e17db6f377ef02df22d01376b4d4e514a5cc 100644 --- a/src/main/java/org/olat/properties/PropertyManager.java +++ b/src/main/java/org/olat/properties/PropertyManager.java @@ -181,10 +181,19 @@ public class PropertyManager extends BasicManager implements UserDataDeletable { * @return a list of Property objects */ public List<Property> listProperties(Identity identity, BusinessGroup grp, OLATResourceable resourceable, String category, String name) { - if (resourceable == null) + if (resourceable == null) { return listProperties(identity, grp, null, null, category, name); - else + } else { return listProperties(identity, grp, resourceable.getResourceableTypeName(), resourceable.getResourceableId(), category, name); + } + } + + public int countProperties(Identity identity, BusinessGroup grp, OLATResourceable resourceable, String category, String name) { + if (resourceable == null) { + return countProperties(identity, grp, null, null, category, name, null, null); + } else { + return countProperties(identity, grp, resourceable.getResourceableTypeName(), resourceable.getResourceableId(), category, name, null, null); + } } /** @@ -201,6 +210,13 @@ public class PropertyManager extends BasicManager implements UserDataDeletable { return listProperties(identity, grp, resourceTypeName, resourceTypeId, category, name, null, null); } + public int countProperties(Identity identity, BusinessGroup grp, String resourceTypeName, Long resourceTypeId, + String category, String name, Long longValue, String stringValue) { + TypedQuery<Number> query = createQueryListProperties(identity, grp, resourceTypeName, resourceTypeId, + category, name, longValue, stringValue, Number.class); + return query.getSingleResult().intValue(); + } + /** * Only to use if no OLATResourceable Object is available. * @param identity @@ -215,14 +231,44 @@ public class PropertyManager extends BasicManager implements UserDataDeletable { */ public List<Property> listProperties(Identity identity, BusinessGroup grp, String resourceTypeName, Long resourceTypeId, String category, String name, Long longValue, String stringValue) { + TypedQuery<Property> query = createQueryListProperties(identity, grp, resourceTypeName, resourceTypeId, + category, name, longValue, stringValue, Property.class); + return query.getResultList(); + } + + /** + * + * @param identity + * @param grp + * @param resourceTypeName + * @param resourceTypeId + * @param category + * @param name + * @param longValue + * @param stringValue + * @param resultClass Only Number and Property are acceptable + * @return + */ + private <U> TypedQuery<U> createQueryListProperties(Identity identity, BusinessGroup grp, String resourceTypeName, Long resourceTypeId, + String category, String name, Long longValue, String stringValue, Class<U> resultClass) { StringBuilder sb = new StringBuilder(); - sb.append("select v from ").append(Property.class.getName()).append(" as v "); - if (identity != null) { - sb.append(" inner join fetch v.identity identity "); - } - if (grp != null) { - sb.append(" inner join fetch v.grp grp "); + if(Number.class.equals(resultClass)) { + sb.append("select count(v) from ").append(Property.class.getName()).append(" as v "); + if (identity != null) { + sb.append(" inner join v.identity identity "); + } + if (grp != null) { + sb.append(" inner join v.grp grp "); + } + } else { + sb.append("select v from ").append(Property.class.getName()).append(" as v "); + if (identity != null) { + sb.append(" inner join fetch v.identity identity "); + } + if (grp != null) { + sb.append(" inner join fetch v.grp grp "); + } } sb.append(" where "); @@ -260,7 +306,7 @@ public class PropertyManager extends BasicManager implements UserDataDeletable { sb.append("v.stringValue=:string"); } - TypedQuery<Property> queryProps = DBFactory.getInstance().getCurrentEntityManager().createQuery(sb.toString(), Property.class); + TypedQuery<U> queryProps = DBFactory.getInstance().getCurrentEntityManager().createQuery(sb.toString(), resultClass); if (identity != null) { queryProps.setParameter("identityKey", identity.getKey()); } @@ -285,7 +331,7 @@ public class PropertyManager extends BasicManager implements UserDataDeletable { if (stringValue != null) { queryProps.setParameter("string", stringValue); } - return queryProps.getResultList(); + return queryProps; } /** diff --git a/src/main/java/org/olat/repository/RepositoryTableModel.java b/src/main/java/org/olat/repository/RepositoryTableModel.java index 0ebaaef1ab6a9360342a23adf1cd5790152dfa91..e3bdd586db9e8f964f4a2e787f5df1ccfcf98f01 100644 --- a/src/main/java/org/olat/repository/RepositoryTableModel.java +++ b/src/main/java/org/olat/repository/RepositoryTableModel.java @@ -117,7 +117,48 @@ public class RepositoryTableModel extends DefaultTableDataModel<RepositoryEntry> //fxdiff VCRP-1,2: access control of resources CustomCellRenderer acRenderer = new RepositoryEntryACColumnDescriptor(); tableCtr.addColumnDescriptor(new CustomRenderColumnDescriptor("table.header.ac", RepoCols.ac.ordinal(), null, - loc, ColumnDescriptor.ALIGNMENT_LEFT, acRenderer)); + loc, ColumnDescriptor.ALIGNMENT_LEFT, acRenderer) { + + @Override + public int compareTo(int rowa, int rowb) { + Object o1 = table.getTableDataModel().getObject(rowa); + Object o2 = table.getTableDataModel().getObject(rowb); + if(o1 == null || !(o1 instanceof RepositoryEntry)) return -1; + if(o2 == null || !(o2 instanceof RepositoryEntry)) return 1; + RepositoryEntry re1 = (RepositoryEntry)o1; + RepositoryEntry re2 = (RepositoryEntry)o2; + + if(re1.isMembersOnly()) { + if(!re2.isMembersOnly()) { + return 1; + } + } else if(re2.isMembersOnly()) { + return -1; + } + + OLATResourceAccess ac1 = repoEntriesWithOffer.get(re1.getOlatResource().getKey()); + OLATResourceAccess ac2 = repoEntriesWithOffer.get(re2.getOlatResource().getKey()); + + if(ac1 == null && ac2 != null) return -1; + if(ac1 != null && ac2 == null) return 1; + if(ac1 != null && ac2 != null) return compareAccess(re1, ac1, re2, ac2); + return super.compareString(re1.getDisplayname(), re2.getDisplayname()); + } + + private int compareAccess(RepositoryEntry re1, OLATResourceAccess ac1, RepositoryEntry re2, OLATResourceAccess ac2) { + int s1 = ac1.getMethods().size(); + int s2 = ac2.getMethods().size(); + int compare = s1 - s2; + if(compare != 0) return compare; + if(s1 > 0 && s2 > 0) { + String t1 = ac1.getMethods().get(0).getMethod().getType(); + String t2 = ac2.getMethods().get(0).getMethod().getType(); + int compareType = super.compareString(t1, t2); + if(compareType != 0) return compareType; + } + return super.compareString(re1.getDisplayname(), re2.getDisplayname()); + } + }); tableCtr.addColumnDescriptor(new RepositoryEntryTypeColumnDescriptor("table.header.typeimg", RepoCols.repoEntry.ordinal(), null, loc, ColumnDescriptor.ALIGNMENT_LEFT)); @@ -133,7 +174,7 @@ public class RepositoryTableModel extends DefaultTableDataModel<RepositoryEntry> ColumnDescriptor nameColDesc = new DefaultColumnDescriptor("table.header.displayname", RepoCols.displayname.ordinal(), enableDirectLaunch ? TABLE_ACTION_SELECT_ENTRY : null, loc) { @Override public int compareTo(int rowa, int rowb) { - Object o1 =table.getTableDataModel().getValueAt(rowa, 1); + Object o1 = table.getTableDataModel().getValueAt(rowa, 1); Object o2 = table.getTableDataModel().getValueAt(rowb, 1); if(o1 == null || !(o1 instanceof RepositoryEntry)) return -1; @@ -191,7 +232,7 @@ public class RepositoryTableModel extends DefaultTableDataModel<RepositoryEntry> * @see org.olat.core.gui.components.table.TableDataModel#getValueAt(int, int) */ public Object getValueAt(int row, int col) { - RepositoryEntry re = (RepositoryEntry)getObject(row); + RepositoryEntry re = getObject(row); switch (RepoCols.values()[col]) { //fxdiff VCRP-1,2: access control of resources case ac: { diff --git a/src/main/java/org/olat/user/_i18n/LocalStrings_pt_BR.properties b/src/main/java/org/olat/user/_i18n/LocalStrings_pt_BR.properties index 0ffa31b8948bf89ef4023e259b7a26410f6959c9..3a2219cfc15ac8e31c8531b5cf6213b1dd5b131c 100644 --- a/src/main/java/org/olat/user/_i18n/LocalStrings_pt_BR.properties +++ b/src/main/java/org/olat/user/_i18n/LocalStrings_pt_BR.properties @@ -1,7 +1,7 @@ #Fri Sep 06 14:29:55 CEST 2013 Failed=Falha na carga do arquivo. NoImage=Este formato de arquivo n\u00E3o pode ser carregado como imagem. -ULLimitExceeded=A imagem n\u00E3o pode exceder { 0 } kByte. +ULLimitExceeded=A imagem n\u00E3o pode exceder {0} kByte. accessibility.web2aMode.label=Modo Web 2.a para leitor em braille ativo action.choose=Selecionar ajaxon.global.label=Modo AJAX ativo em todo o sistema @@ -170,7 +170,7 @@ menu.homepage=Cart\u00E3o de Visita menu.homepage.alt=Cart\u00E3o de Visita do usu\u00E1rio selecionado menu.portfolio=Portfolio menu.portfolio.alt=Portfolio -notallowedtochangepwd=Voc\u00EA n\u00E3o tem permiss\u00E3o para alterar sua senha. Favor contatar { 0 } +notallowedtochangepwd=Voc\u00EA n\u00E3o tem permiss\u00E3o para alterar sua senha. Favor contatar {0} password.failed=Sua nova senha n\u00E3o pode ser salva. Houver um erro inesperado no servidor. password.successful=Sua nova senha foi salva com sucesso. Ela \u00E9 v\u00E1lida de agora em diante. preferences.successful=Suas configura\u00E7\u00F5es de sistema foram salvas. Modifica\u00E7\u00F5es em suas configura\u00E7\u00F5es de linguagem ser\u00E3o ativadas ap\u00F3s seu pr\u00F3ximo login. diff --git a/src/main/java/org/olat/user/_i18n/LocalStrings_pt_PT.properties b/src/main/java/org/olat/user/_i18n/LocalStrings_pt_PT.properties index 7257eb5d813fb5e9e2528d4b576e26a99f70acd0..523ee91027b9681095f0e361201f6c3ad97641eb 100644 --- a/src/main/java/org/olat/user/_i18n/LocalStrings_pt_PT.properties +++ b/src/main/java/org/olat/user/_i18n/LocalStrings_pt_PT.properties @@ -1,7 +1,7 @@ #Wed Jul 28 13:33:31 CEST 2010 Failed=Falha na carga do arquivo. NoImage=Este formato de arquivo n\u00E3o pode ser carregado como imagem. -ULLimitExceeded=A imagem n\u00E3o pode exceder { 0 } kByte. +ULLimitExceeded=A imagem n\u00E3o pode exceder {0} kByte. action.choose=Selecionar ajaxon.label=Vers\u00E3o beta AJAX (reprodu\u00E7\u00E3o r\u00E1pida de p\u00E1ginas) change=Modificar @@ -112,7 +112,7 @@ menu.folder=Pasta menu.folder.alt=Pasta do usu\u00E1rio selecionado menu.homepage=Cart\u00E3o de Visita menu.homepage.alt=Cart\u00E3o de Visita do usu\u00E1rio selecionado -notallowedtochangepwd=Voc\u00EA n\u00E3o tem permiss\u00E3o para alterar sua senha. Favor contatar { 0 } +notallowedtochangepwd=Voc\u00EA n\u00E3o tem permiss\u00E3o para alterar sua senha. Favor contatar {0} password.successful=Sua nova senha foi salva com sucesso. Ela \u00E9 v\u00E1lida de agora em diante. preferences.successful=Suas configura\u00E7\u00F5es de sistema foram salvas. Modifica\u00E7\u00F5es em suas configura\u00E7\u00F5es de linguagem ser\u00E3o ativadas ap\u00F3s seu pr\u00F3ximo login. preferences.unsuccessful=Suas configura\u00E7\u00F5es de sistema n\u00E3o puderam ser salvas. Favor tentar novamente. diff --git a/src/test/java/org/olat/properties/PropertyTest.java b/src/test/java/org/olat/properties/PropertyTest.java index 75bab13753146ac51cd4c179a05bf7eef2551228..cb49d236bee202b30e58f14aa43f8538b323d319 100644 --- a/src/test/java/org/olat/properties/PropertyTest.java +++ b/src/test/java/org/olat/properties/PropertyTest.java @@ -196,6 +196,9 @@ public class PropertyTest extends OlatTestCase { Property prop = (Property) entries.get(0); assertEquals(ores.getResourceableTypeName(), prop.getResourceTypeName()); assertEquals(ores.getResourceableId(), prop.getResourceTypeId()); + + int numOfEntries = PropertyManager.getInstance().countProperties(identity, group, ores.getResourceableTypeName(), ores.getResourceableId(), "cat", "TestProperty", null, null); + Assert.assertEquals(entries.size(), numOfEntries); } /**