submit.php 6.6 KB
Newer Older
Dries's avatar
 
Dries committed
1
<?
Dries's avatar
Dries committed
2

Dries's avatar
 
Dries committed
3
function submit_enter() {
Dries's avatar
 
Dries committed
4
  global $anonymous, $allowed_html, $theme, $user;
Dries's avatar
 
Dries committed
5

Dries's avatar
 
Dries committed
6
  // Guidlines:
Dries's avatar
 
Dries committed
7 8 9
  $output .= "<P>". t("Got some news or some thoughts you would like to share? Fill out this form and they will automatically get whisked away to our submission queue where our moderators will frown at it, poke at it and hopefully post it. Every registered user is automatically a moderator and can vote whether or not your sumbission should be carried to the front page for discussion.") ."</P>\n";
  $output .= "<P>". t("Note that we do not revamp or extend your submission so it is up to you to make sure your submission is well-written: if you don't care enough to be clear and complete, your submission is likely to be moderated down by our army of moderators. Try to be complete, aim for clarity, organize and structure your text, and try to carry out your statements with examples. It is also encouraged to extend your submission with arguments that flow from your unique intellectual capability and experience: offer some insight or explanation as to why you think your submission is interesting. Make sure your submission has some meat on it!") ."</P>\n";
  $output .= "<P>". t("However, if you have bugs to report, complaints, personal questions or anything besides a public submission, we would prefer you to mail us instead, or your message is likely to get lost.") ."</P>\n";
Dries's avatar
 
Dries committed
10

Dries's avatar
 
Dries committed
11
  // Submission form:
Dries's avatar
 
Dries committed
12
  $output .= "<FORM ACTION=\"submit.php\" METHOD=\"post\">\n";
Dries's avatar
Dries committed
13

Dries's avatar
 
Dries committed
14 15
  $output .= "<P>\n";
  $output .= " <B>". t("Your name") .":</B><BR>\n";
Dries's avatar
 
Dries committed
16
  $output .= format_username($user->userid);
Dries's avatar
 
Dries committed
17
  $output .= "</P>\n";
Dries's avatar
 
Dries committed
18

Dries's avatar
 
Dries committed
19
  $output .= "<P>\n";
Dries's avatar
 
Dries committed
20
  $output .= " <B>". t("Subject") .":</B><BR>\n";
Dries's avatar
 
Dries committed
21
  $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\"><BR>\n";
Dries's avatar
 
Dries committed
22 23
  $output .= "</P>\n";

Dries's avatar
 
Dries committed
24 25
  $output .= "<P>\n";
  $output .= " <B>". t("Section") .":</B><BR>\n";
Dries's avatar
 
Dries committed
26
  $output .= " <SELECT NAME=\"section\">\n";
Dries's avatar
 
Dries committed
27
  foreach ($sections = section_get() as $value) $output .= "  <OPTION VALUE=\"$value\">$value</OPTION>\n";
Dries's avatar
 
Dries committed
28 29 30
  $output .= " </SELECT>\n";
  $output .= "</P>\n";

Dries's avatar
 
Dries committed
31
  $output .= "<P>\n";
Dries's avatar
 
Dries committed
32
  $output .= " <B>". t("Abstract") .":</B><BR>\n";
Dries's avatar
 
Dries committed
33
  $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"abstract\" MAXLENGTH=\"20\"></TEXTAREA><BR>\n";
Dries's avatar
 
Dries committed
34
  $output .= " <SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
Dries's avatar
 
Dries committed
35 36
  $output .= "</P>\n";

Dries's avatar
 
Dries committed
37
  $output .= "<P>\n";
Dries's avatar
 
Dries committed
38
  $output .= " <B>". t("Extended story") .":</B><BR>\n";
Dries's avatar
 
Dries committed
39
  $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"article\"></TEXTAREA><BR>\n";
Dries's avatar
 
Dries committed
40
  $output .= " <SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
Dries's avatar
 
Dries committed
41
  $output .= "</P>\n";
Dries's avatar
 
Dries committed
42

Dries's avatar
 
Dries committed
43
  $output .= "<P>\n";
Dries's avatar
 
Dries committed
44
  $output .= " <SMALL><I>". t("You must preview at least once before you can submit") .":</I></SMALL><BR>\n";
Dries's avatar
 
Dries committed
45
  $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\">\n";
Dries's avatar
 
Dries committed
46
  $output .= "</P>\n";
Dries's avatar
 
Dries committed
47

Dries's avatar
 
Dries committed
48
  $output .= "</FORM>\n";
Dries's avatar
 
Dries committed
49

Dries's avatar
 
Dries committed
50
  $theme->header();
Dries's avatar
 
Dries committed
51
  $theme->box(t("Submit a story"), $output);
Dries's avatar
 
Dries committed
52
  $theme->footer();
Dries's avatar
Dries committed
53 54
}

Dries's avatar
 
Dries committed
55 56
function submit_preview($subject, $abstract, $article, $section) {
  global $allowed_html, $theme, $user;
Dries's avatar
 
Dries committed
57

Dries's avatar
 
Dries committed
58 59
  include "includes/story.inc";

Dries's avatar
 
Dries committed
60 61 62
  $output .= "<FORM ACTION=\"submit.php\" METHOD=\"post\">\n";

  $output .= "<P>\n";
Dries's avatar
 
Dries committed
63
  $output .= " <B>". t("Your name") .":</B><BR>\n";
Dries's avatar
 
Dries committed
64
  $output .= format_username($user->userid);
Dries's avatar
 
Dries committed
65 66 67
  $output .= "</P>\n";

  $output .= "<P>\n";
Dries's avatar
 
Dries committed
68
  $output .= " <B>". t("Subject") .":</B><BR>\n";
Dries's avatar
 
Dries committed
69
  $output .= " <INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\" VALUE=\"". check_output(check_textfield($subject)) ."\"><BR>\n";
Dries's avatar
 
Dries committed
70 71
  $output .= "</P>\n";

Dries's avatar
 
Dries committed
72 73
  $output .= "<P>\n";
  $output .= " <B>". t("Section") .":</B><BR>\n";
Dries's avatar
 
Dries committed
74 75
  $output .= " <SELECT NAME=\"section\">\n";
  foreach ($sections = section_get() as $value) $output .= "  <OPTION VALUE=\"$value\"". ($section == $value ? " SELECTED" : "") .">$value</OPTION>\n";
Dries's avatar
 
Dries committed
76 77 78 79
  $output .= "</SELECT>\n";
  $output .= "</P>\n";

  $output .= "<P>\n";
Dries's avatar
 
Dries committed
80
  $output .= "<B>". t("Abstract") .":</B><BR>\n";
Dries's avatar
 
Dries committed
81
  $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"abstract\">". check_textarea($abstract) ."</TEXTAREA><BR>\n";
Dries's avatar
 
Dries committed
82
  $output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
Dries's avatar
 
Dries committed
83 84 85
  $output .= "</P>\n";

  $output .= "<P>\n";
Dries's avatar
 
Dries committed
86
  $output .= " <B>". t("Extended story") .":</B><BR>\n";
Dries's avatar
 
Dries committed
87
  $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"article\">". check_textarea($article) ."</TEXTAREA><BR>\n";
Dries's avatar
 
Dries committed
88
  $output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
Dries's avatar
 
Dries committed
89
  $output .= "</P>\n";
Dries's avatar
 
Dries committed
90 91

  if (empty($subject)) {
Dries's avatar
 
Dries committed
92
    $output .= "<P><FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT></P>\n";
Dries's avatar
 
Dries committed
93 94 95 96 97 98
    $output .= "<P>\n";
    $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\">\n";
    $output .= "</P>\n";
  }
  else if (empty($abstract)) {
    $output .= "<P>\n";
Dries's avatar
 
Dries committed
99
    $output .= " <FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."\n";
Dries's avatar
 
Dries committed
100 101 102 103 104
    $outout .= "</P>\n";
    $output .= "<P>\n";
    $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\">\n";
    $output .= "</P>\n";
  }
Dries's avatar
 
Dries committed
105
  else {
Dries's avatar
 
Dries committed
106
    $output .= "<P>\n";
Dries's avatar
 
Dries committed
107 108
    $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Preview submission\">\n";
    $output .= " <INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Submit submission\">\n";
Dries's avatar
 
Dries committed
109 110
    $output .= "</P>\n";
  }
Dries's avatar
 
Dries committed
111
  $output .= "</FORM>\n";
Dries's avatar
 
Dries committed
112

Dries's avatar
 
Dries committed
113
  $theme->header();
Dries's avatar
 
Dries committed
114
  $theme->article(new Story($user->userid, $subject, $abstract, $article, $section, time()));
Dries's avatar
 
Dries committed
115
  $theme->box(t("Submit a story"), $output);
Dries's avatar
 
Dries committed
116
  $theme->footer();
Dries's avatar
Dries committed
117 118
}

Dries's avatar
 
Dries committed
119
function submit_submit($subject, $abstract, $article, $section) {
Dries's avatar
 
Dries committed
120
  global $user, $theme;
Dries's avatar
Dries committed
121

Dries's avatar
 
Dries committed
122
  // Add log entry:
Dries's avatar
 
Dries committed
123
  watchdog("story", "story: added '$subject'");
Dries's avatar
 
Dries committed
124

Dries's avatar
 
Dries committed
125
  // Add submission to SQL table:
Dries's avatar
 
Dries committed
126
  db_query("INSERT INTO stories (author, subject, abstract, article, section, timestamp) VALUES ('$user->id', '". check_input($subject) ."', '". check_input($abstract) ."', '". check_input($article) ."', '". check_input($section) ."', '". time() ."')");
Dries's avatar
 
Dries committed
127

Dries's avatar
 
Dries committed
128
  // Display confirmation message:
Dries's avatar
 
Dries committed
129
  $theme->header();
Dries's avatar
 
Dries committed
130
  $theme->box("Thank you for your submission.", "Thank you for your submission. Your submission has been whisked away to our submission queue where our registered users will frown at it, poke at it and hopefully carry it to the front page for discussion.");
Dries's avatar
Dries committed
131 132 133
  $theme->footer();
}

134
include_once "includes/common.inc";
Dries's avatar
 
Dries committed
135

Dries's avatar
Dries committed
136
switch($op) {
Dries's avatar
 
Dries committed
137
  case "Preview submission":
Dries's avatar
 
Dries committed
138
    submit_preview($subject, $abstract, $article, $section);
Dries's avatar
Dries committed
139
    break;
Dries's avatar
 
Dries committed
140
  case "Submit submission":
Dries's avatar
 
Dries committed
141
    submit_submit($subject, $abstract, $article, $section);
Dries's avatar
Dries committed
142 143
    break;
  default:
Dries's avatar
 
Dries committed
144
    submit_enter();
Dries's avatar
Dries committed
145 146 147
    break;
}

Dries's avatar
Dries committed
148
?>