userid = $node[userid] ? $node[userid] : $user->userid; $this->title = $node[title]; $this->timestamp = $node[timestamp] ? $node[timestamp] : time(); $this->cid = $node[cid]; $this->tid = $node[tid]; } } function node_conf_filters() { $output .= form_select(t("Strip HTML tags"), "filter_html", variable_get("filter_html", 0), array("Disabled", "Enabled"), t("Strip HTML and PHP tags.")); $output .= form_textfield(t("Allowed HTML tags"), "allowed_html", variable_get("allowed_html", "
      • "), 64, 128, t("If enabled, optionally specify tags which should not be stripped. 'STYLE' attributes, 'ON' attributes and unclosed tags are always stripped.")); $output .= "
        "; $output .= form_select(t("Strip link tags"), "filter_link", variable_get("filter_link", 0), array("Disabled", "Enabled"), t("Substitute special [[link]] tags.")); $output .= "
        "; return $output; } function node_filter_html($text) { $text = eregi_replace("([ \f\r\t\n\'\"])style=[^>]+", "\\1", $text); $text = eregi_replace("([ \f\r\t\n\'\"])on[a-z]+=[^>]+", "\\1", $text); $text = strip_tags($text, variable_get("allowed_html", "")); return $text; } function node_filter_link($text) { $src = array("/\[\[(([^\|]*?)(\|([^\|]*?))?)\]\]/e"); // [link|description] $dst = array(format_tag('\\2', '\\4')); // [link|description] return preg_replace($src, $dst, $text); } function node_filter($text) { if (variable_get("filter_html", 0)) $text = node_filter_html($text); if (variable_get("filter_link", 0)) $text = node_filter_link($text); return $text; } function node_cron() { db_query("UPDATE node SET status = '". node_status("posted") ."', timestamp_posted = '' WHERE timestamp_posted > 0 AND timestamp_posted < ". time()); db_query("UPDATE node SET status = '". node_status("queued") ."', timestamp_posted = '' WHERE timestamp_queued > 0 AND timestamp_queued < ". time()); db_query("UPDATE node SET status = '". node_status("dumped") ."', timestamp_posted = '' WHERE timestamp_hidden > 0 AND timestamp_hidden < ". time()); } function node_overview($query) { global $user; $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"); $output .= status($query[0]); $output .= "\n"; $output .= " \n"; while ($node = db_fetch_object($result)) { unset ($link); $link[] = user_access($user, $node->type) ? "type&op=edit&id=$node->nid\">edit content" : "edit content"; $link[] = user_access($user, "node") ? "nid\">edit options" : "edit options"; $link[] = user_access($user, "node") ? "nid\">edit status" : "edit status"; $link[] = user_access($user, "node") ? "nid\">edit attributes" : "edit attributes"; $link[] = user_access($user, "node") ? "nid\">delete node" : "delete node"; $bg = $color[$i++ % sizeof($color)]; $output .= " \n"; $output .= " \n"; } $output .= "
        titletypestatusmeta attributesauthordate
        nid\">". check_output($node->title) ."$node->type". node_status($node->status) ."". check_output($node->attribute) ."". format_username($node->userid) ."". format_date($node->timestamp, "small") ."
        ". implode(", ", $link) ."
        \n"; return $output; } function node_edit_option($id) { global $user; $node = node_get_object(array("nid" => $id)); $form .= form_item("Document title", check_output($node->title)); $form .= form_select("Comment", "comment", $node->comment, node_comment_status(), "Allow users to post comments to this document."); $form .= form_select("Promote", "promote", $node->promote, node_promote_status(), "Promote this document on the main page."); $form .= form_textfield("Moderate", "moderate", $node->moderate, 35, 255, t("A comma-seperated list of the moderators their usernames.")); $form .= form_hidden("nid", $node->nid); $form .= form_submit("Save node"); return form("admin.php?mod=node&id=$node->nid", $form); } function node_edit_attribute($id) { global $user; $node = node_get_object(array("nid" => $id)); $form .= form_item("Document title", check_output($node->title)); $form .= form_textfield("Attributes", "attribute", $node->attribute, 50, 128, htmlentities("A list meta attributes. Format: :;:;. Example: 'software:apache;type:webserver;os:linux;'.")); $form .= form_hidden("nid", $node->nid); $form .= form_submit("Save node"); return form("admin.php?mod=node&id=$node->nid", $form); } function node_edit_status($id) { global $REQUEST_URI; $node = node_get_object(array("nid" => $id)); $form .= form_item("Document title", check_output($node->title)); $form .= form_select("Current status", "status", $node->status, node_status($node->type)); $form .= form_textfield("Automatically post document", "timestamp_posted", ($node->timestamp_posted ? format_date($node->timestamp_posted) : ""), 30, 55, "The date at which your document will be automatically posted. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ..."); $form .= form_textfield("Automatically queue document", "timestamp_queued", ($node->timestamp_queued ? format_date($node->timestamp_queued) : ""), 30, 55, "The date at which your document will be automatically queued. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ..."); $form .= form_textfield("Automatically hide document", "timestamp_hidden", ($node->timestamp_hidden ? format_date($node->timestamp_hidden) : ""), 30, 55, "The date at which your document will be automatically hidden. Leave empty if you don't want to schedule this document, or fill out a string containing an English date format. Example input: '". date("j F Y G:i") ."', '". date("m/d/y H:i") ."', '". date("F j, Y H:i") ."', ..."); $form .= form_hidden("nid", $node->nid); $form .= form_submit("Save node"); return form($REQUEST_URI, $form); } function node_delete($id) { return (node_del(array("nid" => $id)) ? "node has been deleted." : "failed to delete node: node must be dumped first."); } function node_query($type = -1) { $queries[] = array("all nodes: recent additions", "ORDER BY n.timestamp DESC"); $queries[] = array("all nodes: status set to 'posted'", "WHERE n.status = '". node_status("posted") ."' ORDER BY n.timestamp DESC"); $queries[] = array("all nodes: status set to 'queued'", "WHERE n.status = '". node_status("queued") ."' ORDER BY n.timestamp DESC"); $queries[] = array("all nodes: status set to 'dumped'", "WHERE n.status = '". node_status("dumped") ."' ORDER BY n.timestamp DESC"); $queries[] = array("all nodes: scheduled to be posted", "WHERE n.timestamp_posted > 0 ORDER BY n.timestamp DESC"); $queries[] = array("all nodes: scheduled to be queued", "WHERE n.timestamp_queued > 0 ORDER BY n.timestamp DESC"); $queries[] = array("all nodes: scheduled to be hidden", "WHERE n.timestamp_hidden > 0 ORDER BY n.timestamp DESC"); foreach (module_list() as $name) { if (module_hook($name, "user")) { $queries[] = array("$name: recent additions", "WHERE n.type = '$name' ORDER BY n.timestamp DESC"); $queries[] = array("$name: status set to 'posted'", "WHERE n.type = '$name' AND n.status = '". node_status("posted") ."' ORDER BY n.timestamp DESC"); $queries[] = array("$name: status set to 'queued'", "WHERE n.type = '$name' AND n.status = '". node_status("queued") ."' ORDER BY n.timestamp DESC"); $queries[] = array("$name: status set to 'dumped'", "WHERE n.type = '$name' AND n.status = '". node_status("dumped") ."' ORDER BY n.timestamp DESC"); $queries[] = array("$name: scheduled to be posted", "WHERE n.type = '$name' AND n.timestamp_posted > 0 ORDER BY n.timestamp DESC"); $queries[] = array("$name: scheduled to be queued", "WHERE n.type = '$name' AND n.timestamp_queued > 0 ORDER BY n.timestamp DESC"); $queries[] = array("$name: scheduled to be hidden", "WHERE n.type = '$name' AND n.timestamp_hidden > 0 ORDER BY n.timestamp DESC"); } } return ($type < 0 ? $queries : $queries[$type]); } function node_listing($queries) { global $mod; foreach ($queries as $key=>$array) { $output .= "
      • $array[0]
      • \n"; } return "
          $output
        \n"; } function node_setting() { global $REQUEST_URI; $threshold_post = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100); $threshold_dump = array(-1 => -1, -2 => -2, -3 => -3, -4 => -4, -5 => -5, -6 => -6, -7 => -7, -8 => -8, -9 => -9, -10 => -10, -11 => -11, -12 => -12, -13 => -13, -14 => -14, -15 => -15, -20 => -20, -25 => -25, -30 => -30); $threshold_expire = array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 60 => 60, 70 => 70, 80 => 80, 90 => 90, 100 => 100); foreach (module_list() as $name) { if (module_hook($name, "user")) { $form .= "

        Default settings for $name nodes

        "; $form .= form_select(t("Comment"), $name ."_comment", variable_get($name ."_comment", 0), node_comment_status(), "By default, allow or dissallow users to post comments in this category."); $form .= form_select(t("Promote"), $name ."_promote", variable_get($name ."_promote", 0), node_promote_status(), "By default, promote new submissions in this category to the front page."); $form .= form_select(t("Status"), $name ."_status", variable_get($name ."_status", node_status("queued")), node_status($name), "What to do with new submissions in this category?"); $form .= form_select(t("Post threshold"), $name ."_post", variable_get($name ."_post", 4), $threshold_post, "If new submissions are subject to moderation, select a post threshold."); $form .= form_select(t("Dump threshold"), $name ."_dump", variable_get($name ."_dump", -2), $threshold_dump, "If new submissions are subject to moderation, select a dump threshold."); $form .= form_select(t("Expiration threshold"), $name ."_expire", variable_get($name ."_expire", 8), $threshold_expire, "If new submissions are subject to moderation, select a expiration threshold."); $form .= form_textfield("Moderate", $name ."_moderate", variable_get($name ."_moderate", ""), 35, 255, "A comma-seperated list of the moderators' usernames."); } } $form .= form_submit("Save settings"); $form .= form_submit("Reset to defaults"); return form($REQUEST_URI, $form); } function node_admin_save($edit) { if (isset($edit[status])) { $edit[timestamp_posted] = (strtotime($edit[timestamp_posted]) > time()) ? strtotime($edit[timestamp_posted]) : 0; $edit[timestamp_queued] = (strtotime($edit[timestamp_queued]) > time()) ? strtotime($edit[timestamp_queued]) : 0; $edit[timestamp_hidden] = (strtotime($edit[timestamp_hidden]) > time()) ? strtotime($edit[timestamp_hidden]) : 0; node_save($edit, array(status, timestamp_posted, timestamp_queued, timestamp_hidden)); } else if (isset($edit[attribute])) { node_save($edit, array(attribute)); } else { node_save($edit, array(comment, moderate, promote)); } } function node_search() { global $REQUEST_URI; foreach (module_list() as $name) { if (module_hook($name, "user")) { $options .= "\n"; } } $output .= "
        \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "
        \n"; return $output; } function node_module_edit($edit, $type) { $edit[type] = $type; return node_invoke($edit, "form"); } function node_module_save($edit, $type) { $edit[type] = $type; return node_invoke($edit, "save"); } function node_admin() { global $op, $id, $edit, $query, $type, $keys; foreach (module_list() as $name) { if (module_hook($name, "status") && $name != "node") { $link[] = "add $name"; } } print "". implode(" | ", $link) ." | node settings | node listings | search node | overview
        \n"; $id = check_input($edit[nid] ? $edit[nid] : $id); switch ($op) { case "add": print module_invoke($type, "form"); break; case "search": print node_search($id); print search_data($keys, $type); break; case "status": print node_edit_status($id); break; case "option": print node_edit_option($id); break; case "attribute": print node_edit_attribute($id); break; case "default": print node_setting(); break; case "delete": print status(node_delete($id)); print node_overview($query); break; case "listing": print node_listing(node_query()); break; case "Save settings": print status(conf_save($edit)); print node_setting(); break; case "Reset to defaults": print status(conf_default($edit)); print node_setting(); break; case "Save node": print node_admin_save($edit); print node_overview($query); break; case "edit": print node_module_edit(node_get_array(array("nid" => $id)), $type); break; case "Preview": print node_module_edit($edit, $type); break; case "Submit": print status(node_module_save($edit, $type)); // fall through: default: print node_overview($query); } } ?>