How to automatically create a ftp directory for each FrontEndUser?

Do something cool with CMS? Show us ...
This board is for 'Answers', and the discussion of answers... Not for questions.
Post Reply
kjonix
New Member
New Member
Posts: 9
Joined: Tue Nov 10, 2009 11:09 am

How to automatically create a ftp directory for each FrontEndUser?

Post by kjonix »

Hi!

I have successfully uses Calguy's suggestion for individual file list for each front end user

Modified to:

{capture assign='dir'}medlemsdok/{$username}{/capture}
{file_list folder=$dir sort=d colheaders=1}


BUT:
If folder not excist for logged in user, the filelist shows a lot of warning messages (of course).
In my case i want a directory for each of my users and I want that directory to be created automatically.

How can this be done? I use selv registration combined with FEU.

To avoid manually have to create folder for old users, I think a good solution will be to create the folder when user log in and next time check if folder for user is already created, if yes: don't create a new folder.

But it may be easier to create the folder when the user register? It is possible for me to create folder for old user.

Appreciate any help or hints! ;-)
JeremyBASS

Re: How to automatically create a ftp directory for each FrontEndUser?

Post by JeremyBASS »

Just us a udt on the FEU events.. and the a little php to create the folder and one to delete the folder.. you have the username to work with.. Really straight forward.. HTH cheers -Jeremy
Peciura

Re: How to automatically create a ftp directory for each FrontEndUser?

Post by Peciura »

Assign this UDT ("create_feu_dir") to event "Frontend User Management -> OnLogin". It should send you an email on failure.

Code: Select all

global $gCms;
$config = $gCms->GetConfig();

$subdir = 'front_end_users';
$user_dir = $params['username'];
$email = 'admin@**************';		/*your mail address*/
/*$user_dir = $params['id'];*/		/*sometimes it is better ideato create dir based on user id*/
$destdir = cms_join_path($config['uploads_path'], $subdir, $user_dir);

cge_dir::mkdirr($destdir);
if( !is_dir($destdir) ){
	$body = 'Directory "'.$destdir.'" was not created for user ('.$params['id'].') '.$params['username'];
	$subject = $body;
	$mail =& $gCms->modules['CMSMailer']['object'];
	$mail->AddAddress( $email );
	$mail->SetBody( $body );
	$mail->SetSubject( $subject );
	$mail->Send();
}
Last edited by Peciura on Fri Jul 23, 2010 7:32 pm, edited 1 time in total.
JeremyBASS

Re: How to automatically create a ftp directory for each FrontEndUser?

Post by JeremyBASS »

ay Peciura your not suppost to do the work for them hehe :D j/k nice little snippit
Peciura

Re: How to automatically create a ftp directory for each FrontEndUser?

Post by Peciura »

JeremyBass: normally i would not, but i already thought about smth similar so i did it a bit earlier :).
Besides it is good thing to share some working examples with first-timers. That i know from personal experience :).
JeremyBASS

Re: How to automatically create a ftp directory for each FrontEndUser?

Post by JeremyBASS »

Oh I was only joking :D (the j/k is just kidding) I'm also one of the guilty to just pass over a script. :)
Peciura

Re: How to automatically create a ftp directory for each FrontEndUser?

Post by Peciura »

Oh I was only joking  (the j/k is just kidding)
I don't know... :-\ You sounded so convincing...

I also put this UDT on our wiki (events page). So people who are reading docs will get a bit more help.
Last edited by Peciura on Fri Jul 23, 2010 8:50 pm, edited 1 time in total.
JeremyBASS

Re: How to automatically create a ftp directory for each FrontEndUser?

Post by JeremyBASS »

Peciura wrote:
Oh I was only joking  (the j/k is just kidding)
I don't know... :-\ You sounded so convincing...

I also put this UDT on our wiki (events page). So people who are reading docs will get a bit more help.
Oh that is why I thought I'd say I was joking.. didn't want you to think I was just some a$% :D ...

Side note.. you may want to note that in order to use this you must have CGextensions in case someone wants to try to uses this for some other reason that doesn't relate to FEU and to which wouldn't necessarily have CGext. due to that.  Also FYI there is a mkdirr in the core so you could use that.

One last thing @kjonix you should also make a udt to delete the user folder on the FEU event for user deletion.. you can also find a recursive deletion in the core too..
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: How to automatically create a ftp directory for each FrontEndUser?

Post by calguy1000 »

Side note.. you may want to note that in order to use this you must have CGextensions in case someone wants to try to uses this for some other reason that doesn't relate to FEU and to which wouldn't necessarily have CGext. due to that.  Also FYI there is a mkdirr in the core so you could use that.
FEU requires CGExtensions... so it's safe.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
JeremyBASS

Re: How to automatically create a ftp directory for each FrontEndUser?

Post by JeremyBASS »

it was the
for some other reason that doesn't relate to FEU and to which wouldn't necessarily have CGext. due to that.
if they don't have FEU they may not have it is all I was saying, you know nobs and all hehe :D

*edit* I guess I should be clearer.. the thought was that if someone tries to do the create folder and email for some other event like on cataloger or some other module's event.  That thought is just me being a cautious nellie
Last edited by JeremyBASS on Fri Jul 23, 2010 9:45 pm, edited 1 time in total.
Peciura

Re: How to automatically create a ftp directory for each FrontEndUser?

Post by Peciura »

I decided not to mention that UDT depends on CGE and CMSMailer, since FEU depends on both of them. But i guess it it is better to keep it crystal-clear on wiki.

and almost forgot:
kjonix, do folder deletion UDT yourself. Not kidding  >:(.
Last edited by Peciura on Fri Jul 23, 2010 9:47 pm, edited 1 time in total.
Post Reply

Return to “Tips and Tricks”