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

Dries's avatar
   
Dries committed
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function story_node($field) {
  $info = array("name" => "story");

  return $info[$field];
}

function story_access($op, $node) {

  if ($op == "view") {
    return $node->nid && $node->status && !$node->moderate;
  }

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

  if ($op == "update") {
    return user_access("administer nodes");
  }

  if ($op == "delete") {
    return user_access("adminster nodes");
  }

}

Dries's avatar
   
Dries committed
30
31
function story_help() {
 ?>
Dries's avatar
   
Dries committed
32
33
34
35
36
37
38
/*
  // TODO: update documentation, outdated

  <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's avatar
   
Dries committed
39
 <?php
Dries's avatar
   
Dries committed
40
41
}

Dries's avatar
   
Dries committed
42
function story_form($node, $error) {
Dries's avatar
   
Dries committed
43

Dries's avatar
   
Dries committed
44
45
46
47
48
49
50
  if ($node->body) {
    if (count(explode(" ", $node->body)) < variable_get("minimum_node_size", 0)) {
      $error["body"] = "<div style=\"color: red;\">". t("The body of your story is too short.") ."</div>";
    }
  }

  $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
51

Dries's avatar
   
Dries committed
52
  return $output;
Dries's avatar
   
Dries committed
53
54
}

Dries's avatar
   
Dries committed
55
function story_save($node) {
Dries's avatar
   
Dries committed
56

Dries's avatar
   
Dries committed
57
  if ($node->nid) {
Dries's avatar
   
Dries committed
58
    return array();
Dries's avatar
   
Dries committed
59
  }
Dries's avatar
   
Dries committed
60
61
  else {
    return array("promote" => 1, "moderate" => 1);
Dries's avatar
   
Dries committed
62
  }
Dries's avatar
   
Dries committed
63

Dries's avatar
   
Dries committed
64
65
}

Dries's avatar
   
Dries committed
66
?>