MLB 2.6 * * @package Maarch LetterBox 2.6 * @version 1.0 * @since 10/2007 * @license GPL * @author Loïc Vinet */ require_once("class_db.php"); require_once("class_users.php"); function utf8_maarch($value) { $default_value= $value; $encode_value = utf8_decode($value); if (strstr($encode_value, '?') <> false) { return $default_value; } else { return $encode_value; } } function sendmail_notes($res_id, $notes= "") { $db= new dbquery(); $db->connect(); $user = new users(); //Get the dest user of this document $db->query("select DEST_USER from ".$_SESSION['ressources'][0]['tablename']." where RES_ID = '".$res_id."'"); $result1 = $db->fetch_object(); $this_dest_user = $result1->DEST_USER; if ($this_dest_user <> $_SESSION['user']['UserId']) { //Get mail adresse and notification from this user $db->query("select MAIL, NOTIFICATION from ".$_SESSION['tablename']['users']." where USER_ID = '".$this_dest_user."'"); $result2 = $db->fetch_object(); $mail = $result2->MAIL; //on vérifie que l'user accept la notification if($result2->NOTIFICATION & 16) { //Get this mail template $file = $_SESSION['config']['includedir']."/template_mail_notes.html"; $mail_trait = get_mail_template($file, $resid ); global $rempl; $rempl = get_doc_info($res_id, $notes); $mail_trait = preg_replace_callback('/(\\[(.*?)\\])/',create_function('$match','global $rempl; return $rempl[$match[2]];'),$mail_trait); //$mail_trait = preg_replace_callback('/([^_A-Z]{1})(_[A-Z_]*)([^_A-Z])/',create_function('$match', 'print_r($match);return $match[1].constant($match[2]).$match[3];'),$mail_trait); $mail_trait = preg_replace_callback('/(_[A-Z_]*)/',create_function('$match', 'return constant($match[1]);'),$mail_trait); //Send mail to the dest_user $objet_mail = _NEW_NOTES_BY_MAIL; $sChaineIso = mb_convert_encoding($objet_mail, "auto", "ISO-8859-1"); mail($mail, " Nouvelle annotation - Affaire numero : "." ".$res_id, $mail_trait , "From: ".$_SESSION['config']['adminmail']."\nReply-To: ".$_SESSION['config']['adminmail']." \nContent-Type: text/html; charset=\"iso-8859-1\"\n"); } } } function get_doc_info($res_id, $notes) { $db= new dbquery(); $db->connect(); $db->query("select TYPE_ID, DEST_USER, DESTINATION, AUTHOR, CUSTOM_D2, DESCRIPTION, FIRSTNAME, LASTNAME from ".$_SESSION['ressources'][0]['tablename']." , ".$_SESSION['tablename']['users']." where RES_ID = '".$res_id."'"); //$db->show(); $result = $db->fetch_object(); $rempl = array('id'=>$res_id, 'type'=>html_entity_decode(utf8_maarch(str_replace('\\', '', $result->TYPE_ID))), 'dest_user'=>html_entity_decode(utf8_maarch(str_replace('\\', '', $result->FIRSTNAME." ".$result->LASTNAME))), 'destination'=>html_entity_decode(utf8_maarch(str_replace('\\', '', $result->DESTINATION))), 'actual_user'=>html_entity_decode(utf8_maarch(str_replace('\\', '',$_SESSION['user']['FirstName']." ".$_SESSION['user']['LastName']))), 'actual_note'=>html_entity_decode(utf8_maarch(str_replace('\\', '', $notes))), 'emetteur'=>html_entity_decode(utf8_maarch(str_replace('\\', '', $result->AUTHOR))), 'date_limite'=>html_entity_decode($result->CUSTOM_D2), 'object'=>html_entity_decode(utf8_maarch(str_replace('\\', '', $result->DESCRIPTION))), 'link_to_maarch'=>str_replace('_','_',$_SESSION['config']['MaarchURL']), 'date'=>date("d-m-Y") ); return $rempl; } function get_mail_template($this_file) { //Ouverture du fichier $mail_trait = file_get_contents ($this_file); //Suppression des commantaires dans la page $mail_trait = preg_replace("/()/s","", $mail_trait); return $mail_trait; } ?>