Commit d397bbe9 authored by Dries's avatar Dries

This a rather large commit that needs a lot of fine-tuning.  If you
update, you'll break your site as you need switching from structure
to index.module: so this can be considered an intermediate commit.

If you upgrade, and you are welcome to, just create a collection
called "section" (for now) and assign your nodes some attributes
in the described format.

Feedback and bugreports are welcomed.  Questions will be answered.

CHANGES:

- comment system:
   + when replying to a node (rather then to a comment), that
     node is displayed above the reply form.
   + when replying to a comment (rather then to a node), that
     comment is displayd above the reply form.

- removed structure.inc, removed structure.module.

- node.inc:
   + added 2 new node functions called 'node_attribute_edit()' and
     'node_attribute_save()' used to 'hook in' any indexing system
    including your home-brewed stuff if you'd want to.  Currently,
    index.module is the facto default index system.

    See story.module for usage.

- book.module, story.module, poll.module, page.module, forum.module:
   + added preview functionality to administration section (via node
     module).
   + removed all references to structure.inc (category, topic).

- moderate.module:
   + removed all references to structure.inc (category, topic).

- book.module, story.module, page.module, forum.module:
   + increased the sizes of some textareas.

- submit.php:
   + removed all references to structure.inc (category, topic).

- marvin.theme:
   + removed dead code: function story() was depricated.

- unconed.theme:
   + removed hardcoded references to drop.org.

- marvin.theme, unconed.theme, jeroen.theme, yaroon.theme, example.theme:
   + removed all references to structure.inc (category, topic).

TODO:

- file.module, trip_link.module:
   + update preview functionality:
       see story.module for example.
   + remove references to 'cid' and 'tid', use 'attribute' instead:
       see story.module for example.

- extend and build upon index.module as well as making it configurable
parent 6b343106
......@@ -54,7 +54,10 @@ function comment_reply($pid, $id) {
$item = db_fetch_object(db_query("SELECT comments.*, users.userid FROM comments LEFT JOIN users ON comments.author = users.id WHERE comments.cid = '$pid'"));
comment_view(new Comment($item->userid, $item->subject, $item->comment, $item->timestamp, $item->url, $item->fake_email, comment_score($comment), $comment->votes, $item->cid, $item->lid), t("reply to this comment"));
}
else $pid = 0;
else {
node_view(node_get_object(array("nid" => $id)));
$pid = 0;
}
// Build reply form:
$output .= "<FORM ACTION=\"$REQUEST_URI\" METHOD=\"post\">\n";
......
......@@ -258,7 +258,6 @@ function page_footer() {
$conf = conf_init();
include_once "includes/$conf.php";
include_once "includes/structure.inc";
include_once "includes/database.inc";
include_once "includes/variable.inc";
include_once "includes/comment.inc";
......
......@@ -211,8 +211,12 @@ function node_preview($node) {
return $node;
}
function node_index($string) {
return $string ? implode(" / ", node_attributes_view($string)) : "&nbsp;";
}
function node_attributes_edit($edit) {
return index_collection_form("section", ($edit[section] ? $edit[section] : "section:". field_get($edit[attribute], "section")));
return index_collection_form("section", ($edit[section] ? $edit[section] : "section:". field_get($edit[attribute], "section") .";"));
}
function node_attributes_save($edit) {
......@@ -224,6 +228,16 @@ function node_attributes_save($edit) {
}
}
function node_attributes_view($string) {
foreach (explode(";", $string) as $data) {
$entry = explode(":", $data);
if (in_array($entry[0], array("section"))) {
$array[] = "<a href=\"?$entry[0]=$entry[1]\">$entry[1]</a>";
}
}
return $array ? $array : array();
}
function node_visible($node) {
global $user, $status;
return ($node->status == $status[posted]) || ($node->status == $status[queued] && $user->id) || user_access($user, $node->type) || user_access($user, "node");
......
<?php
// ----- category -----
function _category_get($field, $value) {
return db_query("SELECT * FROM category WHERE $field = '$value'");
}
// returns the category object where $field = $value:
function category_get_object($field, $value) {
return db_fetch_object(_category_get($field, $value));
}
// returns the category array where $field = $value:
function category_get_array($field, $value) {
return db_fetch_array(_category_get($field, $value));
}
// save a category:
function category_save($edit) {
if (!$edit[cid]) $edit[cid] = db_insert_id(db_query("INSERT INTO category (name) VALUES ('". check_query($edit[name])."')"));
foreach ($edit as $key=>$value) db_query("UPDATE category SET $key = '". check_query($value) ."' WHERE cid = '$edit[cid]'");
}
// delete category $cid:
function category_del($cid) {
db_query("DELETE FROM category WHERE cid = '". check_query($cid) ."'");
db_query("UPDATE node SET cid = 0 WHERE cid = '". check_query($cid) ."'");
}
// return post threshold:
function category_post_threshold($cid) {
$category = db_fetch_object(db_query("SELECT post AS threshold FROM category WHERE cid = '". check_query($cid) ."'"));
return $category->threshold;
}
// return dump threshold:
function category_dump_threshold($cid) {
$category = db_fetch_object(db_query("SELECT dump AS threshold FROM category WHERE cid = '". check_query($cid) ."'"));
return $category->threshold;
}
// return expiration threshold:
function category_expire_threshold($cid) {
$category = db_fetch_object(db_query("SELECT expire AS threshold FROM category WHERE cid = '". check_query($cid) ."'"));
return $category->threshold;
}
// return default comment status of category $cid:
function category_comment($cid) {
$category = category_get_object("cid", $cid);
return $category->comment ? $category->comment : 0;
}
// return default promote status of category $cid:
function category_promote($cid) {
$category = category_get_object("cid", $cid);
return $category->promote ? $category->promote : 0;
}
// return default submission status of category $cid:
function category_submission($cid) {
$category = category_get_object("cid", $cid);
return $category->submission ? $category->submission : 0;
}
// return linked string with name of category $cid:
function category_name($cid) {
$category = category_get_object("cid", $cid);
return ($category) ? "<A HREF=\"index.php?category=$category->cid\">$category->name</A>" : "";
}
function category_form_select($type, $edit = array(), $size = 1) {
$result = db_query("SELECT * FROM category WHERE type = '$type'");
while ($category = db_fetch_object($result)) {
$options .= "<OPTION VALUE=\"$category->cid\"". ($edit[cid] == $category->cid ? "SELECTED" : "") .">". check_form($category->name) ."</OPTION>";
}
return "<SELECT NAME=\"edit[cid]\" SIZE=\"$size\"". ($size > 1 ? "MULTIPLE" : "") .">$options</SELECT>\n";
}
// ----- topic -----
function _topic_get($field, $value) {
return db_query("SELECT * FROM topic WHERE $field = '$value'");
}
// returns the topic object where $field = $value:
function topic_get_object($field, $value) {
return db_fetch_object(_topic_get($field, $value));
}
// returns the topic array where $field = $value:
function topic_get_array($field, $value) {
return db_fetch_array(_topic_get($field, $value));
}
// save a topic:
function topic_save($edit) {
if (!$edit[tid]) $edit[tid] = db_insert_id(db_query("INSERT INTO topic (name) VALUES ('". check_query($edit[name])."')"));
foreach ($edit as $key=>$value) db_query("UPDATE topic SET $key = '". check_query($value) ."' WHERE tid = '$edit[tid]'");
}
// returns a sorted tree-representation of all topics:
function topic_tree($parent = 0, $name = "", $tree = array()) {
$result = db_query("SELECT * FROM topic WHERE pid = '$parent' ORDER BY name");
while ($topic = db_fetch_object($result)) {
$tree[$topic->tid] = ($name ? "$name - $topic->name" : $topic->name);
$tree = topic_tree($topic->tid, $tree[$topic->tid], $tree);
}
return $tree;
}
// delete topic $tid:
function topic_del($tid) {
db_query("DELETE FROM topic WHERE tid = '". check_query($tid) ."'");
db_query("UPDATE node SET tid = 0 WHERE tid = '". check_query($tid) ."'");
}
// return linked string with name of topic $tid:
function topic_name($tid, $name = 0) {
$topic = topic_get_object("tid", $tid);
$name = $name ? "<A HREF=\"index.php?topic=$topic->tid\">$topic->name</A> - $name" : "<A HREF=\"index.php?topic=$topic->tid\">$topic->name</A>";
return ($topic->pid) ? topic_name($topic->pid, $name) : $name;
}
// return moderators for topic $tid:
function topic_moderate($tid) {
$topic = topic_get_object("tid", $tid);
return $topic->moderate;
}
// renders a HTML form to select one or more topics:
function topic_form_select($edit = array(), $size = 1) {
foreach (topic_tree() as $tid=>$name) {
$options .= "<OPTION VALUE=\"$tid\"". ($edit[tid] == $tid ? "SELECTED" : "") .">". check_form($name) ."</OPTION>";
}
return "<SELECT NAME=\"edit[tid]\" SIZE=\"$size\"". ($size > 1 ? "MULTIPLE" : "") .">$options</SELECT>\n";
}
// ----- structure -----
// add node $nid to category $cid and topic $tid:
function structure_save($nid, $cid, $tid) {
category_node($nid, $cid);
topic_node($nid, $tid);
}
// render a HMTL selection form:
function structure_form($type, $edit = array(), $size = 1) {
$output .= "<B>Category and topic:</B><BR>\n";
$output .= category_form_select($type, $edit, $size) ." ". topic_form_select($edit, $size) ."<BR>";
$output .= "<SMALL><I>". t("Select the category and the topic this submission belongs in.") ."</I></SMALL><P>";
return $output;
}
?>
\ No newline at end of file
<?php
class BaseTheme {
function links($links = array(), $status = 0, $node = 0) {
if ($status == 1)
$links = array_merge(theme_morelink($node), $links);
foreach ($links as $link) {
$_links[] = count($link) == 2 ? "<A HREF=\"$link[0]\"><FONT COLOR=\"$theme->link\">". t($link[1]) ."</FONT></A>" : t($link[0]);
}
if ($status == 2) return ($_links ? implode(" | ", $_links) : "");
else return ($_links ? "[ ". implode(" | ", $_links) ." ]" : "");
function links($links = array(), $status = 0, $node = 0) {
if ($status == 1)
$links = array_merge(theme_morelink($node), $links);
foreach ($links as $link) {
$_links[] = count($link) == 2 ? "<A HREF=\"$link[0]\"><FONT COLOR=\"$theme->link\">". t($link[1]) ."</FONT></A>" : t($link[0]);
}
if ($status == 2) return ($_links ? implode(" | ", $_links) : "");
else return ($_links ? "[ ". implode(" | ", $_links) ." ]" : "");
}
}
function theme_init() {
......
......@@ -4,16 +4,13 @@
page_header();
if ($category) {
$c = "AND cid = '". check_input($category) ."'";
foreach(explode("&", $QUERY_STRING) as $attribute) {
if ($attribute) $query .= "attribute LIKE '%". check_input(strtr($attribute, "=", ":")) ."%' AND ";
}
if ($topic) {
foreach (topic_tree($topic) as $key=>$value) $t .= "tid = '$key' OR ";
$t = "AND ($t tid = '". check_input($topic) ."')";
}
$query = !$date ? $query : "";
$result = db_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '". node_status("posted") ."' AND timestamp <= '". ($date > 0 ? check_input($date) : time()) ."' $c $t ORDER BY timestamp DESC LIMIT ". ($user->nodes ? $user->nodes : variable_get(default_nodes_main, 10)));
$result = db_query("SELECT nid, type FROM node WHERE $query promote = '1' AND status = '". node_status("posted") ."' AND timestamp <= '". ($date > 0 ? check_input($date) : time()) ."' ORDER BY timestamp DESC LIMIT ". ($user->nodes ? $user->nodes : variable_get(default_nodes_main, 10)));
$theme->header();
while ($node = db_fetch_object($result)) {
......
......@@ -108,10 +108,13 @@ function book_toc($parent = "", $indent = "", $toc = array()) {
function book_form($edit = array()) {
global $REQUEST_URI, $user;
if ($edit[title]) {
$form .= book_view(new Book(node_preview($edit)));
}
$form .= form_item(t("Author"), 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 .= form_item(t("Category"), category_form_select("book", $edit));
if ($edit[pid]) {
$node = node_get_object(array("nid" => $edit[pid]));
......@@ -122,8 +125,8 @@ function book_form($edit = array()) {
$form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in."));
}
$form .= form_textarea(t("Content"), "body", $edit[body], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$form .= form_textarea(t("Log message"), "log", $edit[log], 50, 5, t("An explanation of the additions or updates being made to help the group understand your motivations."));
$form .= form_textarea(t("Content"), "body", $edit[body], 70, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$form .= form_textarea(t("Log message"), "log", $edit[log], 70, 5, t("An explanation of the additions or updates being made to help the group understand your motivations."));
if (user_access($user, "book")) {
$form .= form_select(t("Weight"), "weight", $edit[weight], array(0, 1, 2, 3, 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, 30), t("The heavier nodes will sink and the lighter nodes will be positioned nearer the top."));
......@@ -134,10 +137,7 @@ function book_form($edit = array()) {
$form .= form_hidden("nid", $edit[nid]);
}
if (!$edit) {
$form .= form_submit(t("Preview"));
}
else if (!$edit[title]) {
if (!$edit[title]) {
$form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a title.") ."</FONT><P>\n";
$form .= form_submit(t("Preview"));
}
......@@ -153,10 +153,10 @@ function book_save($edit) {
global $status, $user;
if (!$edit[nid]) {
node_save($edit, array(author => $user->id, body, cid, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), tid, timestamp => time(), title, type => "book", votes => 0, weight));
node_save($edit, array(author => $user->id, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight));
}
else if (user_access($user)) {
node_save($edit, array(body, cid, log, parent, tid, title, type => "book", weight));
node_save($edit, array(body, log, parent, title, type => "book", weight));
}
}
......@@ -232,7 +232,6 @@ function book_user() {
$theme->box($title, book_update($id));
break;
case t("Preview"):
book_view(new Book(node_preview($edit)));
$theme->box($title, book_form($edit));
break;
case t("Submit"):
......
......@@ -108,10 +108,13 @@ function book_toc($parent = "", $indent = "", $toc = array()) {
function book_form($edit = array()) {
global $REQUEST_URI, $user;
if ($edit[title]) {
$form .= book_view(new Book(node_preview($edit)));
}
$form .= form_item(t("Author"), 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 .= form_item(t("Category"), category_form_select("book", $edit));
if ($edit[pid]) {
$node = node_get_object(array("nid" => $edit[pid]));
......@@ -122,8 +125,8 @@ function book_form($edit = array()) {
$form .= form_select(t("Parent"), "parent", $edit[parent], book_toc(), t("The parent subject or category the page belongs in."));
}
$form .= form_textarea(t("Content"), "body", $edit[body], 50, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$form .= form_textarea(t("Log message"), "log", $edit[log], 50, 5, t("An explanation of the additions or updates being made to help the group understand your motivations."));
$form .= form_textarea(t("Content"), "body", $edit[body], 70, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
$form .= form_textarea(t("Log message"), "log", $edit[log], 70, 5, t("An explanation of the additions or updates being made to help the group understand your motivations."));
if (user_access($user, "book")) {
$form .= form_select(t("Weight"), "weight", $edit[weight], array(0, 1, 2, 3, 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, 30), t("The heavier nodes will sink and the lighter nodes will be positioned nearer the top."));
......@@ -134,10 +137,7 @@ function book_form($edit = array()) {
$form .= form_hidden("nid", $edit[nid]);
}
if (!$edit) {
$form .= form_submit(t("Preview"));
}
else if (!$edit[title]) {
if (!$edit[title]) {
$form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a title.") ."</FONT><P>\n";
$form .= form_submit(t("Preview"));
}
......@@ -153,10 +153,10 @@ function book_save($edit) {
global $status, $user;
if (!$edit[nid]) {
node_save($edit, array(author => $user->id, body, cid, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), tid, timestamp => time(), title, type => "book", votes => 0, weight));
node_save($edit, array(author => $user->id, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, promote => variable_get("book_promote", 0), score => 0, status => variable_get("book_status", $status[queued]), timestamp => time(), title, type => "book", votes => 0, weight));
}
else if (user_access($user)) {
node_save($edit, array(body, cid, log, parent, tid, title, type => "book", weight));
node_save($edit, array(body, log, parent, title, type => "book", weight));
}
}
......@@ -232,7 +232,6 @@ function book_user() {
$theme->box($title, book_update($id));
break;
case t("Preview"):
book_view(new Book(node_preview($edit)));
$theme->box($title, book_form($edit));
break;
case t("Submit"):
......
......@@ -14,8 +14,7 @@ function forum_form($edit = array()) {
global $REQUEST_URI;
$form .= form_textfield("Subject", "title", $edit[title], 50, 64);
$form .= structure_form("forum", $edit);
$form .= form_textarea("Body", "body", $edit[body], 50, 10);
$form .= form_textarea("Body", "body", $edit[body], 70, 10);
$form .= form_hidden("nid", $edit[nid]);
$form .= form_submit("Submit");
......@@ -26,7 +25,7 @@ function forum_save($edit) {
global $user, $status;
if (user_access($user)) {
node_save($edit, array(author => $user->id, body, cid, comment => variable_get("forum_comment", 0), moderate => variable_get("forum_moderate", ""), promote => variable_get("forum_promote", 0), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "forum", votes => 0));
node_save($edit, array(author => $user->id, body, comment => variable_get("forum_comment", 0), moderate => variable_get("forum_moderate", ""), promote => variable_get("forum_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0));
}
}
......
......@@ -14,8 +14,7 @@ function forum_form($edit = array()) {
global $REQUEST_URI;
$form .= form_textfield("Subject", "title", $edit[title], 50, 64);
$form .= structure_form("forum", $edit);
$form .= form_textarea("Body", "body", $edit[body], 50, 10);
$form .= form_textarea("Body", "body", $edit[body], 70, 10);
$form .= form_hidden("nid", $edit[nid]);
$form .= form_submit("Submit");
......@@ -26,7 +25,7 @@ function forum_save($edit) {
global $user, $status;
if (user_access($user)) {
node_save($edit, array(author => $user->id, body, cid, comment => variable_get("forum_comment", 0), moderate => variable_get("forum_moderate", ""), promote => variable_get("forum_promote", 0), score => 0, status => $status[posted], tid, timestamp => time(), title, type => "forum", votes => 0));
node_save($edit, array(author => $user->id, body, comment => variable_get("forum_comment", 0), moderate => variable_get("forum_moderate", ""), promote => variable_get("forum_promote", 0), score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0));
}
}
......
......@@ -7,13 +7,13 @@ function index_get_array($id) {
return db_fetch_array(db_query("SELECT * FROM entry WHERE eid = '". check_input($id) ."'"));
}
function index_collection_form($name) {
function index_collection_form($name, $selected = "") {
$result = db_query("SELECT * FROM entry WHERE collection = '$name'");
while ($entry = db_fetch_object($result)) {
$options[$entry->keyword] = $entry->name;
}
return form_select($name, $name, "", $options);
return form_select(ucfirst($name), $name, $selected, $options);
}
function index_collection_link($name) {
......
......@@ -66,7 +66,7 @@ function locale_languages($translation) {
function locale_overview() {
if (variable_get("locale", 0)) {
$result = db_query("SELECT * FROM locales ORDER BY string");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>string</TH><TH>languages</TH><TH COLSPAN=\"2\">operations</TH><TR>\n";
while ($locale = db_fetch_object($result)) {
......@@ -74,10 +74,12 @@ function locale_overview() {
$output .= " <TR><TD>". check_output($locale->string) ."<BR><SMALL><I>$locale->location</I></SMALL></TD><TD ALIGN=\"center\">$languages</TD><TD><A HREF=\"admin.php?mod=locale&op=edit&id=$locale->id\">edit</A></TD><TD><A HREF=\"admin.php?mod=locale&op=delete&id=$locale->id\">delete</A></TD></TR>";
}
$output .= "</TABLE>\n";
return $output;
}
return "Locale disabled.";
else {
return status("locale disabled.");
}
}
function locale_admin() {
......
......@@ -66,7 +66,7 @@ function locale_languages($translation) {
function locale_overview() {
if (variable_get("locale", 0)) {
$result = db_query("SELECT * FROM locales ORDER BY string");
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>string</TH><TH>languages</TH><TH COLSPAN=\"2\">operations</TH><TR>\n";
while ($locale = db_fetch_object($result)) {
......@@ -74,10 +74,12 @@ function locale_overview() {
$output .= " <TR><TD>". check_output($locale->string) ."<BR><SMALL><I>$locale->location</I></SMALL></TD><TD ALIGN=\"center\">$languages</TD><TD><A HREF=\"admin.php?mod=locale&op=edit&id=$locale->id\">edit</A></TD><TD><A HREF=\"admin.php?mod=locale&op=delete&id=$locale->id\">delete</A></TD></TR>";
}
$output .= "</TABLE>\n";
return $output;
}
return "Locale disabled.";
else {
return status("locale disabled.");
}
}
function locale_admin() {
......
......@@ -12,11 +12,11 @@ function moderate_overview($query = array()) {
$output .= status($query[0]);
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TH>node</TH><TH>category / topic</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH>operations</TH></TR>\n";
$output .= " <TR><TH>node</TH><TH>type</TH><TH>status</TH><TH>author</TH><TH>date</TH><TH>operations</TH></TR>\n";
$r1 = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.moderate LIKE '%$user->userid%' ORDER BY n.timestamp DESC LIMIT 30");
while ($node = db_fetch_object($r1)) {
$output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>". category_name($node->cid) ." / ". topic_name($node->tid) ."</TD><TD>". node_status($node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=moderate&type=node&op=edit&id=$node->nid\">edit $node->type</A></TD></TR>\n";
$output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></TD><TD>$node->type</TD><TD>". node_status($node->status) ."</TD><TD>". format_username($node->userid) ."</TD><TD>". format_date($node->timestamp, "small") ."</TD><TD><A HREF=\"admin.php?mod=moderate&type=node&op=edit&id=$node->nid\">edit $node->type</A></TD></TR>\n";
$r2 = db_query("SELECT c.*, u.userid FROM comments c LEFT JOIN users u ON c.author = u.id WHERE c.lid = '$node->nid' ORDER BY c.timestamp DESC");
while ($comment = db_fetch_object($r2)) {
......
......@@ -5,9 +5,8 @@ function Node($node) {
global $user;
$this->userid = $node[userid] ? $node[userid] : $user->userid;
$this->title = $node[title];
$this->timestamp = $node[attribute];
$this->timestamp = $node[timestamp] ? $node[timestamp] : time();
$this->cid = $node[cid];
$this->tid = $node[tid];
}
}
......@@ -67,7 +66,7 @@ function node_overview($query) {
$color = array("#ffdc9b", "#dedec4");
$query = node_query($query ? $query : 0);
$result = db_query("SELECT n.*, u.userid, c.name AS category FROM node n LEFT JOIN users u ON n.author = u.id LEFT JOIN category c ON n.cid = c.cid $query[1] LIMIT 50");
$result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50");
$output .= status($query[0]);
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
......
......@@ -5,9 +5,8 @@ function Node($node) {
global $user;
$this->userid = $node[userid] ? $node[userid] : $user->userid;
$this->title = $node[title];
$this->timestamp = $node[attribute];
$this->timestamp = $node[timestamp] ? $node[timestamp] : time();
$this->cid = $node[cid];
$this->tid = $node[tid];
}
}
......@@ -67,7 +66,7 @@ function node_overview($query) {
$color = array("#ffdc9b", "#dedec4");
$query = node_query($query ? $query : 0);
$result = db_query("SELECT n.*, u.userid, c.name AS category FROM node n LEFT JOIN users u ON n.author = u.id LEFT JOIN category c ON n.cid = c.cid $query[1] LIMIT 50");
$result = db_query("SELECT n.*, u.userid FROM node n LEFT JOIN users u ON n.author = u.id $query[1] LIMIT 50");
$output .= status($query[0]);
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
......
......@@ -2,8 +2,16 @@
$GLOBALS[format] = array(0 => "HTML", 1 => "PHP", 2 => "text");
class Page {
function Page($page) {
$this = new Node($page);
$this->body = $page[body];
$this->format = $page[format];
}
}
function page_view($node, $main = 0) {
global $format, $theme;
global $format;
switch ($format[$node->format]) {
case "PHP":
......@@ -24,13 +32,24 @@ function page_status() {
}
function page_form($edit = array()) {
global $format, $REQUEST_URI;
global $REQUEST_URI, $format;
if ($edit[title]) {
$form = page_view(new Page(node_preview($edit)));
}
$form .= form_textfield("Subject", "title", $edit[title], 50, 64);
$form .= form_textarea("Body", "body", $edit[body], 80, 30);
$form .= form_textarea("Body", "body", $edit[body], 70, 30);
$form .= form_select("Type", "format", $edit[format], $format);
$form .= form_hidden("nid", $edit[nid]);
$form .= form_submit("Submit");
if ($edit[title]) {
$form .= form_submit(t("Preview"));
$form .= form_submit("Submit");
}
else {
$form .= form_submit(t("Preview"));
}
return form($REQUEST_URI, $form);
}
......
......@@ -2,8 +2,16 @@
$GLOBALS[format] = array(0 => "HTML", 1 => "PHP", 2 => "text");
class Page {
function Page($page) {
$this = new Node($page);
$this->body = $page[body];
$this->format = $page[format];
}
}
function page_view($node, $main = 0) {
global $format, $theme;
global $format;
switch ($format[$node->format]) {
case "PHP":
......@@ -24,13 +32,24 @@ function page_status() {
}
function page_form($edit = array()) {
global $format, $REQUEST_URI;
global $REQUEST_URI, $format;
if ($edit[title]) {
$form = page_view(new Page(node_preview($edit)));
}
$form .= form_textfield("Subject", "title", $edit[title], 50, 64);
$form .= form_textarea("Body", "body", $edit[body], 80, 30);
$form .= form_textarea("Body", "body", $edit[body], 70, 30);
$form .= form_select("Type", "format", $edit[format], $format);
$form .= form_hidden("nid", $edit[nid]);
$form .= form_submit("Submit");
if ($edit[title]) {
$form .= form_submit(t("Preview"));
$form .= form_submit("Submit");
}
else {
$form .= form_submit(t("Preview"));
}
return form($REQUEST_URI, $form);
}
......
......@@ -28,7 +28,7 @@ function poll_delete($node) {
if ($node->nid)
{
db_query("DELETE FROM poll_choices WHERE nid='" . $node->nid . "'");
}
}
}
function poll_get_choices_array($poll) {
......@@ -87,7 +87,7 @@ function poll_help() {
?>
<p>Poll.module allows you to run simple multiple choice polls on your site. After creating the necessary categories, you can add a poll through this administration interface.</p>
<p>The poll.module also has a block to show the latest poll. If you combine it with a poll category that doesn't promote to the mainpage, you'll get a side-block only poll system.</p>
<p>If you want to set a limit on the duration of a poll, use the <i>Poll Duration</i> setting. After the specified interval, the poll will automatically be closed, preventing anymore voting.</p>
<p>If you want to set a limit on the duration of a poll, use the <i>Poll Duration</i> setting. After the specified interval, the poll will automatically be closed, preventing anymore voting.</p>
<?php
}
......@@ -175,9 +175,13 @@ function poll_form($edit = array(), $nocheck = 0) {
10713600 => t("4 months"), 31536000 => t("1 year"));
$active = array(0 => "Closed", 1 => "Active");
$admin = ($edit[nid] && user_access($user,"poll")) ? 1 : 0;
if ($edit[title]) {
$form .= poll_view(new Poll(node_preview($edit)));
}
if ($admin && !is_array($edit[choices])) $edit = poll_get_choices_array($edit);
/* Mini-form for number of choiceboxes */
......@@ -198,15 +202,14 @@ function poll_form($edit = array(), $nocheck = 0) {
$form .= form_select(t("Poll duration"), "runtime", $edit[runtime] ? $edit[runtime] : t("1 week"), $duration, t("After this period, the poll will automatically be closed."));
if ($admin) $form .= form_select(t("Poll status"), "active", $edit[active], $active);
$form .= structure_form("poll", $edit);
$form .= node_attributes_edit($edit);
// hidden fields:
if ($edit[nid] > 0) {
$form .= form_hidden("nid", $edit[nid]);
}
if ((!$edit) || ($nocheck)) {
if ($nocheck) {
$form .= form_submit(t("Preview"));
}
else if (!$edit[title]) {
......@@ -229,10 +232,10 @@ function poll_save($edit) {
global $status, $user;
if (!$edit[nid]) {