95 lines
2.2 KiB
Plaintext
95 lines
2.2 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('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_info().
|
|
*/
|
|
function story_node_info() {
|
|
return array('story' => array('name' => t('story'), 'base' => '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().
|
|
*/
|
|
function story_validate(&$node) {
|
|
node_validate_title($node);
|
|
}
|
|
|
|
/**
|
|
* Implementation of hook_form().
|
|
*/
|
|
function story_form(&$node) {
|
|
|
|
$form['title'] = array('#type' => 'textfield', '#title' => t('Title'), '#size' => 60, '#maxlength' => 128, '#required' => TRUE, '#default_value' => $node->title);
|
|
|
|
$form['body'] = array(
|
|
'#type' => 'textarea', '#title' => t('Body'), '#default_value' => $node->body, '#required' => TRUE
|
|
);
|
|
$form = array_merge($form, filter_form($node->format));
|
|
|
|
|
|
$form['log'] = array(
|
|
'#type' => 'textarea', '#title' => t('Log message'), '#default_value' => $node->log, '#rows' => 5,
|
|
'#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.')
|
|
);
|
|
|
|
return $form;
|
|
}
|
|
|
|
|