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: 16209
  • Joined: 03-February 03
  • Gender:Male

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: 15
  • 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: 24
  • 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

#4 User is offline   seraphic 

  • Newbie
  • Pip
  • Group: Members
  • Posts: 1
  • Joined: 19-July 18

Posted 15 January 2019 - 09:24 AM

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
0

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

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users