From 11666090206b84e97b0cd822ca1053aa9d7f53b3 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Thu, 19 Apr 2001 18:59:10 +0000 Subject: [PATCH] - Addition: added new "cvs.module" to display and mail drupal's CVS log messages. Our additional Perl script that hooks into the CVS repository is also provided in ./scripts. Requires a SQL update, see 2.00-to-x.xx.sql. --- modules/cvs.module | 43 ++++++++++++++++++++++++++++++++++++++++ scripts/cvs-to-sql.pl | 17 ++++++++++++++++ updates/2.00-to-x.xx.sql | 13 +++++++----- 3 files changed, 68 insertions(+), 5 deletions(-) create mode 100644 modules/cvs.module create mode 100644 scripts/cvs-to-sql.pl diff --git a/modules/cvs.module b/modules/cvs.module new file mode 100644 index 00000000000..5deee6d5359 --- /dev/null +++ b/modules/cvs.module @@ -0,0 +1,43 @@ + "cvs_cron", + "conf" => "cvs_conf", + "page" => "cvs_page"); + +function cvs_cron() { + $result = db_query("SELECT * FROM cvs WHERE status = '0' ORDER BY timestamp DESC LIMIT 50"); + + while ($cvs = db_fetch_object($result)) { + $body .= "File: $cvs->files\nDate: ". format_date($cvs->timestamp) ."\nUser: $cvs->user\n\n$cvs->message\n----------------------------------------------------------------------\n"; + } + + $result = db_query("UPDATE cvs SET status = '1'"); + + if ($body) mail(variable_get(cvs_mail, "root@localhost"), "CVS log messages", $body, "From: no-reply"); +} + +function cvs_conf() { + $output .= "Recepient for log messages:
\n"; + $output .= "
\n"; + $output .= "The e-mail address to mail the CVS log messages to. Multiple recipients can be specified by putting a comma between each address.

\n"; + return $output; +} + +function cvs_page() { + global $theme; + + $result = db_query("SELECT * FROM cvs ORDER BY timestamp DESC LIMIT 50"); + + while ($cvs = db_fetch_object($result)) { + $output .= "File: $cvs->files
"; + $output .= "Date: ". format_date($cvs->timestamp) ."
"; + $output .= "User: $cvs->user
"; + $output .= "\n". htmlentities($cvs->message) ."


"; + } + + $theme->header(); + $theme->box("CVS commit messages", "
$output
"); + $theme->footer(); +} + +?> \ No newline at end of file diff --git a/scripts/cvs-to-sql.pl b/scripts/cvs-to-sql.pl new file mode 100644 index 00000000000..355d2273935 --- /dev/null +++ b/scripts/cvs-to-sql.pl @@ -0,0 +1,17 @@ +#!/usr/bin/perl -w + +use DBI; + +my $db_name = 'drupal'; +my $db_user = 'drupal'; +my $db_pass = 'drupal'; + +my $files = $ARGV[0]; +my @message = ; +my $message = join '' , @message; +my $user = $ENV{USER}; +my $timestamp = time(); + +my $db = DBI->connect("DBI:mysql:$db_name", "$db_user", "$db_pass") or die "Couldn't connect to database: " . DBI->errstr; +$db->do("INSERT INTO cvs (user, files, message, timestamp) VALUES (". $db->quote($user) .", ". $db->quote($files) .", ". $db->quote($message) .", ". $db->quote($timestamp) .")") or die "Couldn't execute query: " . $db->errstr; +$db->disconnect(); diff --git a/updates/2.00-to-x.xx.sql b/updates/2.00-to-x.xx.sql index 5688d6f5ba6..71e697b7a15 100644 --- a/updates/2.00-to-x.xx.sql +++ b/updates/2.00-to-x.xx.sql @@ -1,8 +1,5 @@ -# 14/04/2001: -ALTER TABLE node ADD cid int(10) unsigned DEFAULT '0' NOT NULL; -ALTER TABLE node ADD tid int(10) unsigned DEFAULT '0' NOT NULL; -ALTER TABLE story DROP section; -ALTER TABLE comments ADD KEY(lid); +# 19/04/2001: +ALTER TABLE node ADD comment int(2) DEFAULT '1' NOT NULL; CREATE TABLE cvs ( user varchar(32) DEFAULT '' NOT NULL, @@ -12,6 +9,12 @@ CREATE TABLE cvs ( timestamp int(11) DEFAULT '0' NOT NULL ); +# 14/04/2001: +ALTER TABLE node ADD cid int(10) unsigned DEFAULT '0' NOT NULL; +ALTER TABLE node ADD tid int(10) unsigned DEFAULT '0' NOT NULL; +ALTER TABLE story DROP section; +ALTER TABLE comments ADD KEY(lid); + CREATE TABLE category ( cid int(10) unsigned DEFAULT '0' NOT NULL auto_increment, name varchar(32) DEFAULT '' NOT NULL,