Hashtable h = _getMenuItems(req,res,config,form, startLevel);
List<Object> items = (List)h.get("menuItems");
boolean show = ((Boolean)h.get("showSaveButton")).booleanValue();
Folder parentFolder = (Folder)h.get("mainMenuFolder");
List<Object> l = _getHtmlTreeList(items, show, depth);
if(!((Boolean)l.get(1)).booleanValue()){
SessionMessages.add(req, "error", "error.menu.reorder.user_has_not_permission");
}
req.setAttribute("htmlTreeList", l.get(0));
req.setAttribute("showSaveButton", l.get(1));
List<Treeable> navs = new ArrayList<Treeable>();
//This condition works while saving the reordered menu
if (((cmd != null) && cmd.equals("generatemenu"))) {
HibernateUtil.startTransaction();
//regenerates menu files
boolean doReorderMenu = false;
if(l != null && (List)l.get(0) != null){
doReorderMenu = ((Boolean)l.get(1)).booleanValue();
}
if(doReorderMenu){
navs = _orderMenuItemsDragAndDrop(req,res,config,form);
}else{
Logger.warn(this, "Possible hack attack: User submitting menu post of which they have no permissions to");
_sendToReferral(req,res,req.getParameter("referer"));
return;
}
RefreshMenus.deleteMenus();
HibernateUtil.commitTransaction();
_sendToReferral(req,res,req.getParameter("referer"));
// we have to clear navs after db commit
for(Treeable treeable : navs){
Identifier id = APILocator.getIdentifierAPI().find(treeable.getIdentifier());
if("folder".equals(id.getAssetType())){
CacheLocator.getNavToolCache().removeNavByPath(id.getHostId(), id.getPath());
}
Folder folder = APILocator.getFolderAPI().findParentFolder(treeable, user, false);
String folderId = (folder==null) ? FolderAPI.SYSTEM_FOLDER : folder.getIdentifier();
CacheLocator.getNavToolCache().removeNav(id.getHostId(), folderId);
}
return;
}