function node_gallery_upload_limits_form in Node Gallery 6.2
gallery upload limitation settings. seperate from upload module for more flexibility.
Parameters
unknown_type $default_settings:
unknown_type $image_type:
Return value
unknown
1 call to node_gallery_upload_limits_form()
File
- ./
node_gallery.admin.inc, line 403 - Node gallery admin page file
Code
function node_gallery_upload_limits_form(&$parent_form, $default_settings, $image_type) {
$default_value = array(
'file_extension' => 'jpg jpeg gif png',
'file_resolution' => 0,
'file_max_size' => 1,
'user_max_size' => 2,
'user_max_number' => 0,
);
$default_settings['general'] = array_merge($default_value, (array) $default_settings['general']);
$form['general'] = array(
'#type' => 'fieldset',
'#tree' => TRUE,
'#title' => t('Image Upload Limitation Default Settings'),
'#description' => t('Specify the image upload limitations'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['general']['file_extension'] = array(
'#type' => 'textfield',
'#title' => t('Default permitted file extensions'),
'#maxlength' => 255,
'#description' => t('Default extensions that users can upload. Separate extensions with a space and do not include the leading dot.'),
'#default_value' => $default_settings['general']['file_extension'],
);
$form['general']['file_resolution'] = array(
'#type' => 'textfield',
'#title' => t('Maximum resolution for uploaded images'),
'#size' => 15,
'#maxlength' => 10,
'#description' => t('The maximum allowed image size (e.g. 640x480). Set to 0 for no restriction. If an <a href="!image-toolkit-link">image toolkit</a> is installed, files exceeding this value will be scaled down to fit.', array(
'!image-toolkit-link' => url('admin/settings/image-toolkit'),
)),
'#field_suffix' => '<kbd>' . t('WIDTHxHEIGHT') . '</kbd>',
'#default_value' => $default_settings['general']['file_resolution'],
);
$form['general']['file_max_size'] = array(
'#type' => 'textfield',
'#title' => t('Default maximum file size per upload'),
'#default_value' => $default_settings['general']['file_max_size'],
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The default maximum file size a user can upload. If an image is uploaded and a maximum resolution is set, the size will be checked after the file has been resized.'),
'#field_suffix' => t('MB'),
);
$form['general']['user_max_size'] = array(
'#type' => 'textfield',
'#title' => t('Default total file size per user'),
'#default_value' => $default_settings['general']['user_max_size'],
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The default maximum size of all files a user can have on the gallery.'),
'#field_suffix' => t('MB'),
);
$form['general']['upload_max_size'] = array(
'#value' => '<p>' . t('Your PHP settings limit the maximum file size per upload to %size.', array(
'%size' => format_size(file_upload_max_size()),
)) . '</p>',
);
$form['general']['user_max_number'] = array(
'#type' => 'textfield',
'#title' => t('Default total file number per user'),
'#default_value' => $default_settings['general']['user_max_number'],
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The maximum number of images a user can upload to the gallery. (Set to 0 for unlimited)'),
);
$roles = user_roles(FALSE, 'create ' . $image_type . ' content');
$form['roles'] = array(
'#type' => 'value',
'#value' => $roles,
);
foreach ($roles as $rid => $role) {
$form['role_' . $rid] = array(
'#type' => 'fieldset',
'#title' => t('Image Upload Limitation Settings for @role', array(
'@role' => $role,
)),
'#tree' => TRUE,
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['role_' . $rid]['role_name'] = array(
'#type' => 'hidden',
'#value' => $role,
);
$form['role_' . $rid]['file_max_size'] = array(
'#type' => 'textfield',
'#title' => t('Maximum file size per upload'),
'#default_value' => empty($default_settings['role_' . $rid]['file_max_size']) ? $default_settings['general']['file_max_size'] : $default_settings['role_' . $rid]['file_max_size'],
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The maximum size of a file a user can upload. If an image is uploaded and a maximum resolution is set, the size will be checked after the file has been resized.'),
'#field_suffix' => t('MB'),
);
$form['role_' . $rid]['user_max_size'] = array(
'#type' => 'textfield',
'#title' => t('Total file size per user'),
'#default_value' => empty($default_settings['role_' . $rid]['user_max_size']) ? $default_settings['general']['user_max_size'] : $default_settings['role_' . $rid]['user_max_size'],
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The maximum size of all files a user can have on the gallery.'),
'#field_suffix' => t('MB'),
);
$form['role_' . $rid]['user_max_number'] = array(
'#type' => 'textfield',
'#title' => t('Total file number per user'),
'#default_value' => empty($default_settings['role_' . $rid]['user_max_number']) ? $default_settings['general']['user_max_number'] : $default_settings['role_' . $rid]['user_max_number'],
'#size' => 5,
'#maxlength' => 5,
'#description' => t('The maximum number of images a user can upload to the gallery. (Set to 0 for unlimited)'),
);
}
$parent_form['#validate'][] = 'node_gallery_upload_limits_form_validate';
$parent_form['config']['upload_limits'] = array_merge(array(), $form);
}