From 8678951608a1f94f0e18ceb217a8d76aaa5ebba9 Mon Sep 17 00:00:00 2001 From: Kjartan Mannes <kjartan@2.no-reply.drupal.org> Date: Thu, 31 Jan 2002 14:03:17 +0000 Subject: [PATCH] - nodes can now be set to static which will pin them to the front page as long as they are promoted and/or static. - needs an sql update. --- modules/node.module | 7 ++++--- modules/node/node.module | 7 ++++--- update.php | 7 ++++++- 3 files changed, 14 insertions(+), 7 deletions(-) diff --git a/modules/node.module b/modules/node.module index 17db52dee3e1..57fe3ad8c881 100644 --- a/modules/node.module +++ b/modules/node.module @@ -102,7 +102,7 @@ function node_load($conditions) { function node_save($node, $filter) { - $fields = array("nid", "uid", "type", "title", "teaser", "body", "revisions", "score", "status", "comment", "promote", "moderate", "created", "changed", "users", "votes"); + $fields = array("nid", "uid", "type", "title", "teaser", "body", "revisions", "score", "status", "comment", "promote", "static", "moderate", "created", "changed", "users", "votes"); foreach ($filter as $key => $value) { /* @@ -848,6 +848,7 @@ function node_form($edit) { $output .= form_select(t("Set public/published"), "status", $edit->status, array("Disabled", "Enabled")); $output .= form_select(t("Queue for moderation"), "moderate", $edit->moderate, array("Disabled", "Enabled")); $output .= form_select(t("Promote to front page"), "promote", $edit->promote, array("Disabled", "Enabled")); + $output .= form_select(t("Static on front page"), "static", $edit->static, array("Disabled", "Enabled")); $output .= form_select(t("Allow users comments"), "comment", $edit->comment, array("Disabled", "Enabled")); $output .= form_select(t("Create new revision"), "revision", $edit->revision, array("Disabled", "Enabled")); } @@ -997,7 +998,7 @@ function node_submit($node) { */ if (user_access("administer nodes")) { - $fields = array("nid", "uid", "body", "comment", "created", "promote", "moderate", "revisions", "status", "teaser", "title", "type" => $node->type); + $fields = array("nid", "uid", "body", "comment", "created", "promote", "static", "moderate", "revisions", "status", "teaser", "title", "type" => $node->type); } else { $fields = array("nid", "uid" => ($user->uid ? $user->uid : 0), "body", "teaser", "title", "type" => $node->type); @@ -1166,7 +1167,7 @@ function node_page() { $theme->box($title, node_delete($edit)); break; default: - $result = db_query("SELECT nid, type FROM node WHERE ". ($meta ? "attributes LIKE '%". check_input($meta) ."%' AND " : "") ." promote = '1' AND status = '1' AND created <= '". ($date > 0 ? check_input($date) : time()) ."' ORDER BY created DESC LIMIT ". ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); + $result = db_query("SELECT nid, type FROM node WHERE ". ($meta ? "attributes LIKE '%". check_input($meta) ."%' AND " : "") ." promote = '1' AND status = '1' AND (static = '1' OR created <= '". ($date > 0 ? check_input($date) : time()) ."') ORDER BY static DESC,created DESC LIMIT ". ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); while ($node = db_fetch_object($result)) { node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1); } diff --git a/modules/node/node.module b/modules/node/node.module index 17db52dee3e1..57fe3ad8c881 100644 --- a/modules/node/node.module +++ b/modules/node/node.module @@ -102,7 +102,7 @@ function node_load($conditions) { function node_save($node, $filter) { - $fields = array("nid", "uid", "type", "title", "teaser", "body", "revisions", "score", "status", "comment", "promote", "moderate", "created", "changed", "users", "votes"); + $fields = array("nid", "uid", "type", "title", "teaser", "body", "revisions", "score", "status", "comment", "promote", "static", "moderate", "created", "changed", "users", "votes"); foreach ($filter as $key => $value) { /* @@ -848,6 +848,7 @@ function node_form($edit) { $output .= form_select(t("Set public/published"), "status", $edit->status, array("Disabled", "Enabled")); $output .= form_select(t("Queue for moderation"), "moderate", $edit->moderate, array("Disabled", "Enabled")); $output .= form_select(t("Promote to front page"), "promote", $edit->promote, array("Disabled", "Enabled")); + $output .= form_select(t("Static on front page"), "static", $edit->static, array("Disabled", "Enabled")); $output .= form_select(t("Allow users comments"), "comment", $edit->comment, array("Disabled", "Enabled")); $output .= form_select(t("Create new revision"), "revision", $edit->revision, array("Disabled", "Enabled")); } @@ -997,7 +998,7 @@ function node_submit($node) { */ if (user_access("administer nodes")) { - $fields = array("nid", "uid", "body", "comment", "created", "promote", "moderate", "revisions", "status", "teaser", "title", "type" => $node->type); + $fields = array("nid", "uid", "body", "comment", "created", "promote", "static", "moderate", "revisions", "status", "teaser", "title", "type" => $node->type); } else { $fields = array("nid", "uid" => ($user->uid ? $user->uid : 0), "body", "teaser", "title", "type" => $node->type); @@ -1166,7 +1167,7 @@ function node_page() { $theme->box($title, node_delete($edit)); break; default: - $result = db_query("SELECT nid, type FROM node WHERE ". ($meta ? "attributes LIKE '%". check_input($meta) ."%' AND " : "") ." promote = '1' AND status = '1' AND created <= '". ($date > 0 ? check_input($date) : time()) ."' ORDER BY created DESC LIMIT ". ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); + $result = db_query("SELECT nid, type FROM node WHERE ". ($meta ? "attributes LIKE '%". check_input($meta) ."%' AND " : "") ." promote = '1' AND status = '1' AND (static = '1' OR created <= '". ($date > 0 ? check_input($date) : time()) ."') ORDER BY static DESC,created DESC LIMIT ". ($user->nodes ? $user->nodes : variable_get("default_nodes_main", 10))); while ($node = db_fetch_object($result)) { node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1); } diff --git a/update.php b/update.php index b053b0578a78..3c1f0c078469 100644 --- a/update.php +++ b/update.php @@ -44,7 +44,8 @@ "2001-12-31" => "update_17", "2002-01-05" => "update_18", "2002-01-17" => "update_19", - "2002-01-27" => "update_20" + "2002-01-27" => "update_20", + "2002-01-30" => "update_21" ); // Update functions @@ -322,6 +323,10 @@ function update_20() { update_sql("INSERT INTO blocks SET name='User information', module='user', delta='0', status='2', weight='0', region='1', remove='0', path='';"); } +function update_21() { + update_sql("ALTER TABLE node ADD static int(2) DEFAULT '0' NOT NULL;"); +} + /* ** System functions */ -- GitLab