[Fusionforge-commits] r9558 - in trunk: gforge/common/include plugins/coclico/forumml/bin plugins/coclico/forumml/include plugins/coclico/forumml/www

Mélanie Le Bail melanelebail at libremir.placard.fr.eu.org
Wed Apr 21 17:16:35 CEST 2010


Author: melanelebail
Date: 2010-04-21 17:16:35 +0200 (Wed, 21 Apr 2010)
New Revision: 9558

Added:
   trunk/plugins/coclico/forumml/bin/mail_2_DB.php
   trunk/plugins/coclico/forumml/bin/mail_2_DB.pl
   trunk/plugins/coclico/forumml/bin/ml_arch_2_DB.pl
Modified:
   trunk/gforge/common/include/PluginManager.class.php
   trunk/plugins/coclico/forumml/include/ForumMLInsert.class.php
   trunk/plugins/coclico/forumml/include/ForumML_MessageDao.class.php
   trunk/plugins/coclico/forumml/include/forummlPlugin.class.php
   trunk/plugins/coclico/forumml/www/forumml_utils.php
Log:
Forumml plugin now works on both FF and Codendi


Modified: trunk/gforge/common/include/PluginManager.class.php
===================================================================
--- trunk/gforge/common/include/PluginManager.class.php	2010-04-21 13:58:40 UTC (rev 9557)
+++ trunk/gforge/common/include/PluginManager.class.php	2010-04-21 15:16:35 UTC (rev 9558)
@@ -250,6 +250,10 @@
 		}
 
 	}
+	function isPluginAllowedForProject($p, $group_id) {
+		$Group = group_get_object($group_id);
+		return $Group->usesPlugin($p->getName());
+	}
 }
 
 /**

Added: trunk/plugins/coclico/forumml/bin/mail_2_DB.php
===================================================================
--- trunk/plugins/coclico/forumml/bin/mail_2_DB.php	                        (rev 0)
+++ trunk/plugins/coclico/forumml/bin/mail_2_DB.php	2010-04-21 15:16:35 UTC (rev 9558)
@@ -0,0 +1,151 @@
+<?php
+#
+# Copyright (c) STMicroelectronics, 2005. All Rights Reserved.
+
+ # Originally written by Jean-Philippe Giola, 2005
+ #
+ # This file is a part of codendi.
+ #
+ # codendi 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 License, or
+ # (at your option) any later version.
+ #
+ # codendi 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 codendi; if not, write to the Free Software
+ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ #
+ # $Id$
+ #
+
+/* This script allows the transfer of an mbox-formatted mail to ForumML database.
+ *  First argument: mailing-list name
+ *  Second argument: type of transfer, depending on the input
+ * 		'1': transfer from '/var/run/forumml/mail_tmp_xyz' temporary file (1-message mbox file)
+ * 		'2': transfer from whole list archive (real mbox file)
+ *  Third argument: temporary file name (used when 2nd arg = 1)
+*/
+
+ini_set('max_execution_time', 0);
+ini_set('memory_limit', -1);
+
+require_once('pre.php');
+require 'Mail/Mbox.php';
+require_once(dirname(__FILE__).'/../include/ForumML_mimeDecode.class.php');
+require_once(dirname(__FILE__).'/../include/ForumMLInsert.class.php');
+require_once(dirname(__FILE__).'/../include/ForumML_FileStorage.class.php');
+require_once('common/plugin/PluginManager.class.php');
+require_once 'plugins_utils.php';
+require_once('www/mail/mail_utils.php');
+require_once('utils.php');
+
+$list = $argv[1];
+// get list id and group id from list name
+$sql = sprintf('SELECT group_id, group_list_id'.
+				' FROM mail_group_list'.
+				' WHERE list_name = "%s"',
+				db_escape_string($list));
+$res = db_query($sql);
+if (db_numrows($res) > 0) {
+	$id_list = db_result($res,0,'group_list_id');
+	$gr_id = db_result($res,0,'group_id');
+} else {
+	$stderr = fopen('php://stderr', 'w');
+	fwrite($stderr, "Invalid mailing-list $list \n");
+	fclose($stderr);
+	exit;
+}
+
+$plugin_manager =& PluginManager::instance();
+$p =& $plugin_manager->getPluginByName('forumml');
+if ($p && $plugin_manager->isPluginAvailable($p) ) {
+    $info =& $p->getPluginInfo();
+	if ($argv[2] == 2) {
+		// get list archive		
+		$forumml_arch = $GLOBALS['forumml_arch'];
+		$mbox_file = $forumml_arch."/private/".$list.".mbox/".$list.".mbox";
+		// check if mbox file exists
+		if (! is_file($mbox_file)) {
+			$stderr = fopen('php://stderr', 'w');
+			fwrite($stderr, "Invalid mbox file $mbox_file \n");
+			fclose($stderr);
+			exit;	
+		}
+
+        // Do not import from archives if there are already messages for this list
+        $sql = 'SELECT NULL FROM plugin_forumml_message WHERE id_list = '.db_ei($id_list).' LIMIT 1';
+        $res = db_query($sql);
+        if ($res && db_numrows($res) > 0) {
+            $stderr = fopen('php://stderr', 'w');
+			fwrite($stderr, "Cannot import messages from archive.\nThere are already messages in the database for $list ($mbox_file)\n");
+			fclose($stderr);
+			exit;
+        }
+	} else {
+		// get 3rd argument
+		$temp_file = $argv[3];
+		// get temp file parent dir
+		$forumml_tmp = $GLOBALS['forumml_tmp'];
+		$mbox_file = $forumml_tmp."/".$temp_file;
+print "mboxfile=".$mbox_file;
+	}
+
+	// Open the mail that has been temporary stored
+    $mbox = new Mail_Mbox($mbox_file);
+	$mbox->open();
+	if (PEAR::isError($mbox)) {
+		print "Unable to open mbox: ".$mbox->getMessage().PHP_EOL;
+	} else {
+        $nbMailInserted = 0;
+print "nb mail inserted=".$nbMailInserted;
+		$num_msg        = $mbox->size();
+		for ($i = 0; $i < $num_msg; $i++) {
+			$thisMessage = $mbox->get($i);
+			if (PEAR::isError($thisMessage)) {
+				print "Unable to get message $i: ".$thisMessage->getMessage().PHP_EOL;
+			} else {
+                // Decode email
+				$args['include_bodies'] = TRUE;
+				$args['decode_bodies']  = TRUE;
+				$args['decode_headers'] = TRUE;
+				$args['crlf']           = "\r\n";
+				$decoder = new ForumML_mimeDecode($thisMessage, "\r\n");
+				$structure = $decoder->decode($args);
+
+                // Get ForumML storage
+                $forumml_dir     = $GLOBALS['forumml_dir'];
+                $forumml_storage = new ForumML_FileStorage($forumml_dir);
+
+                // Store email
+				$insert = new ForumMLInsert($id_list);
+                $msgId  = $insert->storeEmail($structure, $forumml_storage);
+                if ($msgId) {
+                    $nbMailInserted++;
+                }
+			}
+		}
+
+        // Display message when importing a mail archive
+        if ($argv[2] == 2) {
+            if ($num_msg == $nbMailInserted) {
+                echo 'Operation Completed.'.$num_msg.' imported'.PHP_EOL;
+            } else {
+                echo '*** Error: '.$num_msg.' in '.$mbox_file.' file but '. $nbMailInserted.' stored in database'.PHP_EOL;
+            }
+        }
+	}
+}
+
+// delete temporary file
+if ($argv[2] == 1) {
+	if (is_file($mbox_file)) {
+		unlink($mbox_file);
+	}
+}
+
+?>


Property changes on: trunk/plugins/coclico/forumml/bin/mail_2_DB.php
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/forumml/bin/mail_2_DB.pl
===================================================================
--- trunk/plugins/coclico/forumml/bin/mail_2_DB.pl	                        (rev 0)
+++ trunk/plugins/coclico/forumml/bin/mail_2_DB.pl	2010-04-21 15:16:35 UTC (rev 9558)
@@ -0,0 +1,105 @@
+#!/usr/bin/perl -UT
+
+# Copyright (c) STMicroelectronics, 2005. All Rights Reserved.
+#
+# Originally written by Jean-Philippe Giola, 2005
+#
+# This file is a part of codendi.
+#
+# codendi 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 License, or
+# (at your option) any later version.
+#
+# codendi 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 codendi; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+# Taint mode enabled
+
+# mailing-list name should contain only alphabetical characters, '-' and '.' 
+sub validate_listname {
+    my $arg = shift;
+    my $listname = "";
+    my $match = 0;
+
+    if($arg =~ /^([-.\w]+)$/) {
+        if ($match == 0) {
+	    $listname = $1;
+	}
+    }
+    return $listname;
+}
+
+use strict;
+
+# Set default path (required by taint mode)
+$ENV{'PATH'} = '/usr/bin:/bin';
+
+# Hook log file
+my $logfile = "/var/log/codendi/forumml_hook.log";
+
+# Redirect outputs
+open STDOUT, ">>", $logfile or die "cannot append to '$logfile': $!\n";
+open STDERR, ">&STDOUT" or die "cannot append STDERR to STDOUT: $!\n";
+
+# Search if there are lists we shouldn't treat
+my $conf = '/etc/codendi/plugins/forumml/etc/forumml.inc';
+if (-f $conf) {
+    # Get the variable defined in forumml.inc
+    my @exc_lists;
+    open(FORUMML_INC, "<$conf");
+    while (<FORUMML_INC>) {
+	if (m/^\$forumml_excluded_lists[ ]*=[ ]*"(.*)"[ ]*;[ ]*$/) {
+	    @exc_lists = split(/[ ]*,[ ]*/, $1);
+	}
+    }
+    close(FORUMML_INC);
+
+    # Test if given list is excluded or not
+    foreach my $list (@exc_lists) {
+	if ($list eq $ARGV[0]) {
+	    exit 2;
+	}
+    }
+}
+
+# First argument is mandatory (list name)
+my $listname = $ARGV[0];
+chomp($listname);
+if($listname eq "") {
+    exit 1
+}
+
+# Get mail from STDIN, store it in a temporary file, then pass it to php script
+my $range = 100;
+my $random = int(rand($range));
+my $temp = "mail_tmp_".$random."_".time();
+my $path = "/var/run/forumml/".$temp;
+open(OUT, ">>$path");
+while (defined($_ = <STDIN>)) {
+    print OUT $_;
+}
+close(OUT);
+
+# Get PHP_PARAMS variable from php-laucher.sh
+my $PHP_PARAMS="";
+open(PHP_LAUNCHER, "</usr/share/codendi/src/utils/php-launcher.sh");
+while (<PHP_LAUNCHER>) {
+    if (m/^[ ]*PHP_PARAMS="(.*)"$/) {
+	$PHP_PARAMS=$1;
+	last;
+    }
+}
+close(PHP_LAUNCHER);
+
+# store mail in ForumML DB
+exec "/usr/bin/php $PHP_PARAMS /usr/share/codendi/plugins/forumml/bin/mail_2_DB.php $listname 1 $temp";
+
+close STDOUT;
+close STDERR;


Property changes on: trunk/plugins/coclico/forumml/bin/mail_2_DB.pl
___________________________________________________________________
Added: svn:executable
   + *

Added: trunk/plugins/coclico/forumml/bin/ml_arch_2_DB.pl
===================================================================
--- trunk/plugins/coclico/forumml/bin/ml_arch_2_DB.pl	                        (rev 0)
+++ trunk/plugins/coclico/forumml/bin/ml_arch_2_DB.pl	2010-04-21 15:16:35 UTC (rev 9558)
@@ -0,0 +1,78 @@
+#!/usr/bin/perl
+
+#
+# Copyright (c) STMicroelectronics, 2007. All Rights Reserved.
+#
+# Originally written by Mohamed CHAARI, 2007
+#
+# This file is a part of codendi.
+#
+# codendi 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 License, or
+# (at your option) any later version.
+#
+# codendi 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 codendi; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+=pod
+
+This script aims at achieving the migration of archives, of all _active_ mailing-lists, to the ForumML database.
+Only projects that enabled ForumML plugin are concerned by this migration.
+
+=cut
+
+# Search if there are lists we shouldn't treat
+print "Script launched";
+my $conf = '/etc/codendi/plugins/forumml/etc/forumml.inc';
+my %excluded_list;
+if (-f $conf) {
+    # Get the variable defined in forumml.inc
+    my @exc_lists;
+    open(FORUMML_INC, "<$conf");
+    while (<FORUMML_INC>) {
+	if (m/^\$forumml_excluded_lists[ ]*=[ ]*"(.*)"[ ]*;[ ]*$/) {
+	    @exc_lists = split(/[ ]*,[ ]*/, $1);
+	}
+    }
+    close(FORUMML_INC);
+
+    # Test if given list is excluded or not
+    foreach my $list (@exc_lists) {
+	$excluded_list{$list} = 0;
+    }
+}
+
+# Get PHP_PARAMS variable from php-laucher.sh
+my $PHP_PARAMS="";
+open(PHP_LAUNCHER, "</usr/share/codendi/src/utils/php-launcher.sh");
+while (<PHP_LAUNCHER>) {
+    if (m/^[ ]*PHP_PARAMS="(.*)"$/) {
+	$PHP_PARAMS=$1
+    }
+}
+close(PHP_LAUNCHER);
+
+#use strict;
+use DBI;
+
+require "/usr/share/codendi/src/utils/include.pl";
+&db_connect;
+print "Connect to DB";
+# get all active mailing-lists
+my $query = "SELECT list_name, group_id FROM mail_group_list WHERE status = 3";
+my $req = $dbh->prepare($query);
+$req->execute();
+while (my ($list_name,$group_id) = $req->fetchrow()) {
+    if(! exists $excluded_list{$list_name}) {
+	print "Processing ".$list_name." mailing-list ... \n";
+	system("/usr/bin/php $PHP_PARAMS /usr/share/codendi/plugins/forumml/bin/mail_2_DB.php $list_name 2");
+    }
+}


Property changes on: trunk/plugins/coclico/forumml/bin/ml_arch_2_DB.pl
___________________________________________________________________
Added: svn:executable
   + *

Modified: trunk/plugins/coclico/forumml/include/ForumMLInsert.class.php
===================================================================
--- trunk/plugins/coclico/forumml/include/ForumMLInsert.class.php	2010-04-21 13:58:40 UTC (rev 9557)
+++ trunk/plugins/coclico/forumml/include/ForumMLInsert.class.php	2010-04-21 15:16:35 UTC (rev 9558)
@@ -22,27 +22,25 @@
  #
  # $Id$
  #
+require_once 'ForumML_MessageDao.class.php';
 
-
 // ForumML Database Query Class
 class ForumMLInsert {
     var $id_message;
     var $mail;
     var $id_list;
+    var $dao;
 	
     // Class Constructor
 	function __construct($list_id) {
 		// set id_list
 		$this->id_list = $list_id;
+		$this->dao = new ForumML_MessageDao(CodendiDataAccess::instance());
 	}
     
     // Insert values into forumml_messageheader table
     function insertMessageHeader($id_header,$value) {
-        
-    	$qry = sprintf('INSERT INTO plugin_forumml_messageheader'.
-    					' (id_message, id_header, value)'.
-    					' VALUES ($1,$2,$3)');
-    	db_query_params($qry,array($this->id_message , $id_header , $value));
+	$this->dao->insertMessageHeader($this->id_message,$id_header,$value);
     }
 
     // Insert values into forumml_attachment table 
@@ -52,57 +50,40 @@
         } else {
             $filesize = 0;
         }
-    	$qry = sprintf('INSERT INTO plugin_forumml_attachment'.
-                       ' (id_message, file_name, file_type, file_size, file_path, content_id)'.
-                       ' VALUES ($1,$2,$3,$4,$5,$6)');
-    	db_query_params($qry,array($id_message , $filename , $filetype , $filesize , $filepath , $content_id));
+	$this->dao->insertAttachment($id_message, $filename, $filetype, $filesize, $filepath,$content_id);
     }
 
     // Insert values into forumml_header table
     function insertHeader($header) {
         
     	// Search if the header is already in the table
-        $qry = sprintf('SELECT id_header'.
-        				' FROM plugin_forumml_header'.
-        				' WHERE name = $1');
-    	$result = db_query_params($qry,array($header));
-        
+       $result = $this->dao->searchHeader($header);        
         // If not, insert it
-        if (db_result($result,0,'id_header') == "") {
-            $sql = sprintf('INSERT INTO plugin_forumml_header'.
-            				' (name)'.
-            				' VALUES  ($1)');
-        	$res = db_query_params($sql,array($header));
-            return (db_insertid($res,'plugin_forumml_header','id_header'));
-        } else {
-            return (db_result($result,0,'id_header'));
-        }
+       if ($result->rowCount()<1) {
+	       return $this->dao->insertHeader($header);
+       } else {
+	       $row=$result->getRow();
+	       return $row['id_header'];
+       }
     }
 
     function getParentMessageFromHeader($messageIdHeader) {
-        $qry = 'SELECT id_message'.
-            ' FROM plugin_forumml_messageheader'.
-            ' WHERE id_header = 1'.
-            ' AND value = $1 ';
-        $result = db_query_params($qry,array($messageIdHeader));
-        if ($result && !db_error($result)) {
-            $row = db_fetch_array($result);
-            return $row['id_message'];
-        }
-        return false;
+	    $result = $this->dao->getParentMessageFromHeader($messageIdHeader) ;
+	    if ($result && $result->rowCount() >= 1 ) {
+		    $row = $result->getRow();
+		    return $row['id_message'];
+	    }
+	    return false;
+
     }
 
     function updateParentDate($messageId, $date) {
 	    if ($messageId != 0) {
-		    $sql = 'SELECT id_parent, last_thread_update FROM plugin_forumml_message WHERE id_message = $1';
-		    $dar = db_query_params($sql,array($messageId));
-		    if ($dar && !db_error($dar)) {
-			    $row = db_fetch_array($dar);
+		    $dar = $this->dao->getParents($messageId);
+		    if ($dar) {
+			    $row = $dar->getRow();
 			    if ($date > $row['last_thread_update']) {
-				    $sql = 'UPDATE plugin_forumml_message'.
-					    ' SET last_thread_update =$1 '.
-					    ' WHERE id_message=$2';
-				    db_query_params($sql,array($date,$messageId));
+				    $this->dao->updateParentDate($messageId, $date);
 
 				    $this->updateParentDate($row['id_parent'], $date);
 			    }
@@ -147,13 +128,8 @@
 	    if ($id_parent != 0) {
 		    $this->updateParentDate($id_parent, $messageDate);
 	    }
+$this->id_message = $this->dao->insertMessage($this->id_list,  $id_parent , $body , $messageDate , $ctype);
 
-	    $sql = sprintf('INSERT INTO plugin_forumml_message'.
-			    ' ( id_list, id_parent, body, last_thread_update, msg_type)'.
-			    ' VALUES ($1, $2, $3, $4, $5)');
-	    $res = db_query_params($sql,array($this->id_list , $id_parent , $body , $messageDate , $ctype));
-	    $this->id_message = db_insertid($res,'plugin_forumml_message','id_message');
-
 	    // All headers of the current mail are stored in the forumml_messageheader table
 	    $k=0;
 	    foreach ($structure as $header => $value_header) {

Modified: trunk/plugins/coclico/forumml/include/ForumML_MessageDao.class.php
===================================================================
--- trunk/plugins/coclico/forumml/include/ForumML_MessageDao.class.php	2010-04-21 13:58:40 UTC (rev 9557)
+++ trunk/plugins/coclico/forumml/include/ForumML_MessageDao.class.php	2010-04-21 15:16:35 UTC (rev 9558)
@@ -33,6 +33,8 @@
 	}
 
 	function searchHeaderValue($messageId, $headerId) {
+		$messageId = $this->da->quoteSmart($messageId);
+		$headerId = $this->da->quoteSmart($headerId);
 		$sql = 'SELECT mh.value'.
 			' FROM plugin_forumml_message m'.
 			'  JOIN plugin_forumml_messageheader mh'.
@@ -45,6 +47,7 @@
 	}
 
 	function getMessageHeaders($id_message) {
+		$id_message = $this->da->quoteSmart($id_message);
 		$sql = 'SELECT value'.
 			' FROM plugin_forumml_messageheader'.
 			' WHERE id_message = $1'.
@@ -54,6 +57,8 @@
 	}
 
 	function getSpecificMessage($id_message,$list_id) {
+		$id_message = $this->da->quoteSmart($id_message);
+		$list_id = $this->da->quoteSmart($list_id);
 		$sql ='SELECT value, body'.
 			' FROM plugin_forumml_message m, plugin_forumml_messageheader mh'.
 			' WHERE m.id_message =$1 '.
@@ -64,6 +69,8 @@
 	}
 
 	function getHeaderValue($id, $ids) {
+		$id = $this->da->quoteSmart($id);
+		$ids = $this->da->quoteSmart($ids);
 		if (!isset($ids)) {
 			$ids = 'SELECT id_header FROM plugin_forumml_messageheader';
 		}
@@ -73,6 +80,9 @@
 	}
 
 	function getAllThreadsFromList($list_id,$offset,$chunks) {
+		$list_id = $this->da->quoteSmart($list_id);
+		$offset = $this->da->quoteSmart($offset);
+		$chunks = $this->da->quoteSmart($chunks);
 		$sql = 'SELECT m.id_message, m.last_thread_update as lastup, mh_d.value as date, mh_f.value as sender, mh_s.value as subject'.
 			' FROM plugin_forumml_message m'.
 			' LEFT JOIN plugin_forumml_messageheader mh_d ON (mh_d.id_message = m.id_message AND mh_d.id_header = $1)'.
@@ -81,12 +91,13 @@
 			' WHERE m.id_parent = 0'.
 			' AND id_list = $4 '.
 			' ORDER BY m.last_thread_update DESC'.
-			' OFFSET $5'.
-			' LIMIT $6';
+			' LIMIT $6'.
+			' OFFSET $5';
 		return $this->retrieve($sql,array(FORUMML_DATE,FORUMML_FROM,FORUMML_SUBJECT,$list_id,$offset,$chunks));
 	}
 
 	function countAllThreadsFromList($list_id) {
+		$list_id = $this->da->quoteSmart($list_id);
 		$sql = 'SELECT COUNT(*) as nb'.
 			' FROM plugin_forumml_message m'.
 			' LEFT JOIN plugin_forumml_messageheader mh_d ON (mh_d.id_message = m.id_message AND mh_d.id_header = $1)'.
@@ -120,6 +131,7 @@
 	}
 
 	function getFlattenedThread($topic) {
+		$topic = $this->da->quoteSmart($topic);
 		$sql = 'SELECT m.*, mh_d.value as date, mh_f.value as sender, mh_s.value as subject, mh_ct.value as content_type, mh_cc.value as cc, a.id_attachment, a.file_name, a.file_type, a.file_size, a.file_path, a.content_id'.
 			' FROM plugin_forumml_message m'.
 			' LEFT JOIN plugin_forumml_messageheader mh_d ON (mh_d.id_message = m.id_message AND mh_d.id_header = $1)'.
@@ -133,14 +145,20 @@
 	}
 
 	function updateCacheHTML($cache,$id) {
+		$cache = $this->da->quoteSmart($cache);
+		$id = $this->da->quoteSmart($id);
 		return $this->update('UPDATE plugin_forumml_message SET cached_html= $1 WHERE id_message= $2',array($cache,$id));
 	}
 
 	function getAttachment($id_message,$match) {
+		$id_message = $this->da->quoteSmart($id_message);
+		$match = $this->da->quoteSmart($match);
 		$sql = 'SELECT id_attachment FROM plugin_forumml_attachment WHERE id_message=$1 and content_id=<$2>';
 		return $this->retrieve($sql,array($id_message , $match));
 	}
 	function searchArchives($list_id,$pattern) {
+		$list_id = $this->da->quoteSmart($list_id);
+		$pattern = $this->da->quoteSmart($pattern);
 		$sql = 'SELECT mh.id_message, mh.value'.
 			' FROM plugin_forumml_message m, plugin_forumml_messageheader mh'.
 			' WHERE mh.id_header = $1'.
@@ -153,10 +171,89 @@
 	}
 
 	function hasArchives($list_id) {
+		$list_id = $this->da->quoteSmart($list_id);
 		$qry = 'SELECT NULL FROM plugin_forumml_message WHERE id_list = $1 LIMIT 1';
 		return $this->retrieve($qry,array($list_id));
 	}
 
+	function insertMessageHeader($id_message, $id_header,$value) {
+		$id_message = $this->da->quoteSmart($id_message);
+		$id_header = $this->da->quoteSmart($id_header);
+		$value = $this->da->quoteSmart($value);
+		$qry = 'INSERT INTO plugin_forumml_messageheader'.
+			' (id_message, id_header, value)'.
+			' VALUES ($1,$2,$3)';
+		return $this->update($qry,array($id_message , $id_header , $value));
+	}
+	function insertAttachment ($id_message, $filename,$filetype,$filesize,$filepath,$content_id) {
+
+		$id_message = $this->da->quoteSmart($id_message);
+		$filename = $this->da->quoteSmart($filename);
+		$filetype = $this->da->quoteSmart($filetype);
+		$filesize = $this->da->quoteSmart($filesize);
+		$filepath = $this->da->quoteSmart($filepath);
+		$content_id = $this->da->quoteSmart($content_id);
+		$qry = 'INSERT INTO plugin_forumml_attachment'.
+			' (id_message, file_name, file_type, file_size, file_path, content_id)'.
+			' VALUES ($1,$2,$3,$4,$5,$6)';
+		return $this->update($qry,array($id_message , $filename , $filetype , $filesize , $filepath , $content_id));
+	}
+	function searchHeader ($header) {
+		$header = $this->da->quoteSmart($header);
+		$qry = 'SELECT id_header'.
+			' FROM plugin_forumml_header'.
+			' WHERE name = $1';
+		return $this->retrieve($qry,array($header));
+
+	}
+	function insertHeader($header) {
+
+		$header = $this->da->quoteSmart($header);
+		$sql = 'INSERT INTO plugin_forumml_header'.
+			' (name)'.
+			' VALUES  ($1)';
+		return db_insertid($this->update($sql,array($header)),'plugin_forumml_header','id_header');
+	}
+
+	function getParentMessageFromHeader ($id_header) {
+		$id_header = $this->da->quoteSmart($id_header);
+		$qry = 'SELECT id_message'.
+			' FROM plugin_forumml_messageheader'.
+			' WHERE id_header = 1'.
+			' AND value = $1 ';
+		return $this->retrieve($qry,array($id_header));
+
+	}
+
+	function getParents($messageId) {
+		$messageId = $this->da->quoteSmart($messageId);
+		$sql = 'SELECT id_parent, last_thread_update FROM plugin_forumml_message WHERE id_message = $1';
+		return $this->retrieve($sql,array($messageId));
+
+	}
+	function updateParentDate($messageId,$date) {
+		$messageId = $this->da->quoteSmart($messageId);
+		$date = $this->da->quoteSmart($date);
+		$sql = 'UPDATE plugin_forumml_message'.
+			' SET last_thread_update =$1 '.
+			' WHERE id_message=$2';
+		$this->update($sql,array($date,$messageId));
+	}
+
+	function insertMessage ($id_list,$id_parent, $body, $messageDate, $ctype) {
+		$id_list = $this->da->quoteSmart($id_list);
+		$id_parent = $this->da->quoteSmart($id_parent);
+		$body = $this->da->quoteSmart($body);
+		$messageDate = $this->da->quoteSmart($messageDate);
+		$ctype = $this->da->quoteSmart($ctype);
+
+		$sql = 'INSERT INTO plugin_forumml_message'.
+			' ( id_list, id_parent, body, last_thread_update, msg_type)'.
+			' VALUES ($1, $2, $3, $4, $5)';
+		return db_insertid($this->update($sql,array($id_list , $id_parent , $body , $messageDate , $ctype)),'plugin_forumml_message' ,'id_message');
+
+	}
+
 }
 
 ?>

Modified: trunk/plugins/coclico/forumml/include/forummlPlugin.class.php
===================================================================
--- trunk/plugins/coclico/forumml/include/forummlPlugin.class.php	2010-04-21 13:58:40 UTC (rev 9557)
+++ trunk/plugins/coclico/forumml/include/forummlPlugin.class.php	2010-04-21 15:16:35 UTC (rev 9558)
@@ -173,9 +173,11 @@
 			$request =& HTTPRequest::instance();
 			$group_id = (int) $request->get('group_id');
 		}
-		$pm = ProjectManager::instance();
-		$Group = $pm->getProject($group_id);
-		return $Group->usesPlugin('forumml');
+		if(!isset($this->allowedForProject[$group_id])) {
+			$pM =& PluginManager::instance();
+			$this->allowedForProject[$group_id] = $pM->isPluginAllowedForProject($this, $group_id);
+		}
+		return $this->allowedForProject[$group_id];
 	}
 
 	function forumml_searchbox_option($params) {

Modified: trunk/plugins/coclico/forumml/www/forumml_utils.php
===================================================================
--- trunk/plugins/coclico/forumml/www/forumml_utils.php	2010-04-21 13:58:40 UTC (rev 9557)
+++ trunk/plugins/coclico/forumml/www/forumml_utils.php	2010-04-21 15:16:35 UTC (rev 9558)
@@ -730,7 +730,7 @@
 		$mail->setBody($body);
 
 		if ($mail->send()) {
-			$feedback .= _('Mail successfully sent');
+			$feedback .= _('Mail successfully sent ');
 		} else {
 			$feedback .= _('Sending mail failed');
 			$continue = false;




More information about the Fusionforge-commits mailing list