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

Dries Buytaert's avatar
   
Dries Buytaert committed
4
5
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 Buytaert's avatar
   
Dries Buytaert committed
6
 $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 post."));
Dries Buytaert's avatar
   
Dries Buytaert committed
7
8
9
10

 return $output;
}

Dries Buytaert's avatar
   
Dries Buytaert committed
11
function story_node($field) {
Dries Buytaert's avatar
   
Dries Buytaert committed
12
13
  $info["name"] = t("story");
  $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 authomatically published to front page.");
Dries Buytaert's avatar
   
Dries Buytaert committed
14
15
16
17
18
19

  return $info[$field];
}

function story_access($op, $node) {
  if ($op == "view") {
Dries Buytaert's avatar
   
Dries Buytaert committed
20
    return $node->status;
Dries Buytaert's avatar
   
Dries Buytaert committed
21
22
23
24
25
26
27
  }

  if ($op == "create") {
    return 1;
  }
}

Dries Buytaert's avatar
   
Dries Buytaert committed
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
function story_save($op, $node) {

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

  if ($op == "create") {
    return array("moderate" => 1);
  }

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

  if ($op == "update") {
    return array("status");
  }

}

Dries Buytaert's avatar
   
Dries Buytaert committed
48
49
function story_help() {
 ?>
Dries Buytaert's avatar
   
Dries Buytaert committed
50
51
  // TODO: update documentation, outdated

Dries Buytaert's avatar
   
Dries Buytaert committed
52
53
54
  //<p>Queued stories: user-contributed stories are automatically whisked away to a submission queue for moderators (i.e. registered user) to frown at.  Moderators vote whether or not a story should be posted to the front page for discussion.</p>
  //<p>Posted stories: published stories accessible to all visitors.</p>
  //<p>Dumped stories: rejected stories that are no longer available to visitors.</p>
Dries Buytaert's avatar
   
Dries Buytaert committed
55
 <?php
Dries Buytaert's avatar
   
Dries Buytaert committed
56
57
}

Dries Buytaert's avatar
   
Dries Buytaert committed
58
59
60
function story_form($node, $help, $error) {

  if (isset($node->body)) {
Dries Buytaert's avatar
   
Dries Buytaert committed
61

Dries Buytaert's avatar
   
Dries Buytaert committed
62
63
64
65
66
    /*
    ** Validate the size of the story:
    */

    if (count(explode(" ", $node->body)) < variable_get("minimum_story_size", 0)) {
Dries Buytaert's avatar
   
Dries Buytaert committed
67
68
      $error["body"] = "<div style=\"color: red;\">". t("The body of your story is too short.") ."</div>";
    }
Dries Buytaert's avatar
   
Dries Buytaert committed
69
70
71
72
73
74
75
76
77
78

  }
  else {

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

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

Dries Buytaert's avatar
   
Dries Buytaert committed
79
80
81
  }

  $output = form_textarea(t("Body"), "body", $node->body, 60, 15, $error["body"] ? $error["body"] : t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
Dries Buytaert's avatar
   
Dries Buytaert committed
82

Dries Buytaert's avatar
   
Dries Buytaert committed
83
  return $output;
Dries Buytaert's avatar
   
Dries Buytaert committed
84
85
86
}


Dries Buytaert's avatar
   
Dries Buytaert committed
87
?>