initial import from onelab svn codebase
[plewww.git] / modules / story.module
1 <?php
2 // $Id: story.module 144 2007-03-28 07:52:20Z thierry $
3
4 /**
5  * @file
6  * Enables users to submit stories, articles or similar content.
7  */
8
9 /**
10  * Implementation of hook_help().
11  */
12 function story_help($section) {
13   switch ($section) {
14     case 'admin/help#story':
15       $output = '<p>'. t('The story module is used to create a content post type called <em>stories.</em> Stories are articles in their simplest form: they have a title, a teaser and a body. Stories are typically used to post news articles or as a group blog. ') .'</p>';
16       $output .= '<p>'. t('The story administration interface allows for complex configuration. It provides a submission form, workflow, default view permission, default edit permission, permissions for permission, and attachments.  Trackbacks can also be enabled.') .'</p>';
17       $output .= t('<p>You can</p>
18 <ul>
19 <li>post a story at <a href="%node-add-story">create content &gt;&gt; story</a>.</li>
20 <li>configure story at <a href="%admin-settings-content-types-story">administer &gt;&gt; settings &gt;&gt; content types &gt;&gt; configure story</a>.</li>
21 </ul>
22 ', array('%node-add-story' => url('node/add/story'), '%admin-settings-content-types-story' => url('admin/settings/content-types/story')));
23       $output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="%story">Story page</a>.', array('%story' => 'http://drupal.org/handbook/modules/story/')) .'</p>';
24       return $output;
25     case 'admin/modules#description':
26       return t('Allows users to submit stories, articles or similar content.');
27     case 'node/add#story':
28       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.');
29   }
30 }
31
32 /**
33  * Implementation of hook_node_info().
34  */
35 function story_node_info() {
36   return array('story' => array('name' => t('story'), 'base' => 'story'));
37 }
38
39 /**
40  * Implementation of hook_perm().
41  */
42 function story_perm() {
43   return array('create stories', 'edit own stories');
44 }
45
46 /**
47  * Implementation of hook_access().
48  */
49 function story_access($op, $node) {
50   global $user;
51
52   if ($op == 'create') {
53     return user_access('create stories');
54   }
55
56   if ($op == 'update' || $op == 'delete') {
57     if (user_access('edit own stories') && ($user->uid == $node->uid)) {
58       return TRUE;
59     }
60   }
61 }
62
63 /**
64  * Implementation of hook_menu().
65  */
66 function story_menu($may_cache) {
67   $items = array();
68
69   if ($may_cache) {
70     $items[] = array('path' => 'node/add/story', 'title' => t('story'),
71       'access' => user_access('create stories'));
72   }
73
74   return $items;
75 }
76
77 /**
78  * Implementation of hook_form().
79  */
80 function story_form(&$node) {
81   $form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5);
82   $form['body_filter']['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
83   $form['body_filter']['format'] = filter_form($node->format);
84   return $form;
85 }
86