116 lines
4.4 KiB
Plaintext
116 lines
4.4 KiB
Plaintext
<?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('Enables users to submit stories, articles or similar content.');
|
|
case 'admin/settings/story':
|
|
return t("<p>Stories are like newspaper articles. They tend to follow a publishing flow of <strong>submit -> moderate -> post to the main page -> comments</strong>. Below you may fix a minimum word count for stories and also write some submission or content guidelines for users wanting to post a story.</p>");
|
|
case 'admin/help#story':
|
|
return t("
|
|
<p>The story module lets your users submit articles for consideration by the rest of the community, who can vote on them if moderation is enabled. Stories usually follow a publishing flow of <strong>submit -> moderate -> post to the main page -> comments</strong>. Administrators are able to shortcut this flow as desired.</p>
|
|
In <a href=\"%story-config\">administer » settings » story</a> you can set up an introductory text for story authors, and a floor on the number of words which may be included in a story. This is designed to help discourage the submission of trivially short stories.</p>
|
|
<h3>User access permissions for stories</h3>
|
|
<p><strong>create stories:</strong> Allows a role to create stories. They cannot edit or delete stories, even if they are the authors. You must enable this permission to in order for a role to create a story.</p>
|
|
<p><strong>edit own stories:</strong> Allows a role to add/edit stories if they own the story. Use this permission if you want users to be able to edit and maintain their own stories.</p>
|
|
", array('%story-config' => url('admin/settings/story')));
|
|
case 'node/add/story':
|
|
return variable_get('story_help', '');
|
|
case 'node/add#story':
|
|
return t('A story is similar to an article and usually gets promoted to the front page. If you want to post news items, articles or maintain a group blog, use stories.');
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Implementation of hook_settings().
|
|
*/
|
|
function story_settings() {
|
|
$output .= form_textarea(t('Explanation or submission guidelines'), 'story_help', variable_get('story_help', ''), 70, 5, t('This text will be displayed at the top of the story submission form. It is useful for helping or instructing your users.'));
|
|
$output .= form_select(t('Minimum number of words'), 'minimum_story_size', variable_get('minimum_story_size', 0), drupal_map_assoc(array(0, 10, 25, 50, 75, 100, 125, 150, 175, 200)), t('The minimum number of words a story must be to be considered valid. This can be useful to rule out submissions that do not meet the site\'s standards, such as short test posts.'));
|
|
|
|
return $output;
|
|
}
|
|
|
|
/**
|
|
* 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_validate().
|
|
*
|
|
* Ensures the story is of adequate length.
|
|
*/
|
|
function story_validate(&$node) {
|
|
if (isset($node->body) && count(explode(' ', $node->body)) < variable_get('minimum_story_size', 0)) {
|
|
form_set_error('body', t('The body of your story is too short. You need at least %words words to submit your story.', array('%words' => variable_get('minimum_story_size', 0))));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* 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;
|
|
}
|
|
|
|
?>
|