story.module

  1. drupal
    1. 4.6 modules/story.module
    2. 4.7 modules/story.module

Enables users to submit stories, articles or similar content.

Functions & methods

NameDescription
story_accessImplementation of hook_access().
story_formImplementation of hook_form().
story_helpImplementation of hook_help().
story_menuImplementation of hook_menu().
story_node_infoImplementation of hook_node_info().
story_permImplementation of hook_perm().

File

modules/story.module
View source
  1. <?php
  2. /**
  3. * @file
  4. * Enables users to submit stories, articles or similar content.
  5. */
  6. /**
  7. * Implementation of hook_help().
  8. */
  9. function story_help($section) {
  10. switch ($section) {
  11. case 'admin/help#story':
  12. $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>';
  13. $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>';
  14. $output .= t('<p>You can</p>
  15. <ul>
  16. <li>post a story at <a href="%node-add-story">create content &gt;&gt; story</a>.</li>
  17. <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>
  18. </ul>
  19. ', array('%node-add-story' => url('node/add/story'), '%admin-settings-content-types-story' => url('admin/settings/content-types/story')));
  20. $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>';
  21. return $output;
  22. case 'admin/modules#description':
  23. return t('Allows users to submit stories, articles or similar content.');
  24. case 'node/add#story':
  25. 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.');
  26. }
  27. }
  28. /**
  29. * Implementation of hook_node_info().
  30. */
  31. function story_node_info() {
  32. return array('story' => array('name' => t('story'), 'base' => 'story'));
  33. }
  34. /**
  35. * Implementation of hook_perm().
  36. */
  37. function story_perm() {
  38. return array('create stories', 'edit own stories');
  39. }
  40. /**
  41. * Implementation of hook_access().
  42. */
  43. function story_access($op, $node) {
  44. global $user;
  45. if ($op == 'create') {
  46. return user_access('create stories');
  47. }
  48. if ($op == 'update' || $op == 'delete') {
  49. if (user_access('edit own stories') && ($user->uid == $node->uid)) {
  50. return TRUE;
  51. }
  52. }
  53. }
  54. /**
  55. * Implementation of hook_menu().
  56. */
  57. function story_menu($may_cache) {
  58. $items = array();
  59. if ($may_cache) {
  60. $items[] = array('path' => 'node/add/story', 'title' => t('story'),
  61. 'access' => user_access('create stories'));
  62. }
  63. return $items;
  64. }
  65. /**
  66. * Implementation of hook_form().
  67. */
  68. function story_form(&$node) {
  69. $form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#required' => TRUE, '#default_value' => $node->title, '#weight' => -5);
  70. $form['body_filter']['body'] = array('#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#rows' => 20, '#required' => TRUE);
  71. $form['body_filter']['format'] = filter_form($node->format);
  72. return $form;
  73. }
Login or register to post comments