rejetto forum

Software => HFS ~ HTTP File Server => Topic started by: luca69 on January 22, 2009, 10:46:44 AM

Title: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: luca69 on January 22, 2009, 10:46:44 AM
It would be nice if a user which has "upload" rights can also create a folder.
Any plan to implement it?
Is it possible to do it with a macro?
Title: Re: Functional request: folder creation (with upload rights)
Post by: Foggy on January 22, 2009, 12:58:13 PM
yes it would be possible to do with a macro.

Title: Re: Functional request: folder creation (with upload rights)
Post by: rejetto on January 22, 2009, 02:19:54 PM
in the future this function will be totally integrated in HFS.
in the while you can build it via macro. I will write something totally untested, for your inspiration

{.if|{.can upload.}|{:
form to create the folder

{.if|{.postvar|create_folder.}|{:
  {.mkdir|{.postvar|create_folder.}
:}.}

:}.}



...the {.if|{.postvar   may even be omitted, since mkdir should just fail if the name of the folder is empty.
Title: Re: Functional request: folder creation (with upload rights)
Post by: luca69 on January 26, 2009, 09:28:15 AM
Thanks for the hint. I'll try it when I have some free time  ;)

Bye
Luca
--------------- Edit
I tried to create it next to the "Delete" button with this peace of code:
Code: [Select]
<div style='margin-top:2em;'>
{.if|{.get|can delete.}|
<input type='hidden' name='action' value='delete'>
<input type='checkbox' onclick='var is = document.getElementsByName("selection"); for (var i=0; i < is.length; i++) is[i].checked = this.checked;'> All
<input style='margin-left:1em' type='submit' value='Delete selected' onclick='return confirm("Are you sure?")'>
/if.}
{.if|{.get|can upload.}|
Folder name: <input  type='text' name='fldname' maxlength="25" size="25" >
<input  type='submit' name='createfolder' value='Create Folder' >
{.if|{.postvar|fldname.}|
  {.mkdir|{.postvar|fldname.}.}
/if.}
  /if.}
</div>

The text input field and the button are displayed, but the folder is not created :(

Any hint?
Title: Re: Functional request: folder creation (with upload rights)
Post by: rejetto on January 27, 2009, 08:55:33 AM
1. put it just before </form>, so it will work also when there's no file in the folder
2. it was creating the folder in your HFS folder
3. i think it's better to check for the button instead of the content of the field
4. you forgot to {:quote:} the action. When you don't, the action is always done, not only when the IF is true.

Code: [Select]
  {.if|{.get|can upload.}|
Folder name: <input  type='text' name='fldname' maxlength="25" size="25" >
<input  type='submit' name='createfolder' value='Create Folder' >
{.if|{.postvar|createfolder.}|{:
{.mkdir|%folder-resource%\{.postvar|fldname.}.}
:}/if.}
  /if.}
</form>
Title: Re: Functional request: folder creation (with upload rights)
Post by: luca69 on January 27, 2009, 01:09:16 PM
Now it works: the folder is created  ;D, but the folder list is not refreshed  :-[
Any hint how can I force the refresh of the page?
Title: Re: Functional request: folder creation (with upload rights)
Post by: r][m on January 27, 2009, 02:26:45 PM
I've made several trys at this without success.
I can't get either example posted here to work at all?
Code: [Select]
{.if|{.?action = add.}|{: {.add folder|real|C:\HFS-Folder\Files|Folder1.} :}.}does add a folder to the vfs at root level as a real folder, but it should have been a subfolder.
Search will not find it on my hard drive, so it must actually be virtural.
What I need is to be able to specify directory its created in and folder name.
Any help anyone?
Title: Re: Functional request: folder creation (with upload rights)
Post by: rejetto on January 27, 2009, 02:48:58 PM
Now it works: the folder is created  ;D, but the folder list is not refreshed  :-[
Any hint how can I force the refresh of the page?

ah, right, it's because the list is made BEFORE the folder is created.
The easiest solution would be to automatically refresh the page after the creation. But it is ugly.
This is more elegant:

1. replace the code i gave you with this one
Code: [Select]
  {.if|{.get|can upload.}|
Folder name: <input  type='text' name='fldname' maxlength="25" size="25" >
<input  type='submit' name='createfolder' value='Create Folder' >
  /if.}
</form>


2. add this to the template
Code: [Select]
[special:begin]
{.if|{.and| {.get|can upload.} | {.postvar|createfolder.} .}|{:
{.mkdir|%folder-resource%\{.postvar|fldname.}.}
:}/if.}
Title: Re: Functional request: folder creation (with upload rights)
Post by: luca69 on January 27, 2009, 03:20:01 PM
THANKS !!!!
Now it is perfect! My users will love it  ;D
Title: Re: Functional request: folder creation (with upload rights)
Post by: rejetto on January 27, 2009, 03:59:23 PM
does add a folder to the vfs at root level as a real folder, but it should have been a subfolder.

from next build it will be as subfolder.
and more: the name may contain a VFS path, so you can specify where to put it.
"foo" will just go as subfolder of the current folder (or root if not in folder).
while "/foo" will go under the root, "/asd/foo" under asd, and so on.
Title: Re: Functional request: folder creation (with upload rights)
Post by: luca69 on February 03, 2009, 05:06:57 PM
H E L P !!!

I found a bug: if you create a new folder, you enter into it and you click on the path on the top, than a new folder with the same name is create!!!

How to reproduce it:
1. Enter into a folder where you have upload rights (e.g. "temp") and creates a new folder (e.g. "test")
2. Click on the newly created folder
3. On the top there is the current path: /Home/temp/test: click on "test" a new folder called test is created!!
--> now you can go to /Home/test/test

Each time a new path where you have upload rights is selected, the "test" folder is created!!

The problem is that the "createfolder" is not reset, but I do not know how to do that.
Title: Re: Functional request: folder creation (with upload rights)
Post by: rejetto on February 04, 2009, 01:39:29 AM
i tried to reproduce how you said, but it didn't work.
actually, what you saying is strange, because POSTed values should always been discarded by the browser at next request.
did you perhaps remove the method=post of the form
Title: Re: Functional request: folder creation (with upload rights)
Post by: luca69 on February 04, 2009, 07:38:00 AM
No I did not!
Please find enclosed my template (my_hfs.tlp).
There is also the admin panel and an additional function to enable the user to change the password by himself/herself.

Please Help!

Note: I put on the top the values of createfolder and fldname for debugging; also the java script was a test to clean the vars, but it did not work :(

hfs.tlp is the clean one only with the create folder code
Title: Re: Functional request: folder creation (with upload rights)
Post by: r][m on February 04, 2009, 04:34:27 PM
I too had some bizarre results working with add folder.
The folder created, when browsed should have been empty,
but was the hfs.exe directory! Delete section quit working, also.
Aparrently not build related. Restored with back up copy of my
tpl without add folder section, fixed it. Now to try again  :)
Title: Re: Functional request: folder creation (with upload rights)
Post by: luca69 on February 06, 2009, 07:24:17 AM
I did some further tests putting in the top the debug code
Code: [Select]
Vars: createfolder={.postvar|createfolder.}; fldname={.postvar|fldname.};

Even putting back the folder creation to the form ...
Code: [Select]
</div>
{.if|{.get|can upload.}|
Folder name: <input  type='text' name='fldname' maxlength="25" size="25" >
<input  type='submit' name='createfolder' value='Create Folder' >
{.if|{.and| {.get|can upload.} | {.postvar|createfolder.} .}|{:
{.mkdir|%folder-resource%\{.postvar|fldname.}.}
:}/if.}
    /if.}
</form>

I got the same "funny" effect! It looks like the browser "remembers" the last post as the variables are not cleanup (see 3rd screenshot in the attachments)
Title: (SOLVED) Functional request: folder creation (with upload rights)
Post by: luca69 on February 06, 2009, 10:39:36 AM
Hi found a solution, although I do not really like it.
If I used the "get" method instead of the "post" it is working !!!

Place this code in the form to have the "Create Folder" Button

Code: [Select]
<form method='get'>
{.if|{.get|can upload.}|
Folder name: <input  type='text' name='fldname' maxlength="25" size="25" >
<input  type='submit' name='createfolder' value='Create Folder' >
    /if.}
</form>


and add this code to generate the folder
Code: [Select]
[special:begin]
{.if|{.and| {.get|can upload.} | {.urlvar|createfolder.} .}|{:
{.mkdir|%folder-resource%\{.urlvar|fldname.}.}
:}/if.}

Vars in this case are visible in the address bar, but if the user is not logged in and does not have upload rights, the folder is not created, so it's not that dangerous :D

But there is still an annoying bug: if you create a folder and afterwards you want to delete it, the vars are not cleaned (as "delete" uses "post" and not "get") and the folder is created again!
If you navigate somewhere else, the get is cleaned (no vars in the address bar) and you can delete the folder
Title: Re: Functional request: folder creation (with upload rights)
Post by: rejetto on February 07, 2009, 05:12:57 PM
I got the same "funny" effect! It looks like the browser "remembers" the last post as the variables are not cleanup (see 3rd screenshot in the attachments)

it is not the browser.
indeed, if you check the issued request (dump) you won't see such value.
It is HFS. A bug.
Supposed to be fixed now. (next build)

thank you for reporting!
Title: Re: Functional request: folder creation (with upload rights)
Post by: luca69 on February 10, 2009, 10:45:40 AM
..ok I'll wait for next release  8)
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: luca69 on February 12, 2009, 08:28:29 AM
Tested with 223: now it works  ;D ;D
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: Ranger on February 12, 2009, 10:36:24 PM
I assume sine I'm using the RAWR template that this doesnt work?
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: luca69 on February 13, 2009, 07:38:31 AM
I assume sine I'm using the RAWR template that this doesnt work?
I do not know the RAWR template, but this feature was added by me, supported by Rejetto, to the standard template.
The code is rather simple (see posts on the first page). You can chenge the template by yourself or ask the RAWR owners to do that ;)
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: Kremlin on February 19, 2009, 04:48:47 PM
Creating a folder works nicely, but deleting it using 'rm' instead of 'mkdir' doesnt work? (the purpose is to enter the exact name of the folder and when you push the delete button it deletes the folder)

EDIT.

Nevermind ::) didnt think too use the 'delete' lol

EDIT2.

But now i've though about adding folders to the main page (ie. http://localhost/) without using remote access for direct hfs interface, what macro should be used? add?
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: rejetto on February 19, 2009, 05:22:42 PM
{.add folder.}
documented
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: Kremlin on February 19, 2009, 05:37:32 PM
Code: [Select]
{.if|{.and| {.get|can delete.} | {.urlvar|createroot.} .}|{:
{.{.add folder.}|%folder-resource%\{.urlvar|fldname.}.}
:}/if.}

{.if|{.and| {.get|can delete.} | {.urlvar|createroot.} .}|{:
{.add folder|%folder-resource%\{.urlvar|fldname.}.}
:}/if.}

tryed both and didnt work? (not used too work with macro btw)

----------------------------------------------------------------------------------

I think this might be a bug. These are the steps i took:

1. Created single account for hfs
2. Gave delete rights in Tree Root, and Upload rights in a real folder that i added
3. Specified the above code just for delete rights so it should only show in the Tree Root (ie. http://localhost/)
4. Going to the real folder i added (ie. http://localhost/abc) it now shows twice the create/delete buttons, in other words shows for delete and upload rights at the same time.

Below is the full code i used for this:

Code: [Select]
[special:begin]
{.load|/template/languages/language.txt|special:strings.}
{.if|{.and| {.get|can upload.} | {.urlvar|createfolder.} .}|{:
{.mkdir|%folder-resource%\{.urlvar|fldname.}.}
:}/if.}
{.if|{.and| {.get|can upload.} | {.urlvar|deletefolder.} .}|{:
{.delete|%folder-resource%\{.urlvar|fldname.}.}
:}/if.}
{.if|{.and| {.get|can delete.} | {.urlvar|createroot.} .}|{:
{.{.add folder.}|%folder-resource%\{.urlvar|fldname.}.}
:}/if.}
{.if|{.and| {.get|can delete.} | {.urlvar|deleteroot.} .}|{:
{.delete|%folder-resource%\{.urlvar|fldname.}.}
:}/if.}

-----------------------------------

<form method='get'>
{.if|{.get|can upload.}|
<input class="formCreate" type='text' name='fldname' maxlength="25" size="25" value="{.!lv_foldercreate.}" onclick="if(this.value=='{.!lv_foldercreate.}')this.value=''"/>
<input class="create" type='submit' name='createfolder' value='Create Folder' >
<input class="delete" type='submit' name='deletefolder' value='Delete File/Folder' >
/if.}
{.if|{.get|can delete.}|
<input class="formCreate" type='text' name='fldname' maxlength="25" size="25" value="{.!lv_foldercreate.}" onclick="if(this.value=='{.!lv_foldercreate.}')this.value=''"/>
<input class="create" type='submit' name='createroot' value='Create Folder' >
<input class="delete" type='submit' name='deleteroot' value='Delete File/Folder' >
/if.}
</form>

I made it so that it would only add real folder to the hfs tree and create actual folder (without adding them to the tree) within the real folder.

PS. This might be confusing but i will explain again if you want. In other words the delete rights are inherited to the below folders thus showing twice the create/delete buttons. The image below is already in the http://localhost/abc folder.

(http://g.imagehost.org/t/0572/bug.jpg) (http://g.imagehost.org/view/0572/bug)
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: rejetto on February 20, 2009, 11:52:26 AM
as you say, permissions are inherited, so it's normal that your script will show the buttons twice.

my advice is that you would not tell the root from the folder by the name of the variable, but from the path itself.
{.if| {.%folder% = / .} | this is the root | this is the folder.}

so you can have just the same buttons for both, and make difference only when you have to actually create the folder.
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: Kremlin on February 21, 2009, 02:54:42 PM
This is a rename file option based on the same code:

Code: [Select]
[special:begin]
{.if|{.and| {.get|can upload.} | {.urlvar|renamefile.} .}|{:
{.rename|%folder-resource%\{.urlvar|oldname.}|%folder-resource%\{.urlvar|newname.}.}
:}/if.}

Code: [Select]
<form method='get'>
{.if|{.get|can upload.}|
<input type='text' name='oldname' maxlength="25" size="25" value="Old Name.." onclick="if(this.value=='Old Name..')this.value=''"/>
<input type='text' name='newname' maxlength="25" size="25" value="New Name.." onclick="if(this.value=='New Name..')this.value=''"/>
<input type='submit' name='renamefile' value='Rename File'>
/if.}
</form>
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: rejetto on February 22, 2009, 02:43:17 AM
my advice solved your problem?
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: Kremlin on February 22, 2009, 12:23:10 PM
Yes that's why i shared the code.  ;)
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: luca69 on February 23, 2009, 12:15:00 PM
Yes that's why i shared the code.  ;)
Many thanks  ;D
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: Sapphirescales on July 20, 2009, 12:58:40 PM
Is there any way to make this work in another window?  Perhaps a popup window?  It's a really good feature, but it doesn't look too good on the page.........
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: rejetto on July 21, 2009, 12:22:17 PM
best way is to make it expandable.
popups are blocked most times.
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: timteka on August 29, 2009, 05:11:06 PM
i have the latest test build and don't see this feature in the template :-(
Title: Re: SOLVED (v223):Functional request: folder creation (with upload rights)
Post by: rejetto on August 30, 2009, 03:08:33 PM
in fact it's not in the default template.
at the moment it's only if you "install" this feature.