protected function DownloadController::logDownload in Ubercart 8.4
Processes a file download.
Parameters
$file_user: The user that requested the download.
string $ip: The IP address that requested the download.
1 call to DownloadController::logDownload()
- DownloadController::transferDownload in uc_file/
src/ Controller/ DownloadController.php - Sends the file's binary data to a user via HTTP and updates the database.
File
- uc_file/
src/ Controller/ DownloadController.php, line 453
Class
- DownloadController
- Handles administrative view of files that may be purchased and downloaded.
Namespace
Drupal\uc_file\ControllerCode
protected function logDownload($file_user, $ip) {
// Add the address if it doesn't exist.
$addresses = $file_user->addresses;
if (!in_array($ip, $addresses)) {
$addresses[] = $ip;
}
$file_user->addresses = $addresses;
// Accessed again.
$file_user->accessed++;
// Calculate hash.
$file_user->file_key = \Drupal::csrfToken()
->get(serialize($file_user));
$key = NULL;
if (isset($file_user['fuid'])) {
$key = $file_user['fuid'];
}
// Insert or update (if $key is already in table) uc_file_users table.
\Drupal::database()
->merge('uc_file_users')
->key([
'fuid' => $key,
])
->fields($file_user)
->execute();
}