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

Dries's avatar
 
Dries committed
3 4
include_once "includes/common.inc";

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

Dries's avatar
 
Dries committed
8
  // Guidlines:
Dries's avatar
 
Dries committed
9 10 11
  $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
12

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

Dries's avatar
 
Dries committed
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  $output .= "<B>". t("Your name") .":</B><BR>\n";
  $output .= format_username($user->userid) ."<P>\n";

  $output .= "<B>". t("Subject") .":</B><BR>\n";
  $output .= "<INPUT TYPE=\"text\" NAME=\"subject\" SIZE=\"50\" MAXLENGTH=\"60\"><P>\n";

  $output .= "<B>". t("Section") .":</B><BR>\n";
  foreach ($sections = section_get() as $value) $options .= "  <OPTION VALUE=\"$value\">$value</OPTION>\n";
  $output .= "<SELECT NAME=\"section\">$options</SELECT><P>\n";

  $output .= "<B>". t("Abstract") .":</B><BR>\n";
  $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"10\" NAME=\"abstract\" MAXLENGTH=\"20\"></TEXTAREA><BR>\n";
  $output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";

  $output .= "<B>". t("Extended story") .":</B><BR>\n";
  $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"article\"></TEXTAREA><BR>\n";
  $output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";

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

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

Dries's avatar
 
Dries committed
39
  $theme->header();
Dries's avatar
 
Dries committed
40
  $theme->box(t("New submission"), $output);
Dries's avatar
 
Dries committed
41
  $theme->footer();
Dries's avatar
Dries committed
42 43
}

Dries's avatar
 
Dries committed
44 45
function submit_preview($subject, $abstract, $article, $section) {
  global $allowed_html, $theme, $user;
Dries's avatar
 
Dries committed
46

Dries's avatar
 
Dries committed
47 48
  include "includes/story.inc";

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

Dries's avatar
 
Dries committed
51 52
  $output .= "<B>". t("Your name") .":</B><BR>\n";
  $output .= format_username($user->userid) ."<P>";
Dries's avatar
 
Dries committed
53

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

Dries's avatar
 
Dries committed
57 58 59
  $output .= "<B>". t("Section") .":</B><BR>\n";
  foreach ($sections = section_get() as $value) $options .= "  <OPTION VALUE=\"$value\"". ($section == $value ? " SELECTED" : "") .">$value</OPTION>\n";
  $output .= "<SELECT NAME=\"section\">$options</SELECT><P>\n";
Dries's avatar
 
Dries committed
60

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

Dries's avatar
 
Dries committed
65 66 67
  $output .= "<B>". t("Extended story") .":</B><BR>\n";
  $output .= "<TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"article\">". check_textarea($article) ."</TEXTAREA><BR>\n";
  $output .= "<SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL><P>\n";
Dries's avatar
 
Dries committed
68 69

  if (empty($subject)) {
Dries's avatar
 
Dries committed
70 71
    $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n";
    $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview submission") ."\">\n";
Dries's avatar
 
Dries committed
72 73
  }
  else if (empty($abstract)) {
Dries's avatar
 
Dries committed
74 75
    $output .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n";
    $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview submission") ."\">\n";
Dries's avatar
 
Dries committed
76
  }
Dries's avatar
 
Dries committed
77
  else {
Dries's avatar
 
Dries committed
78 79
    $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Preview submission") ."\">\n";
    $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"". t("Submit submission") ."\">\n";
Dries's avatar
 
Dries committed
80
  }
Dries's avatar
 
Dries committed
81
  $output .= "</FORM>\n";
Dries's avatar
 
Dries committed
82

Dries's avatar
 
Dries committed
83
  $theme->header();
Dries's avatar
 
Dries committed
84
  $theme->article(new Story($user->userid, $subject, $abstract, $article, $section, time()));
Dries's avatar
 
Dries committed
85
  $theme->box(t("Submit a story"), $output);
Dries's avatar
 
Dries committed
86
  $theme->footer();
Dries's avatar
Dries committed
87 88
}

Dries's avatar
 
Dries committed
89
function submit_submit($subject, $abstract, $article, $section) {
Dries's avatar
 
Dries committed
90
  global $user, $theme;
Dries's avatar
Dries committed
91

Dries's avatar
 
Dries committed
92
  // Add log entry:
Dries's avatar
 
Dries committed
93
  watchdog("story", "story: added '$subject'");
Dries's avatar
 
Dries committed
94

Dries's avatar
 
Dries committed
95
  // Add submission to SQL table:
Dries's avatar
 
Dries committed
96
  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
97

Dries's avatar
 
Dries committed
98
  // Display confirmation message:
Dries's avatar
 
Dries committed
99
  $theme->header();
Dries's avatar
 
Dries committed
100
  $theme->box(t("Submission completed"), t("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
101 102 103 104
  $theme->footer();
}

switch($op) {
Dries's avatar
 
Dries committed
105
  case t("Preview submission"):
Dries's avatar
 
Dries committed
106
    submit_preview($subject, $abstract, $article, $section);
Dries's avatar
Dries committed
107
    break;
Dries's avatar
 
Dries committed
108
  case t("Submit submission"):
Dries's avatar
 
Dries committed
109
    submit_submit($subject, $abstract, $article, $section);
Dries's avatar
Dries committed
110 111
    break;
  default:
Dries's avatar
 
Dries committed
112
    submit_enter();
Dries's avatar
Dries committed
113 114 115
    break;
}

Dries's avatar
Dries committed
116
?>