Allow admins to mkdir rmdir
[squasher.git] / templates / index.tpl
index 51afa03210e68ed1fb20e07487a3186c000ff227..cd5e8c7be4b7a12db56aa18d2babe7b0b12daf0e 100644 (file)
      aSelect.options[i].selected = true;
     }
    }
+   function deleteFolder(foldername) {
+    if (!confirm('Are you sure you want to delete folder '+foldername+' ?'))
+     return;
+    document.rmdir.submit();
+   }
+   function deleteFolderNotEmpty(foldername) {
+    alert(foldername+' in not empty. Please empty it first');
+   }
+   function createFolder() {
+    var folder = prompt("New folder name");
+    if (folder == null)
+     return; // canceled
+    if (folder.indexOf('/')>=0 || folder=='.' || folder=='..') {
+     // detect the most common errors
+     alert('Invalid name');
+     return;
+    }
+    document.mkdir.newname.value = folder;
+    document.mkdir.submit();
+   }
 {/literal}</script>
 </head>
 <body>
                        <div class="menuhead">current folder</div>
        
                        {foreach item=crumb key=cookie from=$base}<a href="?path={$cookie|escape:'url'}">{$crumb|escape}</a>{/foreach}
-       
+
+                       {if $user_level > 99 AND count($base)>1 }
+                               <form name=rmdir method=post>
+                               <input type=hidden name=tools value=rmdir>
+                               <a href="javascript:deleteFolder{if count($squashed)>0 || count($subfolders)>0}NotEmpty{/if}('{$currentfolder|escape:'javascript'|escape}');" class=tool>delete this folder</a>
+                               </form>
+                       {/if}
+
                </div>
        
                <div class="menu">
-       
+
                        <div class="menuhead">subfolders</div>
-       
+
                        {foreach item=folder key=folderpath from=$subfolders}<a href="?path={$folderpath|escape:'url'}">{$folder|escape}</a>{/foreach}
-       
+
+                       {if $user_level > 99}
+                               <form name=mkdir method=post>
+                               <input type=hidden name=tools value=mkdir>
+                               <input type=hidden name=newname>
+                               <a href="javascript:createFolder();" class=tool>new subfolder</a>
+                               </form>
+                       {/if}
+
                </div>
-       
+
        </div>
        
        <div class="content">