<?php

/**
 * @file
 * Cleans up Workflow cruft that may build up over time.
 */

/**
 * Implements hook_menu().
 */
function workflow_cleanup_menu() {
  $items = array();

  $admin_path = WORKFLOW_ADMIN_UI_PATH;

  $items["$admin_path/cleanup"] = array(
    'title' => 'Clean up workflow',
    'file' => 'workflow_cleanup.pages.inc',
    'access arguments' => array('administer workflow'),
    'page callback' => 'drupal_get_form',
    'page arguments' => array('workflow_cleanup_form'),
    'type' => MENU_LOCAL_ACTION,
  );

  return $items;
}

/**
 * Implements hook_help().
 */
function workflow_cleanup_help($path, $arg) {
  switch ($path) {
    case WORKFLOW_ADMIN_UI_PATH . '/cleanup':
      return t('This page allows you to delete orphaned and inactive states.
        States can be deleted freely in a development environment, but be
        careful if you have used a State in a production environment. The
        transition history of your content will loose the description of a
        previously used state. If your Workflow must comply to some auditing
        standards, you should NOT use this function.');
  }
}

/**
 * Implements hook_theme().
 */
function workflow_cleanup_theme() {
  return array(
    'workflow_cleanup_form' => array('render element' => 'form'),
  );
}
