This topic is locked

Tutorial: how to create folders automatically when new user registers

1/17/2014 8:47:49 PM
DocManager template
admin

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.

P
precisiondi 9/25/2014

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

E
edgarv 9/1/2015



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!!

B
bvteam 1/15/2019

Hi
Followed your tutorial step-by-step, but....It gives me an error:
"Fatal error: Call to undefined function createFolder() in C:\#\Documents\PHPRunnerProjects\DocManager1\output\include\events.php on line 162"
Registration is open, lines of code are in their places.
Any ideea?
DocManager v3
Later edit: (Phprunner 10 b32290)

Looks like in x64 gives me that error, but in x86 is working