2001-03-10 11:07:52 +00:00
<?php
2000-12-14 14:13:37 +00:00
2001-03-24 16:56:10 +00:00
class Story {
2001-04-16 11:38:12 +00:00
function Story($story) {
2001-05-05 13:57:29 +00:00
$this = new Node($story);
2001-04-15 17:01:32 +00:00
$this->abstract = $story[abstract];
$this->body = $story[body];
2001-03-24 16:56:10 +00:00
}
}
2001-04-07 15:02:28 +00:00
function story_status() {
return array(dumped, queued, posted);
}
2001-05-09 18:28:09 +00:00
function story_search($keys) {
2001-03-25 10:57:01 +00:00
global $status, $user;
2001-03-29 19:50:31 +00:00
$result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid AND n.lid = s.lid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') LIMIT 20");
2001-02-07 22:01:57 +00:00
while ($story = db_fetch_object($result)) {
2001-05-09 18:28:09 +00:00
$find[$i++] = array("title" => check_output($story->title), "link" => (user_access($user, "story") ? "admin.php?mod=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->userid, "date" => $story->timestamp);
2001-02-07 22:01:57 +00:00
}
return $find;
}
2001-01-07 19:21:28 +00:00
function story_help() {
?>
2001-02-05 16:42:38 +00:00
<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>
2001-03-10 11:07:52 +00:00
<?php
2001-01-07 19:21:28 +00:00
}
2001-04-16 18:21:22 +00:00
function story_view($node, $main = 0) {
global $theme;
2001-05-27 20:50:34 +00:00
$node->body = ((!$main) && ($node->body)) ? "$node->abstract<HR>$node->body" : $node->abstract;
2001-05-24 10:05:18 +00:00
$theme->node($node, $main);
2001-03-24 16:56:10 +00:00
}
2000-12-24 15:44:29 +00:00
2001-04-16 11:38:12 +00:00
function story_form($edit = array()) {
2001-05-20 13:51:40 +00:00
global $REQUEST_URI, $user;
2000-12-24 15:44:29 +00:00
2001-04-30 17:13:08 +00:00
$form .= form_item(t("Your name"), format_username(($edit[userid] ? $edit[userid] : $user->userid)));
$form .= form_hidden("userid", $edit[userid]);
$form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
$form .= structure_form("story", $edit);
2001-05-20 13:51:40 +00:00
$form .= form_textarea(t("Abstract"), "abstract", $edit[abstract], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$form .= form_textarea(t("Body"), "body", $edit[body], 50, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
2001-03-24 16:56:10 +00:00
2001-05-15 18:38:57 +00:00
if ($edit[nid] > 0) {
$form .= form_hidden("nid", $edit[nid]);
}
2001-02-17 15:52:40 +00:00
2001-04-16 11:38:12 +00:00
if (!$edit) {
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
2001-03-24 16:56:10 +00:00
}
2001-04-16 11:38:12 +00:00
else if (!$edit[title]) {
2001-05-12 21:06:13 +00:00
$form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n";
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
2001-03-24 16:56:10 +00:00
}
2001-04-16 11:38:12 +00:00
else if (!$edit[abstract]) {
2001-05-12 21:06:13 +00:00
$form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n";
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
2001-03-24 16:56:10 +00:00
}
else {
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
$form .= form_submit(t("Submit"));
2001-03-24 16:56:10 +00:00
}
2001-01-07 19:21:28 +00:00
2001-04-30 17:13:08 +00:00
return form($REQUEST_URI, $form);
2001-01-07 19:21:28 +00:00
}
2001-04-16 11:38:12 +00:00
function story_save($edit) {
2001-05-15 18:38:57 +00:00
global $status, $user;
if (!$edit[nid]) {
2001-06-02 22:12:35 +00:00
node_save($edit, array(abstract, author => $user->id, body, cid, comment => variable_get("story_comment", 0), moderate => variable_get("story_moderate", ""), promote => variable_get("story_promote", 0), score => 0, status => variable_get("story_status", $status[queued]), tid, timestamp => time(), title, type => "story", votes => 0));
2001-05-15 18:38:57 +00:00
}
else if (user_access($user)) {
node_save($edit, array(abstract, body, cid, tid, title, type => "story"));
}
2001-01-07 19:21:28 +00:00
}
2001-03-24 16:56:10 +00:00
function story_user() {
2001-04-16 11:38:12 +00:00
global $edit, $op, $theme, $user;
2001-03-24 16:56:10 +00:00
switch($op) {
case t("Preview"):
2001-05-20 13:51:40 +00:00
story_view(new Story(node_preview($edit)));
2001-04-16 11:38:12 +00:00
$theme->box(t("Submit"), story_form($edit));
2001-01-07 19:21:28 +00:00
break;
2001-03-24 16:56:10 +00:00
case t("Submit"):
2001-04-16 11:38:12 +00:00
story_save($edit);
2001-04-15 17:01:32 +00:00
$theme->box(t("Submit"), t("Thank you for your submission."));
2000-12-14 14:13:37 +00:00
break;
default:
2001-04-16 11:38:12 +00:00
$theme->box(t("Submit"), story_form());
2000-12-14 14:13:37 +00:00
}
}
2000-12-24 15:44:29 +00:00
?>