This commit was manufactured as part of Drupal's Great Git Migration to

create branch 'DRUPAL-4-0'.

Sprout from master 2002-06-15 18:35:30 UTC Kjartan Mannes <kjartan@2.no-reply.drupal.org> '- setting date in changelog.'
Cherrypick from master 2002-06-09 14:16:35 UTC Dries Buytaert <dries@buytaert.net> '':
    modules/taxonomy.module
Delete:
    modules/aggregator.module
    modules/aggregator/aggregator.module
    modules/archive/archive.module
    modules/block/block.module
    modules/blog/blog.module
    modules/book/book.module
    modules/comment/comment.module
    modules/drupal/drupal.module
    modules/forum/forum.module
    modules/help/help.module
    modules/locale/locale.module
    modules/node/node.module
    modules/page/page.module
    modules/poll/poll.module
    modules/search/search.module
    modules/statistics/statistics.module
    modules/story/story.module
    modules/system/system.module
    modules/taxonomy/taxonomy.module
    modules/tracker/tracker.module
    modules/user/user.module
    modules/watchdog/watchdog.module
parent d22493f9
This diff is collapsed.
This diff is collapsed.
<?php
// $Id$
function archive_system($field){
$system["description"] = t("Displays a calendar to navigation old content.");
return $system[$field];
}
function archive_display($original = 0) {
// Prevent future dates:
$today = mktime(23, 59, 59, date("n", time()), date("d", time()), date("Y", time()));
$original = (($original && $original <= $today) ? $original : $today);
// Extract information from the given date:
$month = date("n", $original);
$year = date("Y", $original);
$day = date("d", $original);
// Extract today's date:
$today = mktime(23, 59, 59, date("n", time()), date("d", time()), date("Y", time()));
// Extract the timestamp of the last day of today's month:
$thislast = mktime(23, 59, 59, date("n", time()), date("t", time()), date("Y", time()));
// Extract first day of the month:
$first = date("w", mktime(0, 0, 0, $month, 1, $year));
// Extract last day of the month:
$last = date("t", mktime(0, 0, 0, $month, 1, $year));
// Calculate previous and next months dates and check for shorter months (28/30 days)
$prevmonth = mktime(23, 59, 59, $month - 1, 1, $year);
$prev = mktime(23, 59, 59, $month - 1, min(date("t", $prevmonth), $day), $year);
$nextmonth = mktime(23, 59, 59, $month + 1, 1, $year);
$next = mktime(23, 59, 59, $month + 1, min(date("t", $nextmonth), $day), $year);
// Generate calendar header:
$output .= "\n<!-- calendar -->\n";
$output .= "<table width=\"100%\" border=\"1\" cellspacing=\"0\" cellpadding=\"1\">\n";
$output .= " <tr><td align=\"center\" colspan=\"7\"><small>". lm("&lt;", array("mod" => "archive", "date" => $prev)) ."&nbsp;". date("F Y", $original) ."&nbsp;". ($next <= $thislast ? lm("&gt;", array("mod" => "archive", "date" => $next)) : "&gt;") ."</small></td></tr>\n";
// Generate the days of the week:
$somesunday = mktime(0, 0, 0, 3, 20, 1994);
$output .= " <tr>";
for ($i = 0; $i < 7; $i++) {
$output .= "<td align=\"center\"><small>". substr(ucfirst(t(date("l", $somesunday + $i * 86400))), 0, 1) ."</small></td>";
}
$output .= "</tr>\n";
// Initialize temporary variables:
$nday = 1;
$sday = $first;
// Loop through all the days of the month:
while ($nday <= $last) {
// Set up blank days for first week of the month:
if ($first) {
$output .= " <tr><td colspan=\"$first\">&nbsp</td>\n";
$first = 0;
}
// Start every week on a new line:
if ($sday == 0) {
$output .= " <tr>\n";
}
// Print one cell:
$date = mktime(0, 0, 0, $month, $nday, $year);
if ($date == $original) {
$output .= " <td align=\"center\"><small><b>$nday</b></small></td>\n";
}
else if ($date > $today) {
$output .= " <td align=\"center\"><small>$nday</small></td>\n";
}
else {
// due to text-decoration we use drupal_url() instead of lm()
$output .= " <td align=\"center\"><small>". lm($nday, array("mod" => "archive", "date" => $date), "", array("style" => "text-decoration: none;")) ."</small></td>\n";
}
// Start every week on a new line:
if ($sday == 6) {
$output .= " </tr>\n";
}
// Update temporary variables:
$sday++;
$sday = $sday % 7;
$nday++;
}
// Complete the calendar:
if ($sday) {
$end = 7 - $sday;
$output .= " <td colspan=\"$end\">&nbsp;</td>\n </tr>\n";
}
$output .= "</table>\n\n";
return $output;
}
function archive_block() {
global $date;
$block[0]["subject"] = "Browse archives";
$block[0]["content"] = archive_display($date);
$block[0]["info"] = "Calendar to browse archives";
return $block;
}
function archive_link($type) {
if ($type == "page" && user_access("access content")) {
$links[] = lm(t("archives"), array("mod" => "archive"), "", array("title" => t("Read the older content in our archive.")));
}
return $links ? $links : array();
}
function archive_page() {
global $date, $edit, $theme, $op, $month, $year, $meta;
$theme->header();
if (user_access("access content")) {
switch ($op) {
case t("Show"):
$date = mktime(0, 0, 0, $edit["month"], $edit["day"], $edit["year"]);
// Fall though
default:
/*
** Prepare the values of the form fields:
*/
$years = array(2000 => "2000", 2001 => "2001", 2002 => "2002", 2003 => "2003", 2004 => "2004", 2005 => "2005");
$months = array(1 => t("January"), 2 => t("February"), 3 => t("March"), 4 => t("April"), 5 => t("May"), 6 => t("June"), 7 => t("July"), 8 => t("August"), 9 => t("September"), 10 => t("October"), 11 => t("November"), 12 => t("December"));
for ($i = 1; $i <= 31; $i++) $days[$i] = $i;
/*
** If a timestamp is being specified, extract the date:
*/
if ($date) {
$edit["year"] = date("Y", $date);
$edit["month"] = date("m", $date);
$edit["day"] = date("d", $date);
}
$start = form_select("", "year", ($edit["year"] ? $edit["year"] : date("Y")), $years) . form_select("", "month", ($edit["month"] ? $edit["month"] : date("m")), $months) . form_select("", "day", ($edit["day"] ? $edit["day"] : date("d")), $days) . form_submit(t("Show"));
$start = ereg_replace("<[/]?p>", "", $start);
$theme->box(t("Archives"), form($start));
/*
** Fetch nodes for the selected date, or current date if none
** selected.
*/
$result = db_query("SELECT nid FROM node WHERE status = '1' AND created > ". ($date > 0 ? check_query($date) : time()) ." ORDER BY created LIMIT 20");
while ($nid = db_fetch_object($result)) {
node_view(node_load(array("nid" => $nid->nid)), 1);
}
}
}
else {
$theme->box(t("Access denied"), message_access());
}
$theme->footer();
}
?>
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
<?php
function drupal_system($field){
$system["description"] = t("Lets users log in using a Drupal ID and can notify drupal.org about your site.");
return $system[$field];
}
function drupal_conf_options() {
$output .= form_textfield("Drupal XML-RPC server", "drupal_server", variable_get("drupal_server", "http://www.drupal.org/xmlrpc.php"), 55, 128, "The URL of your root Drupal XML-RPC server.");
$output .= form_select("Drupal directory", "drupal_directory", variable_get("drupal_directory", 0), array("Disabled", "Enabled"), "If enabled, your Drupal site will make itself know to the Drupal directory at the specified Drupal XML-RPC server. For this to work properly, you have to set your site's name, e-mail address, slogan and mission statement. When the \"Drupal XML-RPC server\" field is set to \"http://www.drupal.org/xmlrpc.php\", your website will get listed on <a href=\"http://www.drupal.org/\">http://www.drupal.org/</a>. Requires crontab.");
return $output;
}
function drupal_cron() {
if (time() - variable_get("drupal_cron_last", 0) > 21600) {
variable_set("drupal_cron_last", time());
/*
** If this site acts as a Drupal XML-RPC server, delete the sites that
** stopped sending "ping" messages.
*/
db_query("DELETE FROM directory WHERE timestamp < '". (time() - 259200) ."'");
/*
** If this site acts as a Drupal XML-RPC client, send a message to the
** Drupal XML-RPC server.
*/
if (variable_get("drupal_directory", 0) && variable_get("drupal_server", 0)) {
drupal_notify(variable_get("drupal_server", ""));
}
}
}
function drupal_directory_ping($arguments) {
/*
** Parse our parameters:
*/
$argument = $arguments->getparam(0);
$link = strip_tags($argument->scalarval());
$argument = $arguments->getparam(1);
$name = strip_tags($argument->scalarval());
$argument = $arguments->getparam(2);
$mail = strip_tags($argument->scalarval());
$argument = $arguments->getparam(3);
$slogan = strip_tags($argument->scalarval());
$argument = $arguments->getparam(4);
$mission = strip_tags($argument->scalarval());
/*
** Update the data in our database and send back a reply:
*/
if ($link && $name && $mail && $slogan && $mission) {
db_query("DELETE FROM directory WHERE link = '%s' OR mail = '%s'", $link, $mail);
db_query("INSERT INTO directory (link, name, mail, slogan, mission, timestamp) VALUES ('%s', '%s', '%s', '%s', '%s', '%s')", $link, $name, $mail, $slogan, $mission, time());
watchdog("message", "directory: ping from '$name' ($link)");
return new xmlrpcresp(new xmlrpcval(1, "int"));
}
else {
return new xmlrpcresp(new xmlrpcval(0, "int"));
}
}
function drupal_directory_page() {
$result = db_query("SELECT * FROM directory ORDER BY name");
while ($site = db_fetch_object($result)) {
$output .= "<a href=\"$site->link\">$site->name</a> - $site->slogan<div style=\"padding-left: 20px;\">$site->mission</div><br />";
}
return $output;
}
function drupal_xmlrpc() {
return array("drupal.site.ping" => array("function" => "drupal_directory_ping"));
}
function drupal_notify($server) {
$url = parse_url($server);
$client = new xmlrpc_client($url["path"], $url["host"], 80);
$message = new xmlrpcmsg("drupal.site.ping", array(new xmlrpcval(path_uri(), "string"), new xmlrpcval(variable_get("site_name", ""), "string"), new xmlrpcval(variable_get("site_mail", ""), "string"), new xmlrpcval(variable_get("site_slogan", ""), "string"), new xmlrpcval(variable_get("site_mission", ""), "string")));
$result = $client->send($message, 5);
if (!$result || $result->faultCode()) {
watchdog("error", "failed to notify '". $url["host"] ."' at '". $url["path"] ."': ". $result->faultString());
}
}
function drupal_info($field = 0) {
$info["name"] = "Drupal";
$info["protocol"] = "XML-RPC";
if ($field) {
return $info[$field];
}
else {
return $info;
}
}
function drupal_auth($username, $password, $server) {
$message = new xmlrpcmsg("drupal.login", array(new xmlrpcval($username, "string"), new xmlrpcval($password, "string")));
// TODO remove hard coded Port 80
// TODO manage server/path such that HTTP_HOST/xml.rpc.php is not assumed
$client = new xmlrpc_client("/xmlrpc.php", $server, 80);
$result = $client->send($message, 5);
if ($result && !$result->faultCode()) {
$value = $result->value();
$login = $value->scalarval();
}
return $login;
}
function drupal_page() {
global $theme;
$theme->header();
$theme->box("Drupal", drupal_auth_help());
$theme->footer();
}
function drupal_auth_help() {
$site = variable_get("site_name", "this web site");
$output = "<p><a href=\"http://www.drupal.org\">Drupal</a> is the name of the software which powers %s. There are Drupal websites all over the world, and many of them share their registration databases so that users may freely login to any Drupal site using a single <b>Drupal ID</b>.</p>\n";
$output .= "<p>So please feel free to login to your account here at %s with a username from another Drupal site. The format of a Drupal ID is similar to an email address: <b>username</b>@<i>server</i>. An example of valid Drupal ID is <b>mwlily</b><i>@www.drupal.org</i>.</p>";
return t($output, array("%s" => "<i>$site</i>"));
}
function drupal_user($type, $edit, $user) {
global $HTTP_HOST;
$module = "drupal";
$name = module_invoke($module, "info", "name");
switch ($type) {
case "view_private":
$result = user_get_authname($user, $module);
if ($result) {
$output .= form_item(t("$name ID"), $result);
}
else {
// TODO: use a variation of path_uri() instead of $HTTP_HOST below
$output .= form_item(t("$name ID"), "$user->name@$HTTP_HOST");
}
return $output;
}
}
?>
\ No newline at end of file
<?php
// $Id$
function forum_system($field){
$system["description"] = t("Allows threaded discussions about general topics.");
return $system[$field];
}
function forum_node($field) {
$info["name"] = t("discussion forum");
$info["description"] = t("A forum is a threaded discussion, enabling users to communicate about a particular topic.");
return $info[$field];
}
function forum_access($op, $node) {
if ($op == "view") {
return $node->status;
}
}
function forum_save($op, $node) {
if ($op == "approve") {
return array("status" => 1);
}
if ($op == "create") {
return array("body" => filter($node->body), "teaser" => filter($node->teaser));
}
if ($op == "decline") {
return array("status" => 0);
}
if ($op == "update") {
return array("body" => filter($node->body), "teaser" => filter($node->teaser));
}
}
function forum_link($type) {
if ($type == "page" && user_access("access content")) {
$links[] = lm(t("forum"), array("mod" => "forum"), "", array("title" => t("Read and participate in the discussion forums.")));
}
if ($type == "menu.create" && user_access("administer nodes")) {
$links[] = lm(t("create forum"), array("mod" => "node", "op" => "add", "type" => "forum"), "", array("title" => t("Add a new discussion forum.")));
}
return $links ? $links : array();
}
function forum_view($node) {
global $theme;
$output .= "<p>". lm(t("Forum"), array("mod" => "forum")) ." / <b>". l(check_output($node->title), array("id" => $node->nid)) ."</b>:</p><p>". check_output($node->body) ."</p>";
$output .= "<p>". $theme->links(link_node($node, $main)) ."</p>";
$theme->box(t("Discussion forum"), $output);
}
function forum_form(&$node, &$help, &$error) {
if (function_exists("taxonomy_node_form")) {
$output = implode("", taxonomy_node_form("forum", $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 10);
return $output;
}
function forum_num_comments($nid) {
$value = db_fetch_object(db_query("SELECT COUNT(cid) AS count FROM comments WHERE nid = '$nid'"));
return ($value) ? $value->count : 0;
}
function forum_last_comment($nid) {
$value = db_fetch_object(db_query("SELECT timestamp FROM comments WHERE nid = '$nid' ORDER BY timestamp DESC LIMIT 1"));
return ($value) ? format_date($value->timestamp, "small") : "&nbsp;";
}
function forum_page() {
global $theme;
if (user_access("access content")) {
$result = db_query("SELECT nid FROM node WHERE type = 'forum' ORDER BY title");
$output .= "<table border=\"0\" cellspacing=\"4\" cellpadding=\"4\">";
$output .= " <tr><th>". t("Forum") ."</th><th>". t("Comments") ."</th><th>". t("Last comment") ."</th></tr>";
while ($node = db_fetch_object($result)) {
$node = node_load(array("nid" => $node->nid));
$output .= " <tr><td>". l(check_output($node->title), array("id" => $node->nid)) ."<br /><small>". check_output($node->body, 1) ."</small></td><td align=\"center\">". forum_num_comments($node->nid) ."</td><td align=\"center\">". forum_last_comment($node->nid) ."</td></tr>";
}
$output .= "</table>";
$theme->header();
$theme->box(t("Discussion forum"), $output);
$theme->footer();
}
else {
$theme->header();
$theme->box(t("Access denied"), message_access());
$theme->footer();
}
}
?>
\ No newline at end of file
<?php
// $Id$
function help_system($field){
$system["description"] = t("Manages displaying online help.");
return $system[$field];
}
function help_link($type) {
if ($type == "admin") {
$links[] = la(t("help"), array("mod" => "help"));
}
return $links ? $links : array();
}
function help_admin() {
foreach (module_list() as $name) {
if (module_hook($name, "help")) {
print "<h2>". ucfirst($name) ." module</h2>";
print module_invoke($name, "help");
}
}
}
?>
This diff is collapsed.
This diff is collapsed.
<?php
// $Id$
function page_help() {
$output .= "<p>The page module is used to create a <i>site page</i>. Unlike a story, a site page is a persistent web page on your site which usually shortcuts the typical lifecycle of user generated content (i.e. submit -&gt; moderate -&gt; post -&gt; comment). A site page is usually linked from the main navigation bar, using whatever text the author wishes. To create a site page without this navigation link, simply skip the form field which requests link text. Administrators are the exclusive authors of site pages (i.e. requires the <i>administer nodes</i> in ". la("permission", array("mod" => "user", "op" => "permission")) .").</p>";
$output .= "<p>Site pages, unlike many other forms of Drupal content, may be made of PHP code in addition to HTML and text. All Drupal objects and functions are available to the Site Page author.</p>";
return $output;
}
function page_system($field){
$system["description"] = t("Enables the creation of a static pages that can be added to the navigation system.");
return $system[$field];
}
function page_node($field) {
$info["name"] = t("site page");
$info["description"] = t("If you just want to add a page with a link in the menu to your site, this would be the best choice. Unlike a story, a site page by-passes the submission queue.");
return $info[$field];
}
function page_access($op, $node) {
if ($op == "view") {
return $node->status;
}
}
function page_save($op, $node) {
if ($op == "approve") {
return array("status" => 1);
}
if ($op == "create") {
return array("body" => filter($node->body), "teaser" => filter($node->teaser), "format", "link");
}
if ($op == "decline") {
return array("status" => 0);
}
if ($op == "update") {
return array("body" => filter($node->body), "teaser" => filter($node->teaser), "format", "link");
}
}
function page_insert($node) {
db_query("INSERT INTO page (nid, format, link) VALUES ('$node->nid', '$node->format', '$node->link')");
}
function page_update($node) {
db_query("UPDATE page SET format = '$node->format', link = '$node->link' WHERE nid = '$node->nid'");
}
function page_delete(&$node) {
db_query("DELETE FROM page WHERE nid = '$node->nid'");
}
function page_load($node) {
$page = db_fetch_object(db_query("SELECT format, link FROM page WHERE nid = '$node->nid'"));
return $page;
}
function page_link($type) {
if ($type == "page" && user_access("access content")) {
$result = db_query("SELECT n.nid, n.title, p.link FROM page p LEFT JOIN node n ON p.nid = n.nid WHERE n.status = '1' AND p.link != '' ORDER BY p.link");
while ($page = db_fetch_object($result)) {
$links[] = l($page->link, array("id" => $page->nid), "node", "", array("title" => $page->title));
}
}
if ($type == "menu.create" && user_access("administer nodes")) {
$links[] = lm(t("create site page"), array("mod" => "node", "op" => "add", "type" => "page"), "", array("title" => t("Add a new site page.")));
}
return $links ? $links : array();
}
function page_body($node) {
global $theme, $op;
if ($node->format) {
/*
** Make sure only authorized users can preview static (PHP)
** pages.
*/
if ($op == t("Preview")) {
if (user_access("administer nodes")) {
$node->body = stripslashes($node->body); // see also page_form()
}
else {
return;
}
}
ob_start();
eval($node->body);
$output = ob_get_contents();
ob_end_clean();
}
else {
$output = check_output($node->body, 1);
}
return $output;
}
function page_view($node, $main = 0) {
global $theme;
if ($main) {
$theme->node($node, $main);
}
else {
/*
** Extract the page body. If body is dynamic (using PHP code), the body
** will be generated.
*/
$output .= page_body($node);
/*
** Add the node specific links:
*/
$output .= "<div align=\"right\">". $theme->links(link_node($node, $main)) ."</div>";
$theme->box($node->title, $output);
}
}
function page_form(&$node, &$help, &$error) {
global $op;
if ($node->format) {
if ($op != t("Preview")) {
$node->body = addslashes($node->body);
}
}
else {
if ($node->teaser) {
$output .= form_textarea(t("Teaser"), "teaser", $node->teaser, 60, 5, $error["teaser"]);
}
}
if (function_exists("taxonomy_node_form")) {
$output .= implode("", taxonomy_node_form("page", $node));
}
$output .= form_textarea(t("Body"), "body", $node->body, 60, 20);
$output .= form_textfield(t("Navigation link header"), "link", $node->link, 60, 64, t("To make the page show up on the navigation links enter the name of the link, otherwise leave blank."));
$output .= form_select(t("Type"), "format", $node->format, array(0 => "HTML / text", 1 => "PHP"));
return $output;
}
?>
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
<?php
// $Id$
if (variable_get("referrer", 0) && $referrer = getenv("HTTP_REFERER")) {
db_query("INSERT INTO referrer (URL, timestamp) values ('%s', '%s')", $referrer, time());
}
function statistics_help() {
$output .= "<p>The statistics module gathers and presents useful log information from your Drupal site. Currently, the statistics module is limited to internal and external referrals display, but other analysis capabilities might be added in future.</p>";
$output .= "<p>1. The external referrer log indicates which other sites are linking your website and how many visitors they refer. Each link made to your site - when a user on another site clicks on a link to your site - generates a referral entry in the log.</p>";
$output .= "<p>2. The internal referrer log indicates the referrals within the domain of your site. This log is useful for assessing and evaluating the structure of your website, to learn which pages are being accessed, and to gain insight into the way users are navigating your site.</p>";
$output .= "<p>Drupal automatically rotates the referrer logs after a set period of time. The life-time of the accumulated data can be configured via the <i>site configuration</i> option under site administration.</p>";
$output .= "<p>Warning: Drupal gets the referrer information from the HTTP_REFERER environment variable. This is not always set properly by web browsers.</p>";
return $output;
}
function statistics_system($field){
$system["description"] = t("Gathers and displays referers.");
return $system[$field];
}
function statistics_cron() {
db_query("DELETE FROM referrer WHERE ". time() ." - timestamp > ". variable_get("referrer_clear", 604800));
}
function statistics_perm() {
return array("administer statistics");
}
function statistics_link($type) {
if ($type == "admin" && user_access("administer statistics")) {
$links[] = la(t("statistics"), array("mod" => "statistics"));
}
return $links ? $links : array();
}
function statistics_conf_options() {
$period = array(3600 => format_interval(3600), 10800 => format_interval(10800), 21600 => format_interval(21600), 32400 => format_interval(32400), 43200 => format_interval(43200), 86400 => format_interval(86400), 172800 => format_interval(172800), 259200 => format_interval(259200), 604800 => format_interval(604800), 1209600 => format_interval(1209600), 2419200 => format_interval(2419200), 4838400 => format_interval(4838400), 9676800 => format_interval(9676800));
$output .= form_select("Track referrers", "referrer", variable_get("referrer", 0), array("Disabled", "Enabled"), "If enabled, Drupal will count how many times your website is referred to by other websites.");
$output .= form_select("Discard referrers older than", "referrer_clear", variable_get("referrer_clear", 604800), $period, "The time referrer entries should be kept. Older entries will be automatically discarded. Requires crontab.");
return $output;
}
function statistics_table_1($query) {
$result = db_query($query);
$output .= "<table border=\"1\" cellpadding=\"3\" cellspacing=\"0\">\n";
$output .= " <tr><th>URL</th><th>date</th></tr>\n";