adding a form on the edit article pages that allows you to add an image attachment...
authorgrok <grok>
Sun, 7 Aug 2005 17:02:15 +0000 (17:02 +0000)
committergrok <grok>
Sun, 7 Aug 2005 17:02:15 +0000 (17:02 +0000)
ChangeLog
source/mircoders/servlet/ServletModuleContent.java
templates/admin/FUNCTIONS.template
templates/admin/content.template

index 0fb0ece..daf68e2 100755 (executable)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2005-08-7  Grok  <grok@no-log.org>
+        * templates/admin/FUNCTIONS.template:
+       adding a form on the edit article pages that allows you 
+       to add an image attachment by directly typing in its id
+       
 2005-07-26  Grok  <grok@no-log.org>
 
        * source/mir/media/image/ImageMagickImageProcessor.java:
index 6955e26..afba80c 100755 (executable)
@@ -176,10 +176,19 @@ public class ServletModuleContent extends ServletModule {
   public void attach(HttpServletRequest aRequest, HttpServletResponse aResponse) throws ServletModuleExc {
     String  mediaIdParam = aRequest.getParameter("mid");
     String  articleId = aRequest.getParameter("articleid");
-
     if (articleId == null || mediaIdParam==null)
       throw new ServletModuleExc("smod content :: attach :: articleid/mid missing");
-
+    // check if mediaIdParam and articleid are correct integers
+    try
+    {
+      Integer.parseInt(mediaIdParam);
+      Integer.parseInt(articleId);
+    }
+    catch(NumberFormatException e)
+    {
+      throw new ServletModuleExc("smod content :: attach :: invalid articleid/mid");
+    }
+    
     if (!MirGlobal.accessControl().article().mayEditArticle(ServletHelper.getUser(aRequest), articleId))
       throw new ServletModuleExc("Article has been locked");
 
index 6c08aa3..0a0e882 100755 (executable)
       <if aCanEdit=="1">
         <td align="left" valign="top" class="listrow2">
           <a href="${config.actionRoot}?module=Images&amp;do=list&amp;${objectKey}=${anObject.id}&amp;returnurl=${utility.encodeURI(aReturnUrl)}">[+] ${lang("content.addimage")}</a> |
-          <a href="${config.actionRoot}?module=Images&amp;do=add&amp;${objectKey}=${anObject.id}&amp;returnurl=${utility.encodeURI(aReturnUrl)}">${lang("content.uploadimage")}</a>
+          <a href="${config.actionRoot}?module=Images&amp;do=add&amp;${objectKey}=${anObject.id}&amp;returnurl=${utility.encodeURI(aReturnUrl)}">${lang("content.uploadimage")}</a> |
+                   <form method="post" action="${config.actionRoot}">
+                    id:
+             <input type="hidden" name="module" value="${objectModule}">
+             <input type="hidden" name="do" value="attach">
+                    <input type="text" size="5" maxlength="10" name="mid" value="">
+             <input type="hidden" name="${objectKey}" value="${anObject.id}">
+                    <input type="submit" class="minorbutton" value="${lang("content.addimage")}">
+                 </form>
         </td>
       </if>
     </tr>
index dfe72e5..e0f620f 100755 (executable)
     </tr>
   </if>    
 </table>
-  
+
+<if mayEdit=="1">
+  </form>
+</if>  
+
 <if new=="0">
   <table width="90%" cellspacing="0" cellpadding="0">
   
 </table>
 
 </if>          
-<if mayEdit=="1">
-  </form>
-</if>  
 
   <include "foot.template">
 </body>