--- filemanager.module Wed Jul 04 23:44:20 2007
+++ filemanager.module Thu Jan 03 16:56:43 2008
@@ -527,26 +527,6 @@
}
/**
- * Returns a list of file areas used by the current module set
- *
- * @return
- * A list of all file areas
- */
-function filemanager_area_list() {
- $areas = array();
- $areas[] = array('area' => 'general', 'name' => t('General'), 'description' => t('All files not specifically stored in another area.'));
- foreach (module_list() as $module) {
- $module_areas = module_invoke($module, 'filemanager_areas');
- if ($module_areas) {
- foreach ($module_areas as $area) {
- $areas[] = $area;
- }
- }
- }
- return $areas;
-}
-
-/**
* Purges out files over the age limit in the working repository for all areas
*/
function filemanager_purge_orphans() {
@@ -755,32 +735,35 @@
$form['file_areas'] = array(
'#type' => 'fieldset',
- '#title' => t('File areas'),
+ '#title' => t('Modules and File Areas'),
'#tree' => true,
'#theme' => 'filemanager_fileareas_admin',
'info' => array(
'#type' => 'markup',
- '#value' => ''. t("The following numbers control the total size of all files allowed in a particular area. Enter '-1' to allow unlimited size. Select force private to force all files in that area to be streamed (no direct access) through the private directory. If the module that controls that area does not enforce security it will default to allow all access.") .''
+ '#value' => ''. t('The following are all modules and the areas they use for file storage. Clicking on the area takes you to the settings page for the module that controls that area. There you can configure the maximum size and private settings.') .''
),
);
- foreach(filemanager_area_list() as $area) {
- $key = $area['area'];
+ foreach(module_invoke_all('filemanager_areas') as $module) {
+ $key = $module['module'];
$form['file_areas']['areas'][$key] = array(
- '#description' => $area['description'],
- '#title' => $area['name'],
+ '#description' => $module['description'],
+ '#title' => $module['name'],
+ 'area' => array(
+ $key .'_filemanager_area' => array(
+ '#value' => l($key, $module['area settings'])
+ ),
+ ),
'limit' => array(
- 'filemanager_area_limit_' . $key => array(
- '#type' => 'textfield',
- '#default_value' => variable_get('filemanager_area_limit_' . $key, '-1'),
- '#size' => 6,
- '#maxlength' => 10,
+ $key .'_filemanager_area_limit' => array(
+ '#value' => variable_get($key .'_filemanager_area_limit', '-1')
),
),
'force' => array(
- 'filemanager_force_private_' . $key => array(
+ $key .'_filemanager_force_private' => array(
'#type' => 'checkbox',
- '#default_value' => variable_get('filemanager_force_private_' . $key, 0),
+ '#default_value' => variable_get($key .'_filemanager_force_private', 0),
'#return_value' => 1,
+ '#disabled' => true
),
),
);
@@ -792,15 +775,17 @@
function theme_filemanager_fileareas_admin($form) {
$output = drupal_render($form['info']);
- $header = array(t('Area'),t('Description'),t('Max size (Mb)'),t('Force Private'));
foreach (element_children($form['areas']) as $key) {
$row = array();
$row[] = $form['areas'][$key]['#title'];
+ $row[] = drupal_render($form['areas'][$key]['area']);
$row[] = $form['areas'][$key]['#description'];
$row[] = drupal_render($form['areas'][$key]['limit']);
$row[] = drupal_render($form['areas'][$key]['force']);
$rows[] = $row;
}
+
+ $header = array(t('Module'), t('Area'), t('Description'), t('Max size (MB)'), t('Force Private'));
$output .= theme('table', $header, $rows);
$output .= drupal_render($form);
--- filemanager.install Mon Jul 16 18:53:53 2007
+++ filemanager.install Thu Jan 03 16:52:18 2008
@@ -68,10 +68,8 @@
variable_del('filemanager_public_url');
variable_del('filemanager_working_maxage');
variable_del('filemanager_working_sizelimit');
- $fa = variable_get( 'file_areas', NULL );
- foreach( $fa['areas'] as $key => $val ) {
- variable_del('filemanager_area_limit_'. $key);
- variable_del('filemanager_force_private_'. $key);
+ foreach(module_invoke_all('filemanager_areas') as $module) {
+ variable_del($module['module'] .'_filemanager_area_limit');
+ variable_del($module['module'] .'_filemanager_force_private');
}
- variable_del('file_areas');
}
\ No newline at end of file
--- filemanager.php Thu Sep 14 01:07:39 2006
+++ filemanager.php Thu Jan 03 16:36:52 2008
@@ -32,12 +32,27 @@
function hook_filemanager_areas() {
return array(
array(
- 'area' => 'general',
- 'name' => t('General'),
- 'description' => t('All files not specifically stored in another area.')
+ 'module' => 'human-readable name',
+ 'area settings' => 'path to area settings page (controlling module settings page)',
+ 'area' => 'machine-readable module name',
+ 'name' => t('human-readable area name'),
+ 'description' => t('A description of this module\'s use of this area')
)
);
}
+
+/**
+ * Settings for the private and max_area_size are stored in the following
+ * variables:
+ * - MODULENAME_filemanager_area_limit
+ * - MODULENAME_filemanager_force_private
+ *
+ * For example, attachment.module stores it's filemanager settings using the
+ * following:
+ * variable_set('attachment_filemanager_area_limit', VALUE);
+ * variable_set('attachment_filemanager_force_private', VALUE);
+ *
+ */
/**
* Determine whether this private download is accessible by the user.