Create user directory on registration

4 years 3 weeks ago #317050 by 3cellhosting
Replied by 3cellhosting on topic Create user directory on registration
Hello Kyle,

Thanks for the advice. There will be multiple files for each user.

I have uploaded a file to see the result and then checked the database as you suggested.

Quick question...

In the table comprofiler_plugin_gallery_items, the field called "value" is 32 characters long and ends .pdf - Is this simply a random number generated to avoid duplicate file names?

Many thanks for your input.

Regards
David

David
www.3cellhosting.com - where personality, creativity and integrity come as standard.

Please Log in to join the conversation.

4 years 2 weeks ago #317061 by krileon
Replied by krileon on topic Create user directory on registration
The "value" column is the stored filename that's in the actual file system. The "file" column is the readable filename for the file. So for example if the file you upload is Test123.pdf you'd have Test123.pdf in "file" and "value" would typically be something randomly generated. This doesn't have to be the case though you can have "value" and "file" both user readable values it's entirely up to you and is there to avoid multiple uploads of same filename from overwriting each other.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

3 years 11 months ago #317394 by 3cellhosting
Replied by 3cellhosting on topic Create user directory on registration
Hi Kyle,

Based on your advice I resolved my issue about saving to the gallery plugin. Each user could have multiple files and for ease of identification we created meaningful filenames to enable recognition by users.

We are using RSFormsPro and post processing of php. For completion of this post, incase anyone else has a similar need, this is the code we used to update the gallery plugin.
// Prepare variables
$delegate = $_POST['form']['RSEProName'];
$courseTitle = $_POST['form']['courseName'];
$delegateId = $_POST['form']['membershipId'];
$date = date("Y-m-d H:i:s");
$fileTitle = $delegate."-".$courseTitle."-".$SubmissionId.".pdf";

$path_to_directory = 'images/comprofiler/plug_cbgallery/'.$delegateId.'/files/';
if (!file_exists($path_to_directory) && !is_dir($path_to_directory)) {
    mkdir($path_to_directory, 0755, true);
}

// Set query for Comprofiler cbGallery plugin

$pdfName = $delegate.'-'.$courseTitle.'-'.$SubmissionId.'.pdf';
$jsonArray = [
	'name' => $pdfName,
	'extension' => 'pdf',
	'mimetype' => 'application\/pdf',
	'modified' => $date,
	'filesize' => 289565,
	'height' => 0,
	'width' => 0,
	'name_thumbnail' => $pdfName,
	'extension_thumbnail' => 'pdf',
	'mimetype_thumbnail' => 'application\/pdf',
	'modified_thumbnail' => $date,
	'filesize_thumbnail' => 289565,
	'height_thumbnail' => 0,
	'width_thumbnail' => 0
];

$jsonString = json_encode($jsonArray);

$db = JFactory::getDbo();

$query = $db->getQuery(true);
$columns = array('user_id','asset','type','value','file','folder','title','description','published','date','params');
$values = array($db->quote($delegateId), $db->quote('profile.'.$delegateId), $db->quote('files'), $db->quote($pdfName), $db->quote($pdfName), $db->quote('0'), $db->quote($courseTitle), $db->quote('CPPD Certificate'),  $db->quote('1'), $db->quote($date), $db->quote($jsonString));

// Prepare the insert query.
$query
    ->insert($db->quoteName('xho18_comprofiler_plugin_gallery_items')) 
    ->columns($db->quoteName($columns))
    ->values(implode(',', $values));

$db->setQuery($query);
$db->execute();

As usual, thank you for your advice.

David

David
www.3cellhosting.com - where personality, creativity and integrity come as standard.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.859 seconds

Facebook Twitter LinkedIn