<?php
// $Id: draft_views.module,v 1.1.2.8 2009/09/25 20:29:12 darrenferguson Exp $
define('DRAFT_VIEWS_PATH', drupal_get_path('module', 'draft_views'));

/**
 * Implementation of hook_menu()
 */
function draft_views_menu() {
  $items['admin/settings/draft_views'] = array(
    'title' => 'Draft Views',
    'description' => 'Configure draft views settings.',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('draft_views_admin_settings'),
    'access arguments' => array('administer site configuration'),
  );
  return $items;
}

/**
 * Draft Module administration settings
 */
function draft_views_admin_settings() {
  $form['draft_views'] = array('#type' => 'fieldset', '#title' => t('Draft Views Settings'), '#collapsible' => TRUE, '#collapsed' => FALSE);
  $form['draft_views']['draft_views_redirect_url'] = array(
    '#type' => 'textfield',
    '#title' => t('Draft List Url'),
    '#default_value' => variable_get('draft_views_redirect_url', 'draft/list'),
    '#size' => 50,
    '#description' => t('If you change the url for the view then you should change this to the new url for the view so the draft module will redirect back to the correct page'),
  );
  return system_settings_form($form);
}

/**
 * Implementation of hook_menu_alter()
 */
function draft_views_menu_alter(&$items) {
  // Removing the draft module list function since the view will now handle the implementation
  if (isset($items['draft/list'])) {
    unset($items['draft/list']);
  }
}

/**
 * Implementation of hook_views_api()
 */
function draft_views_views_api() {
  return array(
    'api' => 2,
    'path' => DRAFT_VIEWS_PATH,
  );
}

