Pull merge.
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d7 / hook / file_copy.twig
1 /**
2  * Implements hook_file_copy().
3  */
4 function {{ machine_name }}_file_copy($file, $source) {
5   $file_user = user_load($file->uid);
6   // Make sure that the file name starts with the owner's user name.
7   if (strpos($file->filename, $file_user->name) !== 0) {
8     $file->filename = $file_user->name . '_' . $file->filename;
9     $file->save();
10
11     watchdog('file', t('Copied file %source has been renamed to %destination', array('%source' => $source->filename, '%destination' => $file->filename)));
12   }
13 }