summaryrefslogtreecommitdiff
path: root/modules/page.module
blob: 4dcab74cb0ea25dee98bb913ae4d5c30df628fda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
<?php
// $Id$

/**
 * @file
 * Enables the creation of pages that can be added to the navigation system.
 */

/**
 * Implementation of hook_help().
 */
function page_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('Enables the creation of pages that can be added to the navigation system.');
    case 'node/add#page':
      return t('If you want to add a static page, like a contact page or an about page, use a page.');
  }
}

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

/**
 * Implementation of hook_node_name().
 */
function page_node_name($node) {
  return t('page');
}

/**
 * Implementation of hook_access().
 */
function page_access($op, $node) {
  global $user;

  if ($op == 'create') {
    return user_access('create pages');
  }

  if ($op == 'update' || $op == 'delete') {
    if (user_access('edit own pages') && ($user->uid == $node->uid)) {
      return TRUE;
    }
  }
}

/**
 * Implementation of hook_menu().
 */
function page_menu($may_cache) {
  $items = array();

  if ($may_cache) {
    $items[] = array('path' => 'node/add/page', 'title' => t('page'),
      'access' => page_access('create', NULL));
  }

  return $items;
}

/**
 * Implementation of hook_form().
 */
function page_form(&$node) {
  if (function_exists('taxonomy_node_form')) {
    $output .= implode('', taxonomy_node_form('page', $node));
  }

  $output .= form_textarea(t('Body'), 'body', $node->body, 60, 20, '', NULL, TRUE);
  $output .= filter_form('format', $node->format);

  return $output;
}

?>