From d6d60de3ccac7b26ed3a14498279c8f16cdcefe7 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Wed, 11 Jul 2001 22:06:24 +0000 Subject: [PATCH] - Added blog.module to replace diary.module (contrubeted by Julian): + feedback wanted - Added updated import.module (contributed by Julian): + user page do browse the headlines by feed and bundle, to display the item descriptions, etc. - Fixed small bug in common.inc. - Updated database.mysql --- database/database.mysql | 27 +- includes/common.inc | 2 +- misc/blog.gif | Bin 0 -> 930 bytes misc/earth.gif | Bin 0 -> 888 bytes misc/xml.gif | Bin 0 -> 429 bytes modules/aggregator.module | 324 ++++++++++++++++++--- modules/aggregator/aggregator.module | 324 ++++++++++++++++++--- modules/blog.module | 404 +++++++++++++++++++++++++++ modules/blog/blog.module | 404 +++++++++++++++++++++++++++ modules/diary.module | 362 ------------------------ modules/import.module | 324 ++++++++++++++++++--- updates/2.00-to-x.xx.sql | 8 + 12 files changed, 1685 insertions(+), 494 deletions(-) create mode 100644 misc/blog.gif create mode 100644 misc/earth.gif create mode 100644 misc/xml.gif create mode 100644 modules/blog.module create mode 100644 modules/blog/blog.module delete mode 100644 modules/diary.module diff --git a/database/database.mysql b/database/database.mysql index 404eb587fbd..ba13a912d95 100644 --- a/database/database.mysql +++ b/database/database.mysql @@ -18,6 +18,13 @@ CREATE TABLE blocks ( PRIMARY KEY (name) ); +CREATE TABLE blog ( + lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, + nid int(10) unsigned DEFAULT '0' NOT NULL, + body text NOT NULL, + PRIMARY KEY (lid) +); + CREATE TABLE book ( lid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, nid int(10) unsigned DEFAULT '0' NOT NULL, @@ -84,6 +91,20 @@ CREATE TABLE channel ( PRIMARY KEY (id) ); +CREATE TABLE chatevents ( + id int(11) DEFAULT '0' NOT NULL auto_increment, + body varchar(255) DEFAULT '' NOT NULL, + timestamp int(11) DEFAULT '0' NOT NULL, + PRIMARY KEY (id) +); + +CREATE TABLE chatmembers ( + id int(11) DEFAULT '0' NOT NULL auto_increment, + nick varchar(32) DEFAULT '' NOT NULL, + timestamp int(11) DEFAULT '0' NOT NULL, + PRIMARY KEY (id) +); + CREATE TABLE collection ( cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, name varchar(32) DEFAULT '' NOT NULL, @@ -144,13 +165,15 @@ CREATE TABLE entry ( CREATE TABLE feed ( fid int(11) DEFAULT '0' NOT NULL auto_increment, title varchar(255) DEFAULT '' NOT NULL, - link varchar(255) DEFAULT '' NOT NULL, + url varchar(255) DEFAULT '' NOT NULL, refresh int(11), uncache int(11), timestamp int(11), attributes varchar(255) DEFAULT '' NOT NULL, + link varchar(255) DEFAULT '' NOT NULL, + description text NOT NULL, UNIQUE title (title), - UNIQUE link (link), + UNIQUE link (url), PRIMARY KEY (fid) ); diff --git a/includes/common.inc b/includes/common.inc index 1bb337280fa..8eca800480b 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -172,7 +172,7 @@ function format_email($address) { return ($address) ? "$address" : message_na(); } -function format_url($address, $description = "") { +function format_url($address, $description = 0) { $description = ($description) ? $description : $address; return ($address) ? "". check_output($description) ."" : message_na(); } diff --git a/misc/blog.gif b/misc/blog.gif new file mode 100644 index 0000000000000000000000000000000000000000..1547cbad0708fb5569be2f7469809abde26fa7ce GIT binary patch literal 930 zcmZ?wbhEHbNsu%^MAuw!0K=B`+Z(>TS zLV0FMhJw4NZvcbhPZmZ727U$|kRL(0gn=WML7qcKBcQ>tiG@`_K|z7x5IZ}Qgb2fd z2G?$O5hjKQ9~K?$WMi~3Xjq`aG(p6DmW#s1M23kf+#(JI36I^FwS2EFi8N04Wa4P} r)}tAmc448KIGbw2mKA4Oog4M$oDzA~xH@8E*Orr0UpF@}FjxZsFso6k literal 0 HcmV?d00001 diff --git a/misc/earth.gif b/misc/earth.gif new file mode 100644 index 0000000000000000000000000000000000000000..3cf5a1212168ad80805b7e5a8491f9b0290ff06b GIT binary patch literal 888 zcmchWv1*i25QWd0#6;K1Do6;5pol3n(-^b}M0BlO3$0b+U}+yNv58!}>g}twk z?Web0d<6@!8o#;v4BloL=H4^kIrH!R2lsC6J)3H(U;2AYaw(*gN>pYtmxU~4)lE0K z%R`>>>bqeISA-%J)lbuut_)==3ni7QTotNRQJ{@9T0G`<^_)I#7G`NyJ(kMdJj~O) znu2DyMOdUoH57N#EyFS`3r3z=xm8%D6;q)`3}`69qQ_vgkw%Nh)rPv}gnPPI`(rFs zghzT*+l7K=hG%*f?t$X2S9qlt_Q(TFUK0oYfxscuhye{HSK(kV+DM~Som{u6IT=wM zB>osnl^I#&id`sZMr9N^k~9Ip#dU(lEm4vOn7k$qm@te(s1XC2mteucV6>60UQyqs zP0cAbMv(YpELB$Z0>}EBVr;bcIhNE=BllkKh_V?+I=$^-xRHm4UjD#p2V)Y_d=6}h z@bEN7{reXG^UtN-lBS^j_f@V`j(!Sbf>FCRROWBHQ8`u60;56P^* zzP!Ibujv2k;_nYGTqrVrzIWmO#~0^2GXH;e^=XUq|5lU#w+@~QWjUL!{QvF4=bIhHE>a}+pdsF%dZ5LD=| z#BIoD$fL)R)+MjaoZe*E(iZKfn$D=lZj>fa!mKi_xiu;<$&gLPH;q*xU1G(IRRQgO zEX>S3QX36fl}q%t&s^=V*~_0Uvgj}qhaSUrHfe2bE&ts{vGdtA*2!*S^4s2EsK(`Y r&xrl1FO#00(U<3bUyZoF{`+ZkFICdR^-y;+hp<-6iGqin3Jlf&%kitR literal 0 HcmV?d00001 diff --git a/modules/aggregator.module b/modules/aggregator.module index a80994e8c1c..11e25fdc4d1 100644 --- a/modules/aggregator.module +++ b/modules/aggregator.module @@ -11,69 +11,153 @@ function import_help() { 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55, 60 => 60, 65 => 65, 70 => 70, 75 => 75, 80 => 80, 85 => 85, 90 => 90, 95 => 95, 100 => 100); + $output .= form_select("Items per block", "import_block_limit", variable_get("import_block_limit", 15), $number, "The maximum number of items displayed in one block."); + $output .= form_select("Items per page", "import_page_limit", variable_get("import_page_limit", 75), $number, "The maximum number of items displayed on one page."); + return $output; +} + function import_perm() { - return array("administer syndication"); + return array("administer news feeds", "access news feeds"); } function import_link($type) { - if ($type == "admin") { - $links[] = "syndication"; + if ($type == "admin" && user_access("administer news feeds")) { + $links[] = "news feeds"; + } + + if ($type == "menu" && user_access("administer news feeds")) { + $links[] = "". t("update all news") .""; + } + + if ($type == "page" && user_access("access news feeds")) { + $links[] = "". t("latest news") .""; } return $links ? $links : array(); } function import_cron() { - $result = db_query("SELECT * FROM feed"); + $result = db_query("SELECT * FROM feed WHERE timestamp + refresh < ". time()); while ($feed = db_fetch_array($result)) { - // remove expired items: - db_query("DELETE FROM item WHERE fid = '$feed[fid]' AND timestamp < ". (time() - $feed[uncache])); - - // update feeds: - if ($feed[timestamp] + $feed[refresh] < time()) import_update($feed); + import_refresh($feed); } } -function import_bundle($attributes, $limit = 100) { +function import_update() { + $result = db_query("SELECT * FROM feed"); + while ($feed = db_fetch_array($result)) { + import_refresh($feed); + } +} + +function import_format_item($item, $feed = 0, $description = 0) { + if (module_hook("blog", "page")) { + $output .= "iid\">\"" "; + } + + if ($feed != 1) { + $output .= "fid\">\"". "; + } + + $output .= "link) ."\" target=\"new\">". check_output($item->title) .""; + + if ($description && ($feed != 1)) { + $output .= "   ". format_url($item->flink, $item->ftitle) .""; + } + + if ($description) { + $output .= "
". check_output($item->description) ."
\n"; + } + + return $output ."
"; +} + +function import_bundle_block($attributes) { + if ($attributes) { - // compose query: $keys = explode(",", $attributes); foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; - $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT $limit"); + $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); while ($item = db_fetch_object($result)) { - $output .= "
  • link) ."\">". check_output($item->title) ."
  • "; + $output .= import_format_item($item, 0); } - return "$output"; + return $output; } } -function import_view_bundle() { - $result = db_query("SELECT * FROM bundle ORDER BY title"); - while ($bundle = db_fetch_object($result)) { - $output .= "$bundle->title
      ". import_bundle($bundle->attributes) ."
    "; - } - return $output; -} +function import_feed_block($feed) { + $result = db_query("SELECT * FROM item WHERE fid = '$feed->fid' ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); -function import_view_feed() { - $result = db_query("SELECT * FROM feed ORDER BY title"); - while ($feed = db_fetch_object($result)) { - $output .= "$feed->title". ($feed->link ? " (". format_url($feed->link) .")" : "") ."
      ". check_output($feed->description) ."
    "; + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 1); } + + $output .= "
    ". t("Last update:") ." ". format_interval(time() - $feed->timestamp) ." ". t("ago"); + return $output; } function import_block() { + return import_block_bundle(); +} + +function import_block_bundle($attributes = 0) { + + if ($attributes) { + $keys = explode(",", $attributes); + foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; + $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); + } + else { + $result = db_query("SELECT * FROM item ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); + } + + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 0); + } + + $blocks[0][subject] = format_url("module.php?mod=import", t("Latest news")); + $blocks[0][content] = $output; + $blocks[0][info] = t("Latest news"); + $result = db_query("SELECT * FROM bundle ORDER BY title"); + while ($bundle = db_fetch_object($result)) { $i++; - $blocks[$i][subject] = $bundle->title; - $blocks[$i][content] = import_bundle($bundle->attributes, 10); + + $blocks[$i][subject] = format_url("module.php?mod=import&op=bundle&id=$bundle->bid", $bundle->title); + $blocks[$i][content] = import_bundle_block($bundle->attributes); $blocks[$i][info] = "$bundle->title bundle"; } + + return $blocks; +} + +function import_block_feed($attributes = 0) { + + if ($attributes) { + $keys = explode(",", $attributes); + foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; + $result = db_query("SELECT * FROM feed WHERE ". implode(" OR ", $where) ." ORDER BY fid LIMIT ". variable_get("import_block_limit", 15)); + } + else { + $result = db_query("SELECT * FROM feed ORDER BY fid LIMIT ". variable_get("import_block_limit", 15)); + } + + $i = 0; + while ($feed = db_fetch_object($result)) { + $blocks[$i][subject] = format_url("module.php?mod=import&op=feed&id=$feed->fid", $feed->title); + $blocks[$i][content] = import_feed_block($feed); + $blocks[$i][info] = "$feed->title feed"; + + $i++; + } + return $blocks; } @@ -82,7 +166,7 @@ function import_remove($feed) { return "feed '$feed[title]' reset."; } -function import_update($feed) { +function import_refresh($feed) { // open socket: $url = parse_url($feed[url]); @@ -90,16 +174,21 @@ function import_update($feed) { if ($fp) { // fetch data: - fputs($fp, "GET $url[path]?$url[query] HTTP/1.0\nUser-Agent: ". variable_get(site_name, "drupal") ."\nHost: $url[host]\nAccept: */*\n\n"); + fputs($fp, "GET $url[path]?$url[query] HTTP/1.0\nUser-Agent: ". variable_get("site_name", "drupal") ."\nHost: $url[host]\nAccept: */*\n\n"); + + while (!feof($fp)) $data .= fgets($fp, 128); // initialize the translation table: $tt = array_flip(get_html_translation_table(HTML_ENTITIES)); $tt["'"] = "'"; - while(!feof($fp)) $data .= fgets($fp, 128); - if (strstr($data, "200 OK")) { - + /* + ** Remove expired items: + */ + + db_query("DELETE FROM item WHERE fid = '$feed[fid]' AND timestamp < ". (time() - $feed[uncache])); + /* ** Extract and process channel information: */ @@ -118,6 +207,8 @@ function import_update($feed) { eregi("", $data, $data); + // print "
    ". htmlentities($data[0]) ."
    "; + $items = array_reverse(explode("", $data[0])); foreach ($items as $item) { @@ -134,7 +225,7 @@ function import_update($feed) { } } else { - watchdog("error", "import: failed to syndicate from '$feed[title]'"); + watchdog("error", "failed to syndicate from '$feed[title]'"); } } @@ -148,7 +239,7 @@ function import_save_item($edit) { else if ($edit[iid]) { db_query("DELETE FROM item WHERE iid = '". check_input($edit[iid]) ."'"); } - else { + else if ($edit[title] && $edit[link]) { if (!db_fetch_object(db_query("SELECT iid FROM item WHERE link = '". check_input($edit[link]) ."'"))) { db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('". check_input($edit[fid]) ."', '". check_input($edit[title]) ."', '". check_input($edit[link]) ."', '". check_input($edit[author]) ."', '". check_input($edit[description]) ."', '". check_input($edit[attributes]) ."', '". time() ."')"); } @@ -178,7 +269,7 @@ function import_save_bundle($edit) { else if ($edit[bid]) { db_query("DELETE FROM bundle WHERE bid = '". check_input($edit[bid]) ."'"); } - else { + else if ($edit[title]) { db_query("INSERT INTO bundle (title, attributes) VALUES ('". check_input($edit[title]) ."', '". check_input($edit[attributes]) ."')"); } @@ -190,8 +281,11 @@ function import_form_feed($edit = array()) { $period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200)); + if ($edit[refresh]== "") $edit[refresh] = 3600; + if ($edit[uncache]== "") $edit[uncache] = 2419200; + $form .= form_textfield("Title", "title", $edit[title], 50, 64, "The name of the feed; typically the name of the website you syndicate content from."); - $form .= form_textfield("URL", "url", $edit[url], 50, 128, "The fully-qualified URL of the feed."); + $form .= form_textfield("Url", "url", $edit[url], 50, 128, "The fully-qualified URL of the feed."); $form .= form_textfield("Attributes", "attributes", $edit[attributes], 50, 128, "A comma-seperated list of keywords describing the feed."); $form .= form_select("Update interval", "refresh", $edit[refresh], $period, "The refresh interval indicating how often you want to update this feed. Requires crontab."); $form .= form_select("Expiration time", "uncache", $edit[uncache], $period, "The time cached items should be kept. Older items will be automatically discarded. Requires crontab."); @@ -215,7 +309,7 @@ function import_save_feed($edit) { db_query("DELETE FROM feed WHERE fid = '". check_input($edit[fid]) ."'"); db_query("DELETE FROM item WHERE fid = '". check_input($edit[fid]) ."'"); } - else { + else if ($edit[title]) { db_query("INSERT INTO feed (title, url, attributes, refresh, uncache) VALUES ('". check_input($edit[title]) ."', '". check_input($edit[url]) ."', '". check_input($edit[attributes]) ."', '". check_input($edit[refresh]) ."', '". check_input($edit[uncache]) ."')"); } } @@ -240,7 +334,7 @@ function import_view() { $output .= "

    Feed overview

    "; $output .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($feed = db_fetch_object($result)) { $output .= " \n"; } @@ -259,6 +353,22 @@ function import_view() { return $output; } +function import_view_feed() { + $result = db_query("SELECT * FROM feed ORDER BY title"); + while ($feed = db_fetch_object($result)) { + $output .= "$feed->title". ($feed->link ? " (". format_url($feed->link) .")" : "") ."
      ". check_output($feed->description) ."
    "; + } + return $output; +} + +function import_view_bundle() { + $result = db_query("SELECT * FROM bundle ORDER BY title"); + while ($bundle = db_fetch_object($result)) { + $output .= "$bundle->title
      ". import_bundle_block($bundle->attributes) ."
    "; + } + return $output; +} + function import_view_item() { global $REQUEST_URI; @@ -268,7 +378,7 @@ function import_view_item() { $output .= "
    siteattributesitemslast updatenext updateoperations
    titleattributesitemslast updatenext updateoperations
    ". check_output($feed->title) ."". check_output($feed->attributes) ."". format_plural($feed->items, "item", "items") ."". ($feed->timestamp ? format_interval(time() - $feed->timestamp) ." ago" : "never") ."". ($feed->timestamp ? format_interval($feed->timestamp + $feed->refresh - time()) ." left" : "never") ."fid\">edit feedfid\">remove itemsfid\">update items
    \n"; $output .= " \n"; while ($item = db_fetch_object($result)) { - $output .= " \n"; + $output .= " \n"; } $output .= "
    timefeeditem
    ". format_date($item->timestamp, "custom", "m/d/y") ."
    ".format_date($item->timestamp, "custom", "H:i") ."
    fid\">". check_output($item->feed) ."link) ."\">". check_output($item->title) ."". ($item->description ? "
    ". check_output($item->description) ."" : "") ."
    iid]\" value=\"". check_form($item->attributes) ."\" size=\"50\" />
    ". format_date($item->timestamp, "custom", "m/d/y") ."
    ".format_date($item->timestamp, "custom", "H:i") ."
    fid\">". check_output($item->feed) ."url) ."\">". check_output($item->title) ."". ($item->description ? "
    ". check_output($item->description) ."" : "") ."
    iid]\" value=\"". check_form($item->attributes) ."\" size=\"50\" />
    \n"; $output .= "\n"; @@ -280,7 +390,7 @@ function import_view_item() { function import_admin() { global $op, $id, $type, $edit; - if (user_access("administer syndication")) { + if (user_access("administer news feeds")) { print "add new feed | add new bundle | available feeds | available bundles | available items | overview | help
    "; @@ -302,11 +412,11 @@ function import_admin() { break; case "remove": print status(import_remove(import_get_feed($id))); - print import_view_feed(); + print import_view(); break; case "update": - print status(import_update(import_get_feed($id))); - print import_view_feed(); + print status(import_refresh(import_get_feed($id))); + print import_view(); break; case "Save attributes": print status(import_save_attributes($edit)); @@ -337,4 +447,132 @@ function import_admin() { } } +function import_page_all() { + global $theme; + + $result = db_query("SELECT i.*, f.title AS ftitle, f.link AS flink FROM item i LEFT JOIN feed f ON i.fid = f.fid ORDER BY i.iid DESC LIMIT ". variable_get("import_page_limit", 75)); + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 0, 1); + } + + $header = t("Latest news for all bundles") ." (by bundle) (by feed) "; + + $theme->header(); + $theme->box($header, $output); + $theme->footer(); +} + +function import_page_feed($fid) { + global $theme; + + $result = db_query("SELECT * FROM feed WHERE fid = '". check_input($fid) ."'"); + $feed = db_fetch_object($result); + + $header .= "url\">"; + $header .= $feed->title . " link\" target=\"new\">\""."; + + $result = db_query("SELECT * FROM item WHERE fid = '". check_input($fid) ."' ORDER BY iid DESC LIMIT ". variable_get("import_page_limit", 75)); + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 1, 1); + } + + $output .= t("Last update:") ." ". format_interval(time() - $feed->timestamp) ." ". t("ago"); + + $theme->header(); + $theme->box($header, $output); + $theme->footer(); +} + +function import_page_bundle($bid) { + global $theme; + + $bundle = db_fetch_object(db_query("SELECT * FROM bundle where bid = '". check_input($bid) ."'")); + $header = $bundle->title ." ". t("bundle") ." (". t("by feed") .")"; + + $keys = explode(",", $bundle->attributes); + foreach ($keys as $key) $where[] = "i.attributes LIKE '%". trim($key) ."%'"; + $result = db_query("SELECT i.*, f.title AS ftitle, f.link AS flink FROM item i, feed f WHERE (". implode(" OR ", $where) .") AND i.fid = f.fid ORDER BY iid DESC LIMIT ". variable_get("import_page_limit", 75)); + + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 0, 1); + } + + $theme->header(); + $theme->box($header, $output); + $theme->footer(); +} + +function import_page_bundles() { + import_page_blocks(import_block_bundle()); +} + +function import_page_feeds() { + import_page_blocks(import_block_feed()); +} + +function import_page_bundle_feeds($bid) { + $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '". check_input($bid) ."'")); + import_page_blocks(import_block_feed($bundle->attributes)); +} + +function import_page_blocks($blocks) { + global $theme; + + $count = count($blocks); + $items = ceil($count / 3); + $c1 = min($items, $count); + $c2 = min(2 * $items, $count); + $c3 = $count; + $i = 0; + + $theme->header(); + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print "
    \n"; + for ($i; $i < $c1; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]); + print " \n"; + for ($i; $i < $c2; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]); + print " \n"; + for ($i; $i < $c3; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]); + print "
    \n"; + $theme->footer(); +} + +function import_page() { + global $op, $id; + + if (user_access("access news feeds")) { + switch($op) { + case "all": + import_page_all(); + break; + case "feed": + import_page_feed($id); + break; + case "bundle": + import_page_bundle($id); + break; + case "bundlefeeds": + import_page_bundle_feeds($id); + break; + case "bundles": + import_page_bundles(); + break; + case "feeds": + import_page_feeds(); + break; + case "update": + import_update(); + import_page_all(); + break; + default: + import_page_all(); + } + } +} + ?> diff --git a/modules/aggregator/aggregator.module b/modules/aggregator/aggregator.module index a80994e8c1c..11e25fdc4d1 100644 --- a/modules/aggregator/aggregator.module +++ b/modules/aggregator/aggregator.module @@ -11,69 +11,153 @@ function import_help() { 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55, 60 => 60, 65 => 65, 70 => 70, 75 => 75, 80 => 80, 85 => 85, 90 => 90, 95 => 95, 100 => 100); + $output .= form_select("Items per block", "import_block_limit", variable_get("import_block_limit", 15), $number, "The maximum number of items displayed in one block."); + $output .= form_select("Items per page", "import_page_limit", variable_get("import_page_limit", 75), $number, "The maximum number of items displayed on one page."); + return $output; +} + function import_perm() { - return array("administer syndication"); + return array("administer news feeds", "access news feeds"); } function import_link($type) { - if ($type == "admin") { - $links[] = "syndication"; + if ($type == "admin" && user_access("administer news feeds")) { + $links[] = "news feeds"; + } + + if ($type == "menu" && user_access("administer news feeds")) { + $links[] = "". t("update all news") .""; + } + + if ($type == "page" && user_access("access news feeds")) { + $links[] = "". t("latest news") .""; } return $links ? $links : array(); } function import_cron() { - $result = db_query("SELECT * FROM feed"); + $result = db_query("SELECT * FROM feed WHERE timestamp + refresh < ". time()); while ($feed = db_fetch_array($result)) { - // remove expired items: - db_query("DELETE FROM item WHERE fid = '$feed[fid]' AND timestamp < ". (time() - $feed[uncache])); - - // update feeds: - if ($feed[timestamp] + $feed[refresh] < time()) import_update($feed); + import_refresh($feed); } } -function import_bundle($attributes, $limit = 100) { +function import_update() { + $result = db_query("SELECT * FROM feed"); + while ($feed = db_fetch_array($result)) { + import_refresh($feed); + } +} + +function import_format_item($item, $feed = 0, $description = 0) { + if (module_hook("blog", "page")) { + $output .= "iid\">\"" "; + } + + if ($feed != 1) { + $output .= "fid\">\"". "; + } + + $output .= "link) ."\" target=\"new\">". check_output($item->title) .""; + + if ($description && ($feed != 1)) { + $output .= "   ". format_url($item->flink, $item->ftitle) .""; + } + + if ($description) { + $output .= "
    ". check_output($item->description) ."
    \n"; + } + + return $output ."
    "; +} + +function import_bundle_block($attributes) { + if ($attributes) { - // compose query: $keys = explode(",", $attributes); foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; - $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT $limit"); + $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); while ($item = db_fetch_object($result)) { - $output .= "
  • link) ."\">". check_output($item->title) ."
  • "; + $output .= import_format_item($item, 0); } - return "$output"; + return $output; } } -function import_view_bundle() { - $result = db_query("SELECT * FROM bundle ORDER BY title"); - while ($bundle = db_fetch_object($result)) { - $output .= "$bundle->title
      ". import_bundle($bundle->attributes) ."
    "; - } - return $output; -} +function import_feed_block($feed) { + $result = db_query("SELECT * FROM item WHERE fid = '$feed->fid' ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); -function import_view_feed() { - $result = db_query("SELECT * FROM feed ORDER BY title"); - while ($feed = db_fetch_object($result)) { - $output .= "$feed->title". ($feed->link ? " (". format_url($feed->link) .")" : "") ."
      ". check_output($feed->description) ."
    "; + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 1); } + + $output .= "
    ". t("Last update:") ." ". format_interval(time() - $feed->timestamp) ." ". t("ago"); + return $output; } function import_block() { + return import_block_bundle(); +} + +function import_block_bundle($attributes = 0) { + + if ($attributes) { + $keys = explode(",", $attributes); + foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; + $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); + } + else { + $result = db_query("SELECT * FROM item ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); + } + + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 0); + } + + $blocks[0][subject] = format_url("module.php?mod=import", t("Latest news")); + $blocks[0][content] = $output; + $blocks[0][info] = t("Latest news"); + $result = db_query("SELECT * FROM bundle ORDER BY title"); + while ($bundle = db_fetch_object($result)) { $i++; - $blocks[$i][subject] = $bundle->title; - $blocks[$i][content] = import_bundle($bundle->attributes, 10); + + $blocks[$i][subject] = format_url("module.php?mod=import&op=bundle&id=$bundle->bid", $bundle->title); + $blocks[$i][content] = import_bundle_block($bundle->attributes); $blocks[$i][info] = "$bundle->title bundle"; } + + return $blocks; +} + +function import_block_feed($attributes = 0) { + + if ($attributes) { + $keys = explode(",", $attributes); + foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; + $result = db_query("SELECT * FROM feed WHERE ". implode(" OR ", $where) ." ORDER BY fid LIMIT ". variable_get("import_block_limit", 15)); + } + else { + $result = db_query("SELECT * FROM feed ORDER BY fid LIMIT ". variable_get("import_block_limit", 15)); + } + + $i = 0; + while ($feed = db_fetch_object($result)) { + $blocks[$i][subject] = format_url("module.php?mod=import&op=feed&id=$feed->fid", $feed->title); + $blocks[$i][content] = import_feed_block($feed); + $blocks[$i][info] = "$feed->title feed"; + + $i++; + } + return $blocks; } @@ -82,7 +166,7 @@ function import_remove($feed) { return "feed '$feed[title]' reset."; } -function import_update($feed) { +function import_refresh($feed) { // open socket: $url = parse_url($feed[url]); @@ -90,16 +174,21 @@ function import_update($feed) { if ($fp) { // fetch data: - fputs($fp, "GET $url[path]?$url[query] HTTP/1.0\nUser-Agent: ". variable_get(site_name, "drupal") ."\nHost: $url[host]\nAccept: */*\n\n"); + fputs($fp, "GET $url[path]?$url[query] HTTP/1.0\nUser-Agent: ". variable_get("site_name", "drupal") ."\nHost: $url[host]\nAccept: */*\n\n"); + + while (!feof($fp)) $data .= fgets($fp, 128); // initialize the translation table: $tt = array_flip(get_html_translation_table(HTML_ENTITIES)); $tt["'"] = "'"; - while(!feof($fp)) $data .= fgets($fp, 128); - if (strstr($data, "200 OK")) { - + /* + ** Remove expired items: + */ + + db_query("DELETE FROM item WHERE fid = '$feed[fid]' AND timestamp < ". (time() - $feed[uncache])); + /* ** Extract and process channel information: */ @@ -118,6 +207,8 @@ function import_update($feed) { eregi("", $data, $data); + // print "
    ". htmlentities($data[0]) ."
    "; + $items = array_reverse(explode("", $data[0])); foreach ($items as $item) { @@ -134,7 +225,7 @@ function import_update($feed) { } } else { - watchdog("error", "import: failed to syndicate from '$feed[title]'"); + watchdog("error", "failed to syndicate from '$feed[title]'"); } } @@ -148,7 +239,7 @@ function import_save_item($edit) { else if ($edit[iid]) { db_query("DELETE FROM item WHERE iid = '". check_input($edit[iid]) ."'"); } - else { + else if ($edit[title] && $edit[link]) { if (!db_fetch_object(db_query("SELECT iid FROM item WHERE link = '". check_input($edit[link]) ."'"))) { db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('". check_input($edit[fid]) ."', '". check_input($edit[title]) ."', '". check_input($edit[link]) ."', '". check_input($edit[author]) ."', '". check_input($edit[description]) ."', '". check_input($edit[attributes]) ."', '". time() ."')"); } @@ -178,7 +269,7 @@ function import_save_bundle($edit) { else if ($edit[bid]) { db_query("DELETE FROM bundle WHERE bid = '". check_input($edit[bid]) ."'"); } - else { + else if ($edit[title]) { db_query("INSERT INTO bundle (title, attributes) VALUES ('". check_input($edit[title]) ."', '". check_input($edit[attributes]) ."')"); } @@ -190,8 +281,11 @@ function import_form_feed($edit = array()) { $period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200)); + if ($edit[refresh]== "") $edit[refresh] = 3600; + if ($edit[uncache]== "") $edit[uncache] = 2419200; + $form .= form_textfield("Title", "title", $edit[title], 50, 64, "The name of the feed; typically the name of the website you syndicate content from."); - $form .= form_textfield("URL", "url", $edit[url], 50, 128, "The fully-qualified URL of the feed."); + $form .= form_textfield("Url", "url", $edit[url], 50, 128, "The fully-qualified URL of the feed."); $form .= form_textfield("Attributes", "attributes", $edit[attributes], 50, 128, "A comma-seperated list of keywords describing the feed."); $form .= form_select("Update interval", "refresh", $edit[refresh], $period, "The refresh interval indicating how often you want to update this feed. Requires crontab."); $form .= form_select("Expiration time", "uncache", $edit[uncache], $period, "The time cached items should be kept. Older items will be automatically discarded. Requires crontab."); @@ -215,7 +309,7 @@ function import_save_feed($edit) { db_query("DELETE FROM feed WHERE fid = '". check_input($edit[fid]) ."'"); db_query("DELETE FROM item WHERE fid = '". check_input($edit[fid]) ."'"); } - else { + else if ($edit[title]) { db_query("INSERT INTO feed (title, url, attributes, refresh, uncache) VALUES ('". check_input($edit[title]) ."', '". check_input($edit[url]) ."', '". check_input($edit[attributes]) ."', '". check_input($edit[refresh]) ."', '". check_input($edit[uncache]) ."')"); } } @@ -240,7 +334,7 @@ function import_view() { $output .= "

    Feed overview

    "; $output .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($feed = db_fetch_object($result)) { $output .= " \n"; } @@ -259,6 +353,22 @@ function import_view() { return $output; } +function import_view_feed() { + $result = db_query("SELECT * FROM feed ORDER BY title"); + while ($feed = db_fetch_object($result)) { + $output .= "$feed->title". ($feed->link ? " (". format_url($feed->link) .")" : "") ."
      ". check_output($feed->description) ."
    "; + } + return $output; +} + +function import_view_bundle() { + $result = db_query("SELECT * FROM bundle ORDER BY title"); + while ($bundle = db_fetch_object($result)) { + $output .= "$bundle->title
      ". import_bundle_block($bundle->attributes) ."
    "; + } + return $output; +} + function import_view_item() { global $REQUEST_URI; @@ -268,7 +378,7 @@ function import_view_item() { $output .= "
    siteattributesitemslast updatenext updateoperations
    titleattributesitemslast updatenext updateoperations
    ". check_output($feed->title) ."". check_output($feed->attributes) ."". format_plural($feed->items, "item", "items") ."". ($feed->timestamp ? format_interval(time() - $feed->timestamp) ." ago" : "never") ."". ($feed->timestamp ? format_interval($feed->timestamp + $feed->refresh - time()) ." left" : "never") ."fid\">edit feedfid\">remove itemsfid\">update items
    \n"; $output .= " \n"; while ($item = db_fetch_object($result)) { - $output .= " \n"; + $output .= " \n"; } $output .= "
    timefeeditem
    ". format_date($item->timestamp, "custom", "m/d/y") ."
    ".format_date($item->timestamp, "custom", "H:i") ."
    fid\">". check_output($item->feed) ."link) ."\">". check_output($item->title) ."". ($item->description ? "
    ". check_output($item->description) ."" : "") ."
    iid]\" value=\"". check_form($item->attributes) ."\" size=\"50\" />
    ". format_date($item->timestamp, "custom", "m/d/y") ."
    ".format_date($item->timestamp, "custom", "H:i") ."
    fid\">". check_output($item->feed) ."url) ."\">". check_output($item->title) ."". ($item->description ? "
    ". check_output($item->description) ."" : "") ."
    iid]\" value=\"". check_form($item->attributes) ."\" size=\"50\" />
    \n"; $output .= "\n"; @@ -280,7 +390,7 @@ function import_view_item() { function import_admin() { global $op, $id, $type, $edit; - if (user_access("administer syndication")) { + if (user_access("administer news feeds")) { print "add new feed | add new bundle | available feeds | available bundles | available items | overview | help
    "; @@ -302,11 +412,11 @@ function import_admin() { break; case "remove": print status(import_remove(import_get_feed($id))); - print import_view_feed(); + print import_view(); break; case "update": - print status(import_update(import_get_feed($id))); - print import_view_feed(); + print status(import_refresh(import_get_feed($id))); + print import_view(); break; case "Save attributes": print status(import_save_attributes($edit)); @@ -337,4 +447,132 @@ function import_admin() { } } +function import_page_all() { + global $theme; + + $result = db_query("SELECT i.*, f.title AS ftitle, f.link AS flink FROM item i LEFT JOIN feed f ON i.fid = f.fid ORDER BY i.iid DESC LIMIT ". variable_get("import_page_limit", 75)); + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 0, 1); + } + + $header = t("Latest news for all bundles") ." (by bundle) (by feed) "; + + $theme->header(); + $theme->box($header, $output); + $theme->footer(); +} + +function import_page_feed($fid) { + global $theme; + + $result = db_query("SELECT * FROM feed WHERE fid = '". check_input($fid) ."'"); + $feed = db_fetch_object($result); + + $header .= "url\">"; + $header .= $feed->title . " link\" target=\"new\">\""."; + + $result = db_query("SELECT * FROM item WHERE fid = '". check_input($fid) ."' ORDER BY iid DESC LIMIT ". variable_get("import_page_limit", 75)); + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 1, 1); + } + + $output .= t("Last update:") ." ". format_interval(time() - $feed->timestamp) ." ". t("ago"); + + $theme->header(); + $theme->box($header, $output); + $theme->footer(); +} + +function import_page_bundle($bid) { + global $theme; + + $bundle = db_fetch_object(db_query("SELECT * FROM bundle where bid = '". check_input($bid) ."'")); + $header = $bundle->title ." ". t("bundle") ." (". t("by feed") .")"; + + $keys = explode(",", $bundle->attributes); + foreach ($keys as $key) $where[] = "i.attributes LIKE '%". trim($key) ."%'"; + $result = db_query("SELECT i.*, f.title AS ftitle, f.link AS flink FROM item i, feed f WHERE (". implode(" OR ", $where) .") AND i.fid = f.fid ORDER BY iid DESC LIMIT ". variable_get("import_page_limit", 75)); + + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 0, 1); + } + + $theme->header(); + $theme->box($header, $output); + $theme->footer(); +} + +function import_page_bundles() { + import_page_blocks(import_block_bundle()); +} + +function import_page_feeds() { + import_page_blocks(import_block_feed()); +} + +function import_page_bundle_feeds($bid) { + $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '". check_input($bid) ."'")); + import_page_blocks(import_block_feed($bundle->attributes)); +} + +function import_page_blocks($blocks) { + global $theme; + + $count = count($blocks); + $items = ceil($count / 3); + $c1 = min($items, $count); + $c2 = min(2 * $items, $count); + $c3 = $count; + $i = 0; + + $theme->header(); + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print "
    \n"; + for ($i; $i < $c1; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]); + print " \n"; + for ($i; $i < $c2; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]); + print " \n"; + for ($i; $i < $c3; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]); + print "
    \n"; + $theme->footer(); +} + +function import_page() { + global $op, $id; + + if (user_access("access news feeds")) { + switch($op) { + case "all": + import_page_all(); + break; + case "feed": + import_page_feed($id); + break; + case "bundle": + import_page_bundle($id); + break; + case "bundlefeeds": + import_page_bundle_feeds($id); + break; + case "bundles": + import_page_bundles(); + break; + case "feeds": + import_page_feeds(); + break; + case "update": + import_update(); + import_page_all(); + break; + default: + import_page_all(); + } + } +} + ?> diff --git a/modules/blog.module b/modules/blog.module new file mode 100644 index 00000000000..7a6f577ce52 --- /dev/null +++ b/modules/blog.module @@ -0,0 +1,404 @@ +title = $blog[title]; + $this->body = $blog[body]; + $this->userid = $blog[userid] ? $blog[userid] : $user->userid; + $this->timestamp = $blog[timestamp]; + } +} + +function blog_help() { + ?> +

    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.

    +

    TODO

    : +

    Add an entry on the account display for another user, linked to module.php?mod=blog&name=$userid

    +

    Provide links on other "Noded" module displays to allow the node to be blogged module.php?mod=blog&type=blog&id=$nid . Currently these are available on blogs and import displays.

    +

    Combine the calendar display class with the node calendar display class.

    + nid\">\"". userid) ."\">\"". ". format_username($blog->userid) ." ". t("on") ." ". format_date($blog->timestamp) .":
    "; + $output .= "
    ". check_input($blog->title) ."
    " . check_output($blog->body, 1) ."
    \n"; + } + + $theme->header(); + $theme->box(t("Latest blogs"), $output); + $theme->footer(); +} + +function blog_page_user($userid = 0, $date = 0) { + global $theme, $user; + + $userid = $userid ? $userid : $user->userid; + + $theme->header(); + + if ($date) { + + /* + ** Displays today's blogs for this user: + */ + + blog_page_day($userid, $date); + } + else { + + /* + ** Display the last blogs for this user: + */ + + $result = db_query("SELECT n.nid, n.timestamp FROM node n LEFT JOIN users u ON u.id = n.author WHERE u.userid = '". check_input($userid) ."' AND n.timestamp > ". (time() - 2592000) ." LIMIT 15"); + while ($blog = db_fetch_object($result)) { + if ($date != date("ndy", $blog->timestamp)) { + $date = date("ndy", $blog->timestamp); + blog_page_day($userid, $blog->timestamp); + } + } + } + + $theme->footer(); +} + + +function blog_page_day($userid = 0, $date = 0) { + global $theme, $user; + + $header .= "\n"; + $header .= " \n"; + $header .= " \n"; + $header .= " \n"; + $header .= " \n"; + $header .= "
    ". check_output($userid) ."'s ". t("blog") ."". format_date($date, custom, "d-M-Y") ."
    \n"; + + $sdate = mktime(0, 0, 0, date("m", $date), date("d", $date), date("Y", $date)); + $edate = mktime(23, 59, 59, date("m", $date), date("d", $date), date("Y", $date)); + + $result = db_query("SELECT b.body, n.timestamp, n.nid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.userid = '". check_input($userid) ."' AND n.timestamp > '$sdate' AND n.timestamp < '$edate' ORDER BY b.lid DESC LIMIT 50"); + + while ($blog = db_fetch_object($result)) { + if (!$first) $first = $blog->nid; + $output .= "

    nid\">\"". ". check_output($blog->body, 1) ."

    \n"; + } + + if ($userid == $user->userid) { + $output .= "

    [ ". t("edit") ." ]

    "; + } + + $theme->box($header, $output); +} + +function blog_status() { + return array(dumped, posted); +} + +function blog_remove($nid) { + global $status, $user; + + node_save(array(nid => $nid), array(status => $status[dumped])); + $blog = node_get_object(array(type => "blog", nid => "$nid")); + if ((user_access("administer blogs")) or ($blog->userid == $user->userid)) { + node_del(array(type => "blog", nid => $nid, lid => $blog->lid)); + } +} + +function blog_view($node) { + global $status, $theme; + + $userid = urlencode($node->userid); + + $header .= "\n"; + $header .= " \n"; + $header .= " \n"; + $header .= " \n"; + $header .= " \n"; + $header .= "
    ". $node->userid ."'s ". t("blog") ."timestamp\">". format_date($node->timestamp, custom, "d-M-Y") ."
    \n"; + + $output .= "

    ". check_output($node->body, 1) ."

    \n"; + $output .= "

    [ ". implode(" | ", link_node($node)) ."]

    \n"; + + $theme->box($header, $output); +} + +function blog_form($edit = array()) { + global $REQUEST_URI, $id, $type, $user, $theme; + + if ($edit[type] == "blog") { + } + else if ($type == "blog") { + $item = node_get_object(array(type => "blog", nid => $id)); + $edit["title"] = $item->title; + $edit["body"] = $item->body ." [userid) ."&date=$item->timestamp\">$item->userid]"; + } + 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"] = "link\">$item->title - ". check_output($item->description) ." [flink\">$item->ftitle]\n"; + } + + if ($edit[title]) { + $form .= blog_view(new Blog(node_preview($edit))); + } + + $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", ""))); + + $form .= form_hidden("type", "blog"); + + if ($edit["nid"] > 0) { + $form .= form_hidden("nid", $edit["nid"]); + } + + if ($edit && !$edit["title"]) { + $form .= "". t("Warning: you did not supply a subject.") ."

    \n"; + $form .= form_submit(t("Preview")); + } + else if ($edit && !$edit["body"]) { + $form .= "". t("Warning: you did not supply any text.") ."

    \n"; + $form .= form_submit(t("Preview")); + } + else { + $form .= form_submit(t("Preview")); + $form .= form_submit(t("Submit")); + } + + $output .= form($REQUEST_URI, $form); + + return $output; +} + +function blog_save($edit) { + global $status, $user; + + if (!$edit["nid"]) { + node_save($edit, array(author => $user->id, body, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog")); + } + else if (user_access("administer blogs")) { + node_save($edit, array(attributes => node_attributes_save("blog", $edit), body, title, type => "blog")); + } +} + +function blog_edit_history($nid) { + global $user; + + // DB: changed this to 15 older blog entries rather than today's entries + // as there was no way to edit entries older than a day. The notion + // of a day can be quite annoying when bloging around midnight. All + // entries are accessible now. + // + // $blog = node_get_object(array(nid => $nid, type => "blog")); + // $sdate = mktime(0, 0, 0, date("m", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)); + // $edate = mktime(23, 59, 59, date("m", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)); + // $result = db_query("SELECT n.title, b.body, n.timestamp, n.nid FROM blog b LEFT JOIN node n ON b.nid = n.nid WHERE n.author = '$user->id' AND n.timestamp > '$sdate' AND n.timestamp < '$edate' ORDER BY b.lid DESC LIMIT 100"); + + $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.author = '". check_input($user->id) ."' AND n.nid < '". check_input($nid) ."' ORDER BY b.lid DESC LIMIT 15"); + + $output .= ""; + while ($blog = db_fetch_object($result)) { + $output .= "\n"; + } + $output .= "
    ". check_output($blog->title) ."
    ". check_output($blog->body, 1) ."
    nid\">". t("edit") ."nid\">". t("delete") ."
    "; + + return $output; +} + +function blog_page() { + global $op, $name, $date; + + if (user_access("access blogs")) { + if ($name) { + blog_page_user($name, $date); + } + else { + blog_page_all(); + } + } +} + +function blog_user() { + global $op, $id, $name, $date, $edit, $theme, $user; + + if (user_access("post blogs")) { + switch ($op) { + case "delete": + blog_remove($id); + blog_page_day($user->userid, time()); + break; + case "edit": + $theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog")))); + $theme->box(t("Older blogs"), blog_edit_history($id)); + break; + case t("Preview"): + $theme->box(t("Preview Blog"), blog_form($edit)); + break; + case t("Submit"): + blog_save($edit); + blog_page_day($user->userid, time()); + break; + default: + $theme->box(t("Submit a blog"), blog_form($edit)); + } + } +} + + +function blog_link($type) { + global $user; + + if ($type == "page" && user_access("access blogs")) { + $links[] = "". t("latest blogs") .""; + } + + if ($type == "menu" && user_access("post blogs")) { + $links[] = "userid) ."\">". t("your blog") .""; + } + + return $links ? $links : array(); +} + + +function blog_block() { + global $name, $date, $user, $mod; + + $result = db_query("SELECT u.userid, n.timestamp, n.title, n.nid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10"); + while ($node = db_fetch_object($result)) { + $output .= "userid) ."\">". check_output($node->title) ."
    \n"; + } + + $block[0]["subject"] = "
    ". t("Latest blogs") .""; + $block[0]["content"] = $output; + $block[0]["info"] = t("Latest blogs"); + $block[0]["link"] = "module.php?mod=blog"; + + $date = $data ? $data : time(); + $userid = $name ? $name : $user->userid; + + if (($mod == "blog") || ($mod == "block")) { + // Only show this block on "blog pages" and in the admin block section. + $calendar = new BlogCalendar($userid, $date); + $block[1]["subject"] = "" . t("Browse blog") . ""; + $block[1]["content"] = $calendar->display(); + $block[1]["info"] = t("Calendar to browse blogs"); + } + + return $block; +} + + +function blog_search($keys) { + global $status, $user; + $result = db_query("SELECT n.*, b.* FROM blog b LEFT JOIN node n ON n.nid = b.nid AND n.lid = b.lid 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" => (user_access("administer nodes") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->userid, "date" => $blog->timestamp); + } + return $find; +} + + +class BlogCalendar { + var $date; + var $userid; + + function BlogCalendar($userid, $date) { + $this->userid = urlencode($userid); + + // 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\n"; + $output .= "\n"; + $output .= " \n"; + + // Generate the days of the week: + $output .= " "; + $somesunday = mktime(0, 0, 0, 3, 20, 1994); + for ($i = 0; $i < 7; $i++) { + $output .= ""; + } + $output .= "\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 .= " \n"; + $first = 0; + } + + // Start every week on a new line: + if ($sday == 0) $output .= " \n"; + + // Print one cell: + $date = mktime(23, 59, 59, $month, $nday, $year); + if ($date == $this->date) $output .= " \n"; + else if ($date > $today) $output .= " \n"; + else $output .= " \n"; + + // Start every week on a new line: + if ($sday == 6) $output .= " \n"; + + // Update temporary variables: + $sday++; + $sday = $sday % 7; + $nday++; + } + + // Complete the calendar: + if ($sday) { + $end = 7 - $sday; + $output .= " \n \n"; + } + $output .= "
    userid&date=$prev\" STYLE=\"text-decoration: none;\"><<   ". date("F Y", $this->date) ."   " . ($next <= $thislast ? "userid&date=$next\" STYLE=\"text-decoration: none;\">>>" : ">>") . "
    " . substr(ucfirst(t(date("l", $somesunday + $i * 86400))), 0, 1) . "
     
    $nday$ndayuserid&date=$date\" STYLE=\"text-decoration: none;\">$nday
     
    \n\n"; + + // Return calendar: + return $output; + } +} + +?> diff --git a/modules/blog/blog.module b/modules/blog/blog.module new file mode 100644 index 00000000000..7a6f577ce52 --- /dev/null +++ b/modules/blog/blog.module @@ -0,0 +1,404 @@ +title = $blog[title]; + $this->body = $blog[body]; + $this->userid = $blog[userid] ? $blog[userid] : $user->userid; + $this->timestamp = $blog[timestamp]; + } +} + +function blog_help() { + ?> +

    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.

    +

    TODO

    : +

    Add an entry on the account display for another user, linked to module.php?mod=blog&name=$userid

    +

    Provide links on other "Noded" module displays to allow the node to be blogged module.php?mod=blog&type=blog&id=$nid . Currently these are available on blogs and import displays.

    +

    Combine the calendar display class with the node calendar display class.

    + nid\">\"". userid) ."\">\"". ". format_username($blog->userid) ." ". t("on") ." ". format_date($blog->timestamp) .":
    "; + $output .= "
    ". check_input($blog->title) ."
    " . check_output($blog->body, 1) ."
    \n"; + } + + $theme->header(); + $theme->box(t("Latest blogs"), $output); + $theme->footer(); +} + +function blog_page_user($userid = 0, $date = 0) { + global $theme, $user; + + $userid = $userid ? $userid : $user->userid; + + $theme->header(); + + if ($date) { + + /* + ** Displays today's blogs for this user: + */ + + blog_page_day($userid, $date); + } + else { + + /* + ** Display the last blogs for this user: + */ + + $result = db_query("SELECT n.nid, n.timestamp FROM node n LEFT JOIN users u ON u.id = n.author WHERE u.userid = '". check_input($userid) ."' AND n.timestamp > ". (time() - 2592000) ." LIMIT 15"); + while ($blog = db_fetch_object($result)) { + if ($date != date("ndy", $blog->timestamp)) { + $date = date("ndy", $blog->timestamp); + blog_page_day($userid, $blog->timestamp); + } + } + } + + $theme->footer(); +} + + +function blog_page_day($userid = 0, $date = 0) { + global $theme, $user; + + $header .= "\n"; + $header .= " \n"; + $header .= " \n"; + $header .= " \n"; + $header .= " \n"; + $header .= "
    ". check_output($userid) ."'s ". t("blog") ."". format_date($date, custom, "d-M-Y") ."
    \n"; + + $sdate = mktime(0, 0, 0, date("m", $date), date("d", $date), date("Y", $date)); + $edate = mktime(23, 59, 59, date("m", $date), date("d", $date), date("Y", $date)); + + $result = db_query("SELECT b.body, n.timestamp, n.nid FROM blog b LEFT JOIN node n ON b.nid = n.nid LEFT JOIN users u ON n.author = u.id WHERE u.userid = '". check_input($userid) ."' AND n.timestamp > '$sdate' AND n.timestamp < '$edate' ORDER BY b.lid DESC LIMIT 50"); + + while ($blog = db_fetch_object($result)) { + if (!$first) $first = $blog->nid; + $output .= "

    nid\">\"". ". check_output($blog->body, 1) ."

    \n"; + } + + if ($userid == $user->userid) { + $output .= "

    [ ". t("edit") ." ]

    "; + } + + $theme->box($header, $output); +} + +function blog_status() { + return array(dumped, posted); +} + +function blog_remove($nid) { + global $status, $user; + + node_save(array(nid => $nid), array(status => $status[dumped])); + $blog = node_get_object(array(type => "blog", nid => "$nid")); + if ((user_access("administer blogs")) or ($blog->userid == $user->userid)) { + node_del(array(type => "blog", nid => $nid, lid => $blog->lid)); + } +} + +function blog_view($node) { + global $status, $theme; + + $userid = urlencode($node->userid); + + $header .= "\n"; + $header .= " \n"; + $header .= " \n"; + $header .= " \n"; + $header .= " \n"; + $header .= "
    ". $node->userid ."'s ". t("blog") ."timestamp\">". format_date($node->timestamp, custom, "d-M-Y") ."
    \n"; + + $output .= "

    ". check_output($node->body, 1) ."

    \n"; + $output .= "

    [ ". implode(" | ", link_node($node)) ."]

    \n"; + + $theme->box($header, $output); +} + +function blog_form($edit = array()) { + global $REQUEST_URI, $id, $type, $user, $theme; + + if ($edit[type] == "blog") { + } + else if ($type == "blog") { + $item = node_get_object(array(type => "blog", nid => $id)); + $edit["title"] = $item->title; + $edit["body"] = $item->body ." [userid) ."&date=$item->timestamp\">$item->userid]"; + } + 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"] = "link\">$item->title - ". check_output($item->description) ." [flink\">$item->ftitle]\n"; + } + + if ($edit[title]) { + $form .= blog_view(new Blog(node_preview($edit))); + } + + $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", ""))); + + $form .= form_hidden("type", "blog"); + + if ($edit["nid"] > 0) { + $form .= form_hidden("nid", $edit["nid"]); + } + + if ($edit && !$edit["title"]) { + $form .= "". t("Warning: you did not supply a subject.") ."

    \n"; + $form .= form_submit(t("Preview")); + } + else if ($edit && !$edit["body"]) { + $form .= "". t("Warning: you did not supply any text.") ."

    \n"; + $form .= form_submit(t("Preview")); + } + else { + $form .= form_submit(t("Preview")); + $form .= form_submit(t("Submit")); + } + + $output .= form($REQUEST_URI, $form); + + return $output; +} + +function blog_save($edit) { + global $status, $user; + + if (!$edit["nid"]) { + node_save($edit, array(author => $user->id, body, status => variable_get("blog_status", $status[posted]), timestamp => time(), title, type => "blog")); + } + else if (user_access("administer blogs")) { + node_save($edit, array(attributes => node_attributes_save("blog", $edit), body, title, type => "blog")); + } +} + +function blog_edit_history($nid) { + global $user; + + // DB: changed this to 15 older blog entries rather than today's entries + // as there was no way to edit entries older than a day. The notion + // of a day can be quite annoying when bloging around midnight. All + // entries are accessible now. + // + // $blog = node_get_object(array(nid => $nid, type => "blog")); + // $sdate = mktime(0, 0, 0, date("m", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)); + // $edate = mktime(23, 59, 59, date("m", $blog->timestamp), date("d", $blog->timestamp), date("Y", $blog->timestamp)); + // $result = db_query("SELECT n.title, b.body, n.timestamp, n.nid FROM blog b LEFT JOIN node n ON b.nid = n.nid WHERE n.author = '$user->id' AND n.timestamp > '$sdate' AND n.timestamp < '$edate' ORDER BY b.lid DESC LIMIT 100"); + + $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.author = '". check_input($user->id) ."' AND n.nid < '". check_input($nid) ."' ORDER BY b.lid DESC LIMIT 15"); + + $output .= ""; + while ($blog = db_fetch_object($result)) { + $output .= "\n"; + } + $output .= "
    ". check_output($blog->title) ."
    ". check_output($blog->body, 1) ."
    nid\">". t("edit") ."nid\">". t("delete") ."
    "; + + return $output; +} + +function blog_page() { + global $op, $name, $date; + + if (user_access("access blogs")) { + if ($name) { + blog_page_user($name, $date); + } + else { + blog_page_all(); + } + } +} + +function blog_user() { + global $op, $id, $name, $date, $edit, $theme, $user; + + if (user_access("post blogs")) { + switch ($op) { + case "delete": + blog_remove($id); + blog_page_day($user->userid, time()); + break; + case "edit": + $theme->box(t("Submit a blog"), blog_form(node_get_array(array("nid" => $id, "type" => "blog")))); + $theme->box(t("Older blogs"), blog_edit_history($id)); + break; + case t("Preview"): + $theme->box(t("Preview Blog"), blog_form($edit)); + break; + case t("Submit"): + blog_save($edit); + blog_page_day($user->userid, time()); + break; + default: + $theme->box(t("Submit a blog"), blog_form($edit)); + } + } +} + + +function blog_link($type) { + global $user; + + if ($type == "page" && user_access("access blogs")) { + $links[] = "". t("latest blogs") .""; + } + + if ($type == "menu" && user_access("post blogs")) { + $links[] = "userid) ."\">". t("your blog") .""; + } + + return $links ? $links : array(); +} + + +function blog_block() { + global $name, $date, $user, $mod; + + $result = db_query("SELECT u.userid, n.timestamp, n.title, n.nid FROM node n LEFT JOIN users u ON n.author = u.id WHERE n.type = 'blog' ORDER BY n.nid DESC LIMIT 10"); + while ($node = db_fetch_object($result)) { + $output .= "userid) ."\">". check_output($node->title) ."
    \n"; + } + + $block[0]["subject"] = "
    ". t("Latest blogs") .""; + $block[0]["content"] = $output; + $block[0]["info"] = t("Latest blogs"); + $block[0]["link"] = "module.php?mod=blog"; + + $date = $data ? $data : time(); + $userid = $name ? $name : $user->userid; + + if (($mod == "blog") || ($mod == "block")) { + // Only show this block on "blog pages" and in the admin block section. + $calendar = new BlogCalendar($userid, $date); + $block[1]["subject"] = "" . t("Browse blog") . ""; + $block[1]["content"] = $calendar->display(); + $block[1]["info"] = t("Calendar to browse blogs"); + } + + return $block; +} + + +function blog_search($keys) { + global $status, $user; + $result = db_query("SELECT n.*, b.* FROM blog b LEFT JOIN node n ON n.nid = b.nid AND n.lid = b.lid 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" => (user_access("administer nodes") ? "admin.php?mod=node&type=blog&op=edit&id=$blog->nid" : "node.php?id=$blog->nid"), "user" => $blog->userid, "date" => $blog->timestamp); + } + return $find; +} + + +class BlogCalendar { + var $date; + var $userid; + + function BlogCalendar($userid, $date) { + $this->userid = urlencode($userid); + + // 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\n"; + $output .= "\n"; + $output .= " \n"; + + // Generate the days of the week: + $output .= " "; + $somesunday = mktime(0, 0, 0, 3, 20, 1994); + for ($i = 0; $i < 7; $i++) { + $output .= ""; + } + $output .= "\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 .= " \n"; + $first = 0; + } + + // Start every week on a new line: + if ($sday == 0) $output .= " \n"; + + // Print one cell: + $date = mktime(23, 59, 59, $month, $nday, $year); + if ($date == $this->date) $output .= " \n"; + else if ($date > $today) $output .= " \n"; + else $output .= " \n"; + + // Start every week on a new line: + if ($sday == 6) $output .= " \n"; + + // Update temporary variables: + $sday++; + $sday = $sday % 7; + $nday++; + } + + // Complete the calendar: + if ($sday) { + $end = 7 - $sday; + $output .= " \n \n"; + } + $output .= "
    userid&date=$prev\" STYLE=\"text-decoration: none;\"><<   ". date("F Y", $this->date) ."   " . ($next <= $thislast ? "userid&date=$next\" STYLE=\"text-decoration: none;\">>>" : ">>") . "
    " . substr(ucfirst(t(date("l", $somesunday + $i * 86400))), 0, 1) . "
     
    $nday$ndayuserid&date=$date\" STYLE=\"text-decoration: none;\">$nday
     
    \n\n"; + + // Return calendar: + return $output; + } +} + +?> diff --git a/modules/diary.module b/modules/diary.module deleted file mode 100644 index 9a39c1c7cae..00000000000 --- a/modules/diary.module +++ /dev/null @@ -1,362 +0,0 @@ - "$diary->userid's diary", "link" => (user_access("administer diary entries") ? "admin.php?mod=diary&op=edit&id=$diary->id" : "module.php?mod=diary&op=view&name=$diary->userid"), "user" => $diary->userid, "date" => $diary->timestamp); - } - return $find; - -} - -function diary_page_overview($num = 20) { - global $theme, $user; - - if (user_access("access diary entries")) { - $result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id ORDER BY d.timestamp DESC LIMIT $num"); - - while ($diary = db_fetch_object($result)) { - if ($time != date("F jS", $diary->timestamp)) { - $output .= "". $date = t(date("l", $diary->timestamp)) .", ". t(date("F", $diary->timestamp)) ." ". date("j", $diary->timestamp) ."\n"; - $time = date("F jS", $diary->timestamp); - } - $output .= "

    \n"; - $output .= "

    $diary->userid ". t("wrote") .":

    \n"; - $output .= "
    \n"; - $output .= "

    ". check_output($diary->text, 1) ."

    [ userid\">". t("more") ." ]

    \n"; - $output .= "
    \n"; - $output .= "
    \n"; - } - - $theme->header(); - $theme->box(t("Online diary"), $output); - $theme->footer(); - } - else { - $theme->header(); - $theme->box(t("Access denied"), message_access()); - $theme->footer(); - } -} - -function diary_page_entry($timestamp, $text, $id = 0) { - if ($id) { - $output .= "
    \n"; - $output .= "
    ". format_date($timestamp, "large") .":
    \n"; - $output .= "

    [ ". t("edit") ." | ". t("delete") ." ]

    ". check_output($text, 1) ."

    \n"; - $output .= "
    \n"; - } - else { - $output .= "
    \n"; - $output .= "
    ". format_date($timestamp, "large") .":
    \n"; - $output .= "

    ". check_output($text, 1) ."

    \n"; - $output .= "
    \n"; - } - return $output; -} - -function diary_page_display($username) { - global $theme, $user; - - $username = empty($username) ? $user->userid : $username; - - $result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id WHERE u.userid = '$username' ORDER BY timestamp DESC"); - - if ($username == $user->userid) { - $output .= diary_page_entry(time(), "". t("Add new diary entry!") ."

    "); - while ($diary = db_fetch_object($result)) $output .= diary_page_entry($diary->timestamp, $diary->text, $diary->id); - } - else { - $output .= "". t("Username") .": ". format_username($username); - while ($diary = db_fetch_object($result)) $output .= diary_page_entry($diary->timestamp, $diary->text); - } - - $theme->header(); - $theme->box(t("Online diary"), $output); - $theme->footer(); -} - -function diary_page_add() { - global $theme, $user; - - $output .= "

    \n"; - - $output .= "

    \n"; - $output .= "
    \n"; - $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")) .".\n"; - $output .= "

    \n"; - - $output .= "

    \n"; - $output .= " \n"; - $output .= "

    \n"; - - $output .= "
    \n"; - - $theme->header(); - $theme->box(t("Edit your diary"), $output); - $theme->footer(); -} - -function diary_page_delete($id) { - db_query("DELETE FROM diaries WHERE id = '$id'"); - watchdog("message", "diary: diary entry deleted"); -} - -function diary_page_edit($id) { - global $theme, $user; - - $result = db_query("SELECT * FROM diaries WHERE id = '$id'"); - $diary = db_fetch_object($result); - - $output .= diary_page_entry($diary->timestamp, $diary->text); - - $output .= "
    \n"; - $output .= "

    \n"; - $output .= "
    \n"; - $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")) .".\n"; - $output .= "

    \n"; - $output .= "

    \n"; - $output .= " id\">\n"; - $output .= " timestamp\">\n"; - $output .= " \n"; - $output .= "

    \n"; - $output .= "
    \n"; - - $theme->header(); - $theme->box(t("Edit your diary"), $output); - $theme->footer(); -} - -function diary_page_preview($text, $timestamp, $id = 0) { - global $theme, $user; - - $output .= diary_page_entry($timestamp, $text); - - $output .= "
    \n"; - $output .= "

    \n"; - $output .= "
    \n"; - $output .= " ". t("Allowed HTML tags") .": ". htmlspecialchars(variable_get("allowed_html", "")) .".\n"; - $output .= "

    \n"; - $output .= "

    \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= "

    \n"; - - $output .= "
    \n"; - - $theme->header(); - $theme->box(t("Edit your diary"), $output); - $theme->footer(); -} - -function diary_page_submit($text, $id = 0) { - global $user, $theme; - - if ($id) { - watchdog("message", "diary: old diary entry updated"); - db_query("UPDATE diaries SET text = '$text' WHERE id = '$id'"); - } - else { - watchdog("special", "diary: new diary entry added"); - db_query("INSERT INTO diaries (author, text, timestamp) VALUES ('$user->id', '$text', '". time() ."')"); - } - - header("Location: module.php?mod=diary&op=view&name=$user->userid"); -} - -function diary_page() { - global $op, $id, $name, $text, $timestamp; - - // Security check: - if (strstr($id, " ") || strstr($name, " ")) { - watchdog("error", "diary: attempt to provide malicious input through URI"); - exit(); - } - - switch($op) { - case "add": - diary_page_add(); - break; - case "delete": - diary_page_delete(check_input($id)); - diary_page_display(check_input($name)); - break; - case "edit": - diary_page_edit(check_input($id)); - break; - case "view": - diary_page_display(check_input($name)); - break; - case "Preview diary entry": - if ($id) diary_page_preview(($text ? check_output($text) : ""), check_input($timestamp), check_input($id)); - else diary_page_preview(($text ? check_output($text) : ""), time()); - break; - case "Submit diary entry": - if ($id) diary_page_submit(check_input($text), check_input($id)); - else diary_page_submit(check_input($text)); - break; - default: - diary_page_overview(); - } -} - -function diary_help() { - ?> -

    Drupal's diary module allows registered users to maintain an online 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.

    - online diaries"; - } - - if ($type == "page" && user_access("access diary entries")) { - $links[] = "". t("online diaries") .""; - } - - if ($type == "menu" && user_access("post diary entries")) { - $links[] = "". t("edit your diary") .""; - $links[] = "". t("view your diary") .""; - } - - return $links ? $links : array(); -} - -function diary_block() { - $result = db_query("SELECT u.userid, d.timestamp FROM diaries d LEFT JOIN users u ON d.author = u.id ORDER BY timestamp DESC LIMIT 10"); - - while ($diary = db_fetch_object($result)) { - if ($time != date("F jS", $diary->timestamp)) { - $content .= "

    ". t(date("l", $diary->timestamp)) ." (". date("m/d/Y", $diary->timestamp) .")

    \n"; - $time = date("F jS", $diary->timestamp); - } - $content .= "
  • userid\">$diary->userid
  • \n"; - } - - $block[0]["subject"] = "Recent diary entries"; - $block[0]["content"] = $content; - $block[0]["info"] = "Recent diary entries"; - $block[0]["link"] = "module.php?mod=diary"; - - return $block; -} - -function diary_admin_edit($id) { - $result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id WHERE d.id = '$id'"); - - $diary = db_fetch_object($result); - - $output .= "
    \n"; - - $output .= "

    \n"; - $output .= " Author:
    \n"; - $output .= " ". format_username($diary->userid) ."\n"; - $output .= "

    \n"; - - $output .= "

    \n"; - $output .= "Diary entry:
    \n"; - $output .= "
    \n"; - $output .= "

    \n"; - - $output .= "

    \n"; - $output .= " \n"; - $output .= "

    \n"; - $output .= "
    \n"; - - print $output; -} - -function diary_admin_save($id, $text) { - db_query("UPDATE diaries SET text = '$text' WHERE id = $id"); - watchdog("message", "diary: modified entry #$id."); -} - -function diary_admin_delete($id) { - db_query("DELETE FROM diaries WHERE id = '$id'"); - watchdog("message", "diary: deleted entry #$id."); -} - -function diary_admin_display($order = "date") { - // Initialize variables: - $fields = array("author" => "author", "date" => "timestamp DESC"); - - // Perform SQL query: - $result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON u.id = d.author ORDER BY d.$fields[$order] LIMIT 50"); - - // Display stories: - $output .= "\n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - $output .= " \n"; - - while ($diary = db_fetch_object($result)) { - $output .= " \n"; - } - - $output .= "
    \n"; - $output .= "
    \n"; - $output .= " \n"; - $output .= " \n"; - $output .= "
    \n"; - $output .= "
    subjectauthoroperations
    userid\">$diary->userid on ". format_date($diary->timestamp, "small") ."". format_username($diary->userid) ."id\">editid\">delete
    \n"; - - print $output; -} - - -function diary_admin() { - global $op, $id, $mod, $keys, $text, $order; - - if (user_access("administer diary entries")) { - - print "overview | search diary | help
    \n"; - - switch ($op) { - case "delete": - diary_admin_delete(check_input($id)); - diary_admin_display(); - break; - case "edit": - diary_admin_edit(check_input($id)); - break; - case "help": - diary_help(); - break; - case "search": - print search_form($keys); - print search_data($keys, $mod); - break; - case "Save diary entry": - diary_admin_save(check_input($id), check_input($text)); - diary_admin_display(); - break; - case "Update": - diary_admin_display(check_input($order)); - break; - default: - diary_admin_display(); - } - } - else { - print message_access(); - } -} - -?> diff --git a/modules/import.module b/modules/import.module index a80994e8c1c..11e25fdc4d1 100644 --- a/modules/import.module +++ b/modules/import.module @@ -11,69 +11,153 @@ function import_help() { 5, 10 => 10, 15 => 15, 20 => 20, 25 => 25, 30 => 30, 35 => 35, 40 => 40, 45 => 45, 50 => 50, 55 => 55, 60 => 60, 65 => 65, 70 => 70, 75 => 75, 80 => 80, 85 => 85, 90 => 90, 95 => 95, 100 => 100); + $output .= form_select("Items per block", "import_block_limit", variable_get("import_block_limit", 15), $number, "The maximum number of items displayed in one block."); + $output .= form_select("Items per page", "import_page_limit", variable_get("import_page_limit", 75), $number, "The maximum number of items displayed on one page."); + return $output; +} + function import_perm() { - return array("administer syndication"); + return array("administer news feeds", "access news feeds"); } function import_link($type) { - if ($type == "admin") { - $links[] = "syndication"; + if ($type == "admin" && user_access("administer news feeds")) { + $links[] = "news feeds"; + } + + if ($type == "menu" && user_access("administer news feeds")) { + $links[] = "". t("update all news") .""; + } + + if ($type == "page" && user_access("access news feeds")) { + $links[] = "". t("latest news") .""; } return $links ? $links : array(); } function import_cron() { - $result = db_query("SELECT * FROM feed"); + $result = db_query("SELECT * FROM feed WHERE timestamp + refresh < ". time()); while ($feed = db_fetch_array($result)) { - // remove expired items: - db_query("DELETE FROM item WHERE fid = '$feed[fid]' AND timestamp < ". (time() - $feed[uncache])); - - // update feeds: - if ($feed[timestamp] + $feed[refresh] < time()) import_update($feed); + import_refresh($feed); } } -function import_bundle($attributes, $limit = 100) { +function import_update() { + $result = db_query("SELECT * FROM feed"); + while ($feed = db_fetch_array($result)) { + import_refresh($feed); + } +} + +function import_format_item($item, $feed = 0, $description = 0) { + if (module_hook("blog", "page")) { + $output .= "iid\">\"" "; + } + + if ($feed != 1) { + $output .= "fid\">\"". "; + } + + $output .= "link) ."\" target=\"new\">". check_output($item->title) .""; + + if ($description && ($feed != 1)) { + $output .= "   ". format_url($item->flink, $item->ftitle) .""; + } + + if ($description) { + $output .= "
    ". check_output($item->description) ."
    \n"; + } + + return $output ."
    "; +} + +function import_bundle_block($attributes) { + if ($attributes) { - // compose query: $keys = explode(",", $attributes); foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; - $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT $limit"); + $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); while ($item = db_fetch_object($result)) { - $output .= "
  • link) ."\">". check_output($item->title) ."
  • "; + $output .= import_format_item($item, 0); } - return "$output"; + return $output; } } -function import_view_bundle() { - $result = db_query("SELECT * FROM bundle ORDER BY title"); - while ($bundle = db_fetch_object($result)) { - $output .= "$bundle->title
      ". import_bundle($bundle->attributes) ."
    "; - } - return $output; -} +function import_feed_block($feed) { + $result = db_query("SELECT * FROM item WHERE fid = '$feed->fid' ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); -function import_view_feed() { - $result = db_query("SELECT * FROM feed ORDER BY title"); - while ($feed = db_fetch_object($result)) { - $output .= "$feed->title". ($feed->link ? " (". format_url($feed->link) .")" : "") ."
      ". check_output($feed->description) ."
    "; + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 1); } + + $output .= "
    ". t("Last update:") ." ". format_interval(time() - $feed->timestamp) ." ". t("ago"); + return $output; } function import_block() { + return import_block_bundle(); +} + +function import_block_bundle($attributes = 0) { + + if ($attributes) { + $keys = explode(",", $attributes); + foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; + $result = db_query("SELECT * FROM item WHERE ". implode(" OR ", $where) ." ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); + } + else { + $result = db_query("SELECT * FROM item ORDER BY iid DESC LIMIT ". variable_get("import_block_limit", 15)); + } + + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 0); + } + + $blocks[0][subject] = format_url("module.php?mod=import", t("Latest news")); + $blocks[0][content] = $output; + $blocks[0][info] = t("Latest news"); + $result = db_query("SELECT * FROM bundle ORDER BY title"); + while ($bundle = db_fetch_object($result)) { $i++; - $blocks[$i][subject] = $bundle->title; - $blocks[$i][content] = import_bundle($bundle->attributes, 10); + + $blocks[$i][subject] = format_url("module.php?mod=import&op=bundle&id=$bundle->bid", $bundle->title); + $blocks[$i][content] = import_bundle_block($bundle->attributes); $blocks[$i][info] = "$bundle->title bundle"; } + + return $blocks; +} + +function import_block_feed($attributes = 0) { + + if ($attributes) { + $keys = explode(",", $attributes); + foreach ($keys as $key) $where[] = "attributes LIKE '%". trim($key) ."%'"; + $result = db_query("SELECT * FROM feed WHERE ". implode(" OR ", $where) ." ORDER BY fid LIMIT ". variable_get("import_block_limit", 15)); + } + else { + $result = db_query("SELECT * FROM feed ORDER BY fid LIMIT ". variable_get("import_block_limit", 15)); + } + + $i = 0; + while ($feed = db_fetch_object($result)) { + $blocks[$i][subject] = format_url("module.php?mod=import&op=feed&id=$feed->fid", $feed->title); + $blocks[$i][content] = import_feed_block($feed); + $blocks[$i][info] = "$feed->title feed"; + + $i++; + } + return $blocks; } @@ -82,7 +166,7 @@ function import_remove($feed) { return "feed '$feed[title]' reset."; } -function import_update($feed) { +function import_refresh($feed) { // open socket: $url = parse_url($feed[url]); @@ -90,16 +174,21 @@ function import_update($feed) { if ($fp) { // fetch data: - fputs($fp, "GET $url[path]?$url[query] HTTP/1.0\nUser-Agent: ". variable_get(site_name, "drupal") ."\nHost: $url[host]\nAccept: */*\n\n"); + fputs($fp, "GET $url[path]?$url[query] HTTP/1.0\nUser-Agent: ". variable_get("site_name", "drupal") ."\nHost: $url[host]\nAccept: */*\n\n"); + + while (!feof($fp)) $data .= fgets($fp, 128); // initialize the translation table: $tt = array_flip(get_html_translation_table(HTML_ENTITIES)); $tt["'"] = "'"; - while(!feof($fp)) $data .= fgets($fp, 128); - if (strstr($data, "200 OK")) { - + /* + ** Remove expired items: + */ + + db_query("DELETE FROM item WHERE fid = '$feed[fid]' AND timestamp < ". (time() - $feed[uncache])); + /* ** Extract and process channel information: */ @@ -118,6 +207,8 @@ function import_update($feed) { eregi("", $data, $data); + // print "
    ". htmlentities($data[0]) ."
    "; + $items = array_reverse(explode("", $data[0])); foreach ($items as $item) { @@ -134,7 +225,7 @@ function import_update($feed) { } } else { - watchdog("error", "import: failed to syndicate from '$feed[title]'"); + watchdog("error", "failed to syndicate from '$feed[title]'"); } } @@ -148,7 +239,7 @@ function import_save_item($edit) { else if ($edit[iid]) { db_query("DELETE FROM item WHERE iid = '". check_input($edit[iid]) ."'"); } - else { + else if ($edit[title] && $edit[link]) { if (!db_fetch_object(db_query("SELECT iid FROM item WHERE link = '". check_input($edit[link]) ."'"))) { db_query("INSERT INTO item (fid, title, link, author, description, attributes, timestamp) VALUES ('". check_input($edit[fid]) ."', '". check_input($edit[title]) ."', '". check_input($edit[link]) ."', '". check_input($edit[author]) ."', '". check_input($edit[description]) ."', '". check_input($edit[attributes]) ."', '". time() ."')"); } @@ -178,7 +269,7 @@ function import_save_bundle($edit) { else if ($edit[bid]) { db_query("DELETE FROM bundle WHERE bid = '". check_input($edit[bid]) ."'"); } - else { + else if ($edit[title]) { db_query("INSERT INTO bundle (title, attributes) VALUES ('". check_input($edit[title]) ."', '". check_input($edit[attributes]) ."')"); } @@ -190,8 +281,11 @@ function import_form_feed($edit = array()) { $period = array(900 => format_interval(900), 1800 => format_interval(1800), 3600 => format_interval(3600), 7200 => format_interval(7200), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 64800 => format_interval(64800), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200)); + if ($edit[refresh]== "") $edit[refresh] = 3600; + if ($edit[uncache]== "") $edit[uncache] = 2419200; + $form .= form_textfield("Title", "title", $edit[title], 50, 64, "The name of the feed; typically the name of the website you syndicate content from."); - $form .= form_textfield("URL", "url", $edit[url], 50, 128, "The fully-qualified URL of the feed."); + $form .= form_textfield("Url", "url", $edit[url], 50, 128, "The fully-qualified URL of the feed."); $form .= form_textfield("Attributes", "attributes", $edit[attributes], 50, 128, "A comma-seperated list of keywords describing the feed."); $form .= form_select("Update interval", "refresh", $edit[refresh], $period, "The refresh interval indicating how often you want to update this feed. Requires crontab."); $form .= form_select("Expiration time", "uncache", $edit[uncache], $period, "The time cached items should be kept. Older items will be automatically discarded. Requires crontab."); @@ -215,7 +309,7 @@ function import_save_feed($edit) { db_query("DELETE FROM feed WHERE fid = '". check_input($edit[fid]) ."'"); db_query("DELETE FROM item WHERE fid = '". check_input($edit[fid]) ."'"); } - else { + else if ($edit[title]) { db_query("INSERT INTO feed (title, url, attributes, refresh, uncache) VALUES ('". check_input($edit[title]) ."', '". check_input($edit[url]) ."', '". check_input($edit[attributes]) ."', '". check_input($edit[refresh]) ."', '". check_input($edit[uncache]) ."')"); } } @@ -240,7 +334,7 @@ function import_view() { $output .= "

    Feed overview

    "; $output .= "\n"; - $output .= " \n"; + $output .= " \n"; while ($feed = db_fetch_object($result)) { $output .= " \n"; } @@ -259,6 +353,22 @@ function import_view() { return $output; } +function import_view_feed() { + $result = db_query("SELECT * FROM feed ORDER BY title"); + while ($feed = db_fetch_object($result)) { + $output .= "$feed->title". ($feed->link ? " (". format_url($feed->link) .")" : "") ."
      ". check_output($feed->description) ."
    "; + } + return $output; +} + +function import_view_bundle() { + $result = db_query("SELECT * FROM bundle ORDER BY title"); + while ($bundle = db_fetch_object($result)) { + $output .= "$bundle->title
      ". import_bundle_block($bundle->attributes) ."
    "; + } + return $output; +} + function import_view_item() { global $REQUEST_URI; @@ -268,7 +378,7 @@ function import_view_item() { $output .= "
    siteattributesitemslast updatenext updateoperations
    titleattributesitemslast updatenext updateoperations
    ". check_output($feed->title) ."". check_output($feed->attributes) ."". format_plural($feed->items, "item", "items") ."". ($feed->timestamp ? format_interval(time() - $feed->timestamp) ." ago" : "never") ."". ($feed->timestamp ? format_interval($feed->timestamp + $feed->refresh - time()) ." left" : "never") ."fid\">edit feedfid\">remove itemsfid\">update items
    \n"; $output .= " \n"; while ($item = db_fetch_object($result)) { - $output .= " \n"; + $output .= " \n"; } $output .= "
    timefeeditem
    ". format_date($item->timestamp, "custom", "m/d/y") ."
    ".format_date($item->timestamp, "custom", "H:i") ."
    fid\">". check_output($item->feed) ."link) ."\">". check_output($item->title) ."". ($item->description ? "
    ". check_output($item->description) ."" : "") ."
    iid]\" value=\"". check_form($item->attributes) ."\" size=\"50\" />
    ". format_date($item->timestamp, "custom", "m/d/y") ."
    ".format_date($item->timestamp, "custom", "H:i") ."
    fid\">". check_output($item->feed) ."url) ."\">". check_output($item->title) ."". ($item->description ? "
    ". check_output($item->description) ."" : "") ."
    iid]\" value=\"". check_form($item->attributes) ."\" size=\"50\" />
    \n"; $output .= "\n"; @@ -280,7 +390,7 @@ function import_view_item() { function import_admin() { global $op, $id, $type, $edit; - if (user_access("administer syndication")) { + if (user_access("administer news feeds")) { print "add new feed | add new bundle | available feeds | available bundles | available items | overview | help
    "; @@ -302,11 +412,11 @@ function import_admin() { break; case "remove": print status(import_remove(import_get_feed($id))); - print import_view_feed(); + print import_view(); break; case "update": - print status(import_update(import_get_feed($id))); - print import_view_feed(); + print status(import_refresh(import_get_feed($id))); + print import_view(); break; case "Save attributes": print status(import_save_attributes($edit)); @@ -337,4 +447,132 @@ function import_admin() { } } +function import_page_all() { + global $theme; + + $result = db_query("SELECT i.*, f.title AS ftitle, f.link AS flink FROM item i LEFT JOIN feed f ON i.fid = f.fid ORDER BY i.iid DESC LIMIT ". variable_get("import_page_limit", 75)); + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 0, 1); + } + + $header = t("Latest news for all bundles") ." (by bundle) (by feed) "; + + $theme->header(); + $theme->box($header, $output); + $theme->footer(); +} + +function import_page_feed($fid) { + global $theme; + + $result = db_query("SELECT * FROM feed WHERE fid = '". check_input($fid) ."'"); + $feed = db_fetch_object($result); + + $header .= "url\">"; + $header .= $feed->title . " link\" target=\"new\">\""."; + + $result = db_query("SELECT * FROM item WHERE fid = '". check_input($fid) ."' ORDER BY iid DESC LIMIT ". variable_get("import_page_limit", 75)); + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 1, 1); + } + + $output .= t("Last update:") ." ". format_interval(time() - $feed->timestamp) ." ". t("ago"); + + $theme->header(); + $theme->box($header, $output); + $theme->footer(); +} + +function import_page_bundle($bid) { + global $theme; + + $bundle = db_fetch_object(db_query("SELECT * FROM bundle where bid = '". check_input($bid) ."'")); + $header = $bundle->title ." ". t("bundle") ." (". t("by feed") .")"; + + $keys = explode(",", $bundle->attributes); + foreach ($keys as $key) $where[] = "i.attributes LIKE '%". trim($key) ."%'"; + $result = db_query("SELECT i.*, f.title AS ftitle, f.link AS flink FROM item i, feed f WHERE (". implode(" OR ", $where) .") AND i.fid = f.fid ORDER BY iid DESC LIMIT ". variable_get("import_page_limit", 75)); + + while ($item = db_fetch_object($result)) { + $output .= import_format_item($item, 0, 1); + } + + $theme->header(); + $theme->box($header, $output); + $theme->footer(); +} + +function import_page_bundles() { + import_page_blocks(import_block_bundle()); +} + +function import_page_feeds() { + import_page_blocks(import_block_feed()); +} + +function import_page_bundle_feeds($bid) { + $bundle = db_fetch_object(db_query("SELECT * FROM bundle WHERE bid = '". check_input($bid) ."'")); + import_page_blocks(import_block_feed($bundle->attributes)); +} + +function import_page_blocks($blocks) { + global $theme; + + $count = count($blocks); + $items = ceil($count / 3); + $c1 = min($items, $count); + $c2 = min(2 * $items, $count); + $c3 = $count; + $i = 0; + + $theme->header(); + print "\n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print " \n"; + print "
    \n"; + for ($i; $i < $c1; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]); + print " \n"; + for ($i; $i < $c2; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]); + print " \n"; + for ($i; $i < $c3; $i++) $theme->box($blocks[$i]["subject"], $blocks[$i]["content"]); + print "
    \n"; + $theme->footer(); +} + +function import_page() { + global $op, $id; + + if (user_access("access news feeds")) { + switch($op) { + case "all": + import_page_all(); + break; + case "feed": + import_page_feed($id); + break; + case "bundle": + import_page_bundle($id); + break; + case "bundlefeeds": + import_page_bundle_feeds($id); + break; + case "bundles": + import_page_bundles(); + break; + case "feeds": + import_page_feeds(); + break; + case "update": + import_update(); + import_page_all(); + break; + default: + import_page_all(); + } + } +} + ?> diff --git a/updates/2.00-to-x.xx.sql b/updates/2.00-to-x.xx.sql index 0b544edd892..88a7ed12fb0 100644 --- a/updates/2.00-to-x.xx.sql +++ b/updates/2.00-to-x.xx.sql @@ -317,3 +317,11 @@ CREATE TABLE site ( ALTER TABLE feed CHANGE link url varchar(255) DEFAULT '' NOT NULL; ALTER TABLE feed ADD link varchar(255) DEFAULT '' NOT NULL; ALTER TABLE feed ADD description TEXT DEFAULT '' NOT NULL; + +# 12/06/01 +CREATE TABLE blog ( + lid int(10) unsigned NOT NULL auto_increment, + nid int(10) unsigned NOT NULL, + body text NOT NULL, + PRIMARY KEY (lid) +);