drupal/modules/story.module

181 lines
6.8 KiB
Plaintext
Raw Normal View History

<?php
2000-12-14 14:13:37 +00:00
class Story {
function Story($story) {
$this = new Node($story);
$this->abstract = $story[abstract];
$this->body = $story[body];
}
}
function story_status() {
return array(dumped, queued, posted);
}
function story_search($keys) {
global $status, $user;
$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");
while ($story = db_fetch_object($result)) {
$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);
}
return $find;
}
function story_help() {
?>
<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>
<?php
}
function story_view($node, $main = 0) {
global $theme;
$theme->story($node, $main);
}
function story_form($edit = array()) {
global $REQUEST_URI, $user;
Welp. Large commit ahead. CHANGES: - Added "read" and "write" permissions into drupal but removed it again because - when finished after 3 hours of work - it was considered nothing but added complexity that didn't buy us anything. :I (I'll explain this in detail on the mailing list, I guess.) - Added a very simple help.module to group all available documentation on a single page. - Fixed bug in node_control(), book.module: UnConeD forgot to global $user when updating the combobox code. - Removed static wishlist.module: in future, the wishlist can be maintained as a page in our collaborative book. - Revised most of settings.module: tidied up the code and the descriptions to accompany the settings and introduced a new "default maximum number of nodes to display on the main page" variable. - Revised most of comment.module: the administration interface looks better now, integrated node permissions, and -finally- made it possible to delete comments. - Polished on: + account.module + structure.module + locale.module + module.module + forum.module - Form-ified: + account.php + account.module + setting.module + cvs.module + submit.php + comment.module + forum.module + book.module + page.module + locale.module - Updated CHANGELOG INFO: - Designed a "generic tracker system with optional backends" on paper. The idea is to allow registered users to hot-list certain topics, individual nodes or threads (comments) and to "plug-in" output backends like - for instance - an e-mail digest. The design requires "intelligent blocks" though. TODO: - I want to tidy up the headline.module and backend.class as well as merge in headlineRSS10.module. Julian spent quite some time working on headline.module but I'm not sure what he changed and whether he'd contribute it back?
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);
$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", "")));
// hidden fields:
if ($edit[nid] > 0) {
$form .= form_hidden("nid", $edit[nid]);
}
if (!$edit) {
Welp. Large commit ahead. CHANGES: - Added "read" and "write" permissions into drupal but removed it again because - when finished after 3 hours of work - it was considered nothing but added complexity that didn't buy us anything. :I (I'll explain this in detail on the mailing list, I guess.) - Added a very simple help.module to group all available documentation on a single page. - Fixed bug in node_control(), book.module: UnConeD forgot to global $user when updating the combobox code. - Removed static wishlist.module: in future, the wishlist can be maintained as a page in our collaborative book. - Revised most of settings.module: tidied up the code and the descriptions to accompany the settings and introduced a new "default maximum number of nodes to display on the main page" variable. - Revised most of comment.module: the administration interface looks better now, integrated node permissions, and -finally- made it possible to delete comments. - Polished on: + account.module + structure.module + locale.module + module.module + forum.module - Form-ified: + account.php + account.module + setting.module + cvs.module + submit.php + comment.module + forum.module + book.module + page.module + locale.module - Updated CHANGELOG INFO: - Designed a "generic tracker system with optional backends" on paper. The idea is to allow registered users to hot-list certain topics, individual nodes or threads (comments) and to "plug-in" output backends like - for instance - an e-mail digest. The design requires "intelligent blocks" though. TODO: - I want to tidy up the headline.module and backend.class as well as merge in headlineRSS10.module. Julian spent quite some time working on headline.module but I'm not sure what he changed and whether he'd contribute it back?
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
}
else if (!$edit[title]) {
$form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n";
Welp. Large commit ahead. CHANGES: - Added "read" and "write" permissions into drupal but removed it again because - when finished after 3 hours of work - it was considered nothing but added complexity that didn't buy us anything. :I (I'll explain this in detail on the mailing list, I guess.) - Added a very simple help.module to group all available documentation on a single page. - Fixed bug in node_control(), book.module: UnConeD forgot to global $user when updating the combobox code. - Removed static wishlist.module: in future, the wishlist can be maintained as a page in our collaborative book. - Revised most of settings.module: tidied up the code and the descriptions to accompany the settings and introduced a new "default maximum number of nodes to display on the main page" variable. - Revised most of comment.module: the administration interface looks better now, integrated node permissions, and -finally- made it possible to delete comments. - Polished on: + account.module + structure.module + locale.module + module.module + forum.module - Form-ified: + account.php + account.module + setting.module + cvs.module + submit.php + comment.module + forum.module + book.module + page.module + locale.module - Updated CHANGELOG INFO: - Designed a "generic tracker system with optional backends" on paper. The idea is to allow registered users to hot-list certain topics, individual nodes or threads (comments) and to "plug-in" output backends like - for instance - an e-mail digest. The design requires "intelligent blocks" though. TODO: - I want to tidy up the headline.module and backend.class as well as merge in headlineRSS10.module. Julian spent quite some time working on headline.module but I'm not sure what he changed and whether he'd contribute it back?
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
}
else if (!$edit[abstract]) {
$form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n";
Welp. Large commit ahead. CHANGES: - Added "read" and "write" permissions into drupal but removed it again because - when finished after 3 hours of work - it was considered nothing but added complexity that didn't buy us anything. :I (I'll explain this in detail on the mailing list, I guess.) - Added a very simple help.module to group all available documentation on a single page. - Fixed bug in node_control(), book.module: UnConeD forgot to global $user when updating the combobox code. - Removed static wishlist.module: in future, the wishlist can be maintained as a page in our collaborative book. - Revised most of settings.module: tidied up the code and the descriptions to accompany the settings and introduced a new "default maximum number of nodes to display on the main page" variable. - Revised most of comment.module: the administration interface looks better now, integrated node permissions, and -finally- made it possible to delete comments. - Polished on: + account.module + structure.module + locale.module + module.module + forum.module - Form-ified: + account.php + account.module + setting.module + cvs.module + submit.php + comment.module + forum.module + book.module + page.module + locale.module - Updated CHANGELOG INFO: - Designed a "generic tracker system with optional backends" on paper. The idea is to allow registered users to hot-list certain topics, individual nodes or threads (comments) and to "plug-in" output backends like - for instance - an e-mail digest. The design requires "intelligent blocks" though. TODO: - I want to tidy up the headline.module and backend.class as well as merge in headlineRSS10.module. Julian spent quite some time working on headline.module but I'm not sure what he changed and whether he'd contribute it back?
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
}
else {
Welp. Large commit ahead. CHANGES: - Added "read" and "write" permissions into drupal but removed it again because - when finished after 3 hours of work - it was considered nothing but added complexity that didn't buy us anything. :I (I'll explain this in detail on the mailing list, I guess.) - Added a very simple help.module to group all available documentation on a single page. - Fixed bug in node_control(), book.module: UnConeD forgot to global $user when updating the combobox code. - Removed static wishlist.module: in future, the wishlist can be maintained as a page in our collaborative book. - Revised most of settings.module: tidied up the code and the descriptions to accompany the settings and introduced a new "default maximum number of nodes to display on the main page" variable. - Revised most of comment.module: the administration interface looks better now, integrated node permissions, and -finally- made it possible to delete comments. - Polished on: + account.module + structure.module + locale.module + module.module + forum.module - Form-ified: + account.php + account.module + setting.module + cvs.module + submit.php + comment.module + forum.module + book.module + page.module + locale.module - Updated CHANGELOG INFO: - Designed a "generic tracker system with optional backends" on paper. The idea is to allow registered users to hot-list certain topics, individual nodes or threads (comments) and to "plug-in" output backends like - for instance - an e-mail digest. The design requires "intelligent blocks" though. TODO: - I want to tidy up the headline.module and backend.class as well as merge in headlineRSS10.module. Julian spent quite some time working on headline.module but I'm not sure what he changed and whether he'd contribute it back?
2001-04-30 17:13:08 +00:00
$form .= form_submit(t("Preview"));
$form .= form_submit(t("Submit"));
}
Welp. Large commit ahead. CHANGES: - Added "read" and "write" permissions into drupal but removed it again because - when finished after 3 hours of work - it was considered nothing but added complexity that didn't buy us anything. :I (I'll explain this in detail on the mailing list, I guess.) - Added a very simple help.module to group all available documentation on a single page. - Fixed bug in node_control(), book.module: UnConeD forgot to global $user when updating the combobox code. - Removed static wishlist.module: in future, the wishlist can be maintained as a page in our collaborative book. - Revised most of settings.module: tidied up the code and the descriptions to accompany the settings and introduced a new "default maximum number of nodes to display on the main page" variable. - Revised most of comment.module: the administration interface looks better now, integrated node permissions, and -finally- made it possible to delete comments. - Polished on: + account.module + structure.module + locale.module + module.module + forum.module - Form-ified: + account.php + account.module + setting.module + cvs.module + submit.php + comment.module + forum.module + book.module + page.module + locale.module - Updated CHANGELOG INFO: - Designed a "generic tracker system with optional backends" on paper. The idea is to allow registered users to hot-list certain topics, individual nodes or threads (comments) and to "plug-in" output backends like - for instance - an e-mail digest. The design requires "intelligent blocks" though. TODO: - I want to tidy up the headline.module and backend.class as well as merge in headlineRSS10.module. Julian spent quite some time working on headline.module but I'm not sure what he changed and whether he'd contribute it back?
2001-04-30 17:13:08 +00:00
return form($REQUEST_URI, $form);
}
function story_save($edit) {
global $status, $user;
if (!$edit[nid]) {
node_save($edit, array(abstract, author => $user->id, body, cid, comment => category_comment($edit[cid]), moderate => topic_moderate($edit[tid]), promote => category_promote($edit[cid]), score => 0, status => (category_submission($edit[cid]) ? $status[queued] : $status[posted]), tid, timestamp => time(), title, type => "story", votes => 0));
}
else if (user_access($user)) {
node_save($edit, array(abstract, body, cid, tid, title, type => "story"));
}
}
function story_block() {
/*
//
// disabled for now
//
global $status;
$result = db_query("SELECT s.lid, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.lid = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' GROUP BY s.lid ORDER BY comments DESC LIMIT 10");
while ($story = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
}
$blocks[0][subject] = "Top 10:<BR>all stories";
$blocks[0][content] = $content;
$blocks[0][info] = "Top 10: all stories";
unset($content);
$result = db_query("SELECT s.lid, COUNT(c.cid) AS comments, s.title FROM story s LEFT JOIN comments c ON s.lid = c.lid WHERE s.status = '$status[posted]' AND c.link = 'story' AND ". time() ." - s.timestamp < 2419200 GROUP BY s.lid ORDER BY comments DESC LIMIT 10");
while ($story = db_fetch_object($result)) {
$content .= "<LI><A HREF=\"node.php?id=$story->id\">". check_output($story->title) ."</A><BR><SMALL>(". format_plural($story->comments, "comment", "comments") .")</SMALL></LI>\n";
}
$blocks[1][subject] = "Top 10:<BR>recent stories";
$blocks[1][content] = $content;
$blocks[1][info] = "Top 10: recent stories";
2000-12-14 14:13:37 +00:00
return $blocks;
*/
2000-12-14 14:13:37 +00:00
}
function story_query($type = "") {
global $status;
$queries = array(array("recent stories", "WHERE n.type = 'story' ORDER BY n.timestamp DESC"), array("posted stories", "WHERE n.type = 'story' AND n.status = '$status[posted]' ORDER BY n.timestamp DESC"), array("queued stories", "WHERE n.type = 'story' AND n.status = '$status[queued]' ORDER BY n.timestamp DESC"), array("dumped stories", "WHERE n.type = 'story' AND n.status = '$status[dumped]' ORDER BY n.timestamp DESC"), array("stories without category (integrity)", "WHERE n.type = 'story' AND n.cid = '0' ORDER BY n.timestamp DESC"), array("stories without topic (integrity)", "WHERE n.type = 'story' AND n.tid = '0' ORDER BY n.timestamp DESC"));
return ($queries[$type] ? $queries[$type] : $queries);
}
function story_overview($query = array()) {
return node_overview($query);
2000-12-14 14:13:37 +00:00
}
function story_admin() {
global $id, $edit, $mod, $keys, $op, $theme, $type, $user;
print "<SMALL><A HREF=\"admin.php?mod=story&op=add\">add new story</A> | <A HREF=\"admin.php?mod=story&op=listing\">story listing</A> | <A HREF=\"admin.php?mod=story&op=search\">search story</A> | <A HREF=\"admin.php?mod=story\">overview</A> | <A HREF=\"admin.php?mod=story&op=help\">help</A></SMALL><HR>\n";
$type = ($type ? $type : 0);
2000-12-14 14:13:37 +00:00
switch ($op) {
case "add":
print story_form();
break;
case "delete":
print story_delete($id);
print story_overview(story_query($type));
break;
2000-12-14 14:13:37 +00:00
case "edit":
print story_form(node_get_array(array("nid" => check_input($id))));
2000-12-14 14:13:37 +00:00
break;
case "help":
story_help();
2000-12-14 14:13:37 +00:00
break;
case "listing":
print node_listing(story_query());
break;
case "search":
2001-04-04 21:09:24 +00:00
print search_form($keys);
print search_data($keys, $mod);
break;
case t("Preview"):
story_view(new Story(node_preview($edit)));
print story_form($edit);
break;
case t("Submit"):
story_save($edit);
// fall through:
default:
print story_overview(story_query($type));
}
}
function story_user() {
global $edit, $op, $theme, $user;
switch($op) {
case t("Preview"):
story_view(new Story(node_preview($edit)));
$theme->box(t("Submit"), story_form($edit));
break;
case t("Submit"):
story_save($edit);
$theme->box(t("Submit"), t("Thank you for your submission."));
2000-12-14 14:13:37 +00:00
break;
default:
$theme->box(t("Submit"), story_form());
2000-12-14 14:13:37 +00:00
}
}
?>