summaryrefslogtreecommitdiff
path: root/modules/story.module
blob: 4a4c7fc9dc5ad546eb8e973fe833b43eaf96a781 (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
81
82
<?php
// $Id$

/**
 * @file
 * Enables users to submit stories, articles or similar content.
 */

/**
 * Implementation of hook_help().
 */
function story_help($section) {
  switch ($section) {
    case 'admin/modules#description':
      return t('Allows users to submit stories, articles or similar content.');
    case 'node/add#story':
      return t('Stories are articles in their simplest form: they have a title, a teaser and a body, but can be extended by other modules. The teaser is part of the body too. Stories may be used as a personal blog or for news articles.');
  }
}

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

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

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

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

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

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

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

  return $items;
}

/**
 * Implementation of hook_form().
 */
function story_form(&$node) {
  $output = '';

  if (function_exists('taxonomy_node_form')) {
    $output .= implode('', taxonomy_node_form('story', $node));
  }

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

  return $output;
}

?>