=== added directory 'sites/default/modules/contact_form_on_node'
=== added file 'sites/default/modules/contact_form_on_node/contact_form_on_node.module'
--- sites/default/modules/contact_form_on_node/contact_form_on_node.module	1970-01-01 00:00:00 +0000
+++ sites/default/modules/contact_form_on_node/contact_form_on_node.module	2010-07-01 19:00:32 +0000
@@ -0,0 +1,150 @@
+<?php
+// $Id: contact_form_on_node.module,v 1.5 2010/03/24 15:35:26 tahiticlic Exp $
+
+/**
+ * @file
+ * Creates a link or a form to contact the author, above node link.
+ */
+
+define('CONTACT_FORM_ON_NODE_MODE_USER', 1);
+define('CONTACT_FORM_ON_NODE_MODE_SYSTEM', 2);
+
+/**
+ * Display help and module information
+ * @param path which path of the site we're displaying help
+ * @param arg array that holds the current path as would be returned from arg() function
+ * @return help text for the path
+ */
+function contact_form_on_node_help($path, $arg) {
+	$output = '';  //declare your output variable
+	
+	switch ($path) {
+		case "admin/help#contact_form_on_node":
+			$output = '<p>'.  t("Displays contact form or contact link under a node") .'</p>';
+		break;
+	}
+	
+	return $output;
+} // function contact_form_on_node_help
+
+/**
+ * Valid permissions for this module
+ * @return array An array of valid permissions for the onthisdate module
+ */
+function contact_form_on_node_perm() {
+	return array('administer contact_form_on_node','access personal contact form' );
+} // function contact_form_on_node_perm()
+
+/**
+ * Implementation of hook_menu().
+ */
+function contact_form_on_node_menu() {
+  $menu['admin/settings/contact_form_on_node'] = array(
+    'title' => 'Contact Form On Node',
+    'description' => t('Configure Contact Form On Node'),
+    'page callback' => 'drupal_get_form',
+    'page arguments' => array('contact_form_on_node_settings'),
+    'access arguments' => array('administer contact_form_on_node'),
+    'file' => 'contact_form_on_node.admin.inc',
+  );
+  
+  return $menu;
+}
+
+/**
+ * Implementation of hook_link()
+ */
+function contact_form_on_node_link($type, $object, $teaser = FALSE) {
+
+	$links = array ();
+	// do we show the link?
+	$show=variable_get('contact_form_on_node_show_link', FALSE);
+	
+	// are we in teaser?
+	if ($teaser) $show=variable_get('contact_form_on_node_show_link_in_teaser', TRUE);
+	
+	if ($show){
+		// we get the enabled types
+		$enabledTypes = variable_get('contact_form_on_node_types', array());
+		if (user_access('access personal contact form')){
+		  // we test if this type needs a link added
+		  if (user_access('access personal contact form')&&$enabledTypes[$object->type]!="0") {
+		    // we add the link
+		    $links['contact-node'] = array (
+		      'title' => t('Contact'),
+		      'href' => "user/".$object->uid."/contact",
+		
+		    );
+		  }
+	  }
+	}
+
+  // we return the added link
+  return $links;
+}
+
+/**
+ * Implementation of hook_nodeapi()
+ *
+ */
+function contact_form_on_node_nodeapi(&$node, $op, $teaser, $page) {
+	// do we show the form?
+	$show = variable_get('contact_form_on_node_show_form', TRUE);
+
+	// are we in teaser?
+	if ($teaser == 1) {
+    $show = variable_get('contact_form_on_node_show_form_in_teaser', FALSE);
+  }
+	
+	if ($show) {
+    $mode = variable_get('contact_form_on_node_mode', CONTACT_FORM_ON_NODE_MODE_USER);
+    switch($mode) {
+      case CONTACT_FORM_ON_NODE_MODE_USER:
+        // we get the enabled types
+        $enabledTypes = variable_get('contact_form_on_node_types', array());
+        // we test if this type needs a form added
+        if ($op=='view' && user_access('access user contact forms') && $enabledTypes[$node->type] != "0") {
+          // we load contact helpers
+          module_load_include("inc", "contact", "contact.pages");
+          // then we load the author as a user
+          $user=user_load($node->uid);
+          // then we add the form, note that you can manage it your way in template
+          $node->content['contact_form_title'] = array(
+              '#value' => "<h3>".t("Contact")."</h3>",
+              '#weight' => 98,
+              );
+          $node->content['contact_form'] = array(
+              '#value' => drupal_get_form('contact_mail_user', $user),
+              '#weight' => 99,
+              );
+        }
+        else if($op == 'view' && $enabledTypes[$node->type] != "0" && !user_access('access user contact forms')) {
+          $node->content['contact_form_title'] = array(
+              '#value' => "<h3>".t("Contact")."</h3>",
+              '#weight' => 98,
+              );
+          $node->content['contact_form'] = array(
+              '#value' => t("Vous devez être connecté pour envoyer un message"),
+              '#weight' => 99,
+              );
+        }	
+        break;
+      case CONTACT_FORM_ON_NODE_MODE_SYSTEM:
+        // we get the enabled types
+        $enabledTypes = variable_get('contact_form_on_node_types', array());
+        if ($op == 'view' && $enabledTypes[$node->type] != "0" && user_access('access site-wide contact form')) {
+          // we load contact helpers
+          module_load_include("inc", "contact", "contact.pages");
+          $node->content['contact_form_title'] = array(
+              '#value' => "<h3>".t("Contact")."</h3>",
+              '#weight' => 98,
+              );
+          $node->content['contact_form'] = array(
+              '#value' => contact_site_page(),
+              '#weight' => 99,
+          );
+        }
+        break;
+    }	
+  }
+}

