commentadmin better
[mir.git] / source / mircoders / servlet / ServletModuleContent.java
index e01d76f..9d54349 100755 (executable)
@@ -254,6 +254,7 @@ public class ServletModuleContent extends ServletModule
     String  mediaIdParam = req.getParameter("mid");
     String  idParam = req.getParameter("cid");
     if (idParam == null||mediaIdParam==null) throw new ServletModuleException("smod content :: attach :: cid/mid missing");
+    
     try {
       EntityContent entContent = (EntityContent)mainModule.getById(idParam);
       entContent.attach(mediaIdParam);
@@ -266,16 +267,19 @@ public class ServletModuleContent extends ServletModule
 
   public void dettach(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
   {
-    String  idParam = req.getParameter("cid");
-    if (idParam == null) throw new ServletModuleException("smod content :: dettach :: cid missing");
+    String  cidParam = req.getParameter("cid");
+               String  midParam = req.getParameter("mid");
+    if (cidParam == null) throw new ServletModuleException("smod content :: dettach :: cid missing");
+    if (midParam == null) throw new ServletModuleException("smod content :: dettach :: mid missing");
+    
     try {
-      EntityContent entContent = (EntityContent)mainModule.getById(idParam);
-      entContent.dettach();
+      EntityContent entContent = (EntityContent)mainModule.getById(cidParam);
+      entContent.dettach(cidParam,midParam);
     }
     catch(ModuleException e) {
       theLog.printError("smod content :: dettach :: could not get entityContent");
     }
-    _showObject(idParam, req, res);
+    _showObject(cidParam, req, res);
   }
 
   public void newswire(HttpServletRequest req, HttpServletResponse res) throws ServletModuleException
@@ -372,11 +376,10 @@ public class ServletModuleContent extends ServletModule
         theLog.printError("language-popup could not be fetched.");
       }
       // get the images
-      String currentMediaId = entContent.getValue("to_media");
-      SimpleHash imageHash = new SimpleHash();
-      if (currentMediaId!=null && !currentMediaId.equals("")) {
-        imageHash.put(currentMediaId, HTMLTemplateProcessor.makeSimpleHash(imageModule.getById(currentMediaId)));
-        mergeData.put("images", imageHash);
+      EntityList currentMedia = DatabaseContentToMedia.getInstance().getMedia(entContent);
+      if (currentMedia!=null && currentMedia.getCount()>=1) {
+        SimpleList mediaList = HTMLTemplateProcessor.makeSimpleList(currentMedia);
+                               mergeData.put("to_media", mediaList);
       }