story.module 3.95 KB
Newer Older
Dries's avatar
   
Dries committed
1
2
3
<?php
// $Id$

Dries's avatar
   
Dries committed
4
5
6
7
8
9
function story_help() {
  $output .= "<p>The story module enables to users to submit thoughful, cohesive posts for consideration by the rest of the community.  Stories usually follow a specific content flow: <i>submit -&gt; moderate -&gt; post to home page -&gt; comment</i>.  Administrators are able to shortcut this flow as desired.</p>";
  $output .= "<p>Administrators may \"pin\" an important story or announcement to the front page using the <i>static on front page</i> setting while creating or editing a story (this is true for other nodes as well). In addition, administrators may provide helpful introductory text for story authors in the <i>settings</i> page.  There, administrators might also choose to set a floor on the number of words which may be included in a story.  This is designed to help discourage the submission of trvially short stories.</p>";
  return $output;
}

10
function story_system($field){
Kjartan's avatar
Kjartan committed
11
  $system["description"] = t("Enables users to submit stories, articles or similar content.");
12
13
14
  return $system[$field];
}

Dries's avatar
   
Dries committed
15
16
function story_conf_options() {
 $output .= form_textarea("Explanation or submission guidelines", "story_help", variable_get("story_help", ""), 55, 4, "This text will be displayed at the top of the story submission form.  Useful for helping or instructing your users.");
Dries's avatar
   
Dries committed
17
 $output .= form_select(t("Minimum number of words"), "minimum_story_size", variable_get("minimum_story_size", 0), array(0 => "0 words", 10 => "10 words", 25 => "25 words",  50 => "50 words", 75 => "75 words", 100 => "100 words", 125 => "125 words",  150 => "150 words", 175 => "175 words", 200 => "200 words"), t("The minimum number of words a personal story entry should consist of.  This can be useful to rule out submissions that do not meet the site's standards, such as short test posts."));
Dries's avatar
   
Dries committed
18
19
20
21
22
23

 return $output;
}

function story_node($field) {
  $info["name"] = t("story");
Dries's avatar
   
Dries committed
24
  $info["description"] = t("A story is a post that is submitted to the attention of other users and is queued in the submission queue.  Users and moderators vote on the posts they like or dislike, promoting or demoting them.  When a post gets above a certain threshold it gets automatically published to front page.");
Dries's avatar
   
Dries committed
25
26
27
28

  return $info[$field];
}

Dries's avatar
   
Dries committed
29
30
31
32
function story_perm() {
  return array("create stories");
}

Dries's avatar
   
Dries committed
33
34
35
36
37
38
function story_access($op, $node) {
  if ($op == "view") {
    return $node->status;
  }

  if ($op == "create") {
Dries's avatar
   
Dries committed
39
    return user_access("create stories");
Dries's avatar
   
Dries committed
40
41
42
43
44
45
46
47
48
49
  }
}

function story_save($op, $node) {

  if ($op == "approve") {
    return array("status" => 1, "promote" => 1);
  }

  if ($op == "create") {
Dries's avatar
   
Dries committed
50
    if (user_access("administer nodes")) {
51
      return array("body" => filter($node->body), "teaser" => filter($node->teaser));
Dries's avatar
   
Dries committed
52
53
    }
    else {
Dries's avatar
   
Dries committed
54
      return array("moderate" => 1);
Dries's avatar
   
Dries committed
55
    }
Dries's avatar
   
Dries committed
56
57
58
59
60
  }

  if ($op == "decline") {
    return array("status" => 0, "promote" => 0);
  }
Dries's avatar
   
Dries committed
61
62

  if ($op == "update") {
63
    return array("body" => filter($node->body), "teaser" => filter($node->teaser));
Dries's avatar
   
Dries committed
64
  }
Dries's avatar
   
Dries committed
65
66
}

Dries's avatar
   
Dries committed
67
function story_link($type) {
Dries's avatar
   
Dries committed
68
  if ($type == "menu.create" && user_access("create stories")) {
Dries's avatar
   
Dries committed
69
    $links[] = l(t("create story"), "node/add/story", array("title" => t("Add a new story.")));
Dries's avatar
   
Dries committed
70
71
72
73
74
  }

  return $links ? $links : array();
}

Dries's avatar
   
Dries committed
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
function story_form(&$node, &$help, &$error) {

  if (isset($node->body)) {

    /*
    ** Validate the size of the story:
    */

    if (count(explode(" ", $node->body)) < variable_get("minimum_story_size", 0)) {
      $error["body"] = "<div style=\"color: red;\">". t("The body of your story is too short.") ."</div>";
    }

  }
  else {

    /*
    ** Carry out some explanation or submission guidelines:
    */

    $help = variable_get("story_help", "");

  }

98
99
100
  if (function_exists("taxonomy_node_form")) {
    $output .= implode("", taxonomy_node_form("story", $node));
  }
Dries's avatar
   
Dries committed
101

Dries's avatar
   
Dries committed
102
  $output .= form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
Dries's avatar
   
Dries committed
103
104
105
106
107
108

  return $output;
}


?>