You are here

basicevent.module in Event 5

An extremly simple module to implement the event API.

File

contrib/basicevent.module
View source
<?php

/**
 * @file
 * An extremly simple module to implement the event API.
 */

/**
 * Implementation of hook_node_info().
 */
function basicevent_node_info() {
  return array(
    'event' => array(
      'name' => t('Event'),
      'module' => 'basicevent',
      'description' => t('An event is a story which can be given a start and end date, thus appearing in the events calendar.'),
    ),
  );
}

/**
 * Implementation of hook_perm().
 */
function basicevent_perm() {
  return array(
    'create events',
    'edit own events',
  );
}

/**
 * Implementation of hook_access().
 */
function basicevent_access($op, $node) {
  global $user;
  switch ($op) {
    case 'create':
      return user_access('create events');
      break;
    case 'update':
    case 'delete':
      if (user_access('edit own events') && $user->uid == $node->uid) {
        return TRUE;
      }
      break;
  }
}

/**
 * Implementation of hook_menu().
 */
function basicevent_menu($may_cache) {
  $items = array();
  if ($may_cache) {
    $items[] = array(
      'path' => 'node/add/event',
      'title' => t('Event'),
      'access' => user_access('create events'),
    );
  }
  return $items;
}

/**
 * Implementation of hook_form().
 */
function basicevent_form(&$node) {

  // warn them if this isn't set to appear in the calendar
  if (variable_get('event_nodeapi_event', 'never') == 'never') {
    $link = l(t('event content-type settings page'), 'admin/content/types/event');
    drupal_set_message(t('The event node is currently set to never appear in the calendar. You will not be able to set the start and end dates until an administrator changes the content-type settings. This is done using the !link.', array(
      '!link' => $link,
    )));
  }
  $form['title'] = array(
    '#type' => 'textfield',
    '#title' => t('Title'),
    '#default_value' => $node->title,
    '#size' => 60,
    '#maxlength' => 128,
    '#required' => TRUE,
  );
  $form['body_filter']['body'] = array(
    '#type' => 'textarea',
    '#title' => t('Body'),
    '#default_value' => $node->body,
    '#rows' => 20,
    '#required' => TRUE,
  );
  $form['body_filter']['format'] = filter_form($node->format);
  return $form;
}

Functions

Namesort descending Description
basicevent_access Implementation of hook_access().
basicevent_form Implementation of hook_form().
basicevent_menu Implementation of hook_menu().
basicevent_node_info Implementation of hook_node_info().
basicevent_perm Implementation of hook_perm().