[Fusionforge-commits] FusionForge branch 6.0 updated. dc9a80e2207b6d2d9abb181e2f0c07af74b7d13b

Sylvain Beucler beuc-inria at fusionforge.org
Tue Apr 7 15:04:58 CEST 2015


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "FusionForge".

The branch, 6.0 has been updated
       via  dc9a80e2207b6d2d9abb181e2f0c07af74b7d13b (commit)
      from  81f0db00f2cf05d966c6fc47e37c6f3fe540d8cb (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit dc9a80e2207b6d2d9abb181e2f0c07af74b7d13b
Author: Sylvain Beucler <sylvain.beucler at inria.fr>
Date:   Tue Apr 7 14:59:56 2015 +0200

    Get rid of lib/include.pl

diff --git a/src/GNUmakefile b/src/GNUmakefile
index 94676d6..621ab24 100644
--- a/src/GNUmakefile
+++ b/src/GNUmakefile
@@ -63,7 +63,7 @@ install-config: install-base-dirs
 
 install-common: install-config install-plugin-authbuiltin
 	$(MAKE) -C locale DESTDIR=$(DESTDIR) PREFIX=$(PREFIX) install
-	$(CP_R) VERSION bin common templates lib $(DESTDIR)$(pkgdatadir)/
+	$(CP_R) VERSION bin common templates $(DESTDIR)$(pkgdatadir)/
 	chmod 755 $(DESTDIR)$(pkgdatadir)/bin/ssh_akc.php
 	$(INSTALL) -d -m 00755 $(DESTDIR)$(config_path)/custom/
 	$(CP_R) post-install.d/common $(DESTDIR)$(pkgdatadir)/post-install.d/
diff --git a/src/cronjobs/db/get_news_notapproved.php b/src/cronjobs/db/get_news_notapproved.php
new file mode 100755
index 0000000..efdf039
--- /dev/null
+++ b/src/cronjobs/db/get_news_notapproved.php
@@ -0,0 +1,98 @@
+#! /usr/bin/php
+<?php
+/**
+ * Send reminder about not yet approved news items
+ *
+ * Copyright (C) 2004  Vicente J. Ruiz Jurado (vjrj AT ourproject.org)
+ * Copyright (C) 2015  Inria (Sylvain Beucler)
+ *
+ * This file is part of FusionForge. FusionForge is free software;
+ * you can redistribute it and/or modify it under the terms of the
+ * GNU General Public License as published by the Free Software
+ * Foundation; either version 2 of the Licence, or (at your option)
+ * any later version.
+ *
+ * FusionForge is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	 See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with FusionForge; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ */
+
+require dirname(__FILE__).'/../../common/include/env.inc.php';
+require_once $gfcommon.'include/pre.php';
+require $gfcommon.'include/cron_utils.php';
+
+$shortopts = 'd';		// enable verbose mode
+$longopts = array('debug');
+$options = getopt($shortopts, $longopts);
+if (count($options) != (count($argv)-1)) {	// PHP just strips invalid options
+	print "Usage: {$argv[0]} [-d|--debug]\n";
+	exit(1);
+}
+$debug = false;
+if (isset($options['d']) or isset($options['debug'])) {
+	print "verbose mode ON\n";
+	$debug = true;
+}
+
+if ($debug) {
+	print "Getting the news not approved.\n";
+}
+
+$old_date = time()-60*60*24*30;
+$res = db_query_params("SELECT group_name,summary,details
+	FROM news_bytes n, groups g
+	WHERE is_approved = 0
+	AND n.group_id=g.group_id
+	AND n.post_date > $1
+	AND g.status=$2
+	ORDER BY post_date", array($old_date, 'A'));
+
+$results_array = array();
+while ($arr = db_fetch_array($res)) {
+	array_push($results_array, $arr);
+}
+
+$thereisnews = false;
+$emailformatted = '';
+foreach ($results_array as $newsnotapprob) {
+	list($group_name, $summary, $details) = $newsnotapprob;
+
+	$res = db_query_params("SELECT COUNT(*) FROM pfo_role_setting prs, groups g
+		  WHERE prs.role_id=1 AND prs.section_name = 'project_read' AND prs.perm_val = 1
+			AND prs.ref_id = g.group_id AND g.unix_group_name = $1", array($group_name));
+	if (db_numrows($res) >= 1) {  # $is_public == true
+		$thereisnews = true;
+		$title = "$group_name: $summary\n";
+		$emailformatted .= wordwrap($title, 78);
+		$emailformatted .= "----------------------------------------------------------------------\n";
+		$t = explode("\n", wordwrap($details, 70));
+		foreach ($t as $line)
+			$emailformatted .= str_repeat(' ', 8) . $line . "\n";
+		$emailformatted .= "\n\n";
+	}
+}
+
+if ($thereisnews) {
+	if ($debug) { print "Sending the news not approved.\n"; }
+	$web_host = forge_get_config('web_host');
+	$admin_email = forge_get_config('admin_email');
+	$forge_name = forge_get_config('forge_name');
+    $subject = "$forge_name pending news";
+	$emailformatted .= "Please visit: http://$web_host/news/admin/";
+	$emailformatted .= "\n\n";
+	util_send_message($admin_email, $subject, $emailformatted, "noreply@$web_host");
+    if ($debug) {
+        print "Subject: $subject\n";
+        print $emailformatted;
+    }
+} else {
+	if ($debug) { print "No news to approved.\n"; }
+}
+
+if ($debug) { print "get_news_notapproved process finished ok\n"; }
+exit(0);
diff --git a/src/cronjobs/db/get_news_notapproved.pl b/src/cronjobs/db/get_news_notapproved.pl
deleted file mode 100755
index b9a6381..0000000
--- a/src/cronjobs/db/get_news_notapproved.pl
+++ /dev/null
@@ -1,126 +0,0 @@
-#!/usr/bin/perl -w
-#
-# get_news_notapproved.pl: script to get the news not yet approved 
-#   by Vicente J. Ruiz Jurado (vjrj AT ourproject.org) Apr-2004
-#
-# depends: libgetopt-mixed-perl (Getopt::Long), libdbi-perl (DBI),
-#          libtext-autoformat-perl (Text::Autoformat)
-#          libmail-sendmail-perl (Mail::Sendmail)
-#
-use DBI;
-use Text::Autoformat;
-use Getopt::Long qw(:config require_order);
-use Mail::Sendmail;
-
-use strict;
-
-my $source_path = `forge_get_config source_path`;
-chomp $source_path;
-
-require ("$source_path/lib/include.pl") ; # Include all the predefined functions 
-
-use vars qw/ $server_admin $sys_name $sys_default_domain /;
-
-# DB 
-#-------------------------------------------------------------------------------
-use vars qw/ $dbh / ; # Predeclaration of global vars
-
-# Variables
-#-------------------------------------------------------------------------------
-
-my $numArgs = @ARGV;
-my @args = @ARGV;
-my $therearenews = 0;
-
-sub usage();
-
-my $debug;
-my @results_array;
-my $emailformatted;
-
-# Options check
-#-------------------------------------------------------------------------------
-
-my $resultOptions = GetOptions(
-"debug" => \$debug
-);
-
-unless (($debug && $resultOptions == 2) || ($resultOptions == 1)) {
-	usage();
-	exit(1);
-}
-
-chomp($server_admin=`forge_get_config admin_email`);
-
-# Start to get de News
-#-------------------------------------------------------------------------------
-
-if ($debug) {print STDERR "Getting the news not approved.\n"};
-
-&db_connect;
-$dbh->{AutoCommit} = 0;
-$dbh->{RaiseError} = 1;
-
-my $old_date = time()-60*60*24*30;
-my $query = "SELECT group_name,summary,details 
-	FROM news_bytes n, groups g 
-	WHERE is_approved = 0 
-	AND n.group_id=g.group_id
-	AND n.post_date > '$old_date'
-	AND g.status='A'
-	ORDER BY post_date";
-
-my $sth = $dbh->prepare($query);
-$sth->execute();
-
-while (my @array = $sth->fetchrow_array ()) {
-	push @results_array, \@array ;
-}
-$sth->execute() or die "Problems with the query '$query' in DB";
-$sth->finish() or die "Problems with the query '$query' in DB";
-$dbh->commit or die $dbh->errstr;
-
-foreach my $newsnotapprob (@results_array) {
-	my ($group_name, $summary, $details) = @{$newsnotapprob};
-
-	my $query = "SELECT COUNT(*) FROM pfo_role_setting prs, groups g
-          WHERE prs.role_id=1 AND prs.section_name = 'project_read' AND prs.perm_val = 1
-            AND prs.ref_id = g.group_id AND g.unix_group_name = '$group_name'";
-	my $c = $dbh->prepare($query);
-	$c->execute();
-	my $is_public = (int($c->fetchrow()) > 0);
-	next if (!$is_public);
-
-	$therearenews = 1;
-	my $title = "$group_name: $summary\n";
-	$emailformatted .= autoformat $title, {  all => 1, left=>0, right=>78 };
-	$emailformatted .= "----------------------------------------------------------------------\n";
-	$emailformatted .= autoformat $details, {  all => 1, left=>8, right=>78 };
-	$emailformatted .= "\n\n";
-}
-
-if ($therearenews) {
-	if ($debug) {print STDERR "Sending the news not approved.\n"};
-  $emailformatted .= "Please visit: http://$sys_default_domain/news/admin/";
-	$emailformatted .= "\n\n";
-	my %mail = ( To      => "$server_admin",
-		     From    => "noreply\@$sys_default_domain",
-		     Subject => "$sys_name pending news",
-		     Message => $emailformatted
-		   );
-	$mail{'Content-type'} = 'text/plain; charset="UTF-8"';
-	sendmail(%mail) or die $Mail::Sendmail::error;
-}
-else {
-	if ($debug) {print STDERR "No news to approved.\n"};
-}
-
-if ($debug) {print STDERR "get_news_notapproved process finished ok\n"};
-exit(0);
-
-# Functions
-#-------------------------------------------------------------------------------
-
-sub usage() {
-	print STDERR "usage: get_news_notapproved.pl [--debug]\n";
-}
diff --git a/src/etc/cron.d/fusionforge-db b/src/etc/cron.d/fusionforge-db
index 6bdde28..474d228 100644
--- a/src/etc/cron.d/fusionforge-db
+++ b/src/etc/cron.d/fusionforge-db
@@ -46,5 +46,5 @@ PATH=@bindir@:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
 
 # this cronjob send a mail to the admin with all news that have been posted less than 30 days and that have not be validated.
 # Daily mail for not approved news
-30 17 * * * root forge_run_job db/get_news_notapproved.pl
+30 17 * * * root forge_run_job db/get_news_notapproved.php
 
diff --git a/src/lib/include.pl b/src/lib/include.pl
deleted file mode 100644
index 09a2463..0000000
--- a/src/lib/include.pl
+++ /dev/null
@@ -1,180 +0,0 @@
-# include.pl - Include file for all the perl scripts that contains reusable functions
-#
-
-##############################
-# Global Variables
-##############################
-$dummy_user	=	'scm-gforge';		# unix name of the dummy user
-$dummy_uid	=	getpwnam($dummy_user);	# uid of the dummy user that will own group's files
-$date		=	int(time()/3600/24);	# Get the number of days since 1/1/1970 for /etc/shadow
-
- at possible_paths = (
-    '/usr/share/gforge/bin',
-    '/usr/share/fusionforge/bin',
-    '/usr/local/share/gforge/bin',
-    '/usr/local/share/fusionforge/bin',
-    '/opt/gforge/bin',
-    '/opt/fusionforge/bin',
-    '/usr/bin',
-    '/usr/local/bin') ;
-foreach $p (@possible_paths) {
-	if (-x "$p/forge_get_config") {
-		$fgc = "$p/forge_get_config";
-		last;
-	}
-}
-
-%forge_config_cache = ();
-
-sub forge_get_config ($$) {
-    my $var = shift;
-    my $sec = shift || 'core';
-
-    if (!defined $forge_config_cache{$sec}{$var}) {
-	$forge_config_cache{$sec}{$var} = qx!$fgc $var $sec!;
-	chomp $forge_config_cache{$sec}{$var};
-    }
-    return $forge_config_cache{$sec}{$var};
-}
-
-$sys_default_domain = &forge_get_config ('web_host') ;
-$sys_return_domain = &forge_get_config ('forum_return_domain') ;
-$sys_scm_host = &forge_get_config ('web_host') ;
-$domain_name = &forge_get_config ('web_host') ;
-$sys_users_host = &forge_get_config ('users_host') ;
-$sys_lists_host = &forge_get_config ('lists_host') ;
-$sys_name = &forge_get_config ('forge_name') ;
-$sys_themeroot = &forge_get_config ('themes_root') ;
-$sys_news_group = &forge_get_config ('news_group') ;
-$sys_dbhost = &forge_get_config ('database_host') ;
-$sys_dbport = &forge_get_config ('database_port') ;
-$sys_dbname = &forge_get_config ('database_name') ;
-$sys_dbuser = &forge_get_config ('database_user') ;
-$sys_dbpasswd = &forge_get_config ('database_password') ;
-$sys_ldap_base_dn = &forge_get_config ('ldap_base_dn') ;
-$sys_ldap_host = &forge_get_config ('ldap_host') ;
-$server_admin = &forge_get_config ('admin_email') ;
-$chroot_prefix = &forge_get_config ('chroot') ;
-$homedir_prefix = &forge_get_config ('homedir_prefix') ;
-$grpdir_prefix = &forge_get_config ('groupdir_prefix') ;
-$file_dir = &forge_get_config ('data_path') ;
-$sys_use_ssl = &forge_get_config('use_ssl');
-$sys_urlprefix = &forge_get_config('url_prefix');
-
-##############################
-# Database Connect Functions
-##############################
-sub db_connect ( ) {
-    my $str = "DBI:Pg:dbname=$sys_dbname" ;
-    if ($sys_dbhost ne '') {
-	$str .= ";host=$sys_dbhost" ;
-    }
-    if ($sys_dbport ne '') {
-	$str .= ";port=$sys_dbport" ;
-    }
-    $dbh ||= DBI->connect($str,"$sys_dbuser","$sys_dbpasswd") ;
-    if (! $dbh) {
-	die "Error while connecting to database: $!" ;
-    }
-}
-
-sub db_disconnect ( ) {
-	$dbh->disconnect ;
-	$dbh = "" ;
-}
-
-sub db_drop_table_if_exists {
-    my ($sql, $res, $n, $tn) ;
-    $tn = shift ;
-    $sql = "SELECT COUNT(*) FROM pg_class WHERE relname='$tn'";
-    $res = $dbh->prepare($sql);
-    $res->execute();
-    ($n) = $res->fetchrow() ;
-    $res->finish () ;
-    if ($n != 0) {
-	$sql = "DROP TABLE $tn";
-	$res = $dbh->prepare($sql);
-	$res->execute () ;
-	$res->finish () ;
-    }
-}
-
-##############################
-# File open function, spews the entire file to an array.
-##############################
-sub open_array_file {
-	my $filename = shift(@_);
-
-	open (FD, $filename) || die "Can't open $filename: $!.\n";
-	@tmp_array = <FD>;
-	close(FD);
-
-	return @tmp_array;
-}
-
-#############################
-# File write function.
-#############################
-sub write_array_file {
-	my ($file_name, @file_array) = @_;
-	my $oldmask = umask(077);
-
-	use File::Temp qw(tempfile);
-	use File::Basename qw(dirname);
-
-	my ($fd, $filename) ;
-	eval { ($fd, $filename) = tempfile( DIR => dirname($file_name), UNLINK => 0) } ;
-
-	umask($oldmask);
-
-	return 1 unless ($fd && $filename) ;
-
-	foreach (@file_array) {
-		if ($_ ne '') {
-			print $fd $_;
-		}
-	}
-
-	close($fd);
-	unless (rename ($filename, $file_name)) {
-		unlink $filename;
-		return 1;
-	}
-	return 0;
-}
-
-#######################
-# Display a backtrace #
-#######################
-sub
-debug_print_backtrace
-{
-	my $i = 1;
-
-	print "Call Trace:\n";
-	while ((my @call_details = (caller($i++)))) {
-		print " + " . $call_details[1] . ":" . $call_details[2] .
-		    " in function " . $call_details[3] . "\n";
-	}
-}
-
-#############################
-# Compatibility functions.
-#############################
-sub util_make_url {
-	my ($path) = @_;
-	my $url;
-
-	if (($sys_use_ssl eq 'true') || ($sys_use_ssl eq '1')) {
-		$url = 'https://';
-	} else {
-		$url = 'http://';
-	}
-
-	$url .= $sys_default_domain . $sys_urlprefix;
-	$url =~ s,/$,,;
-	$path =~ s,^/,,;
-	$url .= '/' . $path;
-
-	return $url;
-}

-----------------------------------------------------------------------

Summary of changes:
 src/GNUmakefile                          |    2 +-
 src/cronjobs/db/get_news_notapproved.php |   98 ++++++++++++++++
 src/cronjobs/db/get_news_notapproved.pl  |  126 ---------------------
 src/etc/cron.d/fusionforge-db            |    2 +-
 src/lib/include.pl                       |  180 ------------------------------
 5 files changed, 100 insertions(+), 308 deletions(-)
 create mode 100755 src/cronjobs/db/get_news_notapproved.php
 delete mode 100755 src/cronjobs/db/get_news_notapproved.pl
 delete mode 100644 src/lib/include.pl


hooks/post-receive
-- 
FusionForge



More information about the Fusionforge-commits mailing list