You are here

auditfiles.module in Audit Files 6.2

File

auditfiles.module
View source
<?php

/**
 * Audit files carries out a simple audit of the Drupal upload directory
 * and the {files} table, to look for inconsistencies
 */

/**
 * Implementation of hook_help().
 */
function auditfiles_help($path, $arg) {
  switch ($path) {
    case 'admin/settings/auditfiles':
      return t('You can choose to exclude specific files, paths and extensions from the \'files not in database\' audit report by adding them to the relevant lists below.');
    case 'admin/help#auditfiles':
      return '<p>' . t('The audit files module performs an audit of the file table and the files directory to check for inconsistencies.') . '</p>';
    case 'admin/reports/auditfiles/notonserver':
      $output .= '<p>' . t('The files listed below are in the {files} table but the physical files do not exist on the server. This might mean the file has been deleted using a program such as FTP, or it may mean there is an error in the database.</p><p>If the file was uploaded using the upload module then you can click on the node number to view the item to which the missing file relates to try and determine what action needs to be taken, or you can click the edit link to open the node editing form directly.') . '</p>';
      $output .= '<p>' . t('Files in this list are relative to the files directory %directorypath.', array(
        '%directorypath' => file_directory_path(),
      )) . '</p>';
      return $output;
    case 'admin/reports/auditfiles':
      $output .= '<p>' . t('The files listed below are in the files directory on the server but appear to have no corresponding entry in the {files} table. Files in "temporary" folders such as those created by the image module are included in order to check that they are not filling up. You can choose to delete files from this report but remember that if you do this the action cannot be undone.') . '</p>';
      $output .= '<p>' . t('Files in this list are relative to the files directory %directorypath.', array(
        '%directorypath' => file_directory_path(),
      )) . '</p>';

      // If on the delete confirmation form then suppress the help message
      if ($_POST['operation'] == 'delete' && $_POST['files']) {
        $output = '';
      }
      return $output;
  }
}

/**
 * Implementation of hook_perm().
 */
function auditfiles_perm() {
  return array(
    'access file audits',
    'administer file audits',
  );
}

/**
 * Implementation of hook_menu().
 */
function auditfiles_menu() {
  $items = array();
  $items['admin/reports/auditfiles'] = array(
    'title' => 'Audit files',
    'description' => 'List files that are not on the server or not in the database.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'auditfiles_notindb',
    ),
    'access arguments' => array(
      'access file audits',
    ),
    'file' => 'notindb.admin.inc',
  );
  $items['admin/reports/auditfiles/notindb'] = array(
    'title' => t('Files not in database'),
    'description' => 'List files that are on the server but are not in the database.',
    'type' => MENU_DEFAULT_LOCAL_TASK,
    'weight' => -10,
  );
  $items['admin/reports/auditfiles/notonserver'] = array(
    'title' => 'Audit files not on server',
    'description' => 'List files that are in the database, but are not on the server.',
    'page callback' => 'auditfiles_notonserver',
    'access arguments' => array(
      'access file audits',
    ),
    'type' => MENU_LOCAL_TASK,
    'file' => 'notonserver.admin.inc',
  );
  $items['admin/settings/auditfiles'] = array(
    'title' => 'Audit files',
    'description' => 'Set file, extension and path exclusions for file audits.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array(
      'auditfiles_admin_settings',
    ),
    'access arguments' => array(
      'administer file audits',
    ),
    'file' => 'auditfiles.admin.inc',
  );
  return $items;
}

/**
 * Implementation of hook_theme()
 */
function auditfiles_theme() {
  return array(
    'auditfiles_notindb_form' => array(
      'arguments' => array(
        'form' => NULL,
      ),
      'file' => 'notindb.admin.inc',
    ),
  );
}

Functions

Namesort descending Description
auditfiles_help Implementation of hook_help().
auditfiles_menu Implementation of hook_menu().
auditfiles_perm Implementation of hook_perm().
auditfiles_theme Implementation of hook_theme()