function uc_file_feature_settings in Ubercart 5
Same name and namespace in other branches
- 6.2 uc_file/uc_file.module \uc_file_feature_settings()
- 7.3 uc_file/uc_file.module \uc_file_feature_settings()
Form builder for file settings
1 string reference to 'uc_file_feature_settings'
- uc_file_product_feature in uc_file/
uc_file.module - Implementation of hook_product_feature().
File
- uc_file/
uc_file.module, line 448 - Allows products to be associated with downloadable files.
Code
function uc_file_feature_settings() {
uc_add_js('$(document).ready(function() { if ($("#edit-uc-file-download-limit-duration-granularity").val() == "never") {$("#edit-uc-file-download-limit-duration-qty").attr("disabled", "disabled").val("");} });', 'inline');
$statuses = array();
foreach (uc_order_status_list('general') as $status) {
$statuses[$status['id']] = $status['title'];
}
$form['uc_file_default_order_status'] = array(
'#type' => 'select',
'#title' => t('Order status'),
'#default_value' => variable_get('uc_file_default_order_status', 'completed'),
'#description' => t('Where in the order status the user will be given the file download. Be aware that if payments are processed automatically, this happens before anonymous customers have an account created. This order status should not be reached before the user account exists.'),
'#options' => $statuses,
);
$form['uc_file_base_dir'] = array(
'#type' => 'textfield',
'#title' => t('Files path'),
'#description' => t('The absolute path (or relative to Drupal root) where files used for file downloads are located. For security reasons, it is reccommended to choose a path outside the web root.'),
'#default_value' => variable_get('uc_file_base_dir', NULL),
);
$form['uc_file_download_limit'] = array(
'#type' => 'fieldset',
'#title' => t('Download limits'),
'#description' => t('Leave any of these fields empty or unchanged to not enforce a limit with them.'),
);
$form['uc_file_download_limit']['uc_file_download_limit_number'] = array(
'#type' => 'textfield',
'#title' => t('Downloads'),
'#description' => t('The number of times a file can be downloaded.'),
'#default_value' => variable_get('uc_file_download_limit_number', NULL),
'#maxlength' => 4,
'#size' => 4,
);
$form['uc_file_download_limit']['uc_file_download_limit_addresses'] = array(
'#type' => 'textfield',
'#title' => t('IP addresses'),
'#description' => t('The number of unique IP addresses from which a user can download a file.'),
'#default_value' => variable_get('uc_file_download_limit_addresses', NULL),
'#maxlength' => 4,
'#size' => 4,
);
$form['uc_file_download_limit']['uc_file_download_limit_duration_qty'] = array(
'#type' => 'textfield',
'#title' => t('Time'),
'#default_value' => variable_get('uc_file_download_limit_duration_granularity', 'never') == 'never' ? NULL : variable_get('uc_file_download_limit_duration_qty', NULL),
'#size' => 4,
'#maxlength' => 4,
'#prefix' => '<div class="duration">',
'#suffix' => '</div>',
);
$form['uc_file_download_limit']['uc_file_download_limit_duration_granularity'] = array(
'#type' => 'select',
'#options' => array(
'never' => t('never'),
'day' => t('day(s)'),
'week' => t('week(s)'),
'month' => t('month(s)'),
'year' => t('year(s)'),
),
'#default_value' => variable_get('uc_file_download_limit_duration_granularity', 'never'),
'#attributes' => array(
'onchange' => 'if (this.value == "never") {$("#edit-uc-file-download-limit-duration-qty").attr("disabled", "disabled").val("");} else {$("#edit-uc-file-download-limit-duration-qty").removeAttr("disabled");}',
),
'#description' => t('How long after a product has been purchased until its file download expires.'),
'#prefix' => '<div class="duration">',
'#suffix' => '</div>',
);
$form['uc_file_advanced'] = array(
'#type' => 'fieldset',
'#title' => t('Advanced server settings'),
'#description' => t('The defaults should cover most use cases. Do not change these unless you know what you are doing.'),
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['uc_file_advanced']['uc_file_file_mask'] = array(
'#type' => 'textfield',
'#title' => t('Files mask'),
'#description' => t('The regular expression used for masking files in files directory.'),
'#default_value' => variable_get('uc_file_file_mask', ".*"),
);
$form['uc_file_advanced']['uc_file_reverse_proxy_addresses'] = array(
'#type' => 'textarea',
'#rows' => 3,
'#title' => t('Allowed reverse proxy addresses'),
'#description' => t('Add allowed reverse proxy addresses for the file download system to check for (one per line), otherwise @var will be used as the origin address.', array(
'@var' => $_SERVER['REMOTE_ADDR'],
)),
'#default_value' => implode("\n", variable_get('uc_file_reverse_proxy_addresses', array())),
);
return $form;
}