You are here

edit_limit.admin.inc in Edit Limit 6

Same filename and directory in other branches
  1. 7 edit_limit.admin.inc

edit_limit.admin.inc include file containing admin-related functions, likethe system settings form.

File

edit_limit.admin.inc
View source
<?php

/**
 * @file edit_limit.admin.inc
 * include file containing admin-related functions, likethe system settings form.
 */
function edit_limit_settings($form_state) {
  $form = array();
  $form['enabled'] = array(
    '#type' => 'fieldset',
    '#title' => t('Enabled options'),
    '#collapsible' => FALSE,
  );
  $form['enabled']['edit_limit_node_time_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable node time limits'),
    '#description' => t('If enabled, nodes can only be edited within the given time frame.'),
    '#default_value' => variable_get('edit_limit_node_time_enabled', FALSE),
  );
  $form['enabled']['edit_limit_comment_time_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable comment time limits'),
    '#description' => t('If enabled, comments can only be edited within the given time frame.'),
    '#default_value' => variable_get('edit_limit_comment_time_enabled', FALSE),
  );
  $form['enabled']['edit_limit_node_count_enabled'] = array(
    '#type' => 'checkbox',
    '#title' => t('Enable node count limits'),
    '#description' => t('If enabled, nodes can only be edited a certain number of times.'),
    '#default_value' => variable_get('edit_limit_node_count_enabled', FALSE),
  );

  /* TODO: Create the functionality that this enables.
    $form['enabled']['edit_limit_comment_count_enabled'] = array(
      '#type' => 'checkbox',
      '#title' => t('Enable comment count limits'),
      '#description' => t('If enabled, comments can only be edited a certain number of times.'),
      '#default_value' => variable_get('edit_limit_comment_count_enabled', FALSE),
    );
    */

  // TODO: Make the time unit changeable. Currently seconds
  $form['node_limits'] = array(
    '#type' => 'fieldset',
    '#title' => t('Node limits'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['node_limits']['edit_limit_node_time_default'] = array(
    '#type' => 'textfield',
    '#title' => t('Node time limit (seconds)'),
    '#description' => t('The amount of time after a node has been saved that it can be edited (in seconds). 86400 seconds is 1 day.'),
    '#size' => 4,
    '#default_value' => variable_get('edit_limit_node_time_default', EDIT_LIMIT_NODE_TIME_DEFAULT),
    '#maxlength' => 10,
  );
  $form['node_limits']['edit_limit_node_count_default'] = array(
    '#type' => 'textfield',
    '#title' => t('Edit count'),
    '#description' => t('The number of times a node can be edited, after the original submission.'),
    '#size' => 4,
    '#default_value' => variable_get('edit_limit_node_count_default', EDIT_LIMIT_NODE_COUNT_DEFAULT),
    '#maxlength' => 4,
  );
  module_load_include('module', 'node');
  $types = array();
  foreach (node_get_types() as $type_data) {
    $types[$type_data->type] = $type_data->name;
  }
  asort($types);
  $form['node_limits']['edit_limit_node_types'] = array(
    '#type' => 'select',
    '#title' => t('Content types'),
    '#description' => t('Select the content types to apply these node limits to. Only content types selected here will have any limits applied.'),
    '#multiple' => TRUE,
    '#options' => $types,
    '#default_value' => variable_get('edit_limit_node_types', array()),
  );

  // TODO: Make the time unit changeable. Currently seconds
  $form['comment_limits'] = array(
    '#type' => 'fieldset',
    '#title' => t('Comment limits'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['comment_limits']['edit_limit_comment_time'] = array(
    '#type' => 'textfield',
    '#title' => t('Comment time limit (seconds)'),
    '#description' => t('The amount of time after a comment has been saved that it can be edited (in seconds).'),
    '#size' => 4,
    '#default_value' => variable_get('edit_limit_comment_time', EDIT_LIMIT_COMMENT_TIME),
    '#maxlength' => 10,
  );

  /* TODO: Need to add support for this option in edit_limit.module: edit_limit_link_alter().
    $form['comment_limits']['edit_limit_comment_count'] = array(
      '#type' => 'textfield',
      '#title' => t('Edit count'),
      '#description' => t('The number of times a comment can be edited, after the original submission.'),
      '#size' => 4,
      '#default_value' => variable_get('edit_limit_comment_count', EDIT_LIMIT_COMMENT_COUNT),
      '#maxlength' => 4,
    );
    */
  return system_settings_form($form);
}

Functions

Namesort descending Description
edit_limit_settings @file edit_limit.admin.inc include file containing admin-related functions, likethe system settings form.