* @author Claire Figueras * @author Jimmy Cédric Ndoumba */ include("session.php"); if(file_exists($_SESSION['config']['lang'].'.php')) { include($_SESSION['config']['lang'].'.php'); } else { $_SESSION['error'] = "Language file missing...
"; } require_once("class_functions.php"); require_once("class_db.php"); $func = new functions(); $db = new dbquery(); $db->connect(); $time = $db->get_session_time_expire(); function can_read_the_notes($the_user,$accessUsersValue,$accessServicesValue) { global $db; $can_read_the_notes = false; if( $accessServicesValue == "all" || $accessUsersValue == "all" ) { return true; } else if( $accessUsersValue != "not" && !empty($accessUsersValue) && array_search( $the_user,explode(",",$accessUsersValue) ) !== false ) { return true; } else { if( $accessServicesValue != "not" && !empty($accessServicesValue) ) { $db->query("SELECT DEPARTMENT FROM ".$_SESSION['tablename']['users']." WHERE USER_ID = '".$the_user."'"); if( $res = $db->fetch_object() && array_search( $res->DEPARTMENT, explode(",",$accessServicesValue) ) !== false ) return true; } } return false; } ?> <?php echo _ADD_NOTE;?> "RECORD_ID"); foreach( $copy_notes as $k_ct=> $d_ct ) { //INSERT PREVAL TABLE $db->query("INSERT IGNORE INTO ".$suffix_pre_val.$k_ct." SELECT * FROM ".$k_ct." WHERE ".$d_ct." = '".$resid."'"); } } } $db->query("INSERT INTO ".$_SESSION['tablename']['notes']." ( RECORD_ID, INFO, DATE, USER_ID, ACCESS_SERVICES, ACCESS_USERS) VALUES (".$resid.", '".addslashes($_POST[$textareaName])."', '".date("Y")."-".date("m")."-".date("d")." ".date("H:i:s")."', '".$_SESSION['user']['UserId']."', '".$accessServicesValue."', '".$accessUsersValue."')"); $last_insert_id = mysql_insert_id($db->sql_link); //Notification pour le dest_user si ce n'est pas lui qui rajoute l'annotation require_once($_SESSION['mailer']['path_to_mailer']."/class_mailer.php"); $mail = new Mailer("."); $db->query("SELECT DEST_USER, DESTINATION from ".$_SESSION['ressources'][0]['tablename']." where RES_ID = '".$resid."'"); if( $res = $db->fetch_object() ) { $dest_user = $res->DEST_USER; $destination = $res->DESTINATION; } if( $dest_user != $_SESSION['user']['UserId'] && can_read_the_notes($dest_user,$accessUsersValue,$accessServicesValue) ) $mail->send_and_save('notes',$last_insert_id,$dest_user,6); //Notification pour les personnes en copies si elle peuvent voir les courriers $db->query("SELECT USER_ID FROM ".$_SESSION['tablename']['listinstance']." WHERE RES_ID = ".$resid." AND SEQUENCE > 1 ORDER BY SEQUENCE"); $copy = array(); while( $res = $db->fetch_object() ) $copy[] = $res->USER_ID; foreach($copy as $c) if( $c != $_SESSION['user']['UserId'] && can_read_the_notes($c,$accessUsersValue,$accessServicesValue) ) { var_dump($c); if($mail) unset($mail); $mail = new Mailer("."); $mail->send_and_save('notes',$last_insert_id,$c,7); } //Mise à jour de l'historique if($_SESSION['history']['notesadd']) { require_once("class_history.php"); $hist = new history(); $hist->add($_SESSION['tablechoice'], $resid ,"ADD", _ADDITION_NOTE); } ?>