Forums: Tutorial: how to create folders automatically when new user registers - Forums

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Tutorial: how to create folders automatically when new user registers

#1 User is offline   admin 

  • Administrator
  • PipPipPip
  • Group: Admin
  • Posts: 15408
  • Joined: 03-February 03

Posted 18 January 2014 - 01:47 AM

It would be nice if new user or company gets some folders created for them automatically when new account is created. We'll show you how this can be done. We assume that your project has Registration page turned on.

1. Create a project using DocManager template or add DocManager template to existing project. Enable Registration page.

2. Open <project folder>\business\DocManager\source\docman_functions.php file in any text editor and add the following function there somewhere at the end of the file:

function createFolder($name, $parentFolderID, $ownerID) {

	global $dal;
	$tblDocs = $dal->Table("doc_files");

	$tblDocs->Value["parent_folder_id"]=$parentFolderID;
	$tblDocs->Value["file_type"]="folder";
	$tblDocs->Value["file"]=my_json_encode(array($file));
	$tblDocs->Value["hash"]=generatePassword(HASH_LENGTH);
	$tblDocs->Value["name"]=$name;
	$tblDocs->Value["ownerid"]=$ownerID;
	$tblDocs->Value["created"]=now();
	$tblDocs->Add();
}


This function accepts three parameters:
$name - name of the folder to be created
$parentFolderID - ID of the parent folder, 0 if folder is created on the top level
$ownerID - user id from doc_users table

3. AfterSuccessfulRegistration event

Create some folders automatically.

$id = DBLookup("select id from doc_users where email='".$userdata["email"]."'");

createFolder("tmp",0,$id );
createFolder("public",0,$id );
createFolder("private",0,$id );


This is it.

Posted Image
Best regards,
Sergey Kornilov
0

#2 User is offline   PDI 

  • Member
  • PipPip
  • Group: Members
  • Posts: 12
  • Joined: 10-June 14

Posted 25 September 2014 - 07:26 PM

Can you provide an example of how you would do this with ASPRunnerPro?
0

#3 User is offline   edgarv 

  • Member
  • PipPip
  • Group: Members
  • Posts: 22
  • Joined: 03-August 07

Posted 01 September 2015 - 02:17 PM

View PostPDI, on 25 September 2014 - 02:26 PM, said:

Can you provide an example of how you would do this with ASPRunnerPro?


Where you able to get an example for ASPRunnerPro?

I would also like to know how to add the code in ASPRunnerPro.

thanks!!
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic