Needs review
Project:
Disk Node
Version:
master
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
10 Jul 2006 at 03:05 UTC
Updated:
10 Jul 2006 at 03:05 UTC
I believe that Drupal already prevents multiple users with the same name. So I added an override option that allows the peruserdir to create the directories by username rather than numbers.
In disknode.module, at function disknode_settings() around line 136 I added:
$form['disknode_peruserdir_byusername'] = array(
'#type' => 'checkbox',
'#title' => t('Per-user directories override to directory by user name'),
'#default_value' => variable_get('disknode_peruserdir_byusername', 0),
'#description' => t('Overrides the number-based user directories. The base directory will be created per user with the following format: "[basedir]/[username]". For example: "mybase/someuser"for the user "someuser". PER-USER DIRECTORIES MUST ALSO BE SELECTED!'),
);
And in disknode.inc at function __disknode_getbasedir() I changed the function to look like this:
function __disknode_getbasedir()
{
global $user;
$basedir = variable_get('disknode_base', '');
if ((intval(variable_get('disknode_peruserdir', 0)) == 1) && !user_access('escape user directory')) {
if (intval(variable_get('disknode_peruserdir_byusername', 0)) == 1) {
$basedir .= DIRECTORY_SEPARATOR.($user->name);
}
else {
$userdir = preg_replace("#^.*(.)(.)$#", "\\1".DIRECTORY_SEPARATOR."\\2", "00".$user->uid);
$basedir .= DIRECTORY_SEPARATOR.$userdir.DIRECTORY_SEPARATOR.($user->uid);
}
}
return $basedir;
}