summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--admin.php2
-rw-r--r--cron.php2
-rw-r--r--database/database.pgsql1162
-rw-r--r--error.php2
-rw-r--r--includes/comment.inc4
-rw-r--r--includes/common.inc11
-rw-r--r--includes/conf.php6
-rw-r--r--includes/locale.inc2
-rw-r--r--includes/module.inc21
-rw-r--r--includes/node.inc413
-rw-r--r--includes/search.inc2
-rw-r--r--includes/theme.inc2
-rw-r--r--includes/variable.inc2
-rw-r--r--index.php2
-rw-r--r--module.php2
-rw-r--r--modules/aggregator.module2
-rw-r--r--modules/aggregator/aggregator.module2
-rw-r--r--modules/block.module4
-rw-r--r--modules/block/block.module4
-rw-r--r--modules/blog.module282
-rw-r--r--modules/blog/blog.module282
-rw-r--r--modules/book.module211
-rw-r--r--modules/book/book.module211
-rw-r--r--modules/box.module3
-rw-r--r--modules/calendar.module2
-rw-r--r--modules/comment.module6
-rw-r--r--modules/comment/comment.module6
-rw-r--r--modules/cvs.module2
-rw-r--r--modules/forum.module37
-rw-r--r--modules/forum/forum.module37
-rw-r--r--modules/help.module2
-rw-r--r--modules/help/help.module2
-rw-r--r--modules/import.module2
-rw-r--r--modules/locale.module2
-rw-r--r--modules/locale/locale.module2
-rw-r--r--modules/meta.module2
-rw-r--r--modules/node.module668
-rw-r--r--modules/node/node.module668
-rw-r--r--modules/page.module56
-rw-r--r--modules/page/page.module56
-rw-r--r--modules/poll.module8
-rw-r--r--modules/poll/poll.module8
-rw-r--r--modules/queue.module65
-rw-r--r--modules/rating.module10
-rw-r--r--modules/search.module4
-rw-r--r--modules/search/search.module4
-rw-r--r--modules/statistics.module2
-rw-r--r--modules/statistics/statistics.module2
-rw-r--r--modules/story.module104
-rw-r--r--modules/story/story.module104
-rw-r--r--modules/system.module2
-rw-r--r--modules/system/system.module2
-rw-r--r--modules/tracker.module2
-rw-r--r--modules/tracker/tracker.module2
-rw-r--r--modules/user.module70
-rw-r--r--modules/user/user.module70
-rw-r--r--modules/watchdog.module2
-rw-r--r--modules/watchdog/watchdog.module2
-rw-r--r--node.php32
-rw-r--r--themes/example/example.theme2
-rw-r--r--themes/goofy/goofy.theme24
-rw-r--r--themes/marvin/marvin.theme21
-rw-r--r--themes/trillian/trillian.theme11
-rw-r--r--themes/unconed/unconed.theme22
-rw-r--r--updates/3.00-to-x.xx.mysql62
-rw-r--r--updates/3.00-to-x.xx.php33
66 files changed, 1826 insertions, 3030 deletions
diff --git a/admin.php b/admin.php
index 1b5e2111b..3ab5b9375 100644
--- a/admin.php
+++ b/admin.php
@@ -51,5 +51,5 @@ function admin_page($mod) {
if (user_access("access administration pages")) {
admin_page($mod);
}
-
+
?> \ No newline at end of file
diff --git a/cron.php b/cron.php
index 915343dd3..37dd33192 100644
--- a/cron.php
+++ b/cron.php
@@ -18,5 +18,5 @@ if (!get_cfg_var("safe_mode")) {
foreach (module_list() as $module) {
module_invoke($module, "cron");
}
-
+
?> \ No newline at end of file
diff --git a/database/database.pgsql b/database/database.pgsql
index bb8592684..c41d25496 100644
--- a/database/database.pgsql
+++ b/database/database.pgsql
@@ -1,26 +1,36 @@
--
-- Selected TOC Entries:
--
---- \connect - postgres
+\connect - root
+--
+-- TOC Entry ID 1 (OID 0)
+--
+-- Name: drupal Type: DATABASE Owner: root
--
--- TOC Entry ID 174 (OID 18720)
+
+Create Database "drupal";
+
+\connect drupal postgres
+\connect - postgres
+--
+-- TOC Entry ID 92 (OID 18720)
--
-- Name: "plpgsql_call_handler" () Type: FUNCTION Owner: postgres
--
---- CREATE FUNCTION "plpgsql_call_handler" () RETURNS opaque AS '/usr/lib/postgresql/lib/plpgsql.so', 'plpgsql_call_handler' LANGUAGE 'C';
+CREATE FUNCTION "plpgsql_call_handler" () RETURNS opaque AS '/usr/lib/postgresql/lib/plpgsql.so', 'plpgsql_call_handler' LANGUAGE 'C';
--
--- TOC Entry ID 175 (OID 18721)
+-- TOC Entry ID 93 (OID 18721)
--
-- Name: plpgsql Type: PROCEDURAL LANGUAGE Owner:
--
---- CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER "plpgsql_call_handler" LANCOMPILER 'PL/pgSQL';
+CREATE TRUSTED PROCEDURAL LANGUAGE 'plpgsql' HANDLER "plpgsql_call_handler" LANCOMPILER 'PL/pgSQL';
\connect - root
--
--- TOC Entry ID 62 (OID 20075)
+-- TOC Entry ID 27 (OID 46073)
--
-- Name: pga_queries Type: TABLE Owner: root
--
@@ -36,17 +46,7 @@ CREATE TABLE "pga_queries" (
);
--
--- TOC Entry ID 63 (OID 20075)
---
--- Name: pga_queries Type: ACL Owner:
---
-
-REVOKE ALL on "pga_queries" from PUBLIC;
-GRANT ALL on "pga_queries" to PUBLIC;
-GRANT ALL on "pga_queries" to "root";
-
---
--- TOC Entry ID 64 (OID 20106)
+-- TOC Entry ID 28 (OID 46104)
--
-- Name: pga_forms Type: TABLE Owner: root
--
@@ -57,17 +57,7 @@ CREATE TABLE "pga_forms" (
);
--
--- TOC Entry ID 65 (OID 20106)
---
--- Name: pga_forms Type: ACL Owner:
---
-
-REVOKE ALL on "pga_forms" from PUBLIC;
-GRANT ALL on "pga_forms" to PUBLIC;
-GRANT ALL on "pga_forms" to "root";
-
---
--- TOC Entry ID 66 (OID 20132)
+-- TOC Entry ID 29 (OID 46130)
--
-- Name: pga_scripts Type: TABLE Owner: root
--
@@ -78,17 +68,7 @@ CREATE TABLE "pga_scripts" (
);
--
--- TOC Entry ID 67 (OID 20132)
---
--- Name: pga_scripts Type: ACL Owner:
---
-
-REVOKE ALL on "pga_scripts" from PUBLIC;
-GRANT ALL on "pga_scripts" to PUBLIC;
-GRANT ALL on "pga_scripts" to "root";
-
---
--- TOC Entry ID 68 (OID 20158)
+-- TOC Entry ID 30 (OID 46156)
--
-- Name: pga_reports Type: TABLE Owner: root
--
@@ -102,17 +82,7 @@ CREATE TABLE "pga_reports" (
);
--
--- TOC Entry ID 69 (OID 20158)
---
--- Name: pga_reports Type: ACL Owner:
---
-
-REVOKE ALL on "pga_reports" from PUBLIC;
-GRANT ALL on "pga_reports" to PUBLIC;
-GRANT ALL on "pga_reports" to "root";
-
---
--- TOC Entry ID 70 (OID 20187)
+-- TOC Entry ID 31 (OID 46185)
--
-- Name: pga_schema Type: TABLE Owner: root
--
@@ -124,17 +94,7 @@ CREATE TABLE "pga_schema" (
);
--
--- TOC Entry ID 71 (OID 20187)
---
--- Name: pga_schema Type: ACL Owner:
---
-
-REVOKE ALL on "pga_schema" from PUBLIC;
-GRANT ALL on "pga_schema" to PUBLIC;
-GRANT ALL on "pga_schema" to "root";
-
---
--- TOC Entry ID 2 (OID 20214)
+-- TOC Entry ID 2 (OID 46212)
--
-- Name: access_aid_seq Type: SEQUENCE Owner: root
--
@@ -142,17 +102,7 @@ GRANT ALL on "pga_schema" to "root";
CREATE SEQUENCE "access_aid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 3 (OID 20214)
---
--- Name: access_aid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "access_aid_seq" from PUBLIC;
-GRANT ALL on "access_aid_seq" to "root";
-GRANT ALL on "access_aid_seq" to "wallaby";
-
---
--- TOC Entry ID 72 (OID 20233)
+-- TOC Entry ID 32 (OID 46231)
--
-- Name: access Type: TABLE Owner: root
--
@@ -166,76 +116,7 @@ CREATE TABLE "access" (
);
--
--- TOC Entry ID 73 (OID 20233)
---
--- Name: access Type: ACL Owner:
---
-
-REVOKE ALL on "access" from PUBLIC;
-GRANT ALL on "access" to "root";
-GRANT ALL on "access" to "wallaby";
-
---
--- TOC Entry ID 4 (OID 20269)
---
--- Name: blog_lid_seq Type: SEQUENCE Owner: root
---
-
-CREATE SEQUENCE "blog_lid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
-
---
--- TOC Entry ID 5 (OID 20269)
---
--- Name: blog_lid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "blog_lid_seq" from PUBLIC;
-GRANT ALL on "blog_lid_seq" to "root";
-GRANT ALL on "blog_lid_seq" to "wallaby";
-
---
--- TOC Entry ID 74 (OID 20288)
---
--- Name: blog Type: TABLE Owner: root
---
-
-CREATE TABLE "blog" (
- "lid" integer DEFAULT nextval('"blog_lid_seq"'::text) NOT NULL,
- "nid" integer NOT NULL,
- "body" text NOT NULL,
- Constraint "blog_pkey" Primary Key ("lid")
-);
-
---
--- TOC Entry ID 75 (OID 20288)
---
--- Name: blog Type: ACL Owner:
---
-
-REVOKE ALL on "blog" from PUBLIC;
-GRANT ALL on "blog" to "root";
-GRANT ALL on "blog" to "wallaby";
-
---
--- TOC Entry ID 6 (OID 20319)
---
--- Name: book_lid_seq Type: SEQUENCE Owner: root
---
-
-CREATE SEQUENCE "book_lid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
-
---
--- TOC Entry ID 7 (OID 20319)
---
--- Name: book_lid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "book_lid_seq" from PUBLIC;
-GRANT ALL on "book_lid_seq" to "root";
-GRANT ALL on "book_lid_seq" to "wallaby";
-
---
--- TOC Entry ID 8 (OID 20374)
+-- TOC Entry ID 3 (OID 46317)
--
-- Name: boxes_bid_seq Type: SEQUENCE Owner: root
--
@@ -243,17 +124,7 @@ GRANT ALL on "book_lid_seq" to "wallaby";
CREATE SEQUENCE "boxes_bid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 9 (OID 20374)
---
--- Name: boxes_bid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "boxes_bid_seq" from PUBLIC;
-GRANT ALL on "boxes_bid_seq" to "root";
-GRANT ALL on "boxes_bid_seq" to "wallaby";
-
---
--- TOC Entry ID 76 (OID 20393)
+-- TOC Entry ID 33 (OID 46336)
--
-- Name: boxes Type: TABLE Owner: root
--
@@ -268,17 +139,7 @@ CREATE TABLE "boxes" (
);
--
--- TOC Entry ID 77 (OID 20393)
---
--- Name: boxes Type: ACL Owner:
---
-
-REVOKE ALL on "boxes" from PUBLIC;
-GRANT ALL on "boxes" to "root";
-GRANT ALL on "boxes" to "wallaby";
-
---
--- TOC Entry ID 10 (OID 20435)
+-- TOC Entry ID 4 (OID 46369)
--
-- Name: bundle_bid_seq Type: SEQUENCE Owner: root
--
@@ -286,17 +147,7 @@ GRANT ALL on "boxes" to "wallaby";
CREATE SEQUENCE "bundle_bid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 11 (OID 20435)
---
--- Name: bundle_bid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "bundle_bid_seq" from PUBLIC;
-GRANT ALL on "bundle_bid_seq" to "root";
-GRANT ALL on "bundle_bid_seq" to "wallaby";
-
---
--- TOC Entry ID 78 (OID 20454)
+-- TOC Entry ID 34 (OID 46388)
--
-- Name: bundle Type: TABLE Owner: root
--
@@ -309,17 +160,7 @@ CREATE TABLE "bundle" (
);
--
--- TOC Entry ID 79 (OID 20454)
---
--- Name: bundle Type: ACL Owner:
---
-
-REVOKE ALL on "bundle" from PUBLIC;
-GRANT ALL on "bundle" to "root";
-GRANT ALL on "bundle" to "wallaby";
-
---
--- TOC Entry ID 80 (OID 20470)
+-- TOC Entry ID 35 (OID 46404)
--
-- Name: cache Type: TABLE Owner: root
--
@@ -332,17 +173,7 @@ CREATE TABLE "cache" (
);
--
--- TOC Entry ID 81 (OID 20470)
---
--- Name: cache Type: ACL Owner:
---
-
-REVOKE ALL on "cache" from PUBLIC;
-GRANT ALL on "cache" to "root";
-GRANT ALL on "cache" to "wallaby";
-
---
--- TOC Entry ID 12 (OID 20500)
+-- TOC Entry ID 5 (OID 46434)
--
-- Name: category_cid_seq Type: SEQUENCE Owner: root
--
@@ -350,17 +181,7 @@ GRANT ALL on "cache" to "wallaby";
CREATE SEQUENCE "category_cid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 13 (OID 20500)
---
--- Name: category_cid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "category_cid_seq" from PUBLIC;
-GRANT ALL on "category_cid_seq" to "root";
-GRANT ALL on "category_cid_seq" to "wallaby";
-
---
--- TOC Entry ID 82 (OID 20519)
+-- TOC Entry ID 36 (OID 46453)
--
-- Name: category Type: TABLE Owner: root
--
@@ -379,17 +200,7 @@ CREATE TABLE "category" (
);
--
--- TOC Entry ID 83 (OID 20519)
---
--- Name: category Type: ACL Owner:
---
-
-REVOKE ALL on "category" from PUBLIC;
-GRANT ALL on "category" to "root";
-GRANT ALL on "category" to "wallaby";
-
---
--- TOC Entry ID 14 (OID 20544)
+-- TOC Entry ID 6 (OID 46475)
--
-- Name: channel_id_seq Type: SEQUENCE Owner: root
--
@@ -397,17 +208,7 @@ GRANT ALL on "category" to "wallaby";
CREATE SEQUENCE "channel_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 15 (OID 20544)
---
--- Name: channel_id_seq Type: ACL Owner:
---
-
-REVOKE ALL on "channel_id_seq" from PUBLIC;
-GRANT ALL on "channel_id_seq" to "root";
-GRANT ALL on "channel_id_seq" to "wallaby";
-
---
--- TOC Entry ID 84 (OID 20563)
+-- TOC Entry ID 37 (OID 46494)
--
-- Name: channel Type: TABLE Owner: root
--
@@ -423,17 +224,7 @@ CREATE TABLE "channel" (
);
--
--- TOC Entry ID 85 (OID 20563)
---
--- Name: channel Type: ACL Owner:
---
-
-REVOKE ALL on "channel" from PUBLIC;
-GRANT ALL on "channel" to "root";
-GRANT ALL on "channel" to "wallaby";
-
---
--- TOC Entry ID 16 (OID 20591)
+-- TOC Entry ID 7 (OID 46513)
--
-- Name: chatevents_id_seq Type: SEQUENCE Owner: root
--
@@ -441,17 +232,7 @@ GRANT ALL on "channel" to "wallaby";
CREATE SEQUENCE "chatevents_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 17 (OID 20591)
---
--- Name: chatevents_id_seq Type: ACL Owner:
---
-
-REVOKE ALL on "chatevents_id_seq" from PUBLIC;
-GRANT ALL on "chatevents_id_seq" to "root";
-GRANT ALL on "chatevents_id_seq" to "wallaby";
-
---
--- TOC Entry ID 86 (OID 20610)
+-- TOC Entry ID 38 (OID 46532)
--
-- Name: chatevents Type: TABLE Owner: root
--
@@ -464,17 +245,7 @@ CREATE TABLE "chatevents" (
);
--
--- TOC Entry ID 87 (OID 20610)
---
--- Name: chatevents Type: ACL Owner:
---
-
-REVOKE ALL on "chatevents" from PUBLIC;
-GRANT ALL on "chatevents" to "root";
-GRANT ALL on "chatevents" to "wallaby";
-
---
--- TOC Entry ID 18 (OID 20626)
+-- TOC Entry ID 8 (OID 46548)
--
-- Name: chatmembers_id_seq Type: SEQUENCE Owner: root
--
@@ -482,17 +253,7 @@ GRANT ALL on "chatevents" to "wallaby";
CREATE SEQUENCE "chatmembers_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 19 (OID 20626)
---
--- Name: chatmembers_id_seq Type: ACL Owner:
---
-
-REVOKE ALL on "chatmembers_id_seq" from PUBLIC;
-GRANT ALL on "chatmembers_id_seq" to "root";
-GRANT ALL on "chatmembers_id_seq" to "wallaby";
-
---
--- TOC Entry ID 88 (OID 20645)
+-- TOC Entry ID 39 (OID 46567)
--
-- Name: chatmembers Type: TABLE Owner: root
--
@@ -505,17 +266,7 @@ CREATE TABLE "chatmembers" (
);
--
--- TOC Entry ID 89 (OID 20645)
---
--- Name: chatmembers Type: ACL Owner:
---
-
-REVOKE ALL on "chatmembers" from PUBLIC;
-GRANT ALL on "chatmembers" to "root";
-GRANT ALL on "chatmembers" to "wallaby";
-
---
--- TOC Entry ID 20 (OID 20680)
+-- TOC Entry ID 9 (OID 46583)
--
-- Name: collection_cid_seq Type: SEQUENCE Owner: root
--
@@ -523,17 +274,7 @@ GRANT ALL on "chatmembers" to "wallaby";
CREATE SEQUENCE "collection_cid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 21 (OID 20680)
---
--- Name: collection_cid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "collection_cid_seq" from PUBLIC;
-GRANT ALL on "collection_cid_seq" to "root";
-GRANT ALL on "collection_cid_seq" to "wallaby";
-
---
--- TOC Entry ID 90 (OID 20699)
+-- TOC Entry ID 40 (OID 46602)
--
-- Name: collection Type: TABLE Owner: root
--
@@ -546,17 +287,7 @@ CREATE TABLE "collection" (
);
--
--- TOC Entry ID 91 (OID 20699)
---
--- Name: collection Type: ACL Owner:
---
-
-REVOKE ALL on "collection" from PUBLIC;
-GRANT ALL on "collection" to "root";
-GRANT ALL on "collection" to "wallaby";
-
---
--- TOC Entry ID 22 (OID 20718)
+-- TOC Entry ID 10 (OID 46618)
--
-- Name: comments_cid_seq Type: SEQUENCE Owner: root
--
@@ -564,17 +295,7 @@ GRANT ALL on "collection" to "wallaby";
CREATE SEQUENCE "comments_cid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 23 (OID 20718)
---
--- Name: comments_cid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "comments_cid_seq" from PUBLIC;
-GRANT ALL on "comments_cid_seq" to "root";
-GRANT ALL on "comments_cid_seq" to "wallaby";
-
---
--- TOC Entry ID 92 (OID 20780)
+-- TOC Entry ID 41 (OID 46637)
--
-- Name: cvs Type: TABLE Owner: root
--
@@ -588,40 +309,7 @@ CREATE TABLE "cvs" (
);
--
--- TOC Entry ID 93 (OID 20780)
---
--- Name: cvs Type: ACL Owner:
---
-
-REVOKE ALL on "cvs" from PUBLIC;
-GRANT ALL on "cvs" to "root";
-GRANT ALL on "cvs" to "wallaby";
-
---
--- TOC Entry ID 94 (OID 20828)
---
--- Name: diaries Type: TABLE Owner: root
---
-
-CREATE TABLE "diaries" (
- "id" integer DEFAULT nextval('"diary_id_seq"'::text) NOT NULL,
- "author" integer NOT NULL,
- "text" text NOT NULL,
- "timestamp" text NOT NULL
-);
-
---
--- TOC Entry ID 95 (OID 20828)
---
--- Name: diaries Type: ACL Owner:
---
-
-REVOKE ALL on "diaries" from PUBLIC;
-GRANT ALL on "diaries" to "root";
-GRANT ALL on "diaries" to "wallaby";
-
---
--- TOC Entry ID 96 (OID 20860)
+-- TOC Entry ID 42 (OID 46695)
--
-- Name: pga_layout Type: TABLE Owner: root
--
@@ -634,58 +322,7 @@ CREATE TABLE "pga_layout" (
);
--
--- TOC Entry ID 97 (OID 20860)
---
--- Name: pga_layout Type: ACL Owner:
---
-
-REVOKE ALL on "pga_layout" from PUBLIC;
-GRANT ALL on "pga_layout" to PUBLIC;
-GRANT ALL on "pga_layout" to "root";
-
---
--- TOC Entry ID 24 (OID 21124)
---
--- Name: diary_lid_seq Type: SEQUENCE Owner: root
---
-
-CREATE SEQUENCE "diary_lid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
-
---
--- TOC Entry ID 25 (OID 21124)
---
--- Name: diary_lid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "diary_lid_seq" from PUBLIC;
-GRANT ALL on "diary_lid_seq" to "root";
-GRANT ALL on "diary_lid_seq" to "wallaby";
-
---
--- TOC Entry ID 98 (OID 21143)
---
--- Name: diary Type: TABLE Owner: root
---
-
-CREATE TABLE "diary" (
- "lid" integer DEFAULT nextval('"diary_lid_seq"'::text) NOT NULL,
- "nid" integer NOT NULL,
- "body" text NOT NULL,
- Constraint "diary_pkey" Primary Key ("lid")
-);
-
---
--- TOC Entry ID 99 (OID 21143)
---
--- Name: diary Type: ACL Owner:
---
-
-REVOKE ALL on "diary" from PUBLIC;
-GRANT ALL on "diary" to "root";
-GRANT ALL on "diary" to "wallaby";
-
---
--- TOC Entry ID 26 (OID 21174)
+-- TOC Entry ID 11 (OID 46773)
--
-- Name: entry_eid_seq Type: SEQUENCE Owner: root
--
@@ -693,17 +330,7 @@ GRANT ALL on "diary" to "wallaby";
CREATE SEQUENCE "entry_eid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 27 (OID 21174)
---
--- Name: entry_eid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "entry_eid_seq" from PUBLIC;
-GRANT ALL on "entry_eid_seq" to "root";
-GRANT ALL on "entry_eid_seq" to "wallaby";
-
---
--- TOC Entry ID 100 (OID 21193)
+-- TOC Entry ID 43 (OID 46792)
--
-- Name: entry Type: TABLE Owner: root
--
@@ -717,17 +344,7 @@ CREATE TABLE "entry" (
);
--
--- TOC Entry ID 101 (OID 21193)
---
--- Name: entry Type: ACL Owner:
---
-
-REVOKE ALL on "entry" from PUBLIC;
-GRANT ALL on "entry" to "root";
-GRANT ALL on "entry" to "wallaby";
-
---
--- TOC Entry ID 28 (OID 21225)
+-- TOC Entry ID 12 (OID 46824)
--
-- Name: feed_fid_seq Type: SEQUENCE Owner: root
--
@@ -735,17 +352,7 @@ GRANT ALL on "entry" to "wallaby";
CREATE SEQUENCE "feed_fid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 29 (OID 21225)
---
--- Name: feed_fid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "feed_fid_seq" from PUBLIC;
-GRANT ALL on "feed_fid_seq" to "root";
-GRANT ALL on "feed_fid_seq" to "wallaby";
-
---
--- TOC Entry ID 102 (OID 21244)
+-- TOC Entry ID 44 (OID 46843)
--
-- Name: feed Type: TABLE Owner: root
--
@@ -764,17 +371,7 @@ CREATE TABLE "feed" (
);
--
--- TOC Entry ID 103 (OID 21244)
---
--- Name: feed Type: ACL Owner:
---
-
-REVOKE ALL on "feed" from PUBLIC;
-GRANT ALL on "feed" to "root";
-GRANT ALL on "feed" to "wallaby";
-
---
--- TOC Entry ID 30 (OID 21287)
+-- TOC Entry ID 13 (OID 46880)
--
-- Name: file_lid_seq Type: SEQUENCE Owner: root
--
@@ -782,17 +379,7 @@ GRANT ALL on "feed" to "wallaby";
CREATE SEQUENCE "file_lid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 31 (OID 21287)
---
--- Name: file_lid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "file_lid_seq" from PUBLIC;
-GRANT ALL on "file_lid_seq" to "root";
-GRANT ALL on "file_lid_seq" to "wallaby";
-
---
--- TOC Entry ID 104 (OID 21306)
+-- TOC Entry ID 45 (OID 46899)
--
-- Name: file Type: TABLE Owner: root
--
@@ -810,17 +397,7 @@ CREATE TABLE "file" (
);
--
--- TOC Entry ID 105 (OID 21306)
---
--- Name: file Type: ACL Owner:
---
-
-REVOKE ALL on "file" from PUBLIC;
-GRANT ALL on "file" to "root";
-GRANT ALL on "file" to "wallaby";
-
---
--- TOC Entry ID 32 (OID 21342)
+-- TOC Entry ID 14 (OID 46935)
--
-- Name: forum_lid_seq Type: SEQUENCE Owner: root
--
@@ -828,40 +405,7 @@ GRANT ALL on "file" to "wallaby";
CREATE SEQUENCE "forum_lid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 33 (OID 21342)
---
--- Name: forum_lid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "forum_lid_seq" from PUBLIC;
-GRANT ALL on "forum_lid_seq" to "root";
-GRANT ALL on "forum_lid_seq" to "wallaby";
-
---
--- TOC Entry ID 106 (OID 21361)
---
--- Name: forum Type: TABLE Owner: root
---
-
-CREATE TABLE "forum" (
- "lid" integer DEFAULT nextval('"forum_lid_seq"'::text) NOT NULL,
- "nid" integer NOT NULL,
- "body" text NOT NULL,
- Constraint "forum_pkey" Primary Key ("lid")
-);
-
---
--- TOC Entry ID 107 (OID 21361)
---
--- Name: forum Type: ACL Owner:
---
-
-REVOKE ALL on "forum" from PUBLIC;
-GRANT ALL on "forum" to "root";
-GRANT ALL on "forum" to "wallaby";
-
---
--- TOC Entry ID 34 (OID 21392)
+-- TOC Entry ID 15 (OID 46985)
--
-- Name: item_iid_seq Type: SEQUENCE Owner: root
--
@@ -869,17 +413,7 @@ GRANT ALL on "forum" to "wallaby";
CREATE SEQUENCE "item_iid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 35 (OID 21392)
---
--- Name: item_iid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "item_iid_seq" from PUBLIC;
-GRANT ALL on "item_iid_seq" to "root";
-GRANT ALL on "item_iid_seq" to "wallaby";
-
---
--- TOC Entry ID 108 (OID 21411)
+-- TOC Entry ID 46 (OID 47004)
--
-- Name: item Type: TABLE Owner: root
--
@@ -897,17 +431,7 @@ CREATE TABLE "item" (
);
--
--- TOC Entry ID 109 (OID 21411)
---
--- Name: item Type: ACL Owner:
---
-
-REVOKE ALL on "item" from PUBLIC;
-GRANT ALL on "item" to "root";
-GRANT ALL on "item" to "wallaby";
-
---
--- TOC Entry ID 110 (OID 21447)
+-- TOC Entry ID 47 (OID 47040)
--
-- Name: layout Type: TABLE Owner: root
--
@@ -918,17 +442,7 @@ CREATE TABLE "layout" (
);
--
--- TOC Entry ID 111 (OID 21447)
---
--- Name: layout Type: ACL Owner:
---
-
-REVOKE ALL on "layout" from PUBLIC;
-GRANT ALL on "layout" to "root";
-GRANT ALL on "layout" to "wallaby";
-
---
--- TOC Entry ID 36 (OID 21458)
+-- TOC Entry ID 16 (OID 47051)
--
-- Name: locales_id_seq Type: SEQUENCE Owner: root
--
@@ -936,17 +450,7 @@ GRANT ALL on "layout" to "wallaby";
CREATE SEQUENCE "locales_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 37 (OID 21458)
---
--- Name: locales_id_seq Type: ACL Owner:
---
-
-REVOKE ALL on "locales_id_seq" from PUBLIC;
-GRANT ALL on "locales_id_seq" to "root";
-GRANT ALL on "locales_id_seq" to "wallaby";
-
---
--- TOC Entry ID 112 (OID 21477)
+-- TOC Entry ID 48 (OID 47070)
--
-- Name: locales Type: TABLE Owner: root
--
@@ -967,17 +471,7 @@ CREATE TABLE "locales" (
);
--
--- TOC Entry ID 113 (OID 21477)
---
--- Name: locales Type: ACL Owner:
---
-
-REVOKE ALL on "locales" from PUBLIC;
-GRANT ALL on "locales" to "root";
-GRANT ALL on "locales" to "wallaby";
-
---
--- TOC Entry ID 114 (OID 21516)
+-- TOC Entry ID 49 (OID 47109)
--
-- Name: modules Type: TABLE Owner: root
--
@@ -988,17 +482,7 @@ CREATE TABLE "modules" (
);
--
--- TOC Entry ID 115 (OID 21516)
---
--- Name: modules Type: ACL Owner:
---
-
-REVOKE ALL on "modules" from PUBLIC;
-GRANT ALL on "modules" to "root";
-GRANT ALL on "modules" to "wallaby";
-
---
--- TOC Entry ID 38 (OID 21529)
+-- TOC Entry ID 17 (OID 47122)
--
-- Name: node_nid_seq Type: SEQUENCE Owner: root
--
@@ -1006,17 +490,7 @@ GRANT ALL on "modules" to "wallaby";
CREATE SEQUENCE "node_nid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 39 (OID 21529)
---
--- Name: node_nid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "node_nid_seq" from PUBLIC;
-GRANT ALL on "node_nid_seq" to "root";
-GRANT ALL on "node_nid_seq" to "wallaby";
-
---
--- TOC Entry ID 116 (OID 22296)
+-- TOC Entry ID 50 (OID 47141)
--
-- Name: notify Type: TABLE Owner: root
--
@@ -1031,60 +505,7 @@ CREATE TABLE "notify" (
);
--
--- TOC Entry ID 117 (OID 22296)
---
--- Name: notify Type: ACL Owner:
---
-
-REVOKE ALL on "notify" from PUBLIC;
-GRANT ALL on "notify" to "root";
-GRANT ALL on "notify" to "wallaby";
-
---
--- TOC Entry ID 40 (OID 22313)
---
--- Name: page_lid_seq Type: SEQUENCE Owner: root
---
-
-CREATE SEQUENCE "page_lid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
-
---
--- TOC Entry ID 41 (OID 22313)
---
--- Name: page_lid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "page_lid_seq" from PUBLIC;
-GRANT ALL on "page_lid_seq" to "root";
-GRANT ALL on "page_lid_seq" to "wallaby";
-
---
--- TOC Entry ID 118 (OID 22332)
---
--- Name: page Type: TABLE Owner: root
---
-
-CREATE TABLE "page" (
- "lid" integer DEFAULT nextval('"page_lid_seq"'::text) NOT NULL,
- "nid" integer NOT NULL,
- "link" character varying(128) DEFAULT '' NOT NULL,
- "body" text NOT NULL,
- "format" integer NOT NULL,
- Constraint "page_pkey" Primary Key ("lid")
-);
-
---
--- TOC Entry ID 119 (OID 22332)
---
--- Name: page Type: ACL Owner:
---
-
-REVOKE ALL on "page" from PUBLIC;
-GRANT ALL on "page" to "root";
-GRANT ALL on "page" to "wallaby";
-
---
--- TOC Entry ID 42 (OID 22366)
+-- TOC Entry ID 18 (OID 47211)
--
-- Name: poll_lid_seq Type: SEQUENCE Owner: root
--
@@ -1092,17 +513,7 @@ GRANT ALL on "page" to "wallaby";
CREATE SEQUENCE "poll_lid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 43 (OID 22366)
---
--- Name: poll_lid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "poll_lid_seq" from PUBLIC;
-GRANT ALL on "poll_lid_seq" to "root";
-GRANT ALL on "poll_lid_seq" to "wallaby";
-
---
--- TOC Entry ID 120 (OID 22385)
+-- TOC Entry ID 51 (OID 47230)
--
-- Name: poll Type: TABLE Owner: root
--
@@ -1117,17 +528,7 @@ CREATE TABLE "poll" (
);
--
--- TOC Entry ID 121 (OID 22385)
---
--- Name: poll Type: ACL Owner:
---
-
-REVOKE ALL on "poll" from PUBLIC;
-GRANT ALL on "poll" to "root";
-GRANT ALL on "poll" to "wallaby";
-
---
--- TOC Entry ID 44 (OID 22418)
+-- TOC Entry ID 19 (OID 47263)
--
-- Name: poll_choices_chid_seq Type: SEQUENCE Owner: root
--
@@ -1135,17 +536,7 @@ GRANT ALL on "poll" to "wallaby";
CREATE SEQUENCE "poll_choices_chid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 45 (OID 22418)
---
--- Name: poll_choices_chid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "poll_choices_chid_seq" from PUBLIC;
-GRANT ALL on "poll_choices_chid_seq" to "root";
-GRANT ALL on "poll_choices_chid_seq" to "wallaby";
-
---
--- TOC Entry ID 122 (OID 22437)
+-- TOC Entry ID 52 (OID 47282)
--
-- Name: poll_choices Type: TABLE Owner: root
--
@@ -1160,17 +551,7 @@ CREATE TABLE "poll_choices" (
);
--
--- TOC Entry ID 123 (OID 22437)
---
--- Name: poll_choices Type: ACL Owner:
---
-
-REVOKE ALL on "poll_choices" from PUBLIC;
-GRANT ALL on "poll_choices" to "root";
-GRANT ALL on "poll_choices" to "wallaby";
-
---
--- TOC Entry ID 124 (OID 22456)
+-- TOC Entry ID 53 (OID 47301)
--
-- Name: rating Type: TABLE Owner: root
--
@@ -1183,17 +564,7 @@ CREATE TABLE "rating" (
);
--
--- TOC Entry ID 125 (OID 22456)
---
--- Name: rating Type: ACL Owner:
---
-
-REVOKE ALL on "rating" from PUBLIC;
-GRANT ALL on "rating" to "root";
-GRANT ALL on "rating" to "wallaby";
-
---
--- TOC Entry ID 126 (OID 22471)
+-- TOC Entry ID 54 (OID 47316)
--
-- Name: referer Type: TABLE Owner: root
--
@@ -1204,17 +575,7 @@ CREATE TABLE "referer" (
);
--
--- TOC Entry ID 127 (OID 22471)
---
--- Name: referer Type: ACL Owner:
---
-
-REVOKE ALL on "referer" from PUBLIC;
-GRANT ALL on "referer" to "root";
-GRANT ALL on "referer" to "wallaby";
-
---
--- TOC Entry ID 46 (OID 22483)
+-- TOC Entry ID 20 (OID 47328)
--
-- Name: role_rid_seq Type: SEQUENCE Owner: root
--
@@ -1222,17 +583,7 @@ GRANT ALL on "referer" to "wallaby";
CREATE SEQUENCE "role_rid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 47 (OID 22483)
---
--- Name: role_rid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "role_rid_seq" from PUBLIC;
-GRANT ALL on "role_rid_seq" to "root";
-GRANT ALL on "role_rid_seq" to "wallaby";
-
---
--- TOC Entry ID 48 (OID 22534)
+-- TOC Entry ID 21 (OID 47347)
--
-- Name: site_sid_seq Type: SEQUENCE Owner: root
--
@@ -1240,17 +591,7 @@ GRANT ALL on "role_rid_seq" to "wallaby";
CREATE SEQUENCE "site_sid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 49 (OID 22534)
---
--- Name: site_sid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "site_sid_seq" from PUBLIC;
-GRANT ALL on "site_sid_seq" to "root";
-GRANT ALL on "site_sid_seq" to "wallaby";
-
---
--- TOC Entry ID 128 (OID 22553)
+-- TOC Entry ID 55 (OID 47366)
--
-- Name: site Type: TABLE Owner: root
--
@@ -1266,59 +607,7 @@ CREATE TABLE "site" (
);
--
--- TOC Entry ID 129 (OID 22553)
---
--- Name: site Type: ACL Owner:
---
-
-REVOKE ALL on "site" from PUBLIC;
-GRANT ALL on "site" to "root";
-GRANT ALL on "site" to "wallaby";
-
---
--- TOC Entry ID 50 (OID 22590)
---
--- Name: story_lid_seq Type: SEQUENCE Owner: root
---
-
-CREATE SEQUENCE "story_lid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
-
---
--- TOC Entry ID 51 (OID 22590)
---
--- Name: story_lid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "story_lid_seq" from PUBLIC;
-GRANT ALL on "story_lid_seq" to "root";
-GRANT ALL on "story_lid_seq" to "wallaby";
-
---
--- TOC Entry ID 130 (OID 22609)
---
--- Name: story Type: TABLE Owner: root
---
-
-CREATE TABLE "story" (
- "lid" integer DEFAULT nextval('"story_lid_seq"'::text) NOT NULL,
- "nid" integer NOT NULL,
- "abstract" text NOT NULL,
- "body" text NOT NULL,
- Constraint "story_pkey" Primary Key ("lid")
-);
-
---
--- TOC Entry ID 131 (OID 22609)
---
--- Name: story Type: ACL Owner:
---
-
-REVOKE ALL on "story" from PUBLIC;
-GRANT ALL on "story" to "root";
-GRANT ALL on "story" to "wallaby";
-
---
--- TOC Entry ID 52 (OID 22641)
+-- TOC Entry ID 22 (OID 47454)
--
-- Name: tag_tid_seq Type: SEQUENCE Owner: root
--
@@ -1326,17 +615,7 @@ GRANT ALL on "story" to "wallaby";
CREATE SEQUENCE "tag_tid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 53 (OID 22641)
---
--- Name: tag_tid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "tag_tid_seq" from PUBLIC;
-GRANT ALL on "tag_tid_seq" to "root";
-GRANT ALL on "tag_tid_seq" to "wallaby";
-
---
--- TOC Entry ID 132 (OID 22660)
+-- TOC Entry ID 56 (OID 47473)
--
-- Name: tag Type: TABLE Owner: root
--
@@ -1350,17 +629,7 @@ CREATE TABLE "tag" (
);
--
--- TOC Entry ID 133 (OID 22660)
---
--- Name: tag Type: ACL Owner:
---
-
-REVOKE ALL on "tag" from PUBLIC;
-GRANT ALL on "tag" to "root";
-GRANT ALL on "tag" to "wallaby";
-
---
--- TOC Entry ID 54 (OID 22680)
+-- TOC Entry ID 23 (OID 47493)
--
-- Name: topic_tid_seq Type: SEQUENCE Owner: root
--
@@ -1368,17 +637,7 @@ GRANT ALL on "tag" to "wallaby";
CREATE SEQUENCE "topic_tid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 55 (OID 22680)
---
--- Name: topic_tid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "topic_tid_seq" from PUBLIC;
-GRANT ALL on "topic_tid_seq" to "root";
-GRANT ALL on "topic_tid_seq" to "wallaby";
-
---
--- TOC Entry ID 134 (OID 22699)
+-- TOC Entry ID 57 (OID 47512)
--
-- Name: topic Type: TABLE Owner: root
--
@@ -1392,17 +651,7 @@ CREATE TABLE "topic" (
);
--
--- TOC Entry ID 135 (OID 22699)
---
--- Name: topic Type: ACL Owner:
---
-
-REVOKE ALL on "topic" from PUBLIC;
-GRANT ALL on "topic" to "root";
-GRANT ALL on "topic" to "wallaby";
-
---
--- TOC Entry ID 56 (OID 22732)
+-- TOC Entry ID 24 (OID 47545)
--
-- Name: trip_link_lid_seq Type: SEQUENCE Owner: root
--
@@ -1410,17 +659,7 @@ GRANT ALL on "topic" to "wallaby";
CREATE SEQUENCE "trip_link_lid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 57 (OID 22732)
---
--- Name: trip_link_lid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "trip_link_lid_seq" from PUBLIC;
-GRANT ALL on "trip_link_lid_seq" to "root";
-GRANT ALL on "trip_link_lid_seq" to "wallaby";
-
---
--- TOC Entry ID 136 (OID 22751)
+-- TOC Entry ID 58 (OID 47564)
--
-- Name: trip_link Type: TABLE Owner: root
--
@@ -1434,17 +673,7 @@ CREATE TABLE "trip_link" (
);
--
--- TOC Entry ID 137 (OID 22751)
---
--- Name: trip_link Type: ACL Owner:
---
-
-REVOKE ALL on "trip_link" from PUBLIC;
-GRANT ALL on "trip_link" to "root";
-GRANT ALL on "trip_link" to "wallaby";
-
---
--- TOC Entry ID 58 (OID 22783)
+-- TOC Entry ID 25 (OID 47596)
--
-- Name: users_uid_seq Type: SEQUENCE Owner: root
--
@@ -1452,17 +681,7 @@ GRANT ALL on "trip_link" to "wallaby";
CREATE SEQUENCE "users_uid_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 59 (OID 22783)
---
--- Name: users_uid_seq Type: ACL Owner:
---
-
-REVOKE ALL on "users_uid_seq" from PUBLIC;
-GRANT ALL on "users_uid_seq" to "root";
-GRANT ALL on "users_uid_seq" to "wallaby";
-
---
--- TOC Entry ID 138 (OID 22855)
+-- TOC Entry ID 59 (OID 47615)
--
-- Name: variable Type: TABLE Owner: root
--
@@ -1474,17 +693,7 @@ CREATE TABLE "variable" (
);
--
--- TOC Entry ID 139 (OID 22855)
---
--- Name: variable Type: ACL Owner:
---
-
-REVOKE ALL on "variable" from PUBLIC;
-GRANT ALL on "variable" to "root";
-GRANT ALL on "variable" to "wallaby";
-
---
--- TOC Entry ID 60 (OID 22885)
+-- TOC Entry ID 26 (OID 47645)
--
-- Name: watchdog_id_seq Type: SEQUENCE Owner: root
--
@@ -1492,24 +701,14 @@ GRANT ALL on "variable" to "wallaby";
CREATE SEQUENCE "watchdog_id_seq" start 1 increment 1 maxvalue 2147483647 minvalue 1 cache 1 ;
--
--- TOC Entry ID 61 (OID 22885)
---
--- Name: watchdog_id_seq Type: ACL Owner:
---
-
-REVOKE ALL on "watchdog_id_seq" from PUBLIC;
-GRANT ALL on "watchdog_id_seq" to "root";
-GRANT ALL on "watchdog_id_seq" to "wallaby";
-
---
--- TOC Entry ID 140 (OID 22904)
+-- TOC Entry ID 60 (OID 47664)
--
-- Name: watchdog Type: TABLE Owner: root
--
CREATE TABLE "watchdog" (
"id" integer DEFAULT nextval('"watchdog_id_seq"'::text) NOT NULL,
- "userid" integer NOT NULL,
+ "uid" integer NOT NULL,
"type" character varying(16) DEFAULT '' NOT NULL,
"message" character varying(255) DEFAULT '' NOT NULL,
"location" character varying(128) DEFAULT '' NOT NULL,
@@ -1519,17 +718,7 @@ CREATE TABLE "watchdog" (
);
--
--- TOC Entry ID 141 (OID 22904)
---
--- Name: watchdog Type: ACL Owner:
---
-
-REVOKE ALL on "watchdog" from PUBLIC;
-GRANT ALL on "watchdog" to "root";
-GRANT ALL on "watchdog" to "wallaby";
-
---
--- TOC Entry ID 142 (OID 23291)
+-- TOC Entry ID 61 (OID 47688)
--
-- Name: users Type: TABLE Owner: root
--
@@ -1563,17 +752,7 @@ CREATE TABLE "users" (
);
--
--- TOC Entry ID 143 (OID 23291)
---
--- Name: users Type: ACL Owner:
---
-
-REVOKE ALL on "users" from PUBLIC;
-GRANT ALL on "users" to "root";
-GRANT ALL on "users" to "wallaby";
-
---
--- TOC Entry ID 144 (OID 23453)
+-- TOC Entry ID 62 (OID 47739)
--
-- Name: blocks Type: TABLE Owner: root
--
@@ -1590,17 +769,7 @@ CREATE TABLE "blocks" (
);
--
--- TOC Entry ID 145 (OID 23453)
---
--- Name: blocks Type: ACL Owner:
---
-
-REVOKE ALL on "blocks" from PUBLIC;
-GRANT ALL on "blocks" to "root";
-GRANT ALL on "blocks" to "wallaby";
-
---
--- TOC Entry ID 146 (OID 23732)
+-- TOC Entry ID 63 (OID 47758)
--
-- Name: role Type: TABLE Owner: root
--
@@ -1613,17 +782,7 @@ CREATE TABLE "role" (
);
--
--- TOC Entry ID 147 (OID 23732)
---
--- Name: role Type: ACL Owner:
---
-
-REVOKE ALL on "role" from PUBLIC;
-GRANT ALL on "role" to "root";
-GRANT ALL on "role" to "wallaby";
-
---
--- TOC Entry ID 148 (OID 23996)
+-- TOC Entry ID 64 (OID 47790)
--
-- Name: node Type: TABLE Owner: root
--
@@ -1634,7 +793,7 @@ CREATE TABLE "node" (
"type" character varying(16) NOT NULL,
"score" integer NOT NULL,
"votes" integer NOT NULL,
- "author" integer NOT NULL,
+ "uid" integer NOT NULL,
"status" integer NOT NULL,
"timestamp" integer NOT NULL,
"comment" smallint NOT NULL,
@@ -1650,98 +809,103 @@ CREATE TABLE "node" (
);
--
--- TOC Entry ID 149 (OID 23996)
+-- TOC Entry ID 65 (OID 47871)
--
--- Name: node Type: ACL Owner:
+-- Name: moderate Type: TABLE Owner: root
--
-REVOKE ALL on "node" from PUBLIC;
-GRANT ALL on "node" to "root";
-GRANT ALL on "node" to "wallaby";
+CREATE TABLE "moderate" (
+ "cid" integer,
+ "nid" integer,
+ "uid" integer NOT NULL,
+ "score" smallint NOT NULL,
+ "timestamp" integer NOT NULL
+);
--
--- TOC Entry ID 150 (OID 24087)
+-- TOC Entry ID 66 (OID 47885)
--
--- Name: book Type: TABLE Owner: root
+-- Name: comments Type: TABLE Owner: root
--
-CREATE TABLE "book" (
- "lid" integer DEFAULT nextval('"book_lid_seq"'::text) NOT NULL,
- "nid" integer NOT NULL,
- "body" text NOT NULL,
- "section" integer,
- "parent" integer NOT NULL,
- "weight" integer NOT NULL,
+CREATE TABLE "comments" (
+ "cid" integer DEFAULT nextval('"comments_cid_seq"'::text) NOT NULL,
"pid" integer NOT NULL,
- "log" text NOT NULL,
- Constraint "book_pkey" Primary Key ("lid")
+ "lid" integer NOT NULL,
+ "uid" integer NOT NULL,
+ "subject" character varying(64) NOT NULL,
+ "comment" text NOT NULL,
+ "hostname" character varying(128) NOT NULL,
+ "timestamp" integer NOT NULL,
+ "link" character varying(16) NOT NULL,
+ Constraint "comments_pkey" Primary Key ("cid")
);
--
--- TOC Entry ID 151 (OID 24087)
+-- TOC Entry ID 67 (OID 48008)
--
--- Name: book Type: ACL Owner:
+-- Name: blog Type: TABLE Owner: root
--
-REVOKE ALL on "book" from PUBLIC;
-GRANT ALL on "book" to "root";
-GRANT ALL on "book" to "wallaby";
+CREATE TABLE "blog" (
+ "nid" integer NOT NULL,
+ "body" text NOT NULL
+);
--
--- TOC Entry ID 152 (OID 24321)
+-- TOC Entry ID 68 (OID 48061)
--
--- Name: moderate Type: TABLE Owner: root
+-- Name: story Type: TABLE Owner: root
--
-CREATE TABLE "moderate" (
- "cid" integer,
- "nid" integer,
- "uid" integer NOT NULL,
- "score" smallint NOT NULL,
- "timestamp" integer NOT NULL
+CREATE TABLE "story" (
+ "nid" integer NOT NULL,
+ "abstract" text NOT NULL,
+ "body" text NOT NULL
);
--
--- TOC Entry ID 153 (OID 24321)
+-- TOC Entry ID 69 (OID 48116)
--
--- Name: moderate Type: ACL Owner:
+-- Name: page Type: TABLE Owner: root
--
-REVOKE ALL on "moderate" from PUBLIC;
-GRANT ALL on "moderate" to "root";
-GRANT ALL on "moderate" to "wallaby";
+CREATE TABLE "page" (
+ "nid" integer NOT NULL,
+ "link" character varying(128) DEFAULT '' NOT NULL,
+ "body" text NOT NULL,
+ "format" integer NOT NULL
+);
--
--- TOC Entry ID 154 (OID 24599)
+-- TOC Entry ID 70 (OID 48171)
--
--- Name: comments Type: TABLE Owner: root
+-- Name: forum Type: TABLE Owner: root
--
-CREATE TABLE "comments" (
- "cid" integer DEFAULT nextval('"comments_cid_seq"'::text) NOT NULL,
- "pid" integer NOT NULL,
- "lid" integer NOT NULL,
- "author" integer NOT NULL,
- "subject" character varying(64) NOT NULL,
- "comment" text NOT NULL,
- "hostname" character varying(128) NOT NULL,
- "timestamp" integer NOT NULL,
- "link" character varying(16) NOT NULL,
- Constraint "comments_pkey" Primary Key ("cid")
+CREATE TABLE "forum" (
+ "nid" integer NOT NULL,
+ "body" text NOT NULL
);
--
--- TOC Entry ID 155 (OID 24599)
+-- TOC Entry ID 71 (OID 48228)
--
--- Name: comments Type: ACL Owner:
+-- Name: book Type: TABLE Owner: root
--
-REVOKE ALL on "comments" from PUBLIC;
-GRANT ALL on "comments" to "root";
-GRANT ALL on "comments" to "wallaby";
+CREATE TABLE "book" (
+ "nid" integer NOT NULL,
+ "body" text NOT NULL,
+ "section" integer,
+ "parent" integer NOT NULL,
+ "weight" integer NOT NULL,
+ "pid" integer NOT NULL,
+ "log" text NOT NULL
+);
--
--- TOC Entry ID 156 (OID 20233)
+-- TOC Entry ID 72 (OID 46231)
--
-- Name: "mask_access_ukey" Type: INDEX Owner: root
--
@@ -1749,7 +913,7 @@ GRANT ALL on "comments" to "wallaby";
CREATE UNIQUE INDEX "mask_access_ukey" on "access" using btree ( "mask" "varchar_ops" );
--
--- TOC Entry ID 157 (OID 20393)
+-- TOC Entry ID 73 (OID 46336)
--
-- Name: "title_boxes_ukey" Type: INDEX Owner: root
--
@@ -1757,7 +921,7 @@ CREATE UNIQUE INDEX "mask_access_ukey" on "access" using btree ( "mask" "varchar
CREATE UNIQUE INDEX "title_boxes_ukey" on "boxes" using btree ( "title" "varchar_ops" );
--
--- TOC Entry ID 158 (OID 20393)
+-- TOC Entry ID 74 (OID 46336)
--
-- Name: "info_boxes_ukey" Type: INDEX Owner: root
--
@@ -1765,7 +929,7 @@ CREATE UNIQUE INDEX "title_boxes_ukey" on "boxes" using btree ( "title" "varchar
CREATE UNIQUE INDEX "info_boxes_ukey" on "boxes" using btree ( "info" "varchar_ops" );
--
--- TOC Entry ID 159 (OID 20519)
+-- TOC Entry ID 75 (OID 46453)
--
-- Name: "name_category_ukey" Type: INDEX Owner: root
--
@@ -1773,7 +937,7 @@ CREATE UNIQUE INDEX "info_boxes_ukey" on "boxes" using btree ( "info" "varchar_o
CREATE UNIQUE INDEX "name_category_ukey" on "category" using btree ( "name" "varchar_ops" );
--
--- TOC Entry ID 160 (OID 20563)
+-- TOC Entry ID 76 (OID 46494)
--
-- Name: "url_channel_ukey" Type: INDEX Owner: root
--
@@ -1781,7 +945,7 @@ CREATE UNIQUE INDEX "name_category_ukey" on "category" using btree ( "name" "var
CREATE UNIQUE INDEX "url_channel_ukey" on "channel" using btree ( "url" "varchar_ops" );
--
--- TOC Entry ID 161 (OID 20563)
+-- TOC Entry ID 77 (OID 46494)
--
-- Name: "file_channel_ukey" Type: INDEX Owner: root
--
@@ -1789,7 +953,7 @@ CREATE UNIQUE INDEX "url_channel_ukey" on "channel" using btree ( "url" "varchar
CREATE UNIQUE INDEX "file_channel_ukey" on "channel" using btree ( "file" "varchar_ops" );
--
--- TOC Entry ID 162 (OID 20563)
+-- TOC Entry ID 78 (OID 46494)
--
-- Name: "site_channel_ukey" Type: INDEX Owner: root
--
@@ -1797,7 +961,7 @@ CREATE UNIQUE INDEX "file_channel_ukey" on "channel" using btree ( "file" "varch
CREATE UNIQUE INDEX "site_channel_ukey" on "channel" using btree ( "site" "varchar_ops" );
--
--- TOC Entry ID 163 (OID 20699)
+-- TOC Entry ID 79 (OID 46602)
--
-- Name: "name_collection_ukey" Type: INDEX Owner: root
--
@@ -1805,7 +969,7 @@ CREATE UNIQUE INDEX "site_channel_ukey" on "channel" using btree ( "site" "varch
CREATE UNIQUE INDEX "name_collection_ukey" on "collection" using btree ( "name" "varchar_ops" );
--
--- TOC Entry ID 169 (OID 21193)
+-- TOC Entry ID 80 (OID 46792)
--
-- Name: "entry_namcoll_ukey" Type: INDEX Owner: root
--
@@ -1813,7 +977,7 @@ CREATE UNIQUE INDEX "name_collection_ukey" on "collection" using btree ( "name"
CREATE UNIQUE INDEX "entry_namcoll_ukey" on "entry" using btree ( "name" "varchar_ops", "collection" "varchar_ops" );
--
--- TOC Entry ID 164 (OID 21244)
+-- TOC Entry ID 81 (OID 46843)
--
-- Name: "url_feed_ukey" Type: INDEX Owner: root
--
@@ -1821,7 +985,7 @@ CREATE UNIQUE INDEX "entry_namcoll_ukey" on "entry" using btree ( "name" "varcha
CREATE UNIQUE INDEX "url_feed_ukey" on "feed" using btree ( "url" "varchar_ops" );
--
--- TOC Entry ID 165 (OID 21244)
+-- TOC Entry ID 82 (OID 46843)
--
-- Name: "title_feed_ukey" Type: INDEX Owner: root
--
@@ -1829,7 +993,7 @@ CREATE UNIQUE INDEX "url_feed_ukey" on "feed" using btree ( "url" "varchar_ops"
CREATE UNIQUE INDEX "title_feed_ukey" on "feed" using btree ( "title" "varchar_ops" );
--
--- TOC Entry ID 166 (OID 22553)
+-- TOC Entry ID 83 (OID 47366)
--
-- Name: "link_site_ukey" Type: INDEX Owner: root
--
@@ -1837,7 +1001,7 @@ CREATE UNIQUE INDEX "title_feed_ukey" on "feed" using btree ( "title" "varchar_o
CREATE UNIQUE INDEX "link_site_ukey" on "site" using btree ( "link" "varchar_ops" );
--
--- TOC Entry ID 167 (OID 22553)
+-- TOC Entry ID 84 (OID 47366)
--
-- Name: "name_site_ukey" Type: INDEX Owner: root
--
@@ -1845,7 +1009,7 @@ CREATE UNIQUE INDEX "link_site_ukey" on "site" using btree ( "link" "varchar_ops
CREATE UNIQUE INDEX "name_site_ukey" on "site" using btree ( "name" "varchar_ops" );
--
--- TOC Entry ID 170 (OID 22660)
+-- TOC Entry ID 85 (OID 47473)
--
-- Name: "tag_namecoll_ukey" Type: INDEX Owner: root
--
@@ -1853,7 +1017,7 @@ CREATE UNIQUE INDEX "name_site_ukey" on "site" using btree ( "name" "varchar_ops
CREATE UNIQUE INDEX "tag_namecoll_ukey" on "tag" using btree ( "name" "varchar_ops", "collections" "varchar_ops" );
--
--- TOC Entry ID 168 (OID 22699)
+-- TOC Entry ID 86 (OID 47512)
--
-- Name: "name_topic_ukey" Type: INDEX Owner: root
--
@@ -1861,7 +1025,15 @@ CREATE UNIQUE INDEX "tag_namecoll_ukey" on "tag" using btree ( "name" "varchar_o
CREATE UNIQUE INDEX "name_topic_ukey" on "topic" using btree ( "name" "varchar_ops" );
--
--- TOC Entry ID 171 (OID 24321)
+-- TOC Entry ID 91 (OID 47790)
+--
+-- Name: "uid_node_key" Type: INDEX Owner: root
+--
+
+CREATE INDEX "uid_node_key" on "node" using btree ( "uid" "int4_ops" );
+
+--
+-- TOC Entry ID 87 (OID 47871)
--
-- Name: "moderate_cid_key" Type: INDEX Owner: root
--
@@ -1869,7 +1041,7 @@ CREATE UNIQUE INDEX "name_topic_ukey" on "topic" using btree ( "name" "varchar_o
CREATE INDEX "moderate_cid_key" on "moderate" using btree ( "cid" "int4_ops" );
--
--- TOC Entry ID 172 (OID 24321)
+-- TOC Entry ID 88 (OID 47871)
--
-- Name: "moderate_nid_key" Type: INDEX Owner: root
--
@@ -1877,10 +1049,18 @@ CREATE INDEX "moderate_cid_key" on "moderate" using btree ( "cid" "int4_ops" );
CREATE INDEX "moderate_nid_key" on "moderate" using btree ( "nid" "int4_ops" );
--
--- TOC Entry ID 173 (OID 24599)
+-- TOC Entry ID 89 (OID 47885)
--
-- Name: "lid_comments_key" Type: INDEX Owner: root
--
CREATE INDEX "lid_comments_key" on "comments" using btree ( "lid" "int4_ops" );
+--
+-- TOC Entry ID 90 (OID 47885)
+--
+-- Name: "uid_comments_key" Type: INDEX Owner: root
+--
+
+CREATE INDEX "uid_comments_key" on "comments" using btree ( "uid" "int4_ops" );
+
diff --git a/error.php b/error.php
index 8b4711c6e..55f7aef80 100644
--- a/error.php
+++ b/error.php
@@ -13,5 +13,5 @@ if (strstr($REDIRECT_URL, "index.php")) {
else {
drupal_goto("index.php");
}
-
+
?> \ No newline at end of file
diff --git a/includes/comment.inc b/includes/comment.inc
index 81c77d3df..ce0f20404 100644
--- a/includes/comment.inc
+++ b/includes/comment.inc
@@ -83,7 +83,7 @@ function comment_reply($pid, $id) {
comment_view(new Comment($item->uid, $item->name, $item->subject, $item->comment, $item->timestamp, $item->url, $item->cid, $item->lid), t("reply to this comment"));
}
else {
- node_view(node_get_object(array("nid" => $id)));
+ node_view(node_load(array("nid" => $id)));
$pid = 0;
}
@@ -351,5 +351,5 @@ function comment_render($lid, $cid) {
}
}
-
+
?>
diff --git a/includes/common.inc b/includes/common.inc
index e4e410f29..04c9b8a42 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -89,6 +89,14 @@ function drupal_goto($url) {
else {
header("Location: $url?". SID);
}
+
+ /*
+ ** The "Location" header sends a REDIRECT status code to the http
+ ** deamon. In some cases this can go wrong, so we make sure none
+ ** of the code /below/ gets executed when we redirect.
+ */
+
+ exit();
}
function check_form($text) {
@@ -209,7 +217,7 @@ function format_interval($timestamp) {
function format_date($timestamp, $type = "medium", $format = "") {
global $user;
- $timestamp += ($user->timezone) ? $user->timezone - date("Z") : 0;
+ // $timestamp += ($user->timezone) ? $user->timezone - date("Z") : 0;
switch ($type) {
case "small":
@@ -327,7 +335,6 @@ function field_merge($a, $b) {
function link_page() {
$links[] = "<a href=\"index.php\">". t("home") ."</a>";
- $links[] = "<a href=\"submit.php\">". t("submit") ."</a>";
foreach (module_list() as $name) {
if (module_hook($name, "link")) {
diff --git a/includes/conf.php b/includes/conf.php
index 7df27806f..05fe9a3a3 100644
--- a/includes/conf.php
+++ b/includes/conf.php
@@ -5,8 +5,10 @@
# Database settings:
#
-# $db_url = "pgsql://userer:password@hostname/database";
-# $db_url = "mysql://userer:password@hostname/database";
+# $db_url = "pgsql://user:password@hostname/database";
+# $db_url = "mysql://user:password@hostname/database";
+
+$db_url = "mysql://drop:drop@localhost/drop";
#
# PHP settings:
diff --git a/includes/locale.inc b/includes/locale.inc
index 7f0589414..f726156f3 100644
--- a/includes/locale.inc
+++ b/includes/locale.inc
@@ -10,5 +10,5 @@ function t($string) {
global $languages;
return ($languages && function_exists("locale") ? locale($string) : $string);
}
-
+
?> \ No newline at end of file
diff --git a/includes/module.inc b/includes/module.inc
index 007059420..408b3d718 100644
--- a/includes/module.inc
+++ b/includes/module.inc
@@ -24,17 +24,18 @@ function module_list() {
static $list;
if (!$list) {
- $handle = opendir("modules");
- $list = array();
- while ($file = readdir($handle)) {
- if (".module" == substr($file, -7)) {
- $filename = substr($file, 0, -7);
- include "modules/$filename.module";
- $list[$filename] = $filename;
+ if ($handle = @opendir("modules")) {
+ $list = array();
+ while ($file = readdir($handle)) {
+ if (".module" == substr($file, -7)) {
+ $filename = substr($file, 0, -7);
+ include "modules/$filename.module";
+ $list[$filename] = $filename;
+ }
}
+ closedir($handle);
+ asort($list);
}
- closedir($handle);
- asort($list);
}
return $list;
@@ -90,5 +91,5 @@ function module_rehash($name) {
db_query("DELETE FROM blocks WHERE module = '$name'");
}
}
-
+
?>
diff --git a/includes/node.inc b/includes/node.inc
index b8c6a2751..a42cc0232 100644
--- a/includes/node.inc
+++ b/includes/node.inc
@@ -1,301 +1,250 @@
<?php
// $Id$
-$status = array(dumped => 0, expired => 1, queued => 2, posted => 3);
+/*
+** Loading and storing nodes:
+** - load: called when a node is being loaded
+** - save: called before a node gets saved and used to define default
+** values
+** - insert: called when inserting a node to the node table
+** - delete: called when deleting a node from the node table
+** - update: called when updating a node in the noe table
+**
+** Viewing and editing nodes:
+** - view: called to display a node on the screen
+** - form: called to display a node's form
+**
+** - status
+*/
+
+// TODO: still used by themes, yet doesn't return anything at the moment
+function node_index() {
+}
-function _node_get($conditions) {
- foreach ($conditions as $key=>$value) {
- $cond[] = "n.". check_query($key) ." = '". check_query($value) ."'";
- }
+function node_access($node) {
+ global $user;
+ return ($node->status == 1) || user_access("administer nodes");
+}
+
+function node_get_comments($nid) {
+ $comment = db_fetch_object(db_query("SELECT COUNT(c.lid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.lid WHERE n.nid = '$nid' GROUP BY n.nid"));
+ return $comment->number ? $comment->number : 0;
+}
- $where = implode(" AND ", $cond);
+function node_teaser($body) {
- if ($conditions[type]) {
- $type = $conditions[type];
+ $size = 400;
+
+ /*
+ ** If we have a short body, return the entire body:
+ */
+
+ if (strlen($body) < $size) {
+ return $body;
}
- else {
- $node = db_fetch_object(db_query("SELECT n.type FROM node n WHERE $where"));
- $type = $node ? $node->type : 0;
+
+ /*
+ ** If we have a long body, try not to split paragraphs:
+ */
+
+ if ($length = strpos($body, "\n", $size)) {
+ return substr($body, 0, $length + 1);
}
- if ($type) {
+ /*
+ ** If we have a long body, try not to split sentences:
+ */
- // $result = db_query("SELECT n.*, l.*, u.uid, u.name FROM node n LEFT JOIN $type l ON n.nid = l.nid LEFT JOIN users u ON n.uid = u.uid WHERE $where ORDER BY n.timestamp DESC");
+ return substr($body, 0, strpos($body, ". ", $size) + 1);
- db_query("BEGIN");
- db_query("CREATE TEMPORARY TABLE modhole AS SELECT n.nid FROM node n LEFT JOIN $type l ON n.nid = l.nid LEFT JOIN users u ON n.uid = u.uid WHERE $where GROUP BY n.nid");
- $result = db_query("SELECT n.*, l.*, u.uid, u.name FROM node n INNER JOIN modhole m ON m.nid = n.nid LEFT JOIN $type l ON n.nid = l.nid LEFT JOIN users u ON n.uid = u.uid WHERE $where ORDER BY n.timestamp DESC");
- db_query("DROP TABLE modhole");
- db_query("COMMIT");
+}
- return $result;
+function node_invoke($node, $name, $arg = 0) {
+ if (is_array($node)) {
+ $function = $node[type] ."_$name";
+ }
+ else if (is_object($node)) {
+ $function = $node->type ."_$name";
+ }
+ else if (is_string($node)) {
+ $function = $node ."_$name";
}
-}
-function node_comment_status($index = -1) {
- $status = array("Disabled", "Enabled");
- return $index < 0 ? $status : $status[$index];
+ if (function_exists($function)) {
+ return ($arg ? $function($node, $arg) : $function($node));
+ }
}
-function node_promote_status($index = -1) {
- $status = array("Disabled", "Enabled");
- return $index < 0 ? $status : $status[$index];
-}
+function node_object($node) {
-function node_submission_status($index = -1) {
- $status = array("Auto-post new submissions", "Moderate new submissions");
- return $index < 0 ? $status : $status[$index];
-}
+ if (is_array($node)) {
+ foreach ($node as $key => $value) {
+ $object->$key = $value;
+ }
+ }
+ else {
+ $object = $node;
+ }
-function node_get_object($conditions) {
- return db_fetch_object(_node_get($conditions));
+ return $object;
}
-function node_get_array($conditions) {
- return db_fetch_array(_node_get($conditions));
-}
+function node_array($node) {
-function node_del($conditions) {
- global $status;
- if ($node = node_get_object($conditions)) {
- module_invoke($node->type, "delete", $node);
- db_query("DELETE FROM node WHERE nid = '$node->nid'");
- db_query("DELETE FROM $node->type WHERE nid = '$node->nid'");
- db_query("DELETE FROM comments WHERE lid = '$node->nid'");
- db_query("DELETE FROM moderate WHERE nid = '$node->nid'");
- watchdog("special", "node: deleted '$node->title'");
- return $node;
+ if (is_object($node)) {
+ foreach ($node as $key => $value) {
+ $array[$key] = $value;
+ }
+ }
+ else {
+ $array = $node;
}
-}
-function node_get_comments($nid) {
- $comment = db_fetch_object(db_query("SELECT COUNT(c.lid) AS number FROM node n LEFT JOIN comments c ON n.nid = c.lid WHERE n.nid = '$nid' GROUP BY n.nid"));
- return $comment->number ? $comment->number : 0;
+ return $array;
}
-function node_save($node, $filter) {
- global $db_handle;
-
- $rows = array(nid, cid, tid, type, title, score, votes, uid, status, comment, promote, moderate, attributes, timestamp, timestamp_posted, timestamp_queued, timestamp_hidden);
+function node_load($conditions) {
- if ($node[nid] > 0) {
- $n = node_get_object(array("nid" => $node[nid]));
+ // prepare query:
+ foreach ($conditions as $key => $value) {
+ $cond[] = "n.". check_query($key) ." = '". check_query($value) ."'";
+ }
- foreach ($filter as $field=>$value) {
- $f = check_input(is_numeric($field) ? $value : $field);
- $v = check_input(is_numeric($field) ? $node[$value] : $filter[$field]);
+ // retrieve the node:
+ $node = db_fetch_object(db_query("SELECT n.*, u.uid, u.name FROM node n LEFT JOIN users u ON u.uid = n.uid LEFT JOIN comments c ON c.lid = n.nid WHERE ". implode(" AND ", $cond)));
- if (in_array($f, $rows)) {
- $u1[] = check_input($f) ." = '". check_input($v) ."'";
- }
- else {
- $u2[] = check_input($f) ." = '". check_input($v) ."'";
- }
+ // call the node specific callback (if any):
+ if ($extra = module_invoke($node->type, "load", $node)) {
+ foreach ($extra as $key => $value) {
+ $node->$key = $value;
}
+ }
- if ($u1) db_query("UPDATE node SET ". implode(", ", $u1) ." WHERE nid = '$node[nid]'");
- if ($u2) db_query("UPDATE $n->type SET ". implode(", ", $u2) ." WHERE nid = '$node[nid]'");
+ return $node;
- if ($node[nid]) module_invoke($n->type, "update", node_get_object(array(nid => $n->nid)));
+}
- return $node[nid];
- }
- else {
- $duplicate = node_get_object(array("title" => $node[title]));
+function node_save($node, $filter) {
+
+ $fields = array("nid", "uid", "type", "title", "teaser", "body", "status", "comment", "promote", "moderate", "created", "changed");
- if ($duplicate && (time() - $duplicate->timestamp < 60)) {
- watchdog("warning", "node: duplicate '$node[title]'");
+ foreach ($filter as $key => $value) {
+ /*
+ ** Only save those fields specified by the filter. If the filter
+ ** does not specify a default value, use the value of the $node's
+ ** corresponding field instead.
+ */
+
+ if (is_numeric($key)) {
+ $edit->$value = $node->$value;
}
else {
- // verify submission rate:
- throttle("node", variable_get("max_node_rate", 900));
-
- // prepare queries:
- foreach ($filter as $field=>$value) {
- $f = check_input(is_numeric($field) ? $value : $field);
- $v = check_input(is_numeric($field) ? $node[$value] : $filter[$field]);
-
- if (in_array($f, $rows)) {
- $f1[] = $f;
- $v1[] = "'$v'";
- }
- else {
- $f2[] = $f;
- $v2[] = "'$v'";
- }
- }
+ $edit->$key = $value;
+ }
+ }
- $f1 = implode(", ", $f1);
- $v1 = implode(", ", $v1);
- $f2 = implode(", ", $f2);
- $v2 = implode(", ", $v2);
+ $node = $edit;
+ if (empty($node->nid)) {
+ /*
+ ** Verify a user's submission rate and avoid duplicate nodes being
+ ** inserted:
+ */
- $result = db_query("BEGIN");
- if (db_error($result)) {
- watchdog("error", "database: ". $result->getMessage() ."\nquery: ". htmlspecialchars("BEGIN"));
- $db_handle->rollback();
- }
- else {
-
- $nid = $db_handle->nextId("node");
-
- $result = db_query("INSERT INTO node ($f1, nid) VALUES ($v1, '$nid')");
- if (db_error($result)) {
- watchdog("warning", "node: added $filter[type] '$node[title]' - failed");
- $db_handle->rollback();
- }
- else {
- $result = db_query("INSERT INTO $filter[type] ($f2, nid) VALUES ($v2, '$nid')");
- if (db_error($result)) {
- watchdog("warning", "node: added $filter[type] '$node[title]' - failed");
- $db_handle->rollback();
- }
- else {
- $result = db_query("COMMIT");
- if (db_error($result)) {
- watchdog("error", "database: ". $result->getMessage() ."\nquery: ". htmlspecialchars("COMMIT"));
- $db_handle->rollback();
- }
- watchdog("special", "node: added $filter[type] '$node[title]'");
- }
- }
- }
- }
+ throttle("node", variable_get("max_node_rate", 900));
- if ($nid) module_invoke($filter[type], "insert", node_get_object(array(nid => $nid)));
+ /*
+ ** Insert a new node:
+ */
- return $nid;
- }
-}
+ // set some required fields:
+ $node->created = time();
+ $node->nid = db_result(db_query("SELECT MAX(nid) + 1 FROM node"));
-function node_invoke($node, $name, $arg = 0) {
- if (is_array($node)) $function = $node[type] ."_$name";
- else if (is_object($node)) $function = $node->type ."_$name";
- else if (is_string($node)) $function = $node ."_$name";
- if (function_exists($function)) return ($arg ? $function($node, $arg) : $function($node));
-}
+ // prepare the query:
+ foreach ($node as $key => $value) {
+ if (in_array($key, $fields)) {
+ $k[] = check_query($key);
+ $v[] = "'". check_query($value) ."'";
+ }
+ }
-function node_view($node, $main = 0) {
- return node_invoke($node, "view", $main);
-}
+ // insert the node into the database:
+ db_query("INSERT INTO node (". implode(", ", $k) .") VALUES (". implode(", ", $v) .")");
-function node_form($node) {
- return node_invoke($node, "form");
-}
+ // call the node specific callback (if any):
+ module_invoke($node->type, "insert", $node);
-function node_status($value) {
- $status = array("dumped", "expired", "queued", "posted");
- if (module_exist($value)) {
- return array_intersect($status, node_invoke($value, "status"));
- }
- else if (strlen($value) > 3) {
- $status = array_flip($status);
- return $status[$value];
+ watchdog("special", "node: added '$node->title'");
}
else {
- return $status[$value];
- }
-}
-function node_control($node) {
- global $user, $REQUEST_URI;
-
- ?>
- <SCRIPT>
- <!--//
- function visit(site) {
- if (site != "") {
- parent.location = site
- }
- }
- //-->
- </SCRIPT>
- <?php
-
- if ($user->uid) {
- $choices = array("node.php?id=$node->nid" => t("view node"), "submit.php?mod=$node->type" => t("add node"), "submit.php?mod=$node->type&op=update&id=$node->nid" => t("update node"), "node.php?op=history&id=$node->nid" => t("view history"));
- }
- else {
- $choices = array("node.php?id=$node->nid" => t("view node"), "node.php?op=history&id=$node->nid" => t("view history"));
- }
+ /*
+ ** Update an existing node:
+ */
- $output .= "<FORM METHOD=\"get\" ACTION=\"\">\n";
- foreach ($choices as $key => $value) $options .= "<OPTION VALUE=\"$key\"". (strstr($REQUEST_URI, "/$key") ? " SELECTED" : "") .">". check_form($value) ."</OPTION>\n";
- $output .= " <SELECT NAME=\"op\" ONCHANGE=\"visit(this.options[this.selectedIndex].value)\">$options</SELECT>\n";
- $output .= "</FORM>\n";
+ // set some required fields:
+ $node->changed = time();
- return $output;
-}
+ // prepare the query:
+ foreach ($node as $key => $value) {
+ if (in_array($key, $fields)) {
+ $q[] = check_query($key) ." = '". check_query($value) ."'";
+ }
+ }
-function node_preview($node) {
- foreach ($node as $key=>$value) {
- if ($value) $node[$key] = is_array($value) ? node_preview($value) : check_preview($value);
- }
- return $node;
-}
+ // update the node in the database:
+ db_query("UPDATE node SET ". implode(", ", $q) ." WHERE nid = '". check_query($node->nid) ."'");
+ // call the node specific callback (if any):
+ module_invoke($node->type, "update", $node);
-function node_attributes_edit($type, $edit) {
- return meta_form($type, $edit);
-}
+ watchdog("special", "node: updated '$node->title'");
+ }
-function node_attributes_save($type, $edit) {
- return meta_save($type, $edit);
-}
+ /*
+ ** Return the node ID:
+ */
-function node_attributes_view($string) {
- foreach (explode(",", $string) as $attribute) {
- if ($attribute = trim($attribute)) {
- $array[] = "<a href=\"index.php?meta=". urlencode($attribute) ."\">$attribute</a>";
- }
- }
- return $array ? $array : array();
-}
+ return $node->nid;
-function node_index($node) {
- return $node->attributes ? implode(" / ", node_attributes_view($node->attributes)) : "&nbsp;";
}
-function node_access($node) {
- global $user, $status;
- return ($node->status == $status[posted]) || ($node->status == $status[queued] && $user->uid) || user_access("administer nodes");
-}
+function node_delete($conditions) {
-function node_moderate($moderate) {
- global $user;
+ if ($node = node_load($conditions)) {
- if ($user->uid && $moderate) {
- foreach ($moderate as $nid => $score) {
- if ($score > 0 && $score < 6) {
- if (db_fetch_object(db_query("SELECT * FROM moderate WHERE uid = '". check_query($user->uid) ."' AND nid = '". check_query($nid) ."'"))) {
- db_query("UPDATE moderate SET score = '". check_query($score) ."' WHERE uid = '". check_query($user->uid) ."' AND nid = '". check_query($nid) ."'");
- }
- else {
- db_query("INSERT INTO moderate (uid, nid, score, timestamp) VALUES ('". check_query($user->uid) ."', '". check_query($nid) ."', '". check_query($score) ."', '". time() ."')");
- }
- }
- }
- }
-}
+ // delete the node and its comments:
+ db_query("DELETE FROM node WHERE nid = '$node->nid'");
+ db_query("DELETE FROM comments WHERE lid = '$node->nid'");
+ db_query("DELETE FROM moderate WHERE nid = '$node->nid'");
-function node_moderation($nid) {
- global $user;
+ // call the node specific callback (if any):
+ module_invoke($node->type, "delete", &$node);
- $node = node_get_object(array("nid" => $nid));
+ watchdog("special", "node: deleted '$node->title'");
+ }
- $values = array("--", 1, 2, 3, 4, 5);
+}
- $moderate = db_fetch_object(db_query("SELECT * FROM moderate WHERE nid = '$node->nid' AND uid = '$user->uid'"));
+function node_view($node, $main = 0) {
+ global $theme;
- foreach ($values as $key => $value) {
- $options .= " <option value=\"$key\"". ($moderate->score == $key ? " selected=\"selected\"" : "") .">$value</option>\n";
+ if (is_array($node)) {
+ $node = node_object($node);
}
- $output .= "accumulated rating: ". ($node->score ? $node->score : "--") ." / $node->votes<br />";
- $output .= "<select name=\"moderate[node][$node->nid]\">$options</select>";
+ /*
+ ** The "view" hook can be implemented to overwrite the default function
+ ** to display nodes.
+ */
- return $output;
+ if (module_hook($node->type, "view")) {
+ node_invoke($node, "view", $main);
+ }
+ else {
+ $theme->node($node, $main);
+ }
}
-
+
?>
diff --git a/includes/search.inc b/includes/search.inc
index 248384d74..a4d3355f6 100644
--- a/includes/search.inc
+++ b/includes/search.inc
@@ -83,5 +83,5 @@ function search_type($type = 0, $action = 0, $query = 0, $options = 0) {
return search_form($action, $query, $options) . search_data();
}
-
+
?>
diff --git a/includes/theme.inc b/includes/theme.inc
index 1247a1676..79fdeb353 100644
--- a/includes/theme.inc
+++ b/includes/theme.inc
@@ -135,7 +135,7 @@ function theme_blocks($region, &$theme) {
case "/node.php":
if ($region != "left") {
if ($user->uid) $node = db_fetch_object(db_query("SELECT * FROM node WHERE nid = '$id'"));
- if ($node->status == node_status("queued")) theme_moderation_results($theme, $node, $region);
+ if ($node->moderate == 1) theme_moderation_results($theme, $node, $region);
}
default:
if ($user->uid) $result = db_query("SELECT * FROM blocks b LEFT JOIN layout l ON b.name = l.block WHERE (b.status = 2 OR (b.status = 1 AND l.uid = '$user->uid'))". (($region == "left" OR $region == "right") ? ($region == "left" ? " AND b.region = 0" : " AND b.region = 1") : "") ." AND (b.path = '' OR '". strrchr($REQUEST_URI, "/") ."' RLIKE b.path) ORDER BY weight");
diff --git a/includes/variable.inc b/includes/variable.inc
index 7c23c4fa8..9746cc8c6 100644
--- a/includes/variable.inc
+++ b/includes/variable.inc
@@ -34,5 +34,5 @@ function variable_del($name) {
unset($conf[$name]);
}
-
+
?> \ No newline at end of file
diff --git a/index.php b/index.php
index ff7a1e3a1..5b44fe1b2 100644
--- a/index.php
+++ b/index.php
@@ -10,5 +10,5 @@ $function = variable_get("site_frontpage", "node") ."_page";
$function();
page_footer();
-
+
?>
diff --git a/module.php b/module.php
index 731fab274..30954d8ac 100644
--- a/module.php
+++ b/module.php
@@ -8,5 +8,5 @@ page_header();
module_invoke($mod, "page");
page_footer();
-
+
?>
diff --git a/modules/aggregator.module b/modules/aggregator.module
index 42f5e4ca3..51de2e52a 100644
--- a/modules/aggregator.module
+++ b/modules/aggregator.module
@@ -689,5 +689,5 @@ function import_page() {
}
}
}
-
+
?>
diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module
index 42f5e4ca3..51de2e52a 100644
--- a/modules/aggregator/aggregator.module
+++ b/modules/aggregator/aggregator.module
@@ -689,5 +689,5 @@ function import_page() {
}
}
}
-
+
?>
diff --git a/modules/block.module b/modules/block.module
index c85761275..7d25fdff1 100644
--- a/modules/block.module
+++ b/modules/block.module
@@ -57,7 +57,7 @@ function block_admin_display() {
$region .= " <option value=\"0\"". (($block->region == 0) ? " selected" : "") .">left</option>\n";
$region .= " <option value=\"1\"". (($block->region == 1) ? " selected" : "") .">right</option>\n";
$region .= "</select>\n";
-
+
$path = "<input name=\"edit[$block->name][path]\" value=\"$block->path\">\n";
$output .= " <tr><td>". $block->name ."</td><td align=\"center\">$module</td><td>$status</td><td>$weight</td><td>$region</td><td>$path</td></tr>\n";
@@ -150,5 +150,5 @@ function block_admin() {
print message_access();
}
}
-
+
?>
diff --git a/modules/block/block.module b/modules/block/block.module
index c85761275..7d25fdff1 100644
--- a/modules/block/block.module
+++ b/modules/block/block.module
@@ -57,7 +57,7 @@ function block_admin_display() {
$region .= " <option value=\"0\"". (($block->region == 0) ? " selected" : "") .">left</option>\n";
$region .= " <option value=\"1\"". (($block->region == 1) ? " selected" : "") .">right</option>\n";
$region .= "</select>\n";
-
+
$path = "<input name=\"edit[$block->name][path]\" value=\"$block->path\">\n";
$output .= " <tr><td>". $block->name ."</td><td align=\"center\">$module</td><td>$status</td><td>$weight</td><td>$region</td><td>$path</td></tr>\n";
@@ -150,5 +150,5 @@ function block_admin() {
print message_access();
}
}
-
+
?>
diff --git a/modules/blog.module b/modules/blog.module
index f5341a746..97c9a8559 100644
--- a/modules/blog.module
+++ b/modules/blog.module
@@ -1,14 +1,6 @@
<?php
// $Id$
-class Blog {
- function Blog($blog) {
- global $user;
- $this = new Node($blog);
- $this->body = $blog[body];
- }
-}
-
function blog_help() {
?>
<p>Drupal's blog module allows registered users to maintain an online blog or diary. It provides easy-to-write and easy-to-read online diaries or journals that can be filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption.</p>
@@ -19,14 +11,6 @@ function blog_perm() {
return array("administer blogs", "access blogs", "post blogs");
}
-function blog_status() {
- return array(dumped, posted);
-}
-
-function blog_summary($node) {
- return $node->body;
-}
-
function blog_feed_user($uid = 0, $date = 0) {
global $user;
@@ -41,7 +25,7 @@ function blog_feed_user($uid = 0, $date = 0) {
$date = time();
}
- $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid WHERE u.uid = '$uid' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.nid DESC LIMIT 15");
+ $result = db_query("SELECT n.nid, n.title, n.body, n.created, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid WHERE u.uid = '$uid' AND n.created > '". ($date - 2592000) ."' ORDER BY b.nid DESC LIMIT 15");
while ($blog = db_fetch_object($result)) {
$items .= format_rss_item($blog->title, path_uri() ."node.php?id=$blog->nid", $blog->body);
}
@@ -60,9 +44,9 @@ function blog_feed_user($uid = 0, $date = 0) {
}
function blog_feed_last() {
- $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid ORDER BY b.nid DESC LIMIT 15");
+ $result = db_query("SELECT n.nid, n.title, n.body, n.created, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid ORDER BY b.nid DESC LIMIT 15");
while ($blog = db_fetch_object($result)) {
- $items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&id=$blog->uid", $blog->body);
+ $items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&id=$blog->nid", $blog->body);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
@@ -90,29 +74,31 @@ function blog_page_user($uid = 0, $date = 0) {
$date = time();
}
- $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid LEFT JOIN comments c ON n.nid = c.lid WHERE u.uid = '$account->uid' AND n.timestamp <= '$date' AND n.timestamp >= '". ($date - 2592000) ."' GROUP BY n.nid, n.title, n.comment, n.timestamp, b.body, u.uid, u.name ORDER BY n.nid DESC LIMIT 20");
+ $result = db_query("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND created <= '$date' AND created >= '". ($date - 2592000) ."' ORDER BY nid DESC");
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">";
- while ($blog = db_fetch_object($result)) {
+ while ($node = db_fetch_object($result)) {
+
+ $blog = node_load(array("nid" => $node->nid));
$links = array();
- if ($date != date("dny", $blog->timestamp)) {
- $date = date("dny", $blog->timestamp);
- $output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&id=$blog->uid&date=". mktime(23, 59, 59, date("n", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)) ."\">". format_date($blog->timestamp, custom, "d M Y") .":</a></b></td></tr>";
+ if ($date != date("dny", $blog->created)) {
+ $date = date("dny", $blog->created);
+ $output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&id=$blog->uid&date=". mktime(23, 59, 59, date("n", $blog->created), date("d", $blog->created), date("Y", $blog->created)) ."\">". format_date($blog->created, custom, "d M Y") .":</a></b></td></tr>";
}
if ($user->uid && $user->uid == $uid) {
- $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>";
+ $links[] = "<a href=\"module.php?mod=node&op=edit&id=$blog->nid\">". t("edit") ."</a>";
}
if ($user->uid && user_access("post blogs")) {
- $links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>";
+ $links[] = "<a href=\"module.php?mod=blog&op=blog&id=$blog->nid\">". t("blog it") ."</a>";
}
if ($blog->comment) {
- $links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural($blog->comments, t("comment"), t("comments")) ."</a>";
+ $links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural(node_get_comments($blog->nid), t("comment"), t("comments")) ."</a>";
}
$output .= "<tr><td><div style=\"margin-left: 20px;\"><b>". check_output($blog->title) ."</b></div></td><td align=\"right\">". $theme->links($links) ."</td></tr>";
@@ -129,26 +115,27 @@ function blog_page_user($uid = 0, $date = 0) {
function blog_page_last() {
global $theme, $user;
- $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid LEFT JOIN comments c ON n.nid = c.lid GROUP BY n.nid, n.title, n.comment, n.timestamp, b.body, u.uid, u.name ORDER BY n.nid DESC LIMIT 20");
+ $result = db_query("SELECT nid FROM node WHERE type = 'blog' ORDER BY nid DESC LIMIT 20");
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">";
- while ($blog = db_fetch_object($result)) {
+ while ($node = db_fetch_object($result)) {
+ $blog = node_load(array("nid" => $node->nid));
$links = array();
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$blog->uid\">". sprintf("%s's blog", $blog->name) ."</a>";
if ($blog->uid == $user->uid) {
- $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>";
+ $links[] = "<a href=\"module.php?mod=node&op=edit&id=$blog->nid\">". t("edit") ."</a>";
}
if ($user->uid && user_access("post blogs")) {
- $links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>";
+ $links[] = "<a href=\"module.php?mod=blog&op=blog&id=$blog->nid\">". t("blog it") ."</a>";
}
if ($blog->comment) {
- $links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural($blog->comments, t("comment"), t("comments")) ."</a>";
+ $links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural(node_get_comments($blog->nid), t("comment"), t("comments")) ."</a>";
}
$output .= "<tr><td><b>". check_output($blog->title) ."</b></td><td align=\"right\">". $theme->links($links) ."</td></tr>";
@@ -162,101 +149,38 @@ function blog_page_last() {
$theme->box(t("User blogs"), $output, "main");
}
-function blog_remove($nid) {
- global $status, $user;
-
- $blog = node_get_object(array(nid => $nid, type => "blog"));
-
- if ($blog && $blog->uid == $user->uid) {
- node_del(array(type => "blog", nid => $nid));
- }
-}
+function blog_form($edit) {
-function blog_view($node, $main = 0) {
- global $theme;
+ $output = form_textarea(t("Body"), "body", $edit->body, 60, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
- $theme->node($node, $main);
+ return $output;
}
-function blog_form($edit = array()) {
- global $id, $mod, $type, $user, $theme;
-
- if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) {
- if ($mod == "node" || $edit[type] == "blog") {
- // do nothing
- }
- else if ($type == "blog") {
- $item = node_get_object(array(type => "blog", nid => $id));
- $edit["title"] = $item->title;
- $edit["body"] = "<i>". $item->body ."</i> [<a href=\"module.php?mod=blog&name=". urlencode($item->name) ."&date=$item->timestamp\">$item->name</a>]";
- }
- else if ($type == "import") {
- $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = '". check_input($id) ."' AND i.fid = f.fid"));
- $edit["title"] = $item->title;
- $edit["body"] = "<a href=\"$item->link\">$item->title</a> - <i>". check_output($item->description) ."</i> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
- }
-
- if ($edit["title"]) {
- $form .= blog_view(new Blog(node_preview($edit)));
- }
+function blog_save($node) {
+ global $user;
- $form .= form_textfield(t("Subject"), "title", $edit["title"], 50, 64);
- $form .= form_textarea(t("Body"), "body", $edit["body"], 70, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
+ if ($node->nid) {
- $form .= form_hidden("type", "blog");
+ /*
+ ** Load the original blog from the database to make sure that only
+ ** original author can update his blog.
+ */
- if ($edit["nid"] > 0) {
- $form .= form_hidden("nid", $edit["nid"]);
- }
+ $blog = node_load(array("nid" => $node->nid));
- if (!$edit) {
- $form .= form_submit(t("Preview"));
+ if ($user->uid && $user->uid == $node->uid && $user->uid == $blog->uid) {
+ return array();
}
- else if ($edit && !$edit["title"]) {
- $form .= "<font color=\"red\">". t("Warning: you did not supply a subject.") ."</font><p>\n";
- $form .= form_submit(t("Preview"));
- }
- else if ($edit && !$edit["body"]) {
- $form .= "<font color=\"red\">". t("Warning: you did not supply any text.") ."</font><p>\n";
- $form .= form_submit(t("Preview"));
+ else if (user_access("adminster nodes")) {
+ return array();
}
else {
- $form .= form_submit(t("Preview"));
- $form .= form_submit(t("Submit"));
+ return 0;
}
-
- return form($form);
}
else {
- return message_access();
- }
-}
-
-function blog_save($edit) {
- global $status, $user;
-
- if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) {
- if ($edit["nid"]) {
- node_save($edit, array(title, body, type => "blog"));
- }
- else {
- node_save($edit, array(attributes => node_attributes_save("blog", $edit), uid => $user->uid, body, comment => variable_get("blog_comment", 0), moderate => variable_get("blog_moderate", ""), promote => variable_get("blog_promote", 0), score => 0, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog", votes => 0));
- }
- }
-}
-
-function blog_edit_history($nid) {
- global $user;
-
- $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid WHERE n.uid = '$user->uid' AND n.nid <= '". check_input($nid) ."' ORDER BY b.nid DESC LIMIT 15");
-
- $output .= "<table cellpadding=\"3\" cellspacing=\"3\" border=\"0\" width=\"100%\">";
- while ($blog = db_fetch_object($result)) {
- $output .= "<tr><td><b>". check_output($blog->title) ."</b><br />". check_output($blog->body, 1) ."</td><td><a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a></td><td><a href=\"submit.php?mod=blog&op=delete&id=$blog->nid\">". t("delete") ."</a></td></tr>\n";
+ return array("promote" => 0, "moderate" => 0, "status" => 1);
}
- $output .= "</table>";
-
- return $output;
}
function blog_page() {
@@ -291,33 +215,6 @@ function blog_page() {
}
-function blog_user() {
- global $op, $id, $edit, $theme, $user;
-
- if (user_access("post blogs")) {
- switch ($op) {
- case "delete":
- blog_remove($id);
- blog_page_user($user->uid, time());
- break;
- case "edit":
- $theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog"))), "main");
- $theme->box(t("Older blogs"), blog_edit_history($id), "main");
- break;
- case t("Preview"):
- $theme->box(t("Preview Blog"), blog_form($edit), "main");
- break;
- case t("Submit"):
- blog_save($edit);
- blog_page_user($user->uid, time());
- break;
- default:
- $theme->box(t("Submit a blog"), blog_form($edit), "main");
- }
- }
-}
-
-
function blog_link($type, $node = 0) {
global $user;
@@ -326,7 +223,7 @@ function blog_link($type, $node = 0) {
}
if ($type == "menu" && user_access("post blogs")) {
- $links[] = "<a href=\"submit.php?mod=blog\">". t("add blog entry") ."</a>";
+ $links[] = "<a href=\"module.php?mod=node&op=add&type=blog\">". t("add blog entry") ."</a>";
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\">". t("view your blog") ."</a>";
}
@@ -341,7 +238,7 @@ function blog_link($type, $node = 0) {
function blog_block() {
global $user;
- $result = db_query("SELECT u.uid, u.name, n.timestamp, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10");
+ $result = db_query("SELECT u.uid, u.name, n.created, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10");
while ($node = db_fetch_object($result)) {
$output .= "<a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a><br />\n";
@@ -357,107 +254,4 @@ function blog_block() {
return $block;
}
-
-function blog_search($keys) {
- global $PHP_SELF, $status;
-
- $result = db_query("SELECT n.*, b.* FROM blog b LEFT JOIN node n ON n.nid = b.nid WHERE (n.title LIKE '%$keys%' OR b.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
- while ($blog = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($blog->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->name, "date" => $blog->timestamp);
- }
- return $find;
-}
-
-class BlogCalendar {
- var $date;
- var $name;
-
- function BlogCalendar($name, $date) {
- $this->name = urlencode($name);
-
- // Prevent future dates:
- $today = mktime(23, 59, 59, date("n", time()), date("d", time()), date("Y", time()));
- $this->date = (($date && $date <= $today) ? $date : $today);
- $this->date = mktime(23, 59, 59, date("n", $this->date), date("d", $this->date), date("Y", $this->date));
- }
-
- function display() {
- // Extract information from the given date:
- $month = date("n", $this->date);
- $year = date("Y", $this->date);
- $day = date("d", $this->date);
-
- // Extract today's date:
- $today = mktime(23, 59, 59, date("n", time()), date("d", time()), date("Y", time()));
-
- // Extract the timestamp of the last day of today's month:
- $thislast = mktime(23, 59, 59, date("n", time()), date("t", time()), date("Y", time()));
-
- // Extract first day of the month:
- $first = date("w", mktime(0, 0, 0, $month, 1, $year));
-
- // Extract last day of the month:
- $last = date("t", mktime(0, 0, 0, $month, 1, $year));
-
- // Calculate previous and next months dates and check for shorter months (28/30 days)
- $prevmonth = mktime(23, 59, 59, $month - 1, 1, $year);
- $prev = mktime(23, 59, 59, $month - 1, min(date("t", $prevmonth), $day), $year);
- $nextmonth = mktime(23, 59, 59, $month + 1, 1, $year);
- $next = mktime(23, 59, 59, $month + 1, min(date("t", $nextmonth), $day), $year);
-
- // Generate calendar header:
- $output .= "\n<!-- calendar -->\n";
- $output .= "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"1\">\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"7\"><B><A HREF=\"module.php?mod=blog&name=". urlencode($this->name) ."&date=$prev\" STYLE=\"text-decoration: none;\">&lt;&lt;</A> &nbsp; ". date("F Y", $this->date) ." &nbsp; " . ($next <= $thislast ? "<A HREF=\"module.php?mod=blog&name=". urlencode($this->name) ."&date=$next\" STYLE=\"text-decoration: none;\">&gt;&gt;</A>" : "&gt;&gt;") . "<B></TD></TR>\n";
-
- // Generate the days of the week:
- $output .= " <TR>";
- $somesunday = mktime(0, 0, 0, 3, 20, 1994);
- for ($i = 0; $i < 7; $i++) {
- $output .= "<TD ALIGN=\"center\">" . substr(ucfirst(t(date("l", $somesunday + $i * 86400))), 0, 1) . "</TD>";
- }
- $output .= "</TR>\n";
-
- // Initialize temporary variables:
- $nday = 1;
- $sday = $first;
-
- // Loop through all the days of the month:
- while ($nday <= $last) {
- // Set up blank days for first week of the month:
- if ($first) {
- $output .= " <TR><TD COLSPAN=\"$first\">&nbsp</TD>\n";
- $first = 0;
- }
-
- // Start every week on a new line:
- if ($sday == 0) $output .= " <TR>\n";
-
- // Print one cell:
- $date = mktime(23, 59, 59, $month, $nday, $year);
- if ($date == $this->date) $output .= " <TD ALIGN=\"center\" BGCOLOR=\"#CCCCCC\"><B>$nday</B></TD>\n";
- else if ($date > $today) $output .= " <TD ALIGN=\"center\">$nday</TD>\n";
- else $output .= " <TD ALIGN=\"center\"><A HREF=\"module.php?mod=blog&name=". urlencode($this->name) ."&date=$date\" STYLE=\"text-decoration: none;\">$nday</A></TD>\n";
-
- // Start every week on a new line:
- if ($sday == 6) $output .= " </TR>\n";
-
- // Update temporary variables:
- $sday++;
- $sday = $sday % 7;
- $nday++;
- }
-
- // Complete the calendar:
- if ($sday) {
- $end = 7 - $sday;
- $output .= " <TD COLSPAN=\"$end\">&nbsp;</TD>\n </TR>\n";
- }
- $output .= "</TABLE>\n\n";
-
- // Return calendar:
- return $output;
- }
-}
-
?>
diff --git a/modules/blog/blog.module b/modules/blog/blog.module
index f5341a746..97c9a8559 100644
--- a/modules/blog/blog.module
+++ b/modules/blog/blog.module
@@ -1,14 +1,6 @@
<?php
// $Id$
-class Blog {
- function Blog($blog) {
- global $user;
- $this = new Node($blog);
- $this->body = $blog[body];
- }
-}
-
function blog_help() {
?>
<p>Drupal's blog module allows registered users to maintain an online blog or diary. It provides easy-to-write and easy-to-read online diaries or journals that can be filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption.</p>
@@ -19,14 +11,6 @@ function blog_perm() {
return array("administer blogs", "access blogs", "post blogs");
}
-function blog_status() {
- return array(dumped, posted);
-}
-
-function blog_summary($node) {
- return $node->body;
-}
-
function blog_feed_user($uid = 0, $date = 0) {
global $user;
@@ -41,7 +25,7 @@ function blog_feed_user($uid = 0, $date = 0) {
$date = time();
}
- $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid WHERE u.uid = '$uid' AND n.timestamp > '". ($date - 2592000) ."' ORDER BY b.nid DESC LIMIT 15");
+ $result = db_query("SELECT n.nid, n.title, n.body, n.created, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid WHERE u.uid = '$uid' AND n.created > '". ($date - 2592000) ."' ORDER BY b.nid DESC LIMIT 15");
while ($blog = db_fetch_object($result)) {
$items .= format_rss_item($blog->title, path_uri() ."node.php?id=$blog->nid", $blog->body);
}
@@ -60,9 +44,9 @@ function blog_feed_user($uid = 0, $date = 0) {
}
function blog_feed_last() {
- $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid ORDER BY b.nid DESC LIMIT 15");
+ $result = db_query("SELECT n.nid, n.title, n.body, n.created, u.name, u.uid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid ORDER BY b.nid DESC LIMIT 15");
while ($blog = db_fetch_object($result)) {
- $items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&id=$blog->uid", $blog->body);
+ $items .= format_rss_item($blog->title, path_uri() ."module.php?mod=blog&op=view&id=$blog->nid", $blog->body);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
@@ -90,29 +74,31 @@ function blog_page_user($uid = 0, $date = 0) {
$date = time();
}
- $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid LEFT JOIN comments c ON n.nid = c.lid WHERE u.uid = '$account->uid' AND n.timestamp <= '$date' AND n.timestamp >= '". ($date - 2592000) ."' GROUP BY n.nid, n.title, n.comment, n.timestamp, b.body, u.uid, u.name ORDER BY n.nid DESC LIMIT 20");
+ $result = db_query("SELECT nid FROM node WHERE type = 'blog' AND uid = '$account->uid' AND created <= '$date' AND created >= '". ($date - 2592000) ."' ORDER BY nid DESC");
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">";
- while ($blog = db_fetch_object($result)) {
+ while ($node = db_fetch_object($result)) {
+
+ $blog = node_load(array("nid" => $node->nid));
$links = array();
- if ($date != date("dny", $blog->timestamp)) {
- $date = date("dny", $blog->timestamp);
- $output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&id=$blog->uid&date=". mktime(23, 59, 59, date("n", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)) ."\">". format_date($blog->timestamp, custom, "d M Y") .":</a></b></td></tr>";
+ if ($date != date("dny", $blog->created)) {
+ $date = date("dny", $blog->created);
+ $output .= "<tr><td colspan=\"2\"><b><a href=\"module.php?mod=blog&id=$blog->uid&date=". mktime(23, 59, 59, date("n", $blog->created), date("d", $blog->created), date("Y", $blog->created)) ."\">". format_date($blog->created, custom, "d M Y") .":</a></b></td></tr>";
}
if ($user->uid && $user->uid == $uid) {
- $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>";
+ $links[] = "<a href=\"module.php?mod=node&op=edit&id=$blog->nid\">". t("edit") ."</a>";
}
if ($user->uid && user_access("post blogs")) {
- $links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>";
+ $links[] = "<a href=\"module.php?mod=blog&op=blog&id=$blog->nid\">". t("blog it") ."</a>";
}
if ($blog->comment) {
- $links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural($blog->comments, t("comment"), t("comments")) ."</a>";
+ $links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural(node_get_comments($blog->nid), t("comment"), t("comments")) ."</a>";
}
$output .= "<tr><td><div style=\"margin-left: 20px;\"><b>". check_output($blog->title) ."</b></div></td><td align=\"right\">". $theme->links($links) ."</td></tr>";
@@ -129,26 +115,27 @@ function blog_page_user($uid = 0, $date = 0) {
function blog_page_last() {
global $theme, $user;
- $result = db_query("SELECT n.nid, n.title, n.comment, COUNT(c.cid) AS comments, n.timestamp, b.body, u.uid, u.name FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.uid = u.uid LEFT JOIN comments c ON n.nid = c.lid GROUP BY n.nid, n.title, n.comment, n.timestamp, b.body, u.uid, u.name ORDER BY n.nid DESC LIMIT 20");
+ $result = db_query("SELECT nid FROM node WHERE type = 'blog' ORDER BY nid DESC LIMIT 20");
$output .= "<table border=\"0\" cellpadding=\"4\" cellspacing=\"4\">";
- while ($blog = db_fetch_object($result)) {
+ while ($node = db_fetch_object($result)) {
+ $blog = node_load(array("nid" => $node->nid));
$links = array();
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$blog->uid\">". sprintf("%s's blog", $blog->name) ."</a>";
if ($blog->uid == $user->uid) {
- $links[] = "<a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a>";
+ $links[] = "<a href=\"module.php?mod=node&op=edit&id=$blog->nid\">". t("edit") ."</a>";
}
if ($user->uid && user_access("post blogs")) {
- $links[] = "<a href=\"submit.php?mod=blog&type=blog&id=$blog->nid\">". t("blog it") ."</a>";
+ $links[] = "<a href=\"module.php?mod=blog&op=blog&id=$blog->nid\">". t("blog it") ."</a>";
}
if ($blog->comment) {
- $links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural($blog->comments, t("comment"), t("comments")) ."</a>";
+ $links[] = "<a href=\"node.php?id=$blog->nid\">". format_plural(node_get_comments($blog->nid), t("comment"), t("comments")) ."</a>";
}
$output .= "<tr><td><b>". check_output($blog->title) ."</b></td><td align=\"right\">". $theme->links($links) ."</td></tr>";
@@ -162,101 +149,38 @@ function blog_page_last() {
$theme->box(t("User blogs"), $output, "main");
}
-function blog_remove($nid) {
- global $status, $user;
-
- $blog = node_get_object(array(nid => $nid, type => "blog"));
-
- if ($blog && $blog->uid == $user->uid) {
- node_del(array(type => "blog", nid => $nid));
- }
-}
+function blog_form($edit) {
-function blog_view($node, $main = 0) {
- global $theme;
+ $output = form_textarea(t("Body"), "body", $edit->body, 60, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
- $theme->node($node, $main);
+ return $output;
}
-function blog_form($edit = array()) {
- global $id, $mod, $type, $user, $theme;
-
- if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) {
- if ($mod == "node" || $edit[type] == "blog") {
- // do nothing
- }
- else if ($type == "blog") {
- $item = node_get_object(array(type => "blog", nid => $id));
- $edit["title"] = $item->title;
- $edit["body"] = "<i>". $item->body ."</i> [<a href=\"module.php?mod=blog&name=". urlencode($item->name) ."&date=$item->timestamp\">$item->name</a>]";
- }
- else if ($type == "import") {
- $item = db_fetch_object(db_query("SELECT i.*, f.title as ftitle, f.link as flink FROM item i, feed f WHERE i.iid = '". check_input($id) ."' AND i.fid = f.fid"));
- $edit["title"] = $item->title;
- $edit["body"] = "<a href=\"$item->link\">$item->title</a> - <i>". check_output($item->description) ."</i> [<a href=\"$item->flink\">$item->ftitle</a>]\n";
- }
-
- if ($edit["title"]) {
- $form .= blog_view(new Blog(node_preview($edit)));
- }
+function blog_save($node) {
+ global $user;
- $form .= form_textfield(t("Subject"), "title", $edit["title"], 50, 64);
- $form .= form_textarea(t("Body"), "body", $edit["body"], 70, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
+ if ($node->nid) {
- $form .= form_hidden("type", "blog");
+ /*
+ ** Load the original blog from the database to make sure that only
+ ** original author can update his blog.
+ */
- if ($edit["nid"] > 0) {
- $form .= form_hidden("nid", $edit["nid"]);
- }
+ $blog = node_load(array("nid" => $node->nid));
- if (!$edit) {
- $form .= form_submit(t("Preview"));
+ if ($user->uid && $user->uid == $node->uid && $user->uid == $blog->uid) {
+ return array();
}
- else if ($edit && !$edit["title"]) {
- $form .= "<font color=\"red\">". t("Warning: you did not supply a subject.") ."</font><p>\n";
- $form .= form_submit(t("Preview"));
- }
- else if ($edit && !$edit["body"]) {
- $form .= "<font color=\"red\">". t("Warning: you did not supply any text.") ."</font><p>\n";
- $form .= form_submit(t("Preview"));
+ else if (user_access("adminster nodes")) {
+ return array();
}
else {
- $form .= form_submit(t("Preview"));
- $form .= form_submit(t("Submit"));
+ return 0;
}
-
- return form($form);
}
else {
- return message_access();
- }
-}
-
-function blog_save($edit) {
- global $status, $user;
-
- if ($user->uid && (user_access("administer blogs") || user_access("post blogs"))) {
- if ($edit["nid"]) {
- node_save($edit, array(title, body, type => "blog"));
- }
- else {
- node_save($edit, array(attributes => node_attributes_save("blog", $edit), uid => $user->uid, body, comment => variable_get("blog_comment", 0), moderate => variable_get("blog_moderate", ""), promote => variable_get("blog_promote", 0), score => 0, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog", votes => 0));
- }
- }
-}
-
-function blog_edit_history($nid) {
- global $user;
-
- $result = db_query("SELECT n.nid, n.title, n.timestamp, b.body FROM blog b LEFT JOIN node n ON b.nid = n.nid WHERE n.uid = '$user->uid' AND n.nid <= '". check_input($nid) ."' ORDER BY b.nid DESC LIMIT 15");
-
- $output .= "<table cellpadding=\"3\" cellspacing=\"3\" border=\"0\" width=\"100%\">";
- while ($blog = db_fetch_object($result)) {
- $output .= "<tr><td><b>". check_output($blog->title) ."</b><br />". check_output($blog->body, 1) ."</td><td><a href=\"submit.php?mod=blog&op=edit&id=$blog->nid\">". t("edit") ."</a></td><td><a href=\"submit.php?mod=blog&op=delete&id=$blog->nid\">". t("delete") ."</a></td></tr>\n";
+ return array("promote" => 0, "moderate" => 0, "status" => 1);
}
- $output .= "</table>";
-
- return $output;
}
function blog_page() {
@@ -291,33 +215,6 @@ function blog_page() {
}
-function blog_user() {
- global $op, $id, $edit, $theme, $user;
-
- if (user_access("post blogs")) {
- switch ($op) {
- case "delete":
- blog_remove($id);
- blog_page_user($user->uid, time());
- break;
- case "edit":
- $theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog"))), "main");
- $theme->box(t("Older blogs"), blog_edit_history($id), "main");
- break;
- case t("Preview"):
- $theme->box(t("Preview Blog"), blog_form($edit), "main");
- break;
- case t("Submit"):
- blog_save($edit);
- blog_page_user($user->uid, time());
- break;
- default:
- $theme->box(t("Submit a blog"), blog_form($edit), "main");
- }
- }
-}
-
-
function blog_link($type, $node = 0) {
global $user;
@@ -326,7 +223,7 @@ function blog_link($type, $node = 0) {
}
if ($type == "menu" && user_access("post blogs")) {
- $links[] = "<a href=\"submit.php?mod=blog\">". t("add blog entry") ."</a>";
+ $links[] = "<a href=\"module.php?mod=node&op=add&type=blog\">". t("add blog entry") ."</a>";
$links[] = "<a href=\"module.php?mod=blog&op=view&id=$user->uid\">". t("view your blog") ."</a>";
}
@@ -341,7 +238,7 @@ function blog_link($type, $node = 0) {
function blog_block() {
global $user;
- $result = db_query("SELECT u.uid, u.name, n.timestamp, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10");
+ $result = db_query("SELECT u.uid, u.name, n.created, n.title, n.nid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10");
while ($node = db_fetch_object($result)) {
$output .= "<a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a><br />\n";
@@ -357,107 +254,4 @@ function blog_block() {
return $block;
}
-
-function blog_search($keys) {
- global $PHP_SELF, $status;
-
- $result = db_query("SELECT n.*, b.* FROM blog b LEFT JOIN node n ON n.nid = b.nid WHERE (n.title LIKE '%$keys%' OR b.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
- while ($blog = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($blog->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->name, "date" => $blog->timestamp);
- }
- return $find;
-}
-
-class BlogCalendar {
- var $date;
- var $name;
-
- function BlogCalendar($name, $date) {
- $this->name = urlencode($name);
-
- // Prevent future dates:
- $today = mktime(23, 59, 59, date("n", time()), date("d", time()), date("Y", time()));
- $this->date = (($date && $date <= $today) ? $date : $today);
- $this->date = mktime(23, 59, 59, date("n", $this->date), date("d", $this->date), date("Y", $this->date));
- }
-
- function display() {
- // Extract information from the given date:
- $month = date("n", $this->date);
- $year = date("Y", $this->date);
- $day = date("d", $this->date);
-
- // Extract today's date:
- $today = mktime(23, 59, 59, date("n", time()), date("d", time()), date("Y", time()));
-
- // Extract the timestamp of the last day of today's month:
- $thislast = mktime(23, 59, 59, date("n", time()), date("t", time()), date("Y", time()));
-
- // Extract first day of the month:
- $first = date("w", mktime(0, 0, 0, $month, 1, $year));
-
- // Extract last day of the month:
- $last = date("t", mktime(0, 0, 0, $month, 1, $year));
-
- // Calculate previous and next months dates and check for shorter months (28/30 days)
- $prevmonth = mktime(23, 59, 59, $month - 1, 1, $year);
- $prev = mktime(23, 59, 59, $month - 1, min(date("t", $prevmonth), $day), $year);
- $nextmonth = mktime(23, 59, 59, $month + 1, 1, $year);
- $next = mktime(23, 59, 59, $month + 1, min(date("t", $nextmonth), $day), $year);
-
- // Generate calendar header:
- $output .= "\n<!-- calendar -->\n";
- $output .= "<TABLE WIDTH=\"100%\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"1\">\n";
- $output .= " <TR><TD ALIGN=\"center\" COLSPAN=\"7\"><B><A HREF=\"module.php?mod=blog&name=". urlencode($this->name) ."&date=$prev\" STYLE=\"text-decoration: none;\">&lt;&lt;</A> &nbsp; ". date("F Y", $this->date) ." &nbsp; " . ($next <= $thislast ? "<A HREF=\"module.php?mod=blog&name=". urlencode($this->name) ."&date=$next\" STYLE=\"text-decoration: none;\">&gt;&gt;</A>" : "&gt;&gt;") . "<B></TD></TR>\n";
-
- // Generate the days of the week:
- $output .= " <TR>";
- $somesunday = mktime(0, 0, 0, 3, 20, 1994);
- for ($i = 0; $i < 7; $i++) {
- $output .= "<TD ALIGN=\"center\">" . substr(ucfirst(t(date("l", $somesunday + $i * 86400))), 0, 1) . "</TD>";
- }
- $output .= "</TR>\n";
-
- // Initialize temporary variables:
- $nday = 1;
- $sday = $first;
-
- // Loop through all the days of the month:
- while ($nday <= $last) {
- // Set up blank days for first week of the month:
- if ($first) {
- $output .= " <TR><TD COLSPAN=\"$first\">&nbsp</TD>\n";
- $first = 0;
- }
-
- // Start every week on a new line:
- if ($sday == 0) $output .= " <TR>\n";
-
- // Print one cell:
- $date = mktime(23, 59, 59, $month, $nday, $year);
- if ($date == $this->date) $output .= " <TD ALIGN=\"center\" BGCOLOR=\"#CCCCCC\"><B>$nday</B></TD>\n";
- else if ($date > $today) $output .= " <TD ALIGN=\"center\">$nday</TD>\n";
- else $output .= " <TD ALIGN=\"center\"><A HREF=\"module.php?mod=blog&name=". urlencode($this->name) ."&date=$date\" STYLE=\"text-decoration: none;\">$nday</A></TD>\n";
-
- // Start every week on a new line:
- if ($sday == 6) $output .= " </TR>\n";
-
- // Update temporary variables:
- $sday++;
- $sday = $sday % 7;
- $nday++;
- }
-
- // Complete the calendar:
- if ($sday) {
- $end = 7 - $sday;
- $output .= " <TD COLSPAN=\"$end\">&nbsp;</TD>\n </TR>\n";
- }
- $output .= "</TABLE>\n\n";
-
- // Return calendar:
- return $output;
- }
-}
-
?>
diff --git a/modules/book.module b/modules/book.module
index a965a8ea8..39be32c66 100644
--- a/modules/book.module
+++ b/modules/book.module
@@ -1,33 +1,53 @@
<?php
// $Id$
-class Book {
- function Book($book) {
- $this = new Node($book);
- $this->body = $book[body];
- $this->parent = $book[parent];
- $this->weight = $book[weight];
+function book_link($type) {
+ if ($type == "page" && user_access("access content")) {
+ $links[] = "<a href=\"module.php?mod=book\">". t("collaborative book") ."</a>";
}
+
+ return $links ? $links : array();
}
-function book_perm() {
- return array("administer book");
+function book_load($node) {
+ $book = db_fetch_object(db_query("SELECT parent, weight FROM book WHERE nid = '$node->nid'"));
+ return $book;
}
-function book_link($type) {
- if ($type == "admin" && user_access("administer book")) {
- $links[] = "<a href=\"admin.php?mod=book\">collaborative book</a>";
+function book_insert($node) {
+ if ($node->pid && $node->status == 1) {
+ db_query("UPDATE node SET status = 0 WHERE nid = '$node->pid'");
}
+ db_query("INSERT INTO book (nid, pid, parent, weight, log) VALUES ('$node->nid', '$node->pid', '$node->parent', '$node->weight', '$node->log')");
+}
- if ($type == "page" && user_access("access content")) {
- $links[] = "<a href=\"module.php?mod=book\">". t("collaborative book") ."</a>";
+function book_update($node) {
+ if ($node->pid && $node->status == 1) {
+ db_query("UPDATE node SET status = 0 WHERE nid = '$node->pid'");
}
+ db_query("UPDATE book SET parent = '$node->parent', weight = '$node->weight', log = '$node->log' WHERE nid = '$node->nid'");
+}
- return $links ? $links : array();
+function book_delete($node) {
+ if ($node->pid && $node->status == 1) {
+ db_query("UPDATE node SET status = 1 WHERE nid = '$node->pid'");
+ }
+ db_query("DELETE FROM book WHERE nid = '$node->nid'");
}
-function book_status() {
- return array(dumped, expired, queued, posted);
+function book_save($node) {
+ if ($node->nid) {
+ if (user_access("administer nodes")) {
+ return array("moderate" => 1, "promote" => 0, "status" => 0, "log", "parent", "weight");
+ }
+ else {
+ // TODO: temporay disabled book page updates by regular users
+ return 0;
+ }
+ }
+ else {
+ return array("pid", "log", "parent", "weight");
+ }
}
function book_location($node, $nodes = array()) {
@@ -40,7 +60,7 @@ function book_location($node, $nodes = array()) {
}
function book_view($node, $main = 0) {
- global $status, $theme;
+ global $theme;
if ($main) {
$theme->node($node, $main);
@@ -48,8 +68,8 @@ function book_view($node, $main = 0) {
else {
if ($node->nid && $node->parent) {
$list = book_parent_query($node->parent);
- $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = '$status[posted]' AND $list AND (b.weight > '$node->weight' OR (b.weight = '$node->weight' AND n.title > '". check_query($node->title) ."')) ORDER BY b.weight ASC,n.title ASC"));
- $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = '$status[posted]' AND $list AND (b.weight < '$node->weight' OR (b.weight = '$node->weight' AND n.title < '". check_query($node->title) ."')) ORDER BY b.weight DESC,n.title DESC"));
+ $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND $list AND (b.weight > '$node->weight' OR (b.weight = '$node->weight' AND n.title > '". check_query($node->title) ."')) ORDER BY b.weight ASC,n.title ASC"));
+ $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND $list AND (b.weight < '$node->weight' OR (b.weight = '$node->weight' AND n.title < '". check_query($node->title) ."')) ORDER BY b.weight DESC,n.title DESC"));
}
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
@@ -60,9 +80,10 @@ function book_view($node, $main = 0) {
$indent .= "-";
}
- $output .= " <TR><TD COLSPAN=\"2\">$location</TD><TD ALIGN=\"right\">". node_control($node) ."</TD></TR>\n";
+ $output .= " <TR><TD COLSPAN=\"3\">$location</TD></TR>";
+// TODO: <TD ALIGN=\"right\">". node_control($node) ."</TD></TR>\n";
$output .= " <TR><TD COLSPAN=\"3\"><HR></TD></TR>";
- $output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n";
+ $output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node) ." on ". format_date($node->created) ."</I></SMALL> " : "") ."</TD></TR>\n";
}
if ($node->body) {
@@ -82,15 +103,6 @@ function book_view($node, $main = 0) {
}
}
-function book_search($keys) {
- global $PHP_SELF, $status;
- $result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN book b ON n.nid = b.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
- while ($node = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($node->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->name, "date" => $node->timestamp);
- }
- return $find;
-}
-
function book_parent_query($parent) {
if ($parent > 0) {
$list = array();
@@ -103,10 +115,9 @@ function book_parent_query($parent) {
}
function book_toc($parent = "", $indent = "", $toc = array()) {
- global $status;
// select all child nodes:
- $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = '$status[posted]' AND ". book_parent_query($parent) ." ORDER BY b.weight");
+ $result = db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = 1 AND ". book_parent_query($parent) ." ORDER BY b.weight");
// add root node:
if (user_access("administer nodes")) {
@@ -122,81 +133,26 @@ function book_toc($parent = "", $indent = "", $toc = array()) {
return $toc;
}
-function book_form($edit = array()) {
+function book_form($node) {
global $user;
- if ($edit[title]) {
- $form .= book_view(new Book(node_preview($edit)));
- }
-
- $form .= form_item(t("Author"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
- $form .= form_hidden(name, $edit[name]);
- $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
-
- $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], 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."));
+ $output .= form_select(t("Parent"), "parent", $node->parent, book_toc(), t("The parent subject or category the page belongs in."));
+ $output .= form_textarea(t("Content"), "body", $node->body, 60, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
+ $output .= form_textarea(t("Log message"), "log", $node->log, 60, 5, t("An explanation of the additions or updates being made to help the group understand your motivations."));
if (user_access("administer nodes")) {
- $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."));
- }
-
- if ($edit[nid] > 0) {
- $form .= form_hidden("nid", $edit[nid]);
- }
-
- if ($edit[pid] > 0) {
- $form .= form_hidden("pid", $edit[pid]);
- }
-
- if (!$edit) {
- $form .= form_submit(t("Preview"));
- }
- else if ($edit && !$edit[title]) {
- $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a title.") ."</FONT><P>\n";
- $form .= form_submit(t("Preview"));
+ $output .= form_select(t("Weight"), "weight", $node->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."));
}
- else {
- $form .= form_submit(t("Preview"));
- $form .= form_submit(t("Submit"));
- }
-
- return form($form);
-}
-
-function book_save($edit) {
- global $status, $user;
-
- if (!$edit[nid]) {
- node_save($edit, array(uid => $user->uid, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, 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("administer nodes")) {
- node_save($edit, array(body, log, parent, title, type => "book", weight));
- }
-}
-function book_delete($node) {
- if ($node->pid && $node->status == node_status("posted")) {
- db_query("UPDATE node SET status = '". node_status("posted") ."' WHERE nid = '$node->pid'");
+ if ($node->pid > 0) {
+ $output .= form_hidden("pid", $node->pid);
}
-}
-function book_insert($node) {
- if ($node->pid && $node->status == node_status("posted")) {
- db_query("UPDATE node SET status = '". node_status("expired") ."' WHERE nid = '$node->pid'");
- }
-}
-
-function book_update($node) {
- if ($node->pid && $node->status == node_status("posted")) {
- db_query("UPDATE node SET status = '". node_status("expired") ."' WHERE nid = '$node->pid'");
- }
+ return $output;
}
function book_parent($nid) {
- global $status;
- if ($node = node_get_object(array("nid" => $nid))) {
+ if ($node = node_load(array("nid" => $nid))) {
$list[$nid] = $nid;
}
if ($node->pid) {
@@ -206,11 +162,11 @@ function book_parent($nid) {
}
function book_tree($parent = "", $depth = 0) {
- global $PHP_SELF, $status;
+ global $PHP_SELF;
if ($depth < 3 || strstr($PHP_SELF,"admin.php")) {
// select all child nodes:
- $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = '$status[posted]' AND ". book_parent_query($parent) ." ORDER BY b.weight, n.title");
+ $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = 1 AND ". book_parent_query($parent) ." ORDER BY b.weight, n.title");
// render output:
while ($node = db_fetch_object($result)) {
@@ -222,19 +178,10 @@ function book_tree($parent = "", $depth = 0) {
return $output;
}
-function book_admin() {
- if (user_access("administer book")) {
- print book_tree();
- }
- else {
- print message_access();
- }
-}
-
function book_render() {
- global $status, $theme;
+ global $theme;
- $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.parent = 0 AND n.status = $status[posted] ORDER BY b.weight");
+ $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.parent = 0 AND n.status = 1 ORDER BY b.weight");
while ($node = db_fetch_object($result)) {
$output .= "<DT><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></DT><DD>". check_output($node->body, 1) ."<BR><BR></DD>";
@@ -265,47 +212,9 @@ function book_page() {
}
}
-function book_edit($id) {
- global $status;
-
- if ($node = node_get_object(array("nid" => $id))) {
- if ($node->status != $status[posted]) {
- return t("You can only update accepted pages: pages that are still queued or already expired can not be updated.");
- }
- else if (db_result(db_query("SELECT COUNT(n.nid) FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.pid = '$node->nid' AND n.status = '$status[queued]'"))) {
- return t("There is already an update for this node in the queue: we can only process one update at once.");
- }
- else {
- return book_form(array(nid => -1, pid => $id, title => $node->title, body => $node->body, parent => $node->parent));
- }
- }
-}
-
-function book_user() {
- global $edit, $id, $op, $theme, $user;
-
- $title = t("Submit");
-
- switch($op) {
- case "update":
- $theme->box($title, book_edit($id));
- break;
- case t("Preview"):
- $theme->box($title, book_form($edit));
- break;
- case t("Submit"):
- book_save($edit);
- $theme->box($title, t("Thank you for your submission."));
- break;
- default:
- $theme->box($title, book_form());
- }
-}
-
function book_export_html($id = "", $depth = 1) {
- global $status;
- $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = '$status[posted]' AND n.nid = '". check_input($id) ."'");
+ $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = 1 AND n.nid = '". check_input($id) ."'");
while ($node = db_fetch_object($result)) {
$output .= "<H$depth>". check_output($node->title) ."</H$depth>";
@@ -317,9 +226,7 @@ function book_export_html($id = "", $depth = 1) {
}
function book_export_html_recursive($parent = "", $depth = 1) {
- global $status;
-
- $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
+ $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = 1 AND b.parent = '$parent' ORDER BY b.weight");
while ($node = db_fetch_object($result)) {
$output .= "<H$depth>". check_output($node->title) ."</H$depth>";
@@ -330,5 +237,5 @@ function book_export_html_recursive($parent = "", $depth = 1) {
return $output;
}
-
+
?>
diff --git a/modules/book/book.module b/modules/book/book.module
index a965a8ea8..39be32c66 100644
--- a/modules/book/book.module
+++ b/modules/book/book.module
@@ -1,33 +1,53 @@
<?php
// $Id$
-class Book {
- function Book($book) {
- $this = new Node($book);
- $this->body = $book[body];
- $this->parent = $book[parent];
- $this->weight = $book[weight];
+function book_link($type) {
+ if ($type == "page" && user_access("access content")) {
+ $links[] = "<a href=\"module.php?mod=book\">". t("collaborative book") ."</a>";
}
+
+ return $links ? $links : array();
}
-function book_perm() {
- return array("administer book");
+function book_load($node) {
+ $book = db_fetch_object(db_query("SELECT parent, weight FROM book WHERE nid = '$node->nid'"));
+ return $book;
}
-function book_link($type) {
- if ($type == "admin" && user_access("administer book")) {
- $links[] = "<a href=\"admin.php?mod=book\">collaborative book</a>";
+function book_insert($node) {
+ if ($node->pid && $node->status == 1) {
+ db_query("UPDATE node SET status = 0 WHERE nid = '$node->pid'");
}
+ db_query("INSERT INTO book (nid, pid, parent, weight, log) VALUES ('$node->nid', '$node->pid', '$node->parent', '$node->weight', '$node->log')");
+}
- if ($type == "page" && user_access("access content")) {
- $links[] = "<a href=\"module.php?mod=book\">". t("collaborative book") ."</a>";
+function book_update($node) {
+ if ($node->pid && $node->status == 1) {
+ db_query("UPDATE node SET status = 0 WHERE nid = '$node->pid'");
}
+ db_query("UPDATE book SET parent = '$node->parent', weight = '$node->weight', log = '$node->log' WHERE nid = '$node->nid'");
+}
- return $links ? $links : array();
+function book_delete($node) {
+ if ($node->pid && $node->status == 1) {
+ db_query("UPDATE node SET status = 1 WHERE nid = '$node->pid'");
+ }
+ db_query("DELETE FROM book WHERE nid = '$node->nid'");
}
-function book_status() {
- return array(dumped, expired, queued, posted);
+function book_save($node) {
+ if ($node->nid) {
+ if (user_access("administer nodes")) {
+ return array("moderate" => 1, "promote" => 0, "status" => 0, "log", "parent", "weight");
+ }
+ else {
+ // TODO: temporay disabled book page updates by regular users
+ return 0;
+ }
+ }
+ else {
+ return array("pid", "log", "parent", "weight");
+ }
}
function book_location($node, $nodes = array()) {
@@ -40,7 +60,7 @@ function book_location($node, $nodes = array()) {
}
function book_view($node, $main = 0) {
- global $status, $theme;
+ global $theme;
if ($main) {
$theme->node($node, $main);
@@ -48,8 +68,8 @@ function book_view($node, $main = 0) {
else {
if ($node->nid && $node->parent) {
$list = book_parent_query($node->parent);
- $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = '$status[posted]' AND $list AND (b.weight > '$node->weight' OR (b.weight = '$node->weight' AND n.title > '". check_query($node->title) ."')) ORDER BY b.weight ASC,n.title ASC"));
- $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = '$status[posted]' AND $list AND (b.weight < '$node->weight' OR (b.weight = '$node->weight' AND n.title < '". check_query($node->title) ."')) ORDER BY b.weight DESC,n.title DESC"));
+ $next = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND $list AND (b.weight > '$node->weight' OR (b.weight = '$node->weight' AND n.title > '". check_query($node->title) ."')) ORDER BY b.weight ASC,n.title ASC"));
+ $prev = db_fetch_object(db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.status = 1 AND $list AND (b.weight < '$node->weight' OR (b.weight = '$node->weight' AND n.title < '". check_query($node->title) ."')) ORDER BY b.weight DESC,n.title DESC"));
}
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"0\" CELLSPACING=\"0\" WIDTH=\"100%\">\n";
@@ -60,9 +80,10 @@ function book_view($node, $main = 0) {
$indent .= "-";
}
- $output .= " <TR><TD COLSPAN=\"2\">$location</TD><TD ALIGN=\"right\">". node_control($node) ."</TD></TR>\n";
+ $output .= " <TR><TD COLSPAN=\"3\">$location</TD></TR>";
+// TODO: <TD ALIGN=\"right\">". node_control($node) ."</TD></TR>\n";
$output .= " <TR><TD COLSPAN=\"3\"><HR></TD></TR>";
- $output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node) ." on ". format_date($node->timestamp) ."</I></SMALL> " : "") ."</TD></TR>\n";
+ $output .= " <TR><TD COLSPAN=\"3\"><B><BIG>". check_output($node->title) ."</BIG></B>". ($node->body ? "<BR><SMALL><I>Last updated by ". format_name($node) ." on ". format_date($node->created) ."</I></SMALL> " : "") ."</TD></TR>\n";
}
if ($node->body) {
@@ -82,15 +103,6 @@ function book_view($node, $main = 0) {
}
}
-function book_search($keys) {
- global $PHP_SELF, $status;
- $result = db_query("SELECT n.*, u.name FROM node n LEFT JOIN book b ON n.nid = b.nid LEFT JOIN users u ON n.uid = u.uid WHERE n.type = 'book' AND n.status = '$status[posted]' AND (n.title LIKE '%". check_input($keys) ."%' OR b.body LIKE '%". check_input($keys) ."%') ORDER BY n.timestamp DESC LIMIT 20");
- while ($node = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($node->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=book&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->name, "date" => $node->timestamp);
- }
- return $find;
-}
-
function book_parent_query($parent) {
if ($parent > 0) {
$list = array();
@@ -103,10 +115,9 @@ function book_parent_query($parent) {
}
function book_toc($parent = "", $indent = "", $toc = array()) {
- global $status;
// select all child nodes:
- $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = '$status[posted]' AND ". book_parent_query($parent) ." ORDER BY b.weight");
+ $result = db_query("SELECT n.nid, n.title FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = 1 AND ". book_parent_query($parent) ." ORDER BY b.weight");
// add root node:
if (user_access("administer nodes")) {
@@ -122,81 +133,26 @@ function book_toc($parent = "", $indent = "", $toc = array()) {
return $toc;
}
-function book_form($edit = array()) {
+function book_form($node) {
global $user;
- if ($edit[title]) {
- $form .= book_view(new Book(node_preview($edit)));
- }
-
- $form .= form_item(t("Author"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
- $form .= form_hidden(name, $edit[name]);
- $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
-
- $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], 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."));
+ $output .= form_select(t("Parent"), "parent", $node->parent, book_toc(), t("The parent subject or category the page belongs in."));
+ $output .= form_textarea(t("Content"), "body", $node->body, 60, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
+ $output .= form_textarea(t("Log message"), "log", $node->log, 60, 5, t("An explanation of the additions or updates being made to help the group understand your motivations."));
if (user_access("administer nodes")) {
- $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."));
- }
-
- if ($edit[nid] > 0) {
- $form .= form_hidden("nid", $edit[nid]);
- }
-
- if ($edit[pid] > 0) {
- $form .= form_hidden("pid", $edit[pid]);
- }
-
- if (!$edit) {
- $form .= form_submit(t("Preview"));
- }
- else if ($edit && !$edit[title]) {
- $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a title.") ."</FONT><P>\n";
- $form .= form_submit(t("Preview"));
+ $output .= form_select(t("Weight"), "weight", $node->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."));
}
- else {
- $form .= form_submit(t("Preview"));
- $form .= form_submit(t("Submit"));
- }
-
- return form($form);
-}
-
-function book_save($edit) {
- global $status, $user;
-
- if (!$edit[nid]) {
- node_save($edit, array(uid => $user->uid, body, comment => variable_get("book_comment", 0), log, moderate => variable_get("book_moderate", ""), parent, pid, 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("administer nodes")) {
- node_save($edit, array(body, log, parent, title, type => "book", weight));
- }
-}
-function book_delete($node) {
- if ($node->pid && $node->status == node_status("posted")) {
- db_query("UPDATE node SET status = '". node_status("posted") ."' WHERE nid = '$node->pid'");
+ if ($node->pid > 0) {
+ $output .= form_hidden("pid", $node->pid);
}
-}
-function book_insert($node) {
- if ($node->pid && $node->status == node_status("posted")) {
- db_query("UPDATE node SET status = '". node_status("expired") ."' WHERE nid = '$node->pid'");
- }
-}
-
-function book_update($node) {
- if ($node->pid && $node->status == node_status("posted")) {
- db_query("UPDATE node SET status = '". node_status("expired") ."' WHERE nid = '$node->pid'");
- }
+ return $output;
}
function book_parent($nid) {
- global $status;
- if ($node = node_get_object(array("nid" => $nid))) {
+ if ($node = node_load(array("nid" => $nid))) {
$list[$nid] = $nid;
}
if ($node->pid) {
@@ -206,11 +162,11 @@ function book_parent($nid) {
}
function book_tree($parent = "", $depth = 0) {
- global $PHP_SELF, $status;
+ global $PHP_SELF;
if ($depth < 3 || strstr($PHP_SELF,"admin.php")) {
// select all child nodes:
- $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = '$status[posted]' AND ". book_parent_query($parent) ." ORDER BY b.weight, n.title");
+ $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = 1 AND ". book_parent_query($parent) ." ORDER BY b.weight, n.title");
// render output:
while ($node = db_fetch_object($result)) {
@@ -222,19 +178,10 @@ function book_tree($parent = "", $depth = 0) {
return $output;
}
-function book_admin() {
- if (user_access("administer book")) {
- print book_tree();
- }
- else {
- print message_access();
- }
-}
-
function book_render() {
- global $status, $theme;
+ global $theme;
- $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.parent = 0 AND n.status = $status[posted] ORDER BY b.weight");
+ $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.parent = 0 AND n.status = 1 ORDER BY b.weight");
while ($node = db_fetch_object($result)) {
$output .= "<DT><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A></DT><DD>". check_output($node->body, 1) ."<BR><BR></DD>";
@@ -265,47 +212,9 @@ function book_page() {
}
}
-function book_edit($id) {
- global $status;
-
- if ($node = node_get_object(array("nid" => $id))) {
- if ($node->status != $status[posted]) {
- return t("You can only update accepted pages: pages that are still queued or already expired can not be updated.");
- }
- else if (db_result(db_query("SELECT COUNT(n.nid) FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE b.pid = '$node->nid' AND n.status = '$status[queued]'"))) {
- return t("There is already an update for this node in the queue: we can only process one update at once.");
- }
- else {
- return book_form(array(nid => -1, pid => $id, title => $node->title, body => $node->body, parent => $node->parent));
- }
- }
-}
-
-function book_user() {
- global $edit, $id, $op, $theme, $user;
-
- $title = t("Submit");
-
- switch($op) {
- case "update":
- $theme->box($title, book_edit($id));
- break;
- case t("Preview"):
- $theme->box($title, book_form($edit));
- break;
- case t("Submit"):
- book_save($edit);
- $theme->box($title, t("Thank you for your submission."));
- break;
- default:
- $theme->box($title, book_form());
- }
-}
-
function book_export_html($id = "", $depth = 1) {
- global $status;
- $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = '$status[posted]' AND n.nid = '". check_input($id) ."'");
+ $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = 1 AND n.nid = '". check_input($id) ."'");
while ($node = db_fetch_object($result)) {
$output .= "<H$depth>". check_output($node->title) ."</H$depth>";
@@ -317,9 +226,7 @@ function book_export_html($id = "", $depth = 1) {
}
function book_export_html_recursive($parent = "", $depth = 1) {
- global $status;
-
- $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = '$status[posted]' AND b.parent = '$parent' ORDER BY b.weight");
+ $result = db_query("SELECT n.*, b.* FROM node n LEFT JOIN book b ON n.nid = b.nid WHERE n.type = 'book' AND n.status = 1 AND b.parent = '$parent' ORDER BY b.weight");
while ($node = db_fetch_object($result)) {
$output .= "<H$depth>". check_output($node->title) ."</H$depth>";
@@ -330,5 +237,5 @@ function book_export_html_recursive($parent = "", $depth = 1) {
return $output;
}
-
+
?>
diff --git a/modules/box.module b/modules/box.module
index b24481109..cea18119b 100644
--- a/modules/box.module
+++ b/modules/box.module
@@ -1,6 +1,5 @@
<?php
// $Id$
-// $Id$
function box_help() {
?>
@@ -139,5 +138,5 @@ function box_admin() {
print message_access();
}
}
-
+
?> \ No newline at end of file
diff --git a/modules/calendar.module b/modules/calendar.module
index dfb8aa319..3bf145714 100644
--- a/modules/calendar.module
+++ b/modules/calendar.module
@@ -100,5 +100,5 @@ function calendar_block() {
return $block;
}
-
+
?>
diff --git a/modules/comment.module b/modules/comment.module
index 1b789b6da..c45dfd924 100644
--- a/modules/comment.module
+++ b/modules/comment.module
@@ -28,8 +28,8 @@ function comment_edit($id) {
$comment = db_fetch_object($result);
$form .= form_item(t("Author"), format_name($comment));
- $form .= form_textfield(t("Subject"), "subject", $comment->subject, 50, 128);
- $form .= form_textarea(t("Comment"), "comment", $comment->comment, 50, 10);
+ $form .= form_textfield(t("Subject"), "subject", $comment->subject, 70, 128);
+ $form .= form_textarea(t("Comment"), "comment", $comment->comment, 70, 15);
$form .= form_submit(t("Submit"));
return form($form);
@@ -89,5 +89,5 @@ function comment_admin() {
print message_access();
}
}
-
+
?>
diff --git a/modules/comment/comment.module b/modules/comment/comment.module
index 1b789b6da..c45dfd924 100644
--- a/modules/comment/comment.module
+++ b/modules/comment/comment.module
@@ -28,8 +28,8 @@ function comment_edit($id) {
$comment = db_fetch_object($result);
$form .= form_item(t("Author"), format_name($comment));
- $form .= form_textfield(t("Subject"), "subject", $comment->subject, 50, 128);
- $form .= form_textarea(t("Comment"), "comment", $comment->comment, 50, 10);
+ $form .= form_textfield(t("Subject"), "subject", $comment->subject, 70, 128);
+ $form .= form_textarea(t("Comment"), "comment", $comment->comment, 70, 15);
$form .= form_submit(t("Submit"));
return form($form);
@@ -89,5 +89,5 @@ function comment_admin() {
print message_access();
}
}
-
+
?>
diff --git a/modules/cvs.module b/modules/cvs.module
index 82342c255..eb4cde0d5 100644
--- a/modules/cvs.module
+++ b/modules/cvs.module
@@ -57,5 +57,5 @@ function cvs_page() {
$theme->footer();
}
}
-
+
?> \ No newline at end of file
diff --git a/modules/forum.module b/modules/forum.module
index e8866de2b..5364b7e34 100644
--- a/modules/forum.module
+++ b/modules/forum.module
@@ -1,10 +1,6 @@
<?php
// $Id$
-function forum_status() {
- return array(dumped, posted);
-}
-
function forum_link($type) {
if ($type == "page" && user_access("access content")) {
$links[] = "<a href=\"module.php?mod=forum\">". t("forum") ."</a>";
@@ -19,20 +15,27 @@ function forum_view($node) {
$theme->box(t("Discussion forum"), $output);
}
-function forum_form($edit = array()) {
+function forum_form($node) {
- $form .= form_textfield("Subject", "title", $edit[title], 50, 64);
- $form .= form_textarea("Body", "body", $edit[body], 70, 10);
- $form .= form_hidden("nid", $edit[nid]);
- $form .= form_submit(t("Submit"));
+ $output .= form_textarea("Body", "body", $node->body, 60, 10);
- return form($form);
+ return $output;
}
-function forum_save($edit) {
- global $user, $status;
+function forum_save() {
+
+ if (user_access("administer nodes")) {
+ if ($node->nid) {
+ return array();
+ }
+ else {
+ return array("promote" => 0, "moderate" => 0, "status" => 1);
+ }
+ }
+ else {
+ return 0;
+ }
- node_save($edit, array(uid => $user->uid, body, comment => 1, moderate => 0, promote => 0, score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0));
}
function forum_num_comments($nid) {
@@ -52,10 +55,10 @@ function forum_page() {
$result = db_query("SELECT nid FROM node WHERE type = 'forum' ORDER BY title");
$output .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
- $output .= " <TR><TH>". t("Forum") ."</TH><TH>". t("Comments") ."</TH><TH>". t("Last comment") ."</TH><TH>". t("Moderators") ."</TH></TR>";
+ $output .= " <TR><TH>". t("Forum") ."</TH><TH>". t("Comments") ."</TH><TH>". t("Last comment") ."</TH></TR>";
while ($node = db_fetch_object($result)) {
- $node = node_get_object(array("nid" => $node->nid));
- $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A><BR><SMALL>". check_output($node->body, 1) ."</SMALL></TD><TD ALIGN=\"center\">". forum_num_comments($node->nid) ."</TD><TD ALIGN=\"center\">". forum_last_comment($node->nid) ."</TD><TD ALIGN=\"center\"><SMALL>". check_output($node->moderate) ."</SMALL></TD></TR>";
+ $node = node_load(array("nid" => $node->nid));
+ $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A><BR><SMALL>". check_output($node->body, 1) ."</SMALL></TD><TD ALIGN=\"center\">". forum_num_comments($node->nid) ."</TD><TD ALIGN=\"center\">". forum_last_comment($node->nid) ."</TD></TR>";
}
$output .= "</TABLE>\n";
@@ -69,5 +72,5 @@ function forum_page() {
$theme->footer();
}
}
-
+
?> \ No newline at end of file
diff --git a/modules/forum/forum.module b/modules/forum/forum.module
index e8866de2b..5364b7e34 100644
--- a/modules/forum/forum.module
+++ b/modules/forum/forum.module
@@ -1,10 +1,6 @@
<?php
// $Id$
-function forum_status() {
- return array(dumped, posted);
-}
-
function forum_link($type) {
if ($type == "page" && user_access("access content")) {
$links[] = "<a href=\"module.php?mod=forum\">". t("forum") ."</a>";
@@ -19,20 +15,27 @@ function forum_view($node) {
$theme->box(t("Discussion forum"), $output);
}
-function forum_form($edit = array()) {
+function forum_form($node) {
- $form .= form_textfield("Subject", "title", $edit[title], 50, 64);
- $form .= form_textarea("Body", "body", $edit[body], 70, 10);
- $form .= form_hidden("nid", $edit[nid]);
- $form .= form_submit(t("Submit"));
+ $output .= form_textarea("Body", "body", $node->body, 60, 10);
- return form($form);
+ return $output;
}
-function forum_save($edit) {
- global $user, $status;
+function forum_save() {
+
+ if (user_access("administer nodes")) {
+ if ($node->nid) {
+ return array();
+ }
+ else {
+ return array("promote" => 0, "moderate" => 0, "status" => 1);
+ }
+ }
+ else {
+ return 0;
+ }
- node_save($edit, array(uid => $user->uid, body, comment => 1, moderate => 0, promote => 0, score => 0, status => $status[posted], timestamp => time(), title, type => "forum", votes => 0));
}
function forum_num_comments($nid) {
@@ -52,10 +55,10 @@ function forum_page() {
$result = db_query("SELECT nid FROM node WHERE type = 'forum' ORDER BY title");
$output .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
- $output .= " <TR><TH>". t("Forum") ."</TH><TH>". t("Comments") ."</TH><TH>". t("Last comment") ."</TH><TH>". t("Moderators") ."</TH></TR>";
+ $output .= " <TR><TH>". t("Forum") ."</TH><TH>". t("Comments") ."</TH><TH>". t("Last comment") ."</TH></TR>";
while ($node = db_fetch_object($result)) {
- $node = node_get_object(array("nid" => $node->nid));
- $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A><BR><SMALL>". check_output($node->body, 1) ."</SMALL></TD><TD ALIGN=\"center\">". forum_num_comments($node->nid) ."</TD><TD ALIGN=\"center\">". forum_last_comment($node->nid) ."</TD><TD ALIGN=\"center\"><SMALL>". check_output($node->moderate) ."</SMALL></TD></TR>";
+ $node = node_load(array("nid" => $node->nid));
+ $output .= " <TR><TD><A HREF=\"node.php?id=$node->nid\">". check_output($node->title) ."</A><BR><SMALL>". check_output($node->body, 1) ."</SMALL></TD><TD ALIGN=\"center\">". forum_num_comments($node->nid) ."</TD><TD ALIGN=\"center\">". forum_last_comment($node->nid) ."</TD></TR>";
}
$output .= "</TABLE>\n";
@@ -69,5 +72,5 @@ function forum_page() {
$theme->footer();
}
}
-
+
?> \ No newline at end of file
diff --git a/modules/help.module b/modules/help.module
index 8bc9c21f3..49b41b454 100644
--- a/modules/help.module
+++ b/modules/help.module
@@ -17,5 +17,5 @@ function help_admin() {
}
}
}
-
+
?>
diff --git a/modules/help/help.module b/modules/help/help.module
index 8bc9c21f3..49b41b454 100644
--- a/modules/help/help.module
+++ b/modules/help/help.module
@@ -17,5 +17,5 @@ function help_admin() {
}
}
}
-
+
?>
diff --git a/modules/import.module b/modules/import.module
index 42f5e4ca3..51de2e52a 100644
--- a/modules/import.module
+++ b/modules/import.module
@@ -689,5 +689,5 @@ function import_page() {
}
}
}
-
+
?>
diff --git a/modules/locale.module b/modules/locale.module
index 32eb26c35..b6a84a31e 100644
--- a/modules/locale.module
+++ b/modules/locale.module
@@ -238,5 +238,5 @@ function locale($string) {
}
return $string;
}
-
+
?>
diff --git a/modules/locale/locale.module b/modules/locale/locale.module
index 32eb26c35..b6a84a31e 100644
--- a/modules/locale/locale.module
+++ b/modules/locale/locale.module
@@ -238,5 +238,5 @@ function locale($string) {
}
return $string;
}
-
+
?>
diff --git a/modules/meta.module b/modules/meta.module
index 254d17e5a..3fe7e78b4 100644
--- a/modules/meta.module
+++ b/modules/meta.module
@@ -190,5 +190,5 @@ function meta_admin() {
print message_access();
}
}
-
+
?> \ No newline at end of file
diff --git a/modules/node.module b/modules/node.module
index ed4ce2d7e..bf388d76a 100644
--- a/modules/node.module
+++ b/modules/node.module
@@ -1,25 +1,8 @@
<?php
// $Id$
-class Node {
- function Node($node) {
- global $user;
- $this->uid = $node[uid] ? $node[uid] : $user->uid;
- $this->nid = $node[nid];
- $this->type = $node[type];
- $this->comment = $node[comment] ? $node[comment] : variable_get($node[type]."_comment", 0);
- $this->name = $node[name] ? $node[name] : $user->name;
- $this->title = $node[title];
- $this->attributes = $node[attributes];
- $this->timestamp = $node[timestamp] ? $node[timestamp] : time();
- }
-}
-
function node_help() {
global $mod;
- ?>
- <P>Todo.</P>
- <?php
if ($mod == "node") {
foreach (module_list() as $name) {
@@ -35,9 +18,19 @@ function node_perm() {
return array("administer nodes", "access content", "post content");
}
+function node_search($keys) {
+ global $user;
+
+ $result = db_query("SELECT n.nid, n.title, n.created, u.uid, u.name FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.status = 1 AND (n.title LIKE '%$keys%' OR n.teaser LIKE '%$keys%' OR n.body LIKE '%$keys%') ORDER BY n.created DESC LIMIT 20");
+ while ($node = db_fetch_object($result)) {
+ $find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=node&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->name, "date" => $node->created);
+ }
+
+ return $find;
+}
+
function node_conf_options() {
$output .= form_select("Default number of nodes to display", "default_nodes_main", variable_get("default_nodes_main", 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), "The default maximum number of nodes to display on the main page.");
- $output .= form_select("Prompt for confirmation when deleting nodes", "default_nodes_confirm_delete", variable_get("default_nodes_confirm_delete", 1), array("Disabled", "Enabled"), "Prompt for confirmation when deleting nodes.");
return $output;
}
@@ -70,310 +63,160 @@ function node_filter($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_queued = '' WHERE timestamp_queued > 0 AND timestamp_queued < ". time());
- db_query("UPDATE node SET status = '". node_status("dumped") ."', timestamp_hidden = '' WHERE timestamp_hidden > 0 AND timestamp_hidden < ". time());
-}
-
function node_link($type, $node = 0) {
if ($type == "admin" && user_access("administer nodes")) {
- $links[] = "<a href=\"admin.php?mod=node\">content</a>";
+ $links[] = "<a href=\"admin.php?mod=node\">content management</a>";
+ }
+
+ if ($type == "page") {
+ $links[] = "<a href=\"module.php?mod=node&op=add\">submit</a>";
}
if ($type == "node") {
+
if ($node->links) {
$links = $node->links;
}
- if ($node->body) {
+
+ if ($node->teaser != $node->body) {
$links[] = "<a href=\"node.php?id=". $node->nid ."\">". t("read more") ."</a>";
}
+
if ($node->comment) {
$links[] = "<a href=\"node.php?id=". $node->nid ."\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>";
}
+
+ if (user_access("administer nodes")) {
+ $links[] = "<a href=\"admin.php?mod=node&op=edit&id=". $node->nid ."\">". t("edit") ."</a>";
+ }
}
return $links ? $links : array();
}
-function node_links($nid, $type) {
+function node_admin_settings($edit = array()) {
global $op;
- $link[] = ($op == "view") ? "view node" : "<A HREF=\"node.php?id=$nid\">view node</A>";
- $link[] = ($op == "content") ? "edit content" : "<A HREF=\"admin.php?mod=node&type=$type&op=content&id=$nid\">edit content</A>";
- $link[] = ($op == "option") ? "edit options" : "<A HREF=\"admin.php?mod=node&op=option&id=$nid\">edit options</A>";
- $link[] = ($op == "status") ? "edit status" : "<A HREF=\"admin.php?mod=node&op=status&id=$nid\">edit status</A>";
- $link[] = ($op == "attribute") ? "edit attribute" : "<A HREF=\"admin.php?mod=node&op=attribute&id=$nid\">edit attributes</A>";
- $link[] = "<a href=\"admin.php?mod=node&op=". (variable_get("default_nodes_confirm_delete", 1) ? "confirm+" : "") ."delete&id=$nid\">delete node</a>";
- return $link;
-}
-
-function node_overview($query) {
- global $user;
-
- $color = array("#ffffff", "#e5e5e5");
- $query = node_query($query ? $query : 0);
-
- $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid $query[1] LIMIT 50");
-
- $output .= status($query[0]);
- $output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
- $output .= " <tr><th>title</th><th>type</th><th>status</th><th>meta attributes</th><th>author</th><th>date</th></tr>\n";
+ if ($op == t("Save configuration")) {
+ /*
+ ** Save the configuration options:
+ */
- while ($node = db_fetch_object($result)) {
- $bg = $color[$i++ % sizeof($color)];
-
- $output .= " <tr bgcolor=\"$bg\"><td><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></td><td align=\"center\">$node->type</td><td>". node_status($node->status) ."</td><td>". check_output($node->attributes) ."</td><td>". format_name($node) ."</td><td>". format_date($node->timestamp, "small") ."</td></tr>\n";
- $output .= " <tr bgcolor=\"$bg\"><td align=\"right\" colspan=\"6\"><small>". implode(", ", node_links($node->nid, $node->type)) ."</small></td>\n";
+ foreach ($edit as $name => $value) variable_set($name, $value);
}
- $output .= "</table>\n";
- return $output;
-}
-
-function node_edit_option($id) {
-
- $node = node_get_object(array("nid" => $id));
-
- $form .= form_item("Title", check_output($node->title));
- $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
- $form .= form_select("Comment", "comment", $node->comment, node_comment_status(), "Allow users to post comments to this node.");
- $form .= form_select("Promote", "promote", $node->promote, node_promote_status(), "Promote this node on the main page.");
- $form .= form_hidden("nid", $node->nid);
- $form .= form_submit("Save node");
-
- return form($form, "post", "admin.php?mod=node&id=$node->nid");
-}
-
-function node_edit_attribute($id) {
+ if ($op == t("Reset to defaults")) {
+ /*
+ ** Reset the configuration options to their default value:
+ */
- $node = node_get_object(array("nid" => $id));
-
- $form .= form_item("Title", check_output($node->title));
- $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
- $form .= form_textfield("Attributes", "attributes", $node->attributes, 64, 128, "A comma-seperated list of attributes. Example: 'Software, Webserver, Apache'.");
- $form .= form_hidden("nid", $node->nid);
- $form .= form_submit("Save node");
-
- return form($form, "post", "admin.php?mod=node&id=$node->nid");
-}
-
-function node_edit_status($id) {
- $node = node_get_object(array("nid" => $id));
-
- $form .= form_item("Title", check_output($node->title));
- $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
- $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");
+ foreach ($edit as $name=>$value) variable_del($name);
+ }
- return form($form);
-}
+ $output .= node_conf_options();
+ $output .= form_submit(t("Save configuration"));
+ $output .= form_submit(t("Reset to defaults"));
-function node_edit_content($edit, $type) {
- $edit[type] = $type;
- return node_invoke($edit, "form");
+ return form($output);
}
-function node_save_content($edit, $type) {
- $edit[type] = $type;
- return node_invoke($edit, "save");
-}
+function node_admin_edit($node) {
-function node_delete($id) {
- return (node_del(array("nid" => $id)) ? "node has been deleted." : "failed to delete node.");
-}
+ if (is_numeric($node)) {
+ $node = node_array(node_load(array("nid" => $node)));
+ }
+ /*
+ ** Edit node:
+ */
-function node_delete_confirmation($id) {
+ $output .= "<h3>". t("Edit node") ."</h3>";
- $node = node_get_object(array("nid" => $id));
+ $output .= node_form($node);
- $form .= form_item(t("Do you really want to delete this node"), check_output($node->title));
- $form .= form_submit("Delete node");
- $form .= form_submit("Keep node");
+ /*
+ ** Edit comments:
+ */
- return form($form, "post", "admin.php?mod=node&id=$node->nid");
+ $output .= "<h3>". t("Edit comments") ."</h3>";
-}
+ $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE lid = '". $node["nid"] ."' ORDER BY c.timestamp");
-function node_query($type = -1) {
- $queries[] = array("all nodes: recent additions", "ORDER BY 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 timestamp_posted > 0 ORDER BY n.timestamp DESC");
- $queries[] = array("all nodes: scheduled to be queued", "WHERE timestamp_queued > 0 ORDER BY n.timestamp DESC");
- $queries[] = array("all nodes: scheduled to be hidden", "WHERE timestamp_hidden > 0 ORDER BY n.timestamp DESC");
-
- foreach (module_list() as $name) {
- if (module_hook($name, "status")) {
- $queries[] = array("$name: recent additions", "WHERE type = '$name' ORDER BY timestamp DESC");
- $statuses = module_invoke($name, "status");
- if (is_array($statuses)) {
- foreach (array_reverse($statuses) as $key=>$status) {
- $queries[] = array("$name: status set to '$status'", "WHERE type = '$name' AND n.status = '". node_status($status) ."' ORDER BY timestamp DESC");
- }
- $queries[] = array("$name: scheduled to be posted", "WHERE type = '$name' AND timestamp_posted > 0 ORDER BY timestamp DESC");
- $queries[] = array("$name: scheduled to be queued", "WHERE type = '$name' AND timestamp_queued > 0 ORDER BY timestamp DESC");
- $queries[] = array("$name: scheduled to be hidden", "WHERE type = '$name' AND timestamp_hidden > 0 ORDER BY timestamp DESC");
- }
- }
+ while ($comment = db_fetch_object($result)) {
+ $output .= "<a href=\"admin.php?mod=comment&op=edit&id=$comment->cid\">$comment->subject</a> by ". format_name($comment) ."<br />";
}
- return ($type < 0 ? $queries : $queries[$type]);
-}
+ return $output;
-function node_listing($queries) {
- global $mod;
- foreach ($queries as $key=>$array) {
- $output .= "<LI><A HREF=\"admin.php?mod=$mod&query=$key\">$array[0]</A></LI>\n";
- }
- return "<OL>$output</OL>\n";
}
-function node_setting() {
-
- $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 .= "<H3>Default settings for $name nodes</H3>";
- $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.");
- }
- }
+function node_admin_nodes() {
+ global $query;
- $form .= form_submit("Save settings");
- $form .= form_submit("Reset to defaults");
+ $queries = array(array("ORDER BY n.created DESC", "new nodes"), array("ORDER BY n.changed DESC", "updated nodes"), array("WHERE n.status = 1 AND n.moderate = 0 ORDER BY n.nid DESC", "published nodes"), array("WHERE n.status = 0 AND n.moderate = 0 ORDER BY n.nid DESC", "non-published nodes"), array("WHERE n.status = 1 AND n.moderate = 1 ORDER BY n.nid DESC", "pending nodes"), array("WHERE n.status = 1 AND n.promote = 1 ORDER BY n.nid DESC", "promoted nodes"));
- return form($form);
-}
+ $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid ". $queries[$query ? $query : 0][0] ." LIMIT 50");
-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));
+ foreach ($queries as $key => $value) {
+ $links[] = "<a href=\"admin.php?mod=node&op=nodes&query=$key\">$value[1]</a>";
}
- else if (isset($edit[attributes])) {
- node_save($edit, array(attributes));
- }
- else {
- node_save($edit, array(comment, promote));
- }
-}
-function node_module_find() {
+ $output .= "<small>". implode(" :: ", $links) ."</small><hr />";
- foreach (module_list() as $name) {
- if (module_hook($name, "user")) {
- $options .= "<OPTION VALUE=\"$name\">$name</OPTION>\n";
- }
+ $output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
+ $output .= " <tr><th>title</th><th>type</th><th>author</th><th>status</th><th colspan=\"2\">operations</th></tr>\n";
+ while ($node = db_fetch_object($result)) {
+ $output .= "<tr><td><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></td><td>$node->type</td><td nowrap=\"nowrap\">". format_name($node) ."</td><td>". ($node->status ? t("published") : t("not published")) ."</td><td nowrap=\"nowrap\"><a href=\"node.php?id=$node->nid\">view node</a></td><td nowrap=\"nowrap\"><a href=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</a></td></tr>";
}
+ $output .= "</table>";
- $output .= " <input size=\"50\" value=\"". check_form($keys) ."\" name=\"keys\" type=\"text\">\n";
- $output .= " <select name=\"type\">$options</select>\n";
- $output .= " <input type=\"submit\" value=\"Search\">\n";
-
- return form($output);
-}
-
-function node_edit($node) {
- $output .= form_item("Title", $node->title);
- $output .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
return $output;
}
function node_admin() {
- global $op, $id, $edit, $query, $type, $keys;
+ global $op, $id, $edit;
if (user_access("administer nodes")) {
- foreach (module_list() as $name) {
- if (module_hook($name, "status") && $name != "node") {
- $link[] = "<a href=\"admin.php?mod=node&type=$name&op=add\">add $name</a>";
- }
- }
+ /*
+ ** Compile a list of the administrative links:
+ */
- print "<small>". implode(" | ", $link) ." | <a href=\"admin.php?mod=node&op=default\">node settings</a> | <a href=\"admin.php?mod=node&op=listing\">node listings</a> | <a href=\"admin.php?mod=node&op=search\">search node</a> | <a href=\"admin.php?mod=node\">overview</a> | <a href=\"admin.php?mod=node&op=help\">help</a></small><hr />\n";
+ $links[] = "<a href=\"admin.php?mod=node&op=nodes\">nodes</a>";
+ $links[] = "<a href=\"admin.php?mod=node&op=search\">search content</a>";
+ $links[] = "<a href=\"admin.php?mod=node&op=settings\">settings</a>";
+ $links[] = "<a href=\"admin.php?mod=node&op=help\">help</a>";
- $id = check_input($edit[nid] ? $edit[nid] : $id);
+ print "<small>". implode(" &middot; ", $links) ."</small><hr />";
switch ($op) {
- case "add":
- print module_invoke($type, "form");
- break;
case "help":
print node_help();
break;
case "search":
- print node_module_find($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 "content":
- print node_edit_content(node_get_array(array("nid" => $id)), $type);
- break;
- case "default":
- print node_setting();
+ print search_type("node", "admin.php?mod=node&op=search");
break;
- case "confirm delete":
- print node_delete_confirmation($id);
- break;
- case "Delete node":
- 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(system_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);
+ case t("Save configuration"):
+ case t("Reset to defaults"):
+ case "settings":
+ print node_admin_settings($edit);
break;
case "edit":
- print node_edit(node_get_object(array("nid" => $id)));
- break;
- case "view":
- print node_module_view(node_get_array(array("nid" => $id)), $type);
+ print node_admin_edit($id);
break;
case t("Preview"):
- print node_edit_content($edit, $type);
+ print node_preview($edit);
break;
case t("Submit"):
- print status(node_save_content($edit, $type));
- // fall through:
+ print node_submit($edit);
+ print node_admin_nodes();
+ break;
+ case t("Delete"):
+ print node_remove($edit);
+ break;
default:
- print node_overview($query);
+ print node_admin_nodes();
}
}
else {
@@ -393,16 +236,14 @@ function node_block() {
function node_feed() {
- $result = db_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '". node_status("posted") ."' ORDER BY timestamp DESC LIMIT 15");
+ $result = db_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '1' ORDER BY created DESC LIMIT 15");
while ($node = db_fetch_object($result)) {
- $item = node_get_object(array("nid" => $node->nid, "type" => $node->type));
+ $item = node_load(array("nid" => $node->nid, "type" => $node->type));
- $title = $item->title;
$link = path_uri() ."node.php?id=$item->nid";
- $description = module_invoke($item->type, "summary", $item);
- $items .= format_rss_item($title, $link, $description);
+ $items .= format_rss_item($item->title, $link, $item->teaser);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
@@ -417,25 +258,320 @@ function node_feed() {
}
+
+function node_fixup($edit) {
+
+ global $user;
+
+ /*
+ ** Convert the node to an object if necessary:
+ */
+
+ $edit = node_object($edit);
+
+ /*
+ ** Validate the title field:
+ */
+
+ if (($edit->nid || $edit->body) && !$edit->title) {
+ $error["title"] = "<div style=\"color: red;\">". t("You have to specify a valid title.") ."</div>";
+ }
+
+ if (user_access("administer nodes")) {
+
+ /*
+ ** Setup default values if required:
+ */
+
+ if (!$edit->name) {
+ $edit->name = $user->name;
+ }
+
+ if (!$edit->created) {
+ $edit->created = time();
+ }
+
+ if (!$edit->date) {
+ $edit->date = date("M j, Y g:i a", $edit->created);
+ }
+
+ /*
+ ** Validate the "authored by"-field:
+ */
+
+ if ($account = user_load(array("name" => $edit->name))) {
+ $edit->uid = $account->uid;
+ }
+ else {
+ $error["name"] = "<div style=\"color: red;\">". sprintf(t("The name '%s' does not exist."), $edit->name) ."</div>";
+ }
+
+ /*
+ ** Validate the "authored on"-field:
+ */
+
+ if (strtotime($edit->date) > 1000) {
+ $edit->created = strtotime($edit->date);
+ }
+ else {
+ $error["date"] = "<div style=\"color: red;\">". t("You have to specifiy a valid date.") ."</div>";
+ }
+ }
+
+ return $error;
+}
+
+function node_form($edit) {
+
+ $error = node_fixup(&$edit);
+
+ $output .= "<div style=\"margin-right: 40px; float: left;\">";
+
+ /*
+ ** Add the default fields:
+ */
+
+ $output .= form_textfield(t("Title"), "title", $edit->title, 60, 64, $error["title"]);
+
+ if ($edit->body && !$edit->teaser) {
+ $edit->teaser = node_teaser($edit->body);
+ }
+
+ if ($edit->teaser) {
+ $output .= form_textarea(t("Teaser"), "teaser", $edit->teaser, 60, 5);
+ }
+
+ /*
+ ** Add the node specific parts:
+ */
+
+ $output .= module_invoke($edit->type, "form", $edit);
+
+ /*
+ ** Add the hidden fields:
+ */
+
+ if ($edit->nid) {
+ $output .= form_hidden("nid", $edit->nid);
+ }
+
+ if ($edit->uid) {
+ $output .= form_hidden("uid", $edit->uid);
+ }
+
+ if ($edit->created) {
+ $output .= form_hidden("created", $edit->created);
+ }
+
+ $output .= form_hidden("type", $edit->type);
+
+ /*
+ ** Add the buttons:
+ */
+
+ $output .= form_submit(t("Preview"));
+
+ if ($edit->title && $edit->type && !$error) {
+ $output .= form_submit(t("Submit"));
+ }
+
+ if ($edit->nid && user_access("administer nodes")) {
+ $output .= form_submit(t("Delete"));
+ }
+
+ $output .= "</div>";
+
+ /*
+ ** Add the admin specific parts:
+ */
+
+ if (user_access("administer nodes")) {
+ $output .= "<div style=\"float: right;\">";
+ $output .= form_textfield(t("Authored by"), "name", $edit->name, 20, 25, $error["name"]);
+ $output .= form_textfield(t("Authored on"), "date", $edit->date, 20, 25, $error["date"]);
+ $output .= "<br />";
+ $output .= form_select(t("Current status"), "status", $edit->status, array("Disabled", "Enabled"));
+ $output .= form_select(t("User comments"), "comment", $edit->comment, array("Disabled", "Enabled"));
+ $output .= form_select(t("Node location"), "promote", $edit->promote, array("Default", "Front page"));
+ $output .= "</div>";
+ }
+
+ return form($output);
+}
+
+function node_add($type) {
+ global $user;
+
+ if ($type) {
+ $output = node_form(array("uid" => $user->uid, "type" => $type));
+ }
+ else {
+ // TODO: make building a node list generic and find an easy way to associate post permissions with them
+ if (user_access("adminster nodes")) {
+ $nodes = array("book" => "book page", "blog" => "personal blog entry", "poll" => "online survey", "story" => "story", "page" => "static page", "forum" => "discussion forum");
+ }
+ else {
+ $nodes = array("book" => "book page", "blog" => "personal blog entry", "poll" => "online survey", "story" => "story");
+ }
+
+ foreach ($nodes as $type => $name) {
+ $links[] = "<a href=\"module.php?mod=node&op=add&type=$type\">". t($name) ."</a>";
+ }
+
+ $output .= sprintf(t("Submit a %s."), implode(", ", $links));
+ }
+
+ return $output;
+}
+
+function node_edit($id) {
+ global $user;
+
+ $node = node_load(array("nid" => $id));
+ // TODO: make this generic for all node types - temporary solution
+
+ return node_form($node);
+}
+
+function node_preview($edit) {
+
+ /*
+ ** Load the user's name when needed:
+ */
+
+ if ($edit["name"]) {
+ $user = user_load(array("name" => $edit["name"]));
+ $edit["uid"] = $user->uid;
+ }
+ else if ($edit["uid"]) {
+ $user = user_load(array("uid" => $edit["uid"]));
+ $edit["name"] = $user->name;
+ }
+
+ /*
+ ** Set the created time when needed:
+ */
+
+ if (empty($edit["nid"])) {
+ $edit["created"] = time();
+ }
+
+ /*
+ ** Display a preview of the node:
+ */
+
+ node_view($edit);
+
+ return node_form($edit);
+}
+
+function node_submit($edit) {
+
+ global $user;
+
+ /*
+ ** Fixup the node when required:
+ */
+
+ node_fixup(&$edit);
+
+ if ($edit->nid) {
+ /*
+ ** Compile a list of the node fields and their default values that users
+ ** and administrators are allowed to save when updating a node.
+ */
+
+ if (user_access("administer nodes")) {
+ $fields = array("nid", "uid", "body", "comment", "promote", "moderate", "status", "teaser", "title", "created", "type" => $edit->type);
+ }
+ else {
+ $fields = array("nid", "uid" => $user->uid, "body", "teaser", "title", "type" => $edit->type);
+ }
+
+ $output = t("The node has been updated.");
+ }
+ else {
+ /*
+ ** Compile a list of the node fields and their default values that users
+ ** and administrators are allowed to save when inserting a new node.
+ */
+
+ if (user_access("administer nodes")) {
+ $fields = array("uid", "body", "comment" => 1, "promote", "moderate", "status" => 1, "teaser", "title", "type" => $edit->type);
+ }
+ else {
+ $fields = array("uid" => $user->uid, "body", "comment" => 1, "teaser", "title", "type" => $edit->type);
+ }
+
+ $output = t("Thanks for your submission.");
+ }
+
+ /*
+ ** Check whether we are allowed to save the node and if so, whether
+ ** there are more default values to add.
+ */
+
+ $defaults = module_invoke($edit->type, "save", $edit);
+
+ if (is_array($defaults)) {
+ node_save($edit, array_merge($fields, $defaults));
+ }
+ else {
+ $output = t("Could not save or process the specified submission.");
+ }
+
+ return $output;
+}
+
+function node_remove($edit) {
+
+ if ($edit["confirm"]) {
+ node_delete(array(nid => $edit["nid"]));
+
+ $output = node_admin_nodes();
+ }
+ else {
+ $output .= form_item(t("Confirm removal of"), check_output($edit["title"]));
+ $output .= form_hidden("nid", $edit["nid"]);
+ $output .= form_hidden("confirm", 1);
+ $output .= form_submit(t("Delete"));
+ $output = form($output, "post", "admin.php?mod=node");
+ }
+
+ return $output;
+}
+
function node_page() {
- global $op, $theme, $meta, $date;
+ global $op, $id, $user, $edit, $type, $theme, $meta, $date;
if ($op == "feed") {
node_feed();
+ return;
}
- else {
- $theme->header();
- if (user_access("access content")) {
- $result = db_query("SELECT nid, type FROM node WHERE ". ($meta ? "attributes LIKE '%". check_input($meta) ."%' AND " : "") ." 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();
+
+ switch ($op) {
+ case "add":
+ $theme->box(t("Node"), node_add($type));
+ break;
+ case "edit":
+ $theme->box(t("Node"), node_edit($id));
+ break;
+ case t("Preview"):
+ $theme->box(t("Node"), node_preview($edit));
+ break;
+ case t("Submit"):
+ $theme->box(t("Node"), node_submit($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)));
while ($node = db_fetch_object($result)) {
- node_view(node_get_object(array("nid" => $node->nid, "type" => $node->type)), 1);
+ node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1);
}
- }
- else {
- $theme->box(t("Access denied"), message_access());
- }
- $theme->footer();
}
+
+ $theme->footer();
}
-
+
?>
diff --git a/modules/node/node.module b/modules/node/node.module
index ed4ce2d7e..bf388d76a 100644
--- a/modules/node/node.module
+++ b/modules/node/node.module
@@ -1,25 +1,8 @@
<?php
// $Id$
-class Node {
- function Node($node) {
- global $user;
- $this->uid = $node[uid] ? $node[uid] : $user->uid;
- $this->nid = $node[nid];
- $this->type = $node[type];
- $this->comment = $node[comment] ? $node[comment] : variable_get($node[type]."_comment", 0);
- $this->name = $node[name] ? $node[name] : $user->name;
- $this->title = $node[title];
- $this->attributes = $node[attributes];
- $this->timestamp = $node[timestamp] ? $node[timestamp] : time();
- }
-}
-
function node_help() {
global $mod;
- ?>
- <P>Todo.</P>
- <?php
if ($mod == "node") {
foreach (module_list() as $name) {
@@ -35,9 +18,19 @@ function node_perm() {
return array("administer nodes", "access content", "post content");
}
+function node_search($keys) {
+ global $user;
+
+ $result = db_query("SELECT n.nid, n.title, n.created, u.uid, u.name FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.status = 1 AND (n.title LIKE '%$keys%' OR n.teaser LIKE '%$keys%' OR n.body LIKE '%$keys%') ORDER BY n.created DESC LIMIT 20");
+ while ($node = db_fetch_object($result)) {
+ $find[$i++] = array("title" => check_output($node->title), "link" => (user_access("administer nodes") ? "admin.php?mod=node&type=node&op=edit&id=$node->nid" : "node.php?id=$node->nid"), "user" => $node->name, "date" => $node->created);
+ }
+
+ return $find;
+}
+
function node_conf_options() {
$output .= form_select("Default number of nodes to display", "default_nodes_main", variable_get("default_nodes_main", 10), array(1 => 1, 2 => 2, 3 => 3, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30), "The default maximum number of nodes to display on the main page.");
- $output .= form_select("Prompt for confirmation when deleting nodes", "default_nodes_confirm_delete", variable_get("default_nodes_confirm_delete", 1), array("Disabled", "Enabled"), "Prompt for confirmation when deleting nodes.");
return $output;
}
@@ -70,310 +63,160 @@ function node_filter($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_queued = '' WHERE timestamp_queued > 0 AND timestamp_queued < ". time());
- db_query("UPDATE node SET status = '". node_status("dumped") ."', timestamp_hidden = '' WHERE timestamp_hidden > 0 AND timestamp_hidden < ". time());
-}
-
function node_link($type, $node = 0) {
if ($type == "admin" && user_access("administer nodes")) {
- $links[] = "<a href=\"admin.php?mod=node\">content</a>";
+ $links[] = "<a href=\"admin.php?mod=node\">content management</a>";
+ }
+
+ if ($type == "page") {
+ $links[] = "<a href=\"module.php?mod=node&op=add\">submit</a>";
}
if ($type == "node") {
+
if ($node->links) {
$links = $node->links;
}
- if ($node->body) {
+
+ if ($node->teaser != $node->body) {
$links[] = "<a href=\"node.php?id=". $node->nid ."\">". t("read more") ."</a>";
}
+
if ($node->comment) {
$links[] = "<a href=\"node.php?id=". $node->nid ."\">". format_plural(node_get_comments($node->nid), "comment", "comments") ."</a>";
}
+
+ if (user_access("administer nodes")) {
+ $links[] = "<a href=\"admin.php?mod=node&op=edit&id=". $node->nid ."\">". t("edit") ."</a>";
+ }
}
return $links ? $links : array();
}
-function node_links($nid, $type) {
+function node_admin_settings($edit = array()) {
global $op;
- $link[] = ($op == "view") ? "view node" : "<A HREF=\"node.php?id=$nid\">view node</A>";
- $link[] = ($op == "content") ? "edit content" : "<A HREF=\"admin.php?mod=node&type=$type&op=content&id=$nid\">edit content</A>";
- $link[] = ($op == "option") ? "edit options" : "<A HREF=\"admin.php?mod=node&op=option&id=$nid\">edit options</A>";
- $link[] = ($op == "status") ? "edit status" : "<A HREF=\"admin.php?mod=node&op=status&id=$nid\">edit status</A>";
- $link[] = ($op == "attribute") ? "edit attribute" : "<A HREF=\"admin.php?mod=node&op=attribute&id=$nid\">edit attributes</A>";
- $link[] = "<a href=\"admin.php?mod=node&op=". (variable_get("default_nodes_confirm_delete", 1) ? "confirm+" : "") ."delete&id=$nid\">delete node</a>";
- return $link;
-}
-
-function node_overview($query) {
- global $user;
-
- $color = array("#ffffff", "#e5e5e5");
- $query = node_query($query ? $query : 0);
-
- $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid $query[1] LIMIT 50");
-
- $output .= status($query[0]);
- $output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
- $output .= " <tr><th>title</th><th>type</th><th>status</th><th>meta attributes</th><th>author</th><th>date</th></tr>\n";
+ if ($op == t("Save configuration")) {
+ /*
+ ** Save the configuration options:
+ */
- while ($node = db_fetch_object($result)) {
- $bg = $color[$i++ % sizeof($color)];
-
- $output .= " <tr bgcolor=\"$bg\"><td><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></td><td align=\"center\">$node->type</td><td>". node_status($node->status) ."</td><td>". check_output($node->attributes) ."</td><td>". format_name($node) ."</td><td>". format_date($node->timestamp, "small") ."</td></tr>\n";
- $output .= " <tr bgcolor=\"$bg\"><td align=\"right\" colspan=\"6\"><small>". implode(", ", node_links($node->nid, $node->type)) ."</small></td>\n";
+ foreach ($edit as $name => $value) variable_set($name, $value);
}
- $output .= "</table>\n";
- return $output;
-}
-
-function node_edit_option($id) {
-
- $node = node_get_object(array("nid" => $id));
-
- $form .= form_item("Title", check_output($node->title));
- $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
- $form .= form_select("Comment", "comment", $node->comment, node_comment_status(), "Allow users to post comments to this node.");
- $form .= form_select("Promote", "promote", $node->promote, node_promote_status(), "Promote this node on the main page.");
- $form .= form_hidden("nid", $node->nid);
- $form .= form_submit("Save node");
-
- return form($form, "post", "admin.php?mod=node&id=$node->nid");
-}
-
-function node_edit_attribute($id) {
+ if ($op == t("Reset to defaults")) {
+ /*
+ ** Reset the configuration options to their default value:
+ */
- $node = node_get_object(array("nid" => $id));
-
- $form .= form_item("Title", check_output($node->title));
- $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
- $form .= form_textfield("Attributes", "attributes", $node->attributes, 64, 128, "A comma-seperated list of attributes. Example: 'Software, Webserver, Apache'.");
- $form .= form_hidden("nid", $node->nid);
- $form .= form_submit("Save node");
-
- return form($form, "post", "admin.php?mod=node&id=$node->nid");
-}
-
-function node_edit_status($id) {
- $node = node_get_object(array("nid" => $id));
-
- $form .= form_item("Title", check_output($node->title));
- $form .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
- $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");
+ foreach ($edit as $name=>$value) variable_del($name);
+ }
- return form($form);
-}
+ $output .= node_conf_options();
+ $output .= form_submit(t("Save configuration"));
+ $output .= form_submit(t("Reset to defaults"));
-function node_edit_content($edit, $type) {
- $edit[type] = $type;
- return node_invoke($edit, "form");
+ return form($output);
}
-function node_save_content($edit, $type) {
- $edit[type] = $type;
- return node_invoke($edit, "save");
-}
+function node_admin_edit($node) {
-function node_delete($id) {
- return (node_del(array("nid" => $id)) ? "node has been deleted." : "failed to delete node.");
-}
+ if (is_numeric($node)) {
+ $node = node_array(node_load(array("nid" => $node)));
+ }
+ /*
+ ** Edit node:
+ */
-function node_delete_confirmation($id) {
+ $output .= "<h3>". t("Edit node") ."</h3>";
- $node = node_get_object(array("nid" => $id));
+ $output .= node_form($node);
- $form .= form_item(t("Do you really want to delete this node"), check_output($node->title));
- $form .= form_submit("Delete node");
- $form .= form_submit("Keep node");
+ /*
+ ** Edit comments:
+ */
- return form($form, "post", "admin.php?mod=node&id=$node->nid");
+ $output .= "<h3>". t("Edit comments") ."</h3>";
-}
+ $result = db_query("SELECT c.cid, c.subject, u.uid, u.name FROM comments c LEFT JOIN users u ON u.uid = c.uid WHERE lid = '". $node["nid"] ."' ORDER BY c.timestamp");
-function node_query($type = -1) {
- $queries[] = array("all nodes: recent additions", "ORDER BY 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 timestamp_posted > 0 ORDER BY n.timestamp DESC");
- $queries[] = array("all nodes: scheduled to be queued", "WHERE timestamp_queued > 0 ORDER BY n.timestamp DESC");
- $queries[] = array("all nodes: scheduled to be hidden", "WHERE timestamp_hidden > 0 ORDER BY n.timestamp DESC");
-
- foreach (module_list() as $name) {
- if (module_hook($name, "status")) {
- $queries[] = array("$name: recent additions", "WHERE type = '$name' ORDER BY timestamp DESC");
- $statuses = module_invoke($name, "status");
- if (is_array($statuses)) {
- foreach (array_reverse($statuses) as $key=>$status) {
- $queries[] = array("$name: status set to '$status'", "WHERE type = '$name' AND n.status = '". node_status($status) ."' ORDER BY timestamp DESC");
- }
- $queries[] = array("$name: scheduled to be posted", "WHERE type = '$name' AND timestamp_posted > 0 ORDER BY timestamp DESC");
- $queries[] = array("$name: scheduled to be queued", "WHERE type = '$name' AND timestamp_queued > 0 ORDER BY timestamp DESC");
- $queries[] = array("$name: scheduled to be hidden", "WHERE type = '$name' AND timestamp_hidden > 0 ORDER BY timestamp DESC");
- }
- }
+ while ($comment = db_fetch_object($result)) {
+ $output .= "<a href=\"admin.php?mod=comment&op=edit&id=$comment->cid\">$comment->subject</a> by ". format_name($comment) ."<br />";
}
- return ($type < 0 ? $queries : $queries[$type]);
-}
+ return $output;
-function node_listing($queries) {
- global $mod;
- foreach ($queries as $key=>$array) {
- $output .= "<LI><A HREF=\"admin.php?mod=$mod&query=$key\">$array[0]</A></LI>\n";
- }
- return "<OL>$output</OL>\n";
}
-function node_setting() {
-
- $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 .= "<H3>Default settings for $name nodes</H3>";
- $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.");
- }
- }
+function node_admin_nodes() {
+ global $query;
- $form .= form_submit("Save settings");
- $form .= form_submit("Reset to defaults");
+ $queries = array(array("ORDER BY n.created DESC", "new nodes"), array("ORDER BY n.changed DESC", "updated nodes"), array("WHERE n.status = 1 AND n.moderate = 0 ORDER BY n.nid DESC", "published nodes"), array("WHERE n.status = 0 AND n.moderate = 0 ORDER BY n.nid DESC", "non-published nodes"), array("WHERE n.status = 1 AND n.moderate = 1 ORDER BY n.nid DESC", "pending nodes"), array("WHERE n.status = 1 AND n.promote = 1 ORDER BY n.nid DESC", "promoted nodes"));
- return form($form);
-}
+ $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid ". $queries[$query ? $query : 0][0] ." LIMIT 50");
-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));
+ foreach ($queries as $key => $value) {
+ $links[] = "<a href=\"admin.php?mod=node&op=nodes&query=$key\">$value[1]</a>";
}
- else if (isset($edit[attributes])) {
- node_save($edit, array(attributes));
- }
- else {
- node_save($edit, array(comment, promote));
- }
-}
-function node_module_find() {
+ $output .= "<small>". implode(" :: ", $links) ."</small><hr />";
- foreach (module_list() as $name) {
- if (module_hook($name, "user")) {
- $options .= "<OPTION VALUE=\"$name\">$name</OPTION>\n";
- }
+ $output .= "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\">\n";
+ $output .= " <tr><th>title</th><th>type</th><th>author</th><th>status</th><th colspan=\"2\">operations</th></tr>\n";
+ while ($node = db_fetch_object($result)) {
+ $output .= "<tr><td><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></td><td>$node->type</td><td nowrap=\"nowrap\">". format_name($node) ."</td><td>". ($node->status ? t("published") : t("not published")) ."</td><td nowrap=\"nowrap\"><a href=\"node.php?id=$node->nid\">view node</a></td><td nowrap=\"nowrap\"><a href=\"admin.php?mod=node&op=edit&id=$node->nid\">edit node</a></td></tr>";
}
+ $output .= "</table>";
- $output .= " <input size=\"50\" value=\"". check_form($keys) ."\" name=\"keys\" type=\"text\">\n";
- $output .= " <select name=\"type\">$options</select>\n";
- $output .= " <input type=\"submit\" value=\"Search\">\n";
-
- return form($output);
-}
-
-function node_edit($node) {
- $output .= form_item("Title", $node->title);
- $output .= form_item("Operations", implode("<br />", node_links($node->nid, $node->type)));
return $output;
}
function node_admin() {
- global $op, $id, $edit, $query, $type, $keys;
+ global $op, $id, $edit;
if (user_access("administer nodes")) {
- foreach (module_list() as $name) {
- if (module_hook($name, "status") && $name != "node") {
- $link[] = "<a href=\"admin.php?mod=node&type=$name&op=add\">add $name</a>";
- }
- }
+ /*
+ ** Compile a list of the administrative links:
+ */
- print "<small>". implode(" | ", $link) ." | <a href=\"admin.php?mod=node&op=default\">node settings</a> | <a href=\"admin.php?mod=node&op=listing\">node listings</a> | <a href=\"admin.php?mod=node&op=search\">search node</a> | <a href=\"admin.php?mod=node\">overview</a> | <a href=\"admin.php?mod=node&op=help\">help</a></small><hr />\n";
+ $links[] = "<a href=\"admin.php?mod=node&op=nodes\">nodes</a>";
+ $links[] = "<a href=\"admin.php?mod=node&op=search\">search content</a>";
+ $links[] = "<a href=\"admin.php?mod=node&op=settings\">settings</a>";
+ $links[] = "<a href=\"admin.php?mod=node&op=help\">help</a>";
- $id = check_input($edit[nid] ? $edit[nid] : $id);
+ print "<small>". implode(" &middot; ", $links) ."</small><hr />";
switch ($op) {
- case "add":
- print module_invoke($type, "form");
- break;
case "help":
print node_help();
break;
case "search":
- print node_module_find($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 "content":
- print node_edit_content(node_get_array(array("nid" => $id)), $type);
- break;
- case "default":
- print node_setting();
+ print search_type("node", "admin.php?mod=node&op=search");
break;
- case "confirm delete":
- print node_delete_confirmation($id);
- break;
- case "Delete node":
- 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(system_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);
+ case t("Save configuration"):
+ case t("Reset to defaults"):
+ case "settings":
+ print node_admin_settings($edit);
break;
case "edit":
- print node_edit(node_get_object(array("nid" => $id)));
- break;
- case "view":
- print node_module_view(node_get_array(array("nid" => $id)), $type);
+ print node_admin_edit($id);
break;
case t("Preview"):
- print node_edit_content($edit, $type);
+ print node_preview($edit);
break;
case t("Submit"):
- print status(node_save_content($edit, $type));
- // fall through:
+ print node_submit($edit);
+ print node_admin_nodes();
+ break;
+ case t("Delete"):
+ print node_remove($edit);
+ break;
default:
- print node_overview($query);
+ print node_admin_nodes();
}
}
else {
@@ -393,16 +236,14 @@ function node_block() {
function node_feed() {
- $result = db_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '". node_status("posted") ."' ORDER BY timestamp DESC LIMIT 15");
+ $result = db_query("SELECT nid, type FROM node WHERE promote = '1' AND status = '1' ORDER BY created DESC LIMIT 15");
while ($node = db_fetch_object($result)) {
- $item = node_get_object(array("nid" => $node->nid, "type" => $node->type));
+ $item = node_load(array("nid" => $node->nid, "type" => $node->type));
- $title = $item->title;
$link = path_uri() ."node.php?id=$item->nid";
- $description = module_invoke($item->type, "summary", $item);
- $items .= format_rss_item($title, $link, $description);
+ $items .= format_rss_item($item->title, $link, $item->teaser);
}
$output .= "<?xml version=\"1.0\" encoding=\"ISO-8859-1\" ?>\n";
@@ -417,25 +258,320 @@ function node_feed() {
}
+
+function node_fixup($edit) {
+
+ global $user;
+
+ /*
+ ** Convert the node to an object if necessary:
+ */
+
+ $edit = node_object($edit);
+
+ /*
+ ** Validate the title field:
+ */
+
+ if (($edit->nid || $edit->body) && !$edit->title) {
+ $error["title"] = "<div style=\"color: red;\">". t("You have to specify a valid title.") ."</div>";
+ }
+
+ if (user_access("administer nodes")) {
+
+ /*
+ ** Setup default values if required:
+ */
+
+ if (!$edit->name) {
+ $edit->name = $user->name;
+ }
+
+ if (!$edit->created) {
+ $edit->created = time();
+ }
+
+ if (!$edit->date) {
+ $edit->date = date("M j, Y g:i a", $edit->created);
+ }
+
+ /*
+ ** Validate the "authored by"-field:
+ */
+
+ if ($account = user_load(array("name" => $edit->name))) {
+ $edit->uid = $account->uid;
+ }
+ else {
+ $error["name"] = "<div style=\"color: red;\">". sprintf(t("The name '%s' does not exist."), $edit->name) ."</div>";
+ }
+
+ /*
+ ** Validate the "authored on"-field:
+ */
+
+ if (strtotime($edit->date) > 1000) {
+ $edit->created = strtotime($edit->date);
+ }
+ else {
+ $error["date"] = "<div style=\"color: red;\">". t("You have to specifiy a valid date.") ."</div>";
+ }
+ }
+
+ return $error;
+}
+
+function node_form($edit) {
+
+ $error = node_fixup(&$edit);
+
+ $output .= "<div style=\"margin-right: 40px; float: left;\">";
+
+ /*
+ ** Add the default fields:
+ */
+
+ $output .= form_textfield(t("Title"), "title", $edit->title, 60, 64, $error["title"]);
+
+ if ($edit->body && !$edit->teaser) {
+ $edit->teaser = node_teaser($edit->body);
+ }
+
+ if ($edit->teaser) {
+ $output .= form_textarea(t("Teaser"), "teaser", $edit->teaser, 60, 5);
+ }
+
+ /*
+ ** Add the node specific parts:
+ */
+
+ $output .= module_invoke($edit->type, "form", $edit);
+
+ /*
+ ** Add the hidden fields:
+ */
+
+ if ($edit->nid) {
+ $output .= form_hidden("nid", $edit->nid);
+ }
+
+ if ($edit->uid) {
+ $output .= form_hidden("uid", $edit->uid);
+ }
+
+ if ($edit->created) {
+ $output .= form_hidden("created", $edit->created);
+ }
+
+ $output .= form_hidden("type", $edit->type);
+
+ /*
+ ** Add the buttons:
+ */
+
+ $output .= form_submit(t("Preview"));
+
+ if ($edit->title && $edit->type && !$error) {
+ $output .= form_submit(t("Submit"));
+ }
+
+ if ($edit->nid && user_access("administer nodes")) {
+ $output .= form_submit(t("Delete"));
+ }
+
+ $output .= "</div>";
+
+ /*
+ ** Add the admin specific parts:
+ */
+
+ if (user_access("administer nodes")) {
+ $output .= "<div style=\"float: right;\">";
+ $output .= form_textfield(t("Authored by"), "name", $edit->name, 20, 25, $error["name"]);
+ $output .= form_textfield(t("Authored on"), "date", $edit->date, 20, 25, $error["date"]);
+ $output .= "<br />";
+ $output .= form_select(t("Current status"), "status", $edit->status, array("Disabled", "Enabled"));
+ $output .= form_select(t("User comments"), "comment", $edit->comment, array("Disabled", "Enabled"));
+ $output .= form_select(t("Node location"), "promote", $edit->promote, array("Default", "Front page"));
+ $output .= "</div>";
+ }
+
+ return form($output);
+}
+
+function node_add($type) {
+ global $user;
+
+ if ($type) {
+ $output = node_form(array("uid" => $user->uid, "type" => $type));
+ }
+ else {
+ // TODO: make building a node list generic and find an easy way to associate post permissions with them
+ if (user_access("adminster nodes")) {
+ $nodes = array("book" => "book page", "blog" => "personal blog entry", "poll" => "online survey", "story" => "story", "page" => "static page", "forum" => "discussion forum");
+ }
+ else {
+ $nodes = array("book" => "book page", "blog" => "personal blog entry", "poll" => "online survey", "story" => "story");
+ }
+
+ foreach ($nodes as $type => $name) {
+ $links[] = "<a href=\"module.php?mod=node&op=add&type=$type\">". t($name) ."</a>";
+ }
+
+ $output .= sprintf(t("Submit a %s."), implode(", ", $links));
+ }
+
+ return $output;
+}
+
+function node_edit($id) {
+ global $user;
+
+ $node = node_load(array("nid" => $id));
+ // TODO: make this generic for all node types - temporary solution
+
+ return node_form($node);
+}
+
+function node_preview($edit) {
+
+ /*
+ ** Load the user's name when needed:
+ */
+
+ if ($edit["name"]) {
+ $user = user_load(array("name" => $edit["name"]));
+ $edit["uid"] = $user->uid;
+ }
+ else if ($edit["uid"]) {
+ $user = user_load(array("uid" => $edit["uid"]));
+ $edit["name"] = $user->name;
+ }
+
+ /*
+ ** Set the created time when needed:
+ */
+
+ if (empty($edit["nid"])) {
+ $edit["created"] = time();
+ }
+
+ /*
+ ** Display a preview of the node:
+ */
+
+ node_view($edit);
+
+ return node_form($edit);
+}
+
+function node_submit($edit) {
+
+ global $user;
+
+ /*
+ ** Fixup the node when required:
+ */
+
+ node_fixup(&$edit);
+
+ if ($edit->nid) {
+ /*
+ ** Compile a list of the node fields and their default values that users
+ ** and administrators are allowed to save when updating a node.
+ */
+
+ if (user_access("administer nodes")) {
+ $fields = array("nid", "uid", "body", "comment", "promote", "moderate", "status", "teaser", "title", "created", "type" => $edit->type);
+ }
+ else {
+ $fields = array("nid", "uid" => $user->uid, "body", "teaser", "title", "type" => $edit->type);
+ }
+
+ $output = t("The node has been updated.");
+ }
+ else {
+ /*
+ ** Compile a list of the node fields and their default values that users
+ ** and administrators are allowed to save when inserting a new node.
+ */
+
+ if (user_access("administer nodes")) {
+ $fields = array("uid", "body", "comment" => 1, "promote", "moderate", "status" => 1, "teaser", "title", "type" => $edit->type);
+ }
+ else {
+ $fields = array("uid" => $user->uid, "body", "comment" => 1, "teaser", "title", "type" => $edit->type);
+ }
+
+ $output = t("Thanks for your submission.");
+ }
+
+ /*
+ ** Check whether we are allowed to save the node and if so, whether
+ ** there are more default values to add.
+ */
+
+ $defaults = module_invoke($edit->type, "save", $edit);
+
+ if (is_array($defaults)) {
+ node_save($edit, array_merge($fields, $defaults));
+ }
+ else {
+ $output = t("Could not save or process the specified submission.");
+ }
+
+ return $output;
+}
+
+function node_remove($edit) {
+
+ if ($edit["confirm"]) {
+ node_delete(array(nid => $edit["nid"]));
+
+ $output = node_admin_nodes();
+ }
+ else {
+ $output .= form_item(t("Confirm removal of"), check_output($edit["title"]));
+ $output .= form_hidden("nid", $edit["nid"]);
+ $output .= form_hidden("confirm", 1);
+ $output .= form_submit(t("Delete"));
+ $output = form($output, "post", "admin.php?mod=node");
+ }
+
+ return $output;
+}
+
function node_page() {
- global $op, $theme, $meta, $date;
+ global $op, $id, $user, $edit, $type, $theme, $meta, $date;
if ($op == "feed") {
node_feed();
+ return;
}
- else {
- $theme->header();
- if (user_access("access content")) {
- $result = db_query("SELECT nid, type FROM node WHERE ". ($meta ? "attributes LIKE '%". check_input($meta) ."%' AND " : "") ." 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();
+
+ switch ($op) {
+ case "add":
+ $theme->box(t("Node"), node_add($type));
+ break;
+ case "edit":
+ $theme->box(t("Node"), node_edit($id));
+ break;
+ case t("Preview"):
+ $theme->box(t("Node"), node_preview($edit));
+ break;
+ case t("Submit"):
+ $theme->box(t("Node"), node_submit($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)));
while ($node = db_fetch_object($result)) {
- node_view(node_get_object(array("nid" => $node->nid, "type" => $node->type)), 1);
+ node_view(node_load(array("nid" => $node->nid, "type" => $node->type)), 1);
}
- }
- else {
- $theme->box(t("Access denied"), message_access());
- }
- $theme->footer();
}
+
+ $theme->footer();
}
-
+
?>
diff --git a/modules/page.module b/modules/page.module
index cfecf2a66..84488f296 100644
--- a/modules/page.module
+++ b/modules/page.module
@@ -3,14 +3,6 @@
$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_link($type) {
if ($type == "page") {
$result = db_query("SELECT nid,link FROM page WHERE link != '' ORDER BY link");
@@ -22,6 +14,11 @@ function page_link($type) {
return $links ? $links : array();
}
+function page_load($node) {
+ $page = db_fetch_object(db_query("SELECT format, link FROM page WHERE nid = '$node->nid'"));
+ return $page;
+}
+
function page_view($node, $main = 0) {
global $format, $theme;
@@ -38,42 +35,35 @@ function page_view($node, $main = 0) {
}
-function page_status() {
- return array(dumped, posted);
-}
-
-function page_form($edit = array()) {
+function page_form($node) {
global $format, $op;
- if ($op != t("Preview") && $format[$edit["format"]] == "PHP") {
- $edit["body"] = addslashes($edit["body"]);
+ if ($op != t("Preview") && $format[$node->format] == "PHP") {
+ $node->body = addslashes($node->body);
}
- if ($edit["title"]) {
- $form = page_view(new Page(node_preview($edit)));
- }
+ $output .= form_textarea("Body", "body", $node->body, 60, 30);
+ $output .= form_select("Type", "format", $node->format, $format);
+
+ return $output;
+}
- $form .= form_textfield("Subject", "title", $edit["title"], 50, 64);
- $form .= form_textfield("Link", "link", $edit["link"], 50, 64);
- $form .= form_textarea("Body", "body", $edit["body"], 70, 30);
- $form .= form_select("Type", "format", $edit["format"], $format);
- $form .= form_hidden("nid", $edit["nid"]);
+function page_save() {
- if ($edit["title"]) {
- $form .= form_submit(t("Preview"));
- $form .= form_submit(t("Submit"));
+ if (user_access("administer nodes")) {
+ if ($node->nid) {
+ return array();
+ }
+ else {
+ return array("promote" => 0, "moderate" => 0, "status" => 1);
+ }
}
else {
- $form .= form_submit(t("Preview"));
+ return 0;
}
- return form($form);
}
-function page_save($edit) {
- global $status, $user;
- node_save($edit, array(uid => $user->uid, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status["posted"], timestamp => time(), title, type => "page", votes => 0));
-}
-
+
?> \ No newline at end of file
diff --git a/modules/page/page.module b/modules/page/page.module
index cfecf2a66..84488f296 100644
--- a/modules/page/page.module
+++ b/modules/page/page.module
@@ -3,14 +3,6 @@
$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_link($type) {
if ($type == "page") {
$result = db_query("SELECT nid,link FROM page WHERE link != '' ORDER BY link");
@@ -22,6 +14,11 @@ function page_link($type) {
return $links ? $links : array();
}
+function page_load($node) {
+ $page = db_fetch_object(db_query("SELECT format, link FROM page WHERE nid = '$node->nid'"));
+ return $page;
+}
+
function page_view($node, $main = 0) {
global $format, $theme;
@@ -38,42 +35,35 @@ function page_view($node, $main = 0) {
}
-function page_status() {
- return array(dumped, posted);
-}
-
-function page_form($edit = array()) {
+function page_form($node) {
global $format, $op;
- if ($op != t("Preview") && $format[$edit["format"]] == "PHP") {
- $edit["body"] = addslashes($edit["body"]);
+ if ($op != t("Preview") && $format[$node->format] == "PHP") {
+ $node->body = addslashes($node->body);
}
- if ($edit["title"]) {
- $form = page_view(new Page(node_preview($edit)));
- }
+ $output .= form_textarea("Body", "body", $node->body, 60, 30);
+ $output .= form_select("Type", "format", $node->format, $format);
+
+ return $output;
+}
- $form .= form_textfield("Subject", "title", $edit["title"], 50, 64);
- $form .= form_textfield("Link", "link", $edit["link"], 50, 64);
- $form .= form_textarea("Body", "body", $edit["body"], 70, 30);
- $form .= form_select("Type", "format", $edit["format"], $format);
- $form .= form_hidden("nid", $edit["nid"]);
+function page_save() {
- if ($edit["title"]) {
- $form .= form_submit(t("Preview"));
- $form .= form_submit(t("Submit"));
+ if (user_access("administer nodes")) {
+ if ($node->nid) {
+ return array();
+ }
+ else {
+ return array("promote" => 0, "moderate" => 0, "status" => 1);
+ }
}
else {
- $form .= form_submit(t("Preview"));
+ return 0;
}
- return form($form);
}
-function page_save($edit) {
- global $status, $user;
- node_save($edit, array(uid => $user->uid, link, body, comment => variable_get("page_comment", 0), format, moderate => variable_get("page_moderate", ""), promote => variable_get("page_promote", 0), score => 0, status => $status["posted"], timestamp => time(), title, type => "page", votes => 0));
-}
-
+
?> \ No newline at end of file
diff --git a/modules/poll.module b/modules/poll.module
index 286cccd87..4f25544e9 100644
--- a/modules/poll.module
+++ b/modules/poll.module
@@ -1,6 +1,8 @@
<?php
// $Id$
+/*
+
class Poll {
function Poll($poll) {
$this = new Node($poll);
@@ -180,13 +182,13 @@ function poll_form($edit = array(), $nocheck = 0) {
if ($admin && !is_array($edit[choices])) $edit = poll_get_choices_array($edit);
- /* Mini-form for number of choiceboxes */
+ // Mini-form for number of choiceboxes
$choices = $edit[choices] ? $edit[choices] : max(2, count($edit[choices]) ? count($edit[choices]) : 5);
for ($c = 2; $c <= 20; $c++) $opts[$c]=$c;
$form .= form_select(t("Number of choices"), "choices", $choices, $opts, t("This box only specifies the number of boxes in this form, it doesn't have to equal the actual amount of choices in the poll."));
$form .= form_submit(t("Preview")) . "<br><br><br>";
- /* Main form */
+ // Main form
$form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
$form .= form_hidden("name", $edit[name]);
$form .= form_textfield(t("Question"), "title", $edit[title], 50, 127);
@@ -279,5 +281,5 @@ function poll_user() {
$theme->box(t("Submit"), poll_form());
}
}
-
+*/
?>
diff --git a/modules/poll/poll.module b/modules/poll/poll.module
index 286cccd87..4f25544e9 100644
--- a/modules/poll/poll.module
+++ b/modules/poll/poll.module
@@ -1,6 +1,8 @@
<?php
// $Id$
+/*
+
class Poll {
function Poll($poll) {
$this = new Node($poll);
@@ -180,13 +182,13 @@ function poll_form($edit = array(), $nocheck = 0) {
if ($admin && !is_array($edit[choices])) $edit = poll_get_choices_array($edit);
- /* Mini-form for number of choiceboxes */
+ // Mini-form for number of choiceboxes
$choices = $edit[choices] ? $edit[choices] : max(2, count($edit[choices]) ? count($edit[choices]) : 5);
for ($c = 2; $c <= 20; $c++) $opts[$c]=$c;
$form .= form_select(t("Number of choices"), "choices", $choices, $opts, t("This box only specifies the number of boxes in this form, it doesn't have to equal the actual amount of choices in the poll."));
$form .= form_submit(t("Preview")) . "<br><br><br>";
- /* Main form */
+ // Main form
$form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
$form .= form_hidden("name", $edit[name]);
$form .= form_textfield(t("Question"), "title", $edit[title], 50, 127);
@@ -279,5 +281,5 @@ function poll_user() {
$theme->box(t("Submit"), poll_form());
}
}
-
+*/
?>
diff --git a/modules/queue.module b/modules/queue.module
index ae69b780b..cbb1c5798 100644
--- a/modules/queue.module
+++ b/modules/queue.module
@@ -19,13 +19,12 @@ function queue_link($type) {
}
function queue_cron() {
- global $status;
- db_query("UPDATE node SET status = '$status[dumped]' WHERE status = '$status[queued]' AND ". time() ." - timestamp > ". variable_get("queue_clear", 604800));
+ // TODO: use 'created' or 'changed' ?
+ // db_query("UPDATE node SET status = 0 WHERE moderate = 1 AND ". time() ." - timestamp > ". variable_get("queue_clear", 604800));
}
function queue_count() {
- global $status;
- $result = db_query("SELECT COUNT(nid) FROM node WHERE status = '$status[queued]'");
+ $result = db_query("SELECT COUNT(nid) FROM node WHERE moderate = 1");
return ($result) ? db_result($result, 0) : 0;
}
@@ -35,27 +34,27 @@ function queue_score($id) {
}
function queue_vote($id, $vote) {
- global $status, $user;
+ global $user;
- if ($node = node_get_object(array(nid => $id))) {
+ if ($node = node_load(array(nid => $id))) {
if (!field_get($node->users, $user->uid)) {
// Update submission's score- and votes-field:
db_query("UPDATE node SET score = score $vote, votes = votes + 1, users = '". field_set($node->users, $user->uid, $vote) ."' WHERE nid = $id");
- $node = node_get_object(array(nid => $id, type => $node->type));
+ $node = node_load(array(nid => $id, type => $node->type));
if (variable_get($node->type ."_post", 4) <= $node->score) {
- node_save(array(nid => $id, status => $status[posted], timestamp => time()), array(status, timestamp));
+ node_save($node, array("nid", "status" => 1, "moderate" => 0));
watchdog("special", "node: posted '$node->title' - moderation");
}
else if (variable_get($node->type ."_dump", -2) >= $node->score) {
- node_save(array(nid => $id, status => $status[dumped], timestamp => time()), array(status, timestamp));
+ node_save($node, array("nid", "status" => 1, "moderate" => 0));
watchdog("special", "node: dumped '$node->title' - moderation");
}
else if (variable_get($node->type ."_expire", 8) <= $node->votes) {
- node_save(array(nid => $id, status => $status[expired], timestamp => time()), array(status, timestamp));
+ node_save($node, array("nid", "status" => 0, "moderate" => 0));
watchdog("special", "node: expired '$node->title' - moderation");
}
}
@@ -63,17 +62,17 @@ function queue_vote($id, $vote) {
}
function queue_overview() {
- global $status, $theme, $user;
+ global $theme, $user;
- $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.status = '$status[queued]'");
+ $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.moderate = 1");
- $content .= "<TABLE BORDER=\"0\" CELLSPACING=\"4\" CELLPADDING=\"4\">\n";
- $content .= " <TR><TH>". t("Subject") ."</TH><TH>". t("Author") ."</TH><TH>". t("Type") ."</TH><TH>". t("Score") ."</TH></TR>\n";
+ $content .= "<table border=\"0\" cellspacing=\"4\" cellpadding=\"4\">";
+ $content .= " <tr><th>". t("Subject") ."</th><th>". t("Author") ."</th><th>". t("Type") ."</TH><TH>". t("Score") ."</th></tr>";
while ($node = db_fetch_object($result)) {
- if ($user->uid == $node->uid || field_get($node->users, $user->uid)) $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_name($node) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\">". queue_score($node->nid) ."</TD></TR>\n";
- else $content .= " <TR><TD><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</A></TD><TD ALIGN=\"center\">". format_name($node) ."</TD><TD ALIGN=\"center\">". check_output($node->type) ."</TD><TD ALIGN=\"center\"><A HREF=\"module.php?mod=queue&op=view&id=$node->nid\">". t("vote") ."</A></TD></TR>\n";
+ if ($user->uid == $node->uid || field_get($node->users, $user->uid)) $content .= " <tr><td><a href=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</a></td><td align=\"center\">". format_name($node) ."</td><td align=\"center\">". check_output($node->type) ."</td><td align=\"center\">". queue_score($node->nid) ."</td></tr>";
+ else $content .= " <tr><td><a href=\"module.php?mod=queue&op=view&id=$node->nid\">". check_output($node->title) ."</a></td><td align=\"center\">". format_name($node) ."</td><td align=\"center\">". check_output($node->type) ."</td><td align=\"center\"><a href=\"module.php?mod=queue&op=view&id=$node->nid\">". t("vote") ."</a></td></tr>";
}
- $content .= "</TABLE>\n";
+ $content .= "</table>";
$theme->header();
$theme->box(t("Moderation queue"), $content);
@@ -83,31 +82,37 @@ function queue_overview() {
function queue_node($id) {
global $theme, $user;
-
- $node = node_get_object(array(nid => $id));
+ $node = node_load(array(nid => $id));
if ($user->uid == $node->uid || field_get($node->users, $user->uid)) {
drupal_goto("node.php?id=$node->nid");
}
else {
+
+ /*
+ ** The keys of this associative array are displayed in each submission's
+ ** selection box whereas the corresponding values represent the
+ ** mathematical calculation to be performed to update a comment's value.
+ */
$queue_votes = array("neutral (+0)" => "+ 0", "post it (+1)" => "+ 1", "dump it (-1)" => "- 1");
- // The keys of this associative array are displayed in each submission's selection box whereas the corresponding values represent the mathematical calculation to be performed to update a comment's value.
- if ($n = node_get_object(array("nid" => $node->pid))) {
- $output .= " ". t("The above node is a proposed update of an existing node:") ." \"<A HREF=\"node.php?id=$n->nid\">". check_output($n->title) ."</A>\".";
+ // TODO: this is where the upcoming versioning system should come in
+ if ($n = node_load(array("nid" => $node->pid))) {
+ $output .= " ". t("The above node is a proposed update of an existing node:") ." \"<a href=\"node.php?id=$n->nid\">". check_output($n->title) ."</a>\".";
}
+ // TODO: this is where the upcoming versioning system should come in
if ($node->log) {
- $output .= " ". t("The log message to accompany this submission is given below:") ."<P><I>". check_output($node->log, 1) ."</I></P>";
+ $output .= " ". t("The log message to accompany this submission is given below:") ."<p><i>". check_output($node->log, 1) ."</i></p>";
}
// moderation form:
- $output .= "<FORM ACTION=\"module.php?mod=queue\" METHOD=\"post\">\n";
- foreach ($queue_votes as $key=>$value) $options .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
- $output .= "<SELECT NAME=\"vote\">$options</SELECT>\n";
- $output .= "<INPUT TYPE=\"hidden\" NAME=\"id\" VALUE=\"$node->nid\">\n";
- $output .= "<INPUT TYPE=\"submit\" NAME=\"op\" VALUE=\"Vote\">\n";
- $output .= "</FORM>\n";
+ $output .= "<form action=\"module.php?mod=queue\" method=\"post\">";
+ foreach ($queue_votes as $key=>$value) $options .= " <option value=\"$value\">$key</option>";
+ $output .= " <select name=\"vote\">$options</select>";
+ $output .= " <input type=\"hidden\" name=\"id\" value=\"$node->nid\">";
+ $output .= " <input type=\"submit\" name=\"op\" value=\"Vote\">";
+ $output .= "</form>";
$theme->header();
node_view($node);
@@ -138,5 +143,5 @@ function queue_page() {
$theme->footer();
}
}
-
+
?>
diff --git a/modules/rating.module b/modules/rating.module
index d7e391501..e2b577247 100644
--- a/modules/rating.module
+++ b/modules/rating.module
@@ -52,23 +52,21 @@ function rating_help() {
}
function rating_gravity($uid) {
- global $status;
-
$period = 5184000; // maximum 60 days
$number = 30; // maximum 30 comments
- $r1 = db_query("SELECT nid, type FROM node WHERE uid = '$uid' AND (". time() ." - timestamp < $period) AND status = '$status[posted]'");
+ $r1 = db_query("SELECT nid, type FROM node WHERE uid = '$uid' AND (". time() ." - created < $period) AND status = 1");
while ($node = db_fetch_object($r1)) {
$bonus += variable_get("rating_weight_$node->type", 0);
}
- $r2 = db_query("SELECT nid, type FROM node WHERE uid = '$uid' AND (". time() ." - timestamp < $period) AND status = '$status[dumped]'");
+ $r2 = db_query("SELECT nid, type FROM node WHERE uid = '$uid' AND (". time() ." - created < $period) AND status = 0");
while ($node = db_fetch_object($r1)) {
$bonus -= variable_get("rating_weight_$node->type", 0);
}
/*
- $r3 = db_query("SELECT score, votes FROM comments WHERE uid = '$uid' AND votes > 0 AND (". time() ." - timestamp < $period) ORDER BY timestamp LIMIT $number");
+ $r3 = db_query("SELECT score, votes FROM comments WHERE uid = '$uid' AND votes > 0 AND (". time() ." - created < $period) ORDER BY created LIMIT $number");
while ($comment = db_fetch_object($r3)) {
$weight++;
$score += $weight * $comment->score;
@@ -114,5 +112,5 @@ function rating_block() {
$block[0][info] = "Top 10: users";
return $block;
}
-
+
?>
diff --git a/modules/search.module b/modules/search.module
index f3cac8390..116b671c6 100644
--- a/modules/search.module
+++ b/modules/search.module
@@ -45,7 +45,7 @@ function search_page() {
$form .= t("Restrict search to") .": ";
foreach (module_list() as $name) {
- if (module_hook($name, "search")) {
+ if (module_hook($name, "user") || module_hook($name, "search")) {
$form .= " <input type=\"checkbox\" name=\"edit[type][$name]\" ". ($edit["type"][$name] ? " checked=\"checked\"" : "") ."/> ". t($name);
}
}
@@ -95,5 +95,5 @@ function search_page() {
$theme->footer();
}
}
-
+
?>
diff --git a/modules/search/search.module b/modules/search/search.module
index f3cac8390..116b671c6 100644
--- a/modules/search/search.module
+++ b/modules/search/search.module
@@ -45,7 +45,7 @@ function search_page() {
$form .= t("Restrict search to") .": ";
foreach (module_list() as $name) {
- if (module_hook($name, "search")) {
+ if (module_hook($name, "user") || module_hook($name, "search")) {
$form .= " <input type=\"checkbox\" name=\"edit[type][$name]\" ". ($edit["type"][$name] ? " checked=\"checked\"" : "") ."/> ". t($name);
}
}
@@ -95,5 +95,5 @@ function search_page() {
$theme->footer();
}
}
-
+
?>
diff --git a/modules/statistics.module b/modules/statistics.module
index 2cd684a23..4e4f2fb8c 100644
--- a/modules/statistics.module
+++ b/modules/statistics.module
@@ -96,5 +96,5 @@ function statistics_admin() {
}
}
}
-
+
?> \ No newline at end of file
diff --git a/modules/statistics/statistics.module b/modules/statistics/statistics.module
index 2cd684a23..4e4f2fb8c 100644
--- a/modules/statistics/statistics.module
+++ b/modules/statistics/statistics.module
@@ -96,5 +96,5 @@ function statistics_admin() {
}
}
}
-
+
?> \ No newline at end of file
diff --git a/modules/story.module b/modules/story.module
index 3753bbc9c..91bb9ef81 100644
--- a/modules/story.module
+++ b/modules/story.module
@@ -1,27 +1,6 @@
<?php
// $Id$
-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 $PHP_SELF, $status;
- $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
- while ($story = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($story->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "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>
@@ -30,78 +9,29 @@ function story_help() {
<?php
}
-function story_summary($node) {
- return $node->abstract;
-}
-
-function story_view($node, $main = 0) {
- global $theme;
- $node->body = ((!$main) && ($node->body)) ? "$node->abstract<HR>$node->body" : $node->abstract;
- $theme->node($node, $main);
-}
-
-function story_form($edit = array()) {
- global $user;
-
- if ($edit[title]) {
- story_view(new Story(node_preview($edit)));
- }
+function story_form($node) {
- $form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
- $form .= form_hidden("name", $edit[name]);
- $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
- $form .= node_attributes_edit("story", $edit);
- $form .= form_textarea(t("Abstract"), "abstract", $edit[abstract], 70, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
- $form .= form_textarea(t("Body"), "body", $edit[body], 70, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
+ $output = form_textarea(t("Body"), "body", $node->body, 60, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
- if ($edit[nid] > 0) {
- $form .= form_hidden("nid", $edit[nid]);
- }
-
- if (!$edit) {
- $form .= form_submit(t("Preview"));
- }
- else if ($edit && !$edit[title]) {
- $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n";
- $form .= form_submit(t("Preview"));
- }
- else if ($edit && !$edit[abstract]) {
- $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n";
- $form .= form_submit(t("Preview"));
- }
- else {
- $form .= form_submit(t("Preview"));
- $form .= form_submit(t("Submit"));
- }
-
- return form($form);
+ return $output;
}
-function story_save($edit) {
- global $status, $user;
-
- if (!$edit[nid]) {
- node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), uid => $user->uid, body, 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]), timestamp => time(), title, type => "story", votes => 0));
+function story_save($node) {
+ if ($node->nid) {
+ if (user_access("administer nodes")) {
+ return array();
+ }
+ else {
+ return 0;
+ }
}
- else if (user_access("administer nodes")) {
- node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), body, title, type => "story"));
+ else {
+ /*
+ ** By default, stories get promoted to the front page and they are
+ ** subject to moderation.
+ */
+ return array("promote" => 1, "moderate" => 1);
}
}
-function story_user() {
- global $edit, $op, $theme;
-
- switch($op) {
- case t("Preview"):
- $theme->box(t("Submit"), story_form($edit));
- break;
- case t("Submit"):
- story_save($edit);
- $theme->box(t("Submit"), t("Thank you for your submission."));
- break;
- default:
- $theme->box(t("Submit"), story_form());
- }
-}
-
?>
diff --git a/modules/story/story.module b/modules/story/story.module
index 3753bbc9c..91bb9ef81 100644
--- a/modules/story/story.module
+++ b/modules/story/story.module
@@ -1,27 +1,6 @@
<?php
// $Id$
-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 $PHP_SELF, $status;
- $result = db_query("SELECT n.*, s.* FROM story s LEFT JOIN node n ON n.nid = s.nid WHERE n.status = '$status[posted]' AND (n.title LIKE '%$keys%' OR s.abstract LIKE '%$keys%' OR s.body LIKE '%$keys%') ORDER BY n.timestamp DESC LIMIT 20");
- while ($story = db_fetch_object($result)) {
- $find[$i++] = array("title" => check_output($story->title), "link" => (strstr($PHP_SELF, "admin.php") ? "admin.php?mod=node&type=story&op=edit&id=$story->nid" : "node.php?id=$story->nid"), "user" => $story->name, "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>
@@ -30,78 +9,29 @@ function story_help() {
<?php
}
-function story_summary($node) {
- return $node->abstract;
-}
-
-function story_view($node, $main = 0) {
- global $theme;
- $node->body = ((!$main) && ($node->body)) ? "$node->abstract<HR>$node->body" : $node->abstract;
- $theme->node($node, $main);
-}
-
-function story_form($edit = array()) {
- global $user;
-
- if ($edit[title]) {
- story_view(new Story(node_preview($edit)));
- }
+function story_form($node) {
- $form .= form_item(t("Your name"), ($edit[name] ? $edit[name] : ($user->name ? $user->name : variable_get(anonymous, "Anonymous"))));
- $form .= form_hidden("name", $edit[name]);
- $form .= form_textfield(t("Subject"), "title", $edit[title], 50, 64);
- $form .= node_attributes_edit("story", $edit);
- $form .= form_textarea(t("Abstract"), "abstract", $edit[abstract], 70, 10, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
- $form .= form_textarea(t("Body"), "body", $edit[body], 70, 20, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
+ $output = form_textarea(t("Body"), "body", $node->body, 60, 15, t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")));
- if ($edit[nid] > 0) {
- $form .= form_hidden("nid", $edit[nid]);
- }
-
- if (!$edit) {
- $form .= form_submit(t("Preview"));
- }
- else if ($edit && !$edit[title]) {
- $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply a subject.") ."</FONT><P>\n";
- $form .= form_submit(t("Preview"));
- }
- else if ($edit && !$edit[abstract]) {
- $form .= "<FONT COLOR=\"red\">". t("Warning: you did not supply an abstract.") ."</FONT><P>\n";
- $form .= form_submit(t("Preview"));
- }
- else {
- $form .= form_submit(t("Preview"));
- $form .= form_submit(t("Submit"));
- }
-
- return form($form);
+ return $output;
}
-function story_save($edit) {
- global $status, $user;
-
- if (!$edit[nid]) {
- node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), uid => $user->uid, body, 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]), timestamp => time(), title, type => "story", votes => 0));
+function story_save($node) {
+ if ($node->nid) {
+ if (user_access("administer nodes")) {
+ return array();
+ }
+ else {
+ return 0;
+ }
}
- else if (user_access("administer nodes")) {
- node_save($edit, array(abstract, attributes => node_attributes_save("story", $edit), body, title, type => "story"));
+ else {
+ /*
+ ** By default, stories get promoted to the front page and they are
+ ** subject to moderation.
+ */
+ return array("promote" => 1, "moderate" => 1);
}
}
-function story_user() {
- global $edit, $op, $theme;
-
- switch($op) {
- case t("Preview"):
- $theme->box(t("Submit"), story_form($edit));
- break;
- case t("Submit"):
- story_save($edit);
- $theme->box(t("Submit"), t("Thank you for your submission."));
- break;
- default:
- $theme->box(t("Submit"), story_form());
- }
-}
-
?>
diff --git a/modules/system.module b/modules/system.module
index e6c92496a..6a450eea9 100644
--- a/modules/system.module
+++ b/modules/system.module
@@ -160,5 +160,5 @@ function system_admin() {
print message_access();
}
}
-
+
?> \ No newline at end of file
diff --git a/modules/system/system.module b/modules/system/system.module
index e6c92496a..6a450eea9 100644
--- a/modules/system/system.module
+++ b/modules/system/system.module
@@ -160,5 +160,5 @@ function system_admin() {
print message_access();
}
}
-
+
?> \ No newline at end of file
diff --git a/modules/tracker.module b/modules/tracker.module
index 61eee8b35..5ebfe218c 100644
--- a/modules/tracker.module
+++ b/modules/tracker.module
@@ -66,5 +66,5 @@ function tracker_page() {
$theme->footer();
}
-
+
?>
diff --git a/modules/tracker/tracker.module b/modules/tracker/tracker.module
index 61eee8b35..5ebfe218c 100644
--- a/modules/tracker/tracker.module
+++ b/modules/tracker/tracker.module
@@ -66,5 +66,5 @@ function tracker_page() {
$theme->footer();
}
-
+
?>
diff --git a/modules/user.module b/modules/user.module
index 1ea99a00d..b504f96e9 100644
--- a/modules/user.module
+++ b/modules/user.module
@@ -16,20 +16,20 @@ function sess_close() {
function sess_read($key) {
global $user;
- $user = user_load(array("session" => $key, "status" => 1));
+ $user = user_load(array("sid" => $key, "status" => 1));
return $user;
}
function sess_write($key, $value) {
global $HTTP_SERVER_VARS;
- db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', timestamp = '". time() ."' WHERE session = '$key'");
+ db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', timestamp = '". time() ."' WHERE sid = '$key'");
}
function sess_destroy($key) {
global $HTTP_SERVER_VARS;
- db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', timestamp = '". time() ."', session = '' WHERE session = '$key'");
+ db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', timestamp = '". time() ."', sid = '' WHERE sid = '$key'");
}
function sess_gc($lifetime) {
@@ -151,18 +151,32 @@ function user_password($min_length = 6) {
return $password;
}
-function user_access($perm) {
+function user_access($string) {
+
global $user;
+ static $perm;
+
+ /*
+ ** To reduce the number of SQL queries, we cache the user's permissions
+ ** in a static variable.
+ */
+
+ if (!$perm) {
+ if ($user->uid) {
+ $perm = db_result(db_query("SELECT perm FROM role WHERE name = '$user->role'"), 0);
+ }
+ else {
+ $perm = db_result(db_query("SELECT perm FROM role WHERE name = 'anonymous user'"), 0);
+ }
+ }
if ($user->uid == 1) {
return 1;
}
- else if ($user->perm) {
- return strstr($user->perm, $perm);
- }
else {
- return db_fetch_object(db_query("SELECT * FROM role WHERE name = 'anonymous user' AND perm LIKE '%$perm%'"));
+ return strstr($perm, $string);
}
+
}
function user_mail($mail, $subject, $message, $header) {
@@ -171,6 +185,7 @@ function user_mail($mail, $subject, $message, $header) {
}
function user_deny($type, $mask) {
+
$allow = db_fetch_object(db_query("SELECT * FROM access WHERE status = '1' AND type = '$type' AND LOWER('$mask') LIKE LOWER(mask)"));
$deny = db_fetch_object(db_query("SELECT * FROM access WHERE status = '0' AND type = '$type' AND LOWER('$mask') LIKE LOWER(mask)"));
@@ -181,6 +196,7 @@ function user_deny($type, $mask) {
else {
return 0;
}
+
}
/*** Module hooks **********************************************************/
@@ -205,7 +221,7 @@ function user_help() {
<ul>
<li>&nbsp;% : matches any number of characters, including zero characters.</li>
<li>&nbsp;_ : matches exactly one character.</li>
- </UL>
+ </ul>
<p><u>Examples:</u></p>
<ul>
<li>E-mail address bans <code>%@hotmail.com</code>, <code>%@altavista.%</code>, <code>%@usa.net</code>, etc. Used to prevent users from using free email accounts, which might be used to cause trouble.</li>
@@ -219,7 +235,7 @@ function user_help() {
<ul>
<li>Anonymous user: this role is used for users that don't have a user account or that are not authenticated.</li>
<li>Registered user: this role is assigned automatically to authenticated users. Most users will belong to this user role unless specified otherwise.</li>
- </uL>
+ </ul>
<p>For basic Drupal sites you can get by with <i>anonymous user</i> and <i>authenticated user</i> but for more complex sites where you want other users to be able to perform maintainance or administrative duties, you may want to create your own roles to classify your users into different groups.</p>
<h3>User permissions</h3>
@@ -408,7 +424,7 @@ function jabber_auth($username, $password, $server, $port = 5222) {
}
}
-function drupal_auth($username, $password, $server) {
+function drupal_auth($username, $password, $server, $port = 80) {
$message = new xmlrpcmsg("drupal.login", array(new xmlrpcval($username, "string"), new xmlrpcval($password, "string")));
@@ -432,6 +448,14 @@ function drupal_auth($username, $password, $server) {
function user_login($edit = array()) {
global $user, $HTTP_REFERER;
+ /*
+ ** If we are already logged on, go to the user page instead.
+ */
+
+ if ($user->uid) {
+ drupal_goto("module.php?mod=user");
+ }
+
if (user_deny("user", $edit["name"])) {
$error = sprintf(t("The name '%s' has been denied access."), $edit["name"]);
}
@@ -492,7 +516,7 @@ function user_login($edit = array()) {
** Write session ID to database:
*/
- user_save($user, array("session" => session_id()));
+ user_save($user, array("sid" => session_id()));
/*
** Redirect the user to the page he logged on from or to his personal
@@ -502,7 +526,6 @@ function user_login($edit = array()) {
$url = $HTTP_REFERER ? $HTTP_REFERER : "module.php?mod=user&op=view";
drupal_goto($url);
- return;
}
else {
@@ -545,12 +568,15 @@ function user_logout() {
session_destroy();
unset($user);
- /*
- ** Redirect the user to his personal information page:
- */
- drupal_goto("index.php");
}
+
+ /*
+ ** Redirect the user to his personal information page:
+ */
+
+ drupal_goto("index.php");
+
}
function user_pass($edit = array()) {
@@ -720,8 +746,8 @@ function user_edit($edit = array()) {
$output .= form_textfield(t("E-mail address"), "mail", $user->mail, 30, 55, t("Insert a valid e-mail address. All emails from the system will be sent to this address. The email address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by email."));
$output .= form_textfield(t("Jabber ID"), "jabber", $user->jabber, 30, 55, t("Insert a valid Jabber ID. If you are using your Jabber ID to log in, it must be correct. Your Jabber ID is not made public and is only used to log in or to authenticate for affilliate services."));
$output .= form_textfield(t("Homepage"), "homepage", $user->homepage, 30, 55, t("Optional") .". ". t("Make sure you enter a fully qualified URL: remember to include \"http://\"."));
- foreach ($themes as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". (($user->theme == $key) ? " SELECTED" : "") .">$key - $value[1]</OPTION>\n";
- $output .= form_item(t("Theme"), "<SELECT NAME=\"edit[theme]\">$options</SELECT>", t("Selecting a different theme will change the look and feel of the site."));
+ foreach ($themes as $key=>$value) $options .= "<option value=\"$key\"". (($user->theme == $key) ? " selected=\"selected\"" : "") .">$key - $value[1]</option>\n";
+ $output .= form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site."));
for ($zone = -43200; $zone <= 46800; $zone += 3600) $zones[$zone] = date("l, F dS, Y - h:i A", time() - date("Z") + $zone) ." (GMT ". $zone / 3600 .")";
$output .= form_select(t("Timezone"), "timezone", $user->timezone, $zones, t("Select what time you currently have and your timezone settings will be set appropriate."));
$output .= form_select(t("Language"), "language", $user->language, $languages, t("Selecting a different language will change the language of the site."));
@@ -1126,7 +1152,7 @@ function user_admin_edit($edit = array()) {
function user_admin_account() {
global $query;
- $queries = array(array("ORDER BY timestamp DESC", "active users"), array("ORDER BY uid DESC", "new users"), array("WHERE status = 0 ORDER BY uid DESC", "blocked users"), array("WHERE role != 'authenticated user' ORDER BY uid DESC", "special users"));
+ $queries = array(array("ORDER BY timestamp DESC", "active users"), array("ORDER BY uid DESC", "new users"), array("WHERE status = 0 ORDER BY uid DESC", "blocked users"), array("WHERE role != 'authenticated user' ORDER BY uid DESC", "non-regular users"));
$result = db_query("SELECT uid, name, timestamp FROM users ". $queries[$query ? $query : 0][0] ." LIMIT 50");
@@ -1168,7 +1194,7 @@ function user_admin() {
admin_access_init();
/*
- ** Compile all the administrative links:
+ ** Compile a list of the administrative links:
*/
$links[] = "<a href=\"admin.php?mod=user&op=create\">add new user</a>";
@@ -1223,5 +1249,5 @@ function user_admin() {
}
}
}
-
+
?>
diff --git a/modules/user/user.module b/modules/user/user.module
index 1ea99a00d..b504f96e9 100644
--- a/modules/user/user.module
+++ b/modules/user/user.module
@@ -16,20 +16,20 @@ function sess_close() {
function sess_read($key) {
global $user;
- $user = user_load(array("session" => $key, "status" => 1));
+ $user = user_load(array("sid" => $key, "status" => 1));
return $user;
}
function sess_write($key, $value) {
global $HTTP_SERVER_VARS;
- db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', timestamp = '". time() ."' WHERE session = '$key'");
+ db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', timestamp = '". time() ."' WHERE sid = '$key'");
}
function sess_destroy($key) {
global $HTTP_SERVER_VARS;
- db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', timestamp = '". time() ."', session = '' WHERE session = '$key'");
+ db_query("UPDATE users SET hostname = '". check_input($HTTP_SERVER_VARS[REMOTE_ADDR]) ."', timestamp = '". time() ."', sid = '' WHERE sid = '$key'");
}
function sess_gc($lifetime) {
@@ -151,18 +151,32 @@ function user_password($min_length = 6) {
return $password;
}
-function user_access($perm) {
+function user_access($string) {
+
global $user;
+ static $perm;
+
+ /*
+ ** To reduce the number of SQL queries, we cache the user's permissions
+ ** in a static variable.
+ */
+
+ if (!$perm) {
+ if ($user->uid) {
+ $perm = db_result(db_query("SELECT perm FROM role WHERE name = '$user->role'"), 0);
+ }
+ else {
+ $perm = db_result(db_query("SELECT perm FROM role WHERE name = 'anonymous user'"), 0);
+ }
+ }
if ($user->uid == 1) {
return 1;
}
- else if ($user->perm) {
- return strstr($user->perm, $perm);
- }
else {
- return db_fetch_object(db_query("SELECT * FROM role WHERE name = 'anonymous user' AND perm LIKE '%$perm%'"));
+ return strstr($perm, $string);
}
+
}
function user_mail($mail, $subject, $message, $header) {
@@ -171,6 +185,7 @@ function user_mail($mail, $subject, $message, $header) {
}
function user_deny($type, $mask) {
+
$allow = db_fetch_object(db_query("SELECT * FROM access WHERE status = '1' AND type = '$type' AND LOWER('$mask') LIKE LOWER(mask)"));
$deny = db_fetch_object(db_query("SELECT * FROM access WHERE status = '0' AND type = '$type' AND LOWER('$mask') LIKE LOWER(mask)"));
@@ -181,6 +196,7 @@ function user_deny($type, $mask) {
else {
return 0;
}
+
}
/*** Module hooks **********************************************************/
@@ -205,7 +221,7 @@ function user_help() {
<ul>
<li>&nbsp;% : matches any number of characters, including zero characters.</li>
<li>&nbsp;_ : matches exactly one character.</li>
- </UL>
+ </ul>
<p><u>Examples:</u></p>
<ul>
<li>E-mail address bans <code>%@hotmail.com</code>, <code>%@altavista.%</code>, <code>%@usa.net</code>, etc. Used to prevent users from using free email accounts, which might be used to cause trouble.</li>
@@ -219,7 +235,7 @@ function user_help() {
<ul>
<li>Anonymous user: this role is used for users that don't have a user account or that are not authenticated.</li>
<li>Registered user: this role is assigned automatically to authenticated users. Most users will belong to this user role unless specified otherwise.</li>
- </uL>
+ </ul>
<p>For basic Drupal sites you can get by with <i>anonymous user</i> and <i>authenticated user</i> but for more complex sites where you want other users to be able to perform maintainance or administrative duties, you may want to create your own roles to classify your users into different groups.</p>
<h3>User permissions</h3>
@@ -408,7 +424,7 @@ function jabber_auth($username, $password, $server, $port = 5222) {
}
}
-function drupal_auth($username, $password, $server) {
+function drupal_auth($username, $password, $server, $port = 80) {
$message = new xmlrpcmsg("drupal.login", array(new xmlrpcval($username, "string"), new xmlrpcval($password, "string")));
@@ -432,6 +448,14 @@ function drupal_auth($username, $password, $server) {
function user_login($edit = array()) {
global $user, $HTTP_REFERER;
+ /*
+ ** If we are already logged on, go to the user page instead.
+ */
+
+ if ($user->uid) {
+ drupal_goto("module.php?mod=user");
+ }
+
if (user_deny("user", $edit["name"])) {
$error = sprintf(t("The name '%s' has been denied access."), $edit["name"]);
}
@@ -492,7 +516,7 @@ function user_login($edit = array()) {
** Write session ID to database:
*/
- user_save($user, array("session" => session_id()));
+ user_save($user, array("sid" => session_id()));
/*
** Redirect the user to the page he logged on from or to his personal
@@ -502,7 +526,6 @@ function user_login($edit = array()) {
$url = $HTTP_REFERER ? $HTTP_REFERER : "module.php?mod=user&op=view";
drupal_goto($url);
- return;
}
else {
@@ -545,12 +568,15 @@ function user_logout() {
session_destroy();
unset($user);
- /*
- ** Redirect the user to his personal information page:
- */
- drupal_goto("index.php");
}
+
+ /*
+ ** Redirect the user to his personal information page:
+ */
+
+ drupal_goto("index.php");
+
}
function user_pass($edit = array()) {
@@ -720,8 +746,8 @@ function user_edit($edit = array()) {
$output .= form_textfield(t("E-mail address"), "mail", $user->mail, 30, 55, t("Insert a valid e-mail address. All emails from the system will be sent to this address. The email address is not made public and will only be used if you wish to receive a new password or wish to receive certain news or notifications by email."));
$output .= form_textfield(t("Jabber ID"), "jabber", $user->jabber, 30, 55, t("Insert a valid Jabber ID. If you are using your Jabber ID to log in, it must be correct. Your Jabber ID is not made public and is only used to log in or to authenticate for affilliate services."));
$output .= form_textfield(t("Homepage"), "homepage", $user->homepage, 30, 55, t("Optional") .". ". t("Make sure you enter a fully qualified URL: remember to include \"http://\"."));
- foreach ($themes as $key=>$value) $options .= "<OPTION VALUE=\"$key\"". (($user->theme == $key) ? " SELECTED" : "") .">$key - $value[1]</OPTION>\n";
- $output .= form_item(t("Theme"), "<SELECT NAME=\"edit[theme]\">$options</SELECT>", t("Selecting a different theme will change the look and feel of the site."));
+ foreach ($themes as $key=>$value) $options .= "<option value=\"$key\"". (($user->theme == $key) ? " selected=\"selected\"" : "") .">$key - $value[1]</option>\n";
+ $output .= form_item(t("Theme"), "<select name=\"edit[theme]\">$options</select>", t("Selecting a different theme will change the look and feel of the site."));
for ($zone = -43200; $zone <= 46800; $zone += 3600) $zones[$zone] = date("l, F dS, Y - h:i A", time() - date("Z") + $zone) ." (GMT ". $zone / 3600 .")";
$output .= form_select(t("Timezone"), "timezone", $user->timezone, $zones, t("Select what time you currently have and your timezone settings will be set appropriate."));
$output .= form_select(t("Language"), "language", $user->language, $languages, t("Selecting a different language will change the language of the site."));
@@ -1126,7 +1152,7 @@ function user_admin_edit($edit = array()) {
function user_admin_account() {
global $query;
- $queries = array(array("ORDER BY timestamp DESC", "active users"), array("ORDER BY uid DESC", "new users"), array("WHERE status = 0 ORDER BY uid DESC", "blocked users"), array("WHERE role != 'authenticated user' ORDER BY uid DESC", "special users"));
+ $queries = array(array("ORDER BY timestamp DESC", "active users"), array("ORDER BY uid DESC", "new users"), array("WHERE status = 0 ORDER BY uid DESC", "blocked users"), array("WHERE role != 'authenticated user' ORDER BY uid DESC", "non-regular users"));
$result = db_query("SELECT uid, name, timestamp FROM users ". $queries[$query ? $query : 0][0] ." LIMIT 50");
@@ -1168,7 +1194,7 @@ function user_admin() {
admin_access_init();
/*
- ** Compile all the administrative links:
+ ** Compile a list of the administrative links:
*/
$links[] = "<a href=\"admin.php?mod=user&op=create\">add new user</a>";
@@ -1223,5 +1249,5 @@ function user_admin() {
}
}
}
-
+
?>
diff --git a/modules/watchdog.module b/modules/watchdog.module
index db6e42214..f968df964 100644
--- a/modules/watchdog.module
+++ b/modules/watchdog.module
@@ -87,5 +87,5 @@ function watchdog_admin() {
print message_access();
}
}
-
+
?>
diff --git a/modules/watchdog/watchdog.module b/modules/watchdog/watchdog.module
index db6e42214..f968df964 100644
--- a/modules/watchdog/watchdog.module
+++ b/modules/watchdog/watchdog.module
@@ -87,5 +87,5 @@ function watchdog_admin() {
print message_access();
}
}
-
+
?>
diff --git a/node.php b/node.php
index 1513fee06..161d7465b 100644
--- a/node.php
+++ b/node.php
@@ -42,7 +42,6 @@ function node_render($node) {
$theme->footer();
break;
case t("Update ratings"):
- node_moderate($moderate["node"]);
comment_moderate($moderate["comment"]);
$theme->header();
node_view($node);
@@ -76,24 +75,15 @@ function node_failure() {
$theme->footer();
}
-function node_history($node) {
- if ($node->status == node_status("expired") || $node->status == node_status("posted")) {
- $output .= "<dt><b>". format_date($node->timestamp) ." by ". format_name($node) .":</b></dt><dd>". check_output($node->log, 1) ."<p /></dd>";
- }
- if ($node->pid) {
- $output .= node_history(node_get_object(array("nid" => $node->pid)));
- }
- return $output;
-}
-
-$number = ($title ? db_num_rows(db_query("SELECT nid FROM node WHERE title = '$title' AND status = '". node_status("posted") ."'")) : 1);
+$number = ($title ? db_num_rows(db_query("SELECT nid FROM node WHERE title = '$title' AND status = 1")) : 1);
+// TODO: this is dead code
if ($number > 1) {
- $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.title = '$title' AND n.status = '". node_status("posted") ."' ORDER BY timestamp DESC");
+ $result = db_query("SELECT n.*, u.name, u.uid FROM node n LEFT JOIN users u ON n.uid = u.uid WHERE n.title = '$title' AND n.status = 1 ORDER BY created DESC");
while ($node = db_fetch_object($result)) {
if (node_access($node)) {
- $output .= "<p><b><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></b><br /><small>$node->type - ". format_name($node) ." - ". format_date($node->timestamp, "small") ."</small></p>";
+ $output .= "<p><b><a href=\"node.php?id=$node->nid\">". check_output($node->title) ."</a></b><br /><small>$node->type - ". format_name($node) ." - ". format_date($node->ccreated, "small") ."</small></p>";
}
}
@@ -102,17 +92,9 @@ if ($number > 1) {
$theme->footer();
}
elseif ($number) {
- $node = ($title ? node_get_object(array("title" => $title, "status" => node_status("posted"))) : node_get_object(array("nid" => ($edit[id] ? $edit[id] : $id))));
+ $node = ($title ? node_load(array("title" => $title, "status" => 1)) : node_load(array("nid" => ($edit[id] ? $edit[id] : $id))));
if ($node && node_access($node)) {
- switch ($op) {
- case "history":
- $theme->header();
- $theme->box(t("History"), node_control($node) ."<dl>". node_history($node) ."</dl>");
- $theme->footer();
- break;
- default:
- node_render($node);
- }
+ node_render($node);
}
else {
node_failure();
@@ -123,5 +105,5 @@ else {
}
page_footer();
-
+
?> \ No newline at end of file
diff --git a/themes/example/example.theme b/themes/example/example.theme
index c1e75e3b1..326580c4c 100644
--- a/themes/example/example.theme
+++ b/themes/example/example.theme
@@ -4,5 +4,5 @@
class Theme extends BaseTheme {
}
-
+
?> \ No newline at end of file
diff --git a/themes/goofy/goofy.theme b/themes/goofy/goofy.theme
index 963c89b21..d38aea3d8 100644
--- a/themes/goofy/goofy.theme
+++ b/themes/goofy/goofy.theme
@@ -103,9 +103,20 @@ function c(subject,mod,author,date,body) {document.writeln("<table border=\"0\"
function node($node, $main = 0) {
echo "\n<!-- node: \"$node->title\" -->\n";
$title = check_output($node->title);
- $subleft = strtr(t("Submitted by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->timestamp, "large")));
+ $subleft = strtr(t("Submitted by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->created, "large")));
$subright = node_index($node);
- $body = check_output($node->body, 1) . ($main ? "<hr color=\"#404040\" size=\"1\"><div align=\"right\">[ " . $this->links(link_node($node)) . " ]</div>" : "");
+
+ if ($main && $node->teaser) {
+ $body = check_output($node->teaser, 1);
+ }
+ else {
+ $body = check_output($node->body, 1);
+ }
+
+ if ($main) {
+ $body .= "<hr color=\"#404040\" size=\"1\"><div align=\"right\">[ " . $this->links(link_node($node)) . " ]</div>";
+ }
+
print "<script language=\"JavaScript\"><!--\ns(\"". $this->stripbreaks(addslashes($title)) ."\",\"". $this->stripbreaks(addslashes($subleft)) ."\",\"". $this->stripbreaks(addslashes($subright)) ."\",\"". $this->stripbreaks(addslashes($body)) ."\"); // -->\n</script>\n";
} // close node function
@@ -114,11 +125,6 @@ function c(subject,mod,author,date,body) {document.writeln("<table border=\"0\"
echo "<A NAME=\"$comment->cid\"></A>\n";
$author = "<b>" . format_name($comment) . "</b>";
- if ($comment->name) {
- if ($comment->fake_email) $info[] = format_email($comment->fake_email);
- if (eregi("http://",$comment->url)) $info[] = format_url($comment->url);
- if ($info) $author .= "<br>[ ". implode(" | ",$info) . " ]";
- }
$body = check_output($comment->comment, 1) . "<br><hr color=\"#404040\" size=\"1\"><div align=\"right\">[ $link ]</div>";
print "<script language=\"JavaScript\"><!--\nc(\"". $this->stripbreaks(addslashes(check_output($comment->subject))) ."\",\"". $this->stripbreaks(addslashes(comment_moderation($comment))) ."\",\"". $this->stripbreaks(addslashes($author)) ."\",\"". $this->stripbreaks(addslashes(format_date($comment->timestamp))) ."\",\"". $this->stripbreaks(addslashes($body)) ."\"); // -->\n</script>\n";
@@ -140,7 +146,7 @@ function c(subject,mod,author,date,body) {document.writeln("<table border=\"0\"
</td>
<td valign="top">
<?php
- $this->user("all", $this);
+ $this->user("all");
theme_blocks("all", $this);
?>
</td>
@@ -154,5 +160,5 @@ function c(subject,mod,author,date,body) {document.writeln("<table border=\"0\"
<?
} // close footer function
} // close theme-class
-
+
?>
diff --git a/themes/marvin/marvin.theme b/themes/marvin/marvin.theme
index e55842390..87dbe9f8b 100644
--- a/themes/marvin/marvin.theme
+++ b/themes/marvin/marvin.theme
@@ -57,11 +57,22 @@
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" width=\"100%\">\n";
print " <tr><td colspan=\"2\"><img src=\"themes/marvin/images/drop.gif\" alt=\"\" /> &nbsp; <b>". check_output($node->title) ."</b></td></tr>\n";
print " <tr valign=\"bottom\"><td colspan=\"2\" bgcolor=\"#000000\" width=\"100%\"><img src=\"themes/marvin/images/pixel.gif\" width=\"1\" height=\"1\" alt=\"\" /></td></tr>\n";
- print " <tr><td nowrap=\"nowrap\"><font color=\"#7C7C7C\"><small>". strtr(t("Submitted by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->timestamp, "large"))); ?><?php print "</small></font></td><td align=\"right\" valign=\"top\" nowrap><small>". node_index($node) ."</small></td></tr>\n";
+ print " <tr><td nowrap=\"nowrap\"><font color=\"#7C7C7C\"><small>". strtr(t("Submitted by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->created, "large"))); ?><?php print "</small></font></td><td align=\"right\" valign=\"top\" nowrap><small>". node_index($node) ."</small></td></tr>\n";
print " <tr><td colspan=\"2\">&nbsp;</td></tr>\n";
- print " <tr><td colspan=\"2\"><p>". check_output($node->body, 1) ."</p></td></tr>\n";
+
+ if ($main && $node->teaser) {
+ print " <tr><td colspan=\"2\"><p>". check_output($node->teaser, 1) ."</p></td></tr>\n";
+ }
+ else {
+ print " <tr><td colspan=\"2\"><p>". check_output($node->body, 1) ."</p></td></tr>\n";
+ }
+
print " <tr><td colspan=\"2\">&nbsp;</td></tr>\n";
- if ($main) print " <tr><td colspan=\"2\">". $this->links(link_node($node)) ."</td></tr>\n";
+
+ if ($main) {
+ print " <tr><td colspan=\"2\">". $this->links(link_node($node)) ."</td></tr>\n";
+ }
+
print "</table>\n";
print "<br /><br />\n\n";
}
@@ -141,7 +152,7 @@
</td>
<td valign="top" width="200">
<?php
- $this->user("all", $this);
+ $this->user("all");
theme_blocks("all", $this);
?>
</td>
@@ -159,5 +170,5 @@
<?php
}
}
-
+
?>
diff --git a/themes/trillian/trillian.theme b/themes/trillian/trillian.theme
index 7f1e112ea..b55dcbb73 100644
--- a/themes/trillian/trillian.theme
+++ b/themes/trillian/trillian.theme
@@ -6,6 +6,7 @@
var $background = "#FFFFFF";
function header() {
+ global $user;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html>
@@ -27,7 +28,7 @@
</table>
</div>
<table border="0" cellspacing="5" cellpadding="1" width="100%">
- <tr><td valign="top" width="150"><div style="border: 1px solid; padding: 10px; border-color: green; background: #eaeaea;"><?php echo $this->box(t("Navigation"), implode("<br />", link_page()) . $this->user("all", $this)); ?></div><br /><div style="border: 1px solid; padding: 10px; border-color: green; background: #eaeaea;"><?php theme_blocks("all", $this); ?></div></td>
+ <tr><td valign="top" width="150"><div style="border: 1px solid; padding: 10px; border-color: green; background: #eaeaea;"><?php echo $this->box(t("Navigation"), implode("<br />", link_page()) . $this->user("all")); ?></div><br /><div style="border: 1px solid; padding: 10px; border-color: green; background: #eaeaea;"><?php theme_blocks("all", $this); ?></div></td>
<td valign="top">
<?php
}
@@ -40,11 +41,11 @@
static $date;
if ($main == 1) {
- if ($date != date("dny", $node->timestamp)) {
- $date = date("dny", $node->timestamp);
+ if ($date != date("dny", $node->created)) {
+ $date = date("dny", $node->created);
print "<table width=\"100%\" cellspacing=\"1\" cellpadding=\"0\" border=\"0\">";
- print "<tr><td align=\"left\"> &nbsp; <div style=\"font-weight: bold;\">". format_date($node->timestamp, "custom", "l, F d, Y") ."</div></td><td align=\"right\"><img src=\"themes/trillian/images/icon.gif\" alt=\"\" /></td><tr>";
+ print "<tr><td align=\"left\"> &nbsp; <div style=\"font-weight: bold;\">". format_date($node->created, "custom", "l, F d, Y") ."</div></td><td align=\"right\"><img src=\"themes/trillian/images/icon.gif\" alt=\"\" /></td><tr>";
print " <tr valign=\"bottom\"><td colspan=\"2\" bgcolor=\"green\" width=\"100%\"><spacer type=\"block\" height=\"100\" /></td></tr>\n";
print "</table>";
print "<br />";
@@ -64,7 +65,7 @@
else {
?>
<div style="text-transform: capitalize; font-size: 120%; font-weight: bold;"><?php echo check_output($node->title); ?></div>
- <div style="padding-left: 20px; padding-top: 10px; padding-bottom: 10px;"><?php echo sprintf(t("by %s on %s"), format_name($node), format_date($node->timestamp)); ?></div>
+ <div style="padding-left: 20px; padding-top: 10px; padding-bottom: 10px;"><?php echo sprintf(t("by %s on %s"), format_name($node), format_date($node->created)); ?></div>
<div style="margin-left: 10px;"><?php echo check_output($node->body, 1); ?></div>
<?php
}
diff --git a/themes/unconed/unconed.theme b/themes/unconed/unconed.theme
index 43503a96d..95c36244f 100644
--- a/themes/unconed/unconed.theme
+++ b/themes/unconed/unconed.theme
@@ -93,20 +93,26 @@
<TR><TD COLSPAN="2" BGCOLOR="<?php echo $this->bgcolor1; ?>" WIDTH="100%"><table width="100%" cellpadding="0" cellspacing="0"><tr><td width="100%"><FONT COLOR="<?php echo $this->fgcolor1; ?>"><B><?php echo "". check_output($node->title) .""; ?></B></FONT></td><td valign="middle" align="center"><IMG SRC="themes/<?php print $this->themename; ?>/images/icon.gif" valign="middle"></td></tr></table></TD></TR>
<TR BGCOLOR="<?php echo $this->bgcolor2; ?>">
<?php
- print "<TD WIDTH=\"70%\" BGCOLOR=\"$this->bgcolor2\"><SMALL>" . strtr(t("Submitted by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->timestamp, "large"))) . "</TD><TD WIDTH=\"30%\" BGCOLOR=\"$this->bgcolor2\" ALIGN=\"center\" NOWRAP><B>". node_index($node) ."</B>";
+ print "<TD WIDTH=\"70%\" BGCOLOR=\"$this->bgcolor2\"><SMALL>" . strtr(t("Submitted by %a on %b"), array("%a" => format_name($node), "%b" => format_date($node->created, "large"))) . "</TD><TD WIDTH=\"30%\" BGCOLOR=\"$this->bgcolor2\" ALIGN=\"center\" NOWRAP><B>". node_index($node) ."</B>";
?>
</TD>
</TR>
<TR BGCOLOR="<?php echo $this->bgcolor2; ?>">
<TD BGCOLOR="<?php echo $this->bgcolor2 ?>" COLSPAN="2">
<?php
- echo "<P>". check_output($node->body, 1) ."</P>";
+ if ($main && $node->teaser) {
+ echo "<P>". check_output($node->teaser, 1) ."</P>";
+ }
+ else {
+ echo "<P>". check_output($node->body, 1) ."</P>";
+ }
?>
</TD>
</TR>
<?php
- if ($main)
+ if ($main) {
echo "<TR BGCOLOR=\"". $this->bgcolor3 ."\"><TD BGCOLOR=\"". $this->bgcolor3 ."\" ALIGN=\"right\" COLSPAN=\"2\">[ ". $this->links(link_node($node)) ." ]</TD></TR>";
+ }
?>
</TABLE></TD></TR></TABLE><BR>
<?php
@@ -143,12 +149,6 @@
// Author:
echo " <TR>";
echo " <TD ALIGN=\"right\" VALIGN=\"top\">" . t("Author") . ":</TD><TD><B>" . format_name($comment) . "</B> ";
- if ($comment->name) {
- // Display extra information line:
- if ($comment->fake_email) $info .= format_email($comment->fake_email);
- if (eregi("http://",$comment->url)) $info .= ($info?" | ":"") . format_url($comment->url);
- if ($info) echo "<BR>[ $info ]";
- }
echo " </TD>";
echo " </TR>";
@@ -191,7 +191,7 @@
</TD>
<TD VALIGN="top" WIDTH="20%">
<?php
- $this->user("all", $this);
+ $this->user("all");
theme_blocks("all", $this);
?>
</TD>
@@ -217,5 +217,5 @@
<?php
}
}
-
+
?>
diff --git a/updates/3.00-to-x.xx.mysql b/updates/3.00-to-x.xx.mysql
index 9ed6a10fb..0bc71e41a 100644
--- a/updates/3.00-to-x.xx.mysql
+++ b/updates/3.00-to-x.xx.mysql
@@ -97,14 +97,62 @@ ALTER TABLE comments CHANGE lid lid int(10) NOT NULL;
## 17/10/01:
-# drop the "lid"s:
-ALTER TABLE story ADD KEY nid (nid);
-ALTER TABLE blog ADD KEY nid (nid);
-ALTER TABLE page ADD KEY nid (nid);
-ALTER TABLE forum ADD KEY nid (nid);
-ALTER TABLE book ADD KEY nid (nid);
+# add primary keys:
+ALTER TABLE story ADD PRIMARY KEY nid (nid);
+ALTER TABLE blog ADD PRIMARY KEY nid (nid);
+ALTER TABLE page ADD PRIMARY KEY nid (nid);
+ALTER TABLE forum ADD PRIMARY KEY nid (nid);
+ALTER TABLE book ADD PRIMARY KEY nid (nid);
## 22/10/01
# add new field to blocks
-ALTER TABLE blocks ADD path varchar(255) NOT NULL DEFAULT ''; \ No newline at end of file
+ALTER TABLE blocks ADD path varchar(255) NOT NULL DEFAULT '';
+
+## 01/31/01
+
+# rename the body fields:
+ALTER TABLE story CHANGE body body_old TEXT DEFAULT '' NOT NULL;
+ALTER TABLE page CHANGE body body_old TEXT DEFAULT '' NOT NULL;
+ALTER TABLE blog CHANGE body body_old TEXT DEFAULT '' NOT NULL;
+ALTER TABLE forum CHANGE body body_old TEXT DEFAULT '' NOT NULL;
+ALTER TABLE book CHANGE body body_old TEXT DEFAULT '' NOT NULL;
+
+#
+# Run the last part of updates/3.00-to-x.xx.php
+#
+
+# update the node table:
+ALTER TABLE node DROP lid;
+ALTER TABLE node ADD teaser TEXT DEFAULT '' NOT NULL;
+ALTER TABLE node ADD body TEXT DEFAULT '' NOT NULL;
+ALTER TABLE node ADD changed int(11) DEFAULT '0' NOT NULL;
+ALTER TABLE node CHANGE timestamp created int(11) DEFAULT '0' NOT NULL;
+ALTER TABLE node CHANGE comment comment int(2) DEFAULT '0' NOT NULL;
+ALTER TABLE node CHANGE promote promote int(2) DEFAULT '0' NOT NULL;
+ALTER TABLE node CHANGE moderate moderate int(2) DEFAULT '0' NOT NULL;
+ALTER TABLE node DROP timestamp_posted;
+ALTER TABLE node DROP timestamp_queued;
+ALTER TABLE node DROP timestamp_hidden;
+
+UPDATE node SET status = 1 WHERE status = 3;
+
+ALTER TABLE book DROP section;
+
+# change
+ALTER TABLE users CHANGE session sid varchar(32) DEFAULT '' NOT NULL;
+
+
+# ALTER TABLE users ADD session TEXT DEFAULT '' NOT NULL;
+# ALTER TABLE users ADD data TEXT DEFAULT '' NOT NULL;
+
+#CREATE TABLE mail (
+# mid tinyint(10) DEFAULT '0' NOT NULL auto_increment,
+# subject varchar(255) DEFAULT '' NOT NULL,
+# recepient varchar(255) DEFAULT '' NOT NULL,
+# sender varchar(255) DEFAULT '' NOT NULL,
+# header text,
+# body text,
+# timestamp int(11) DEFAULT '0' NOT NULL,
+# PRIMARY KEY (mid)
+#);
diff --git a/updates/3.00-to-x.xx.php b/updates/3.00-to-x.xx.php
index fb7e252f7..6d2add3a1 100644
--- a/updates/3.00-to-x.xx.php
+++ b/updates/3.00-to-x.xx.php
@@ -13,6 +13,8 @@ include "includes/common.inc";
** Create sequence tables for pear-ification of MySQL
*/
+/*
+
foreach (module_list() as $name) {
if (module_hook($name, "status")) {
print "$name ...";
@@ -24,5 +26,34 @@ foreach (module_list() as $name) {
print "done ($count)<br />";
}
}
-
+*/
+
+/*
+** Give old nodes a teaser:
+** update your source tree and database first
+*/
+
+$result = db_query("SELECT nid FROM node");
+
+while ($object = db_fetch_object($result)) {
+
+ $node = node_load(array("nid" => $object->nid));
+
+ $body = db_result(db_query("SELECT body_old FROM $node->type WHERE nid = $node->nid"), 0);
+
+ switch ($node->type) {
+ case "forum":
+ case "story":
+ case "book":
+ case "page":
+ case "blog":
+ node_save($node, array("nid", "body" => $body, "teaser" => node_teaser($body)));
+ print "updated node '$node->title' ($node->type)<br />";
+ break;
+ default:
+ print "unknown node '$node->title' ($node->type)<br />";
+ }
+
+}
+
?> \ No newline at end of file