Changeset 4376
- Timestamp:
- Jul 4, 2008, 2:04:48 PM (15 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/core/common-queries.xml
r4335 r4376 1898 1898 </query> 1899 1899 1900 <query id="LOAD_USER_CONTEXTS" type="HQL"> 1901 <sql> 1902 SELECT ctx 1903 FROM ContextData ctx 1904 WHERE ctx.user.id = :user 1905 AND ctx.client.id = :client 1906 AND ctx.name = :name 1907 </sql> 1908 <description> 1909 A Hibernate query that loads all saved context information 1910 with a given name for a specific user/client. 1911 </description> 1912 </query> 1913 1900 1914 <query id="COUNT_PLUGINS_BY_TYPE_FOR_CONTEXT" type="HQL"> 1901 1915 <sql> -
trunk/src/core/net/sf/basedb/core/SessionControl.java
r4232 r4376 50 50 51 51 import java.util.Date; 52 import java.util.Iterator; 52 53 import java.util.Set; 53 54 import java.util.Map; … … 1581 1582 1582 1583 /** 1584 Delete all default contexts for the logged in user. 1585 1586 @param itemType The item type to delete the contexts for, or null 1587 to delete all contexts 1588 @param inMemory TRUE to delete in-memory contexts 1589 @param inDatabase TRUE to delete in-database contexts 1590 @return The number of contexts deleted 1591 @since 2.8 1592 */ 1593 public int deleteCurrentContexts(Item itemType, boolean inMemory, boolean inDatabase) 1594 { 1595 int numDeleted = 0; 1596 if (inMemory) 1597 { 1598 if (itemType == null) 1599 { 1600 numDeleted += currentContexts.size(); 1601 currentContexts.clear(); 1602 } 1603 else 1604 { 1605 Iterator<ItemContext> ccit = currentContexts.values().iterator(); 1606 while (ccit.hasNext()) 1607 { 1608 ItemContext cc = ccit.next(); 1609 if (cc.getItemType() == itemType) 1610 { 1611 ccit.remove(); 1612 numDeleted++; 1613 } 1614 } 1615 } 1616 } 1617 1618 if (inDatabase) 1619 { 1620 org.hibernate.Session session = null; 1621 org.hibernate.Transaction tx = null; 1622 ItemContext context = null; 1623 try 1624 { 1625 session = HibernateUtil.newSession(); 1626 tx = HibernateUtil.newTransaction(session); 1627 1628 org.hibernate.Query query = HibernateUtil.getPredefinedQuery(session, 1629 "LOAD_USER_CONTEXTS"); 1630 /* 1631 SELECT ctx 1632 FROM ContextData ctx 1633 WHERE ctx.user.id = :user 1634 AND ctx.client.id = :client 1635 AND ctx.name = :name 1636 */ 1637 query.setInteger("user", loginInfo.userId); 1638 query.setInteger("client", getClientId()); 1639 query.setString("name", ItemContext.DEFAULT_NAME); 1640 List<ContextData> contexts = HibernateUtil.loadList(ContextData.class, query, this); 1641 for (ContextData ctx : contexts) 1642 { 1643 if (itemType == null || itemType.getValue() == ctx.getItemType()) 1644 { 1645 HibernateUtil.deleteData(session, ctx); 1646 numDeleted++; 1647 } 1648 } 1649 HibernateUtil.commit(tx); 1650 } 1651 catch (BaseException ex) 1652 { 1653 if (tx != null) HibernateUtil.rollback(tx); 1654 throw ex; 1655 } 1656 finally 1657 { 1658 if (session != null) HibernateUtil.close(session); 1659 } 1660 } 1661 return numDeleted; 1662 } 1663 1664 /** 1583 1665 Get the value of a session setting with the specified name. 1584 1666 @param name The name of the setting -
trunk/www/include/menu.jsp
r4338 r4376 489 489 title="Reload permissions" 490 490 onclick="<%="Main.openPopup('"+root+"my_base/user/submit_user.jsp?ID="+ID+"&cmd=ReloadPermissions', 'ReloadPermissions', 300, 200);"%>" 491 tooltip="Reload permissions" 492 /> 493 <m:menuitem 494 title="Reset list settings…" 495 onclick="<%="Main.openPopup('"+root+"my_base/user/reset_filters.jsp?ID="+ID+"', 'ResetFilter', 400, 300);"%>" 491 496 tooltip="Reload permissions" 492 497 /> -
trunk/www/my_base/user/submit_user.jsp
r3679 r4376 155 155 message = "Permissions reloaded"; 156 156 } 157 else if ("ResetFilters".equals(cmd)) 158 { 159 boolean inDatabase = Values.getBoolean(request.getParameter("database")); 160 int numDeleted = sc.deleteCurrentContexts(null, true, inDatabase); 161 message = numDeleted + " list settings deleted"; 162 } 163 else 164 { 165 throw new WebException("popup", "Invalid command", "The command {1} is not recognised as a valid command.", cmd); 166 } 157 167 } 158 168 finally
Note: See TracChangeset
for help on using the changeset viewer.