db = $db; $this->my_user_id = $my_user_id; $this->delete_copy_rights = ( $delete_copy_rights == "true"); $this->modify_copy_list = ( $modify_copy_list == "true" ); $this->redirect_list = ( $redirect_list == "true" ); $this->tag100_for_copy = ( $tag100_for_copy == "true"); $this->history = array(); //COMPATIBILITE NEW MAILER //require_once($_SESSION['mailer']['path_to_mailer']."/class_mailer.php"); //$this->mail = new Mailer("."); } public function set_ressource($res_table,$res_id) { $this->table_res_x = $res_table; $this->res_id = $res_id; } public function update_service($service_id) { $this->db->query("UPDATE ".$this->table_res_x." set DESTINATION = '".$service_id."' WHERE RES_ID = '".$this->res_id."' "); } /* This function loads the diffusion list from the database according to the service associated * @parameter $res_table table which contains the ressource * @parameter $res_id identifier of the ressource * returns the list in a array * */ public function load_from_db($res_table,$res_id) { $this->diff_list_copy = array(); $this->res_id = $res_id; $this->table_res_x = $res_table; $this->db->query("SELECT DEST_USER, DESTINATION, MAIL_ACTION FROM ".$this->table_res_x." WHERE RES_ID = ".$this->res_id); if( $res = $this->db->fetch_object() ) { $this->dest_user = $res->DEST_USER; $this->destination = $res->DESTINATION; $this->mail_action = $res->MAIL_ACTION; } $this->db->query("SELECT RES_TABLE, RES_ID, USER_ID, SERVICE_ID, BY_USER_ID, VIEWED, SEEN, MAIL_ACTION FROM ".$this->table_listinstance." WHERE RES_TABLE = '".$this->table_res_x."' AND RES_ID = '".$this->res_id."' AND SEQUENCE > 1 ORDER BY SEQUENCE ASC"); while( $res = $this->db->fetch_object() ) { $this_diff = array( "RES_TABLE" => $res->RES_TABLE, "RES_ID" => $res->RES_ID, "USER_ID" => $res->USER_ID, "BY_USER_ID" => $res->BY_USER_ID ); if( !empty($res->SERVICE_ID) ) $this_diff['SERVICE_ID'] = $res->SERVICE_ID; if( is_numeric($res->VIEWED) ) $this_diff['VIEWED'] = $res->VIEWED; if( is_numeric($res->SEEN) ) $this_diff['SEEN'] = $res->SEEN; if( $res->MAIL_ACTION ) $this_diff['MAIL_ACTION'] = $res->MAIL_ACTION; $this->diff_list_copy[] = $this_diff; } $this->history = array(); } /*This function loads the diffusion list from the database * * */ public function reload() { $this->db->connect(); if($this->res_id <> '') $this->load_from_db($this->table_res_x,$this->res_id); $this->history = array(); } /* This function resets the diffusion list * */ public function reset() { $this->dest_user =null; $this->destination =null; $this->mail_action = null; $this->diff_list_copy = array(); $this->history = array(); } /*This function gives the list diffusion according to the service associated * Param: string service_id identifier of the service * */ private function get_model( $service_id ) { $this->db->connect(); $this->db->query("SELECT SEQUENCE, USER_ID FROM ".$this->table_listmodel." l, ".$this->table_listmodel_assoc." la WHERE l.RES_TABLE = '".$this->table_res_x."' AND l.ID = la.ID AND la.ASSOC_SERVICE = '".$service_id."' ORDER BY l.SEQUENCE ASC"); $models = array(); while( $res = $this->db->fetch_object() ) $models[($res->SEQUENCE - 1)]["USER"] = $res->USER_ID; return $models; } /*This function gives the free diffusion list * Param: integer free_list_id identifier of the free list * */ private function get_free_model( $free_list_id ) { $this->db->connect(); $this->db->query("SELECT SEQUENCE, USER_ID FROM ".$this->table_listmodel." l, ".$this->table_listmodel_assoc." la WHERE l.RES_TABLE = '".$this->table_res_x."' AND l.ID = la.ID AND la.ID = '".$free_list_id."' ORDER BY l.SEQUENCE ASC"); $models = array(); while( $res = $this->db->fetch_object() ) $models[($res->SEQUENCE - 1)]["USER"] = $res->USER_ID; return $models; } /*This function gives the dest_user of a ressource * return bool * */ public function get_dest_user() { if( !empty( $this->dest_user) ) return $this->dest_user; return false; } /*This function gives the destination of a ressource * return bool * */ public function get_destination() { if( !empty( $this->destination) ) return $this->destination; return false; } /*This function checks if a user exists in the diffusion list * @parameter string identifier of the user * */ private function user_exists($user_id) { for( $index=0; $index < count($this->diff_list_copy); $index++ ) if( !isset($this->diff_list_copy[$index]['SERVICE_ID']) AND $this->diff_list_copy[$index]['USER_ID'] == $user_id ) return $index; return -1; } /*This function checks if a service exists in the diffusion list * @parameter string identifier of the service * */ private function service_exists($service_id) { for( $index=0; $index < count($this->diff_list_copy); $index++ ) if( isset($this->diff_list_copy[$index]['SERVICE_ID']) AND $this->diff_list_copy[$index]['SERVICE_ID'] == $service_id ) return $index; return -1; } public function can_delete_user($user_id) { foreach( $this->diff_list_copy as $dlc ) if( $dlc['USER_ID'] == $user_id AND $dlc['BY_USER_ID'] == $this->my_user_id ) return true; if( $this->delete_copy_rights) return true; return false; } public function can_delete_service($service_id) { foreach( $this->diff_list_copy as $dlc ) if( isset($dlc['SERVICE_ID']) AND $dlc['SERVICE_ID'] == $service_id AND $dlc['BY_USER_ID'] == $this->my_user_id ) return true; if( $this->delete_copy_rights) return true; return false; } public function can_add_user($user_id) { if( $this->user_exists($user_id) > -1 OR $this->dest_user == $user_id OR !$this->modify_copy_list ) { return false; } return true; } public function can_add_service($service_id) { if( $this->service_exists($service_id) > -1 OR $this->destination == $service_id OR !$this->modify_copy_list ) { return false; } return true; } public function add_copy_user($user_id,$mail_action=null,$viewed=0) { if( !$this->can_add_user($user_id) ) { return false; } else { $this_user = array( "RES_TABLE" => $this->table_res_x, "RES_ID" => $this->res_id, "USER_ID" => $user_id, "BY_USER_ID" => $this->my_user_id, "VIEWED" => $viewed, "SEEN" => 0 ); if( !empty($mail_action) ) $this_user["MAIL_ACTION"] = $mail_action; $this->diff_list_copy[] = $this_user; return true; } } public function add_primary_user($user_id,$mail_action=null) { $index = $this->user_exists($user_id); if( $index > -1 ) { unset($this->diff_list_copy[$index]); $this->diff_list_copy = array_values($this->diff_list_copy); } $old_dest_user = $this->dest_user; $old_mail_action = $this->mail_action; $this->dest_user = $user_id; $this->mail_action = $mail_action; if( !empty($old_dest_user) ) $this->add_copy_user($old_dest_user,$old_mail_action); } public function add_copy_service($service_id,$mail_action=null,$viewed=0) { $this->db->connect(); if( !$this->can_add_service($service_id) ) return false; //Recuperer la liste des utilisateurs pour ce service $this->db->query("SELECT USER_ID FROM ".$this->table_users." WHERE DEPARTMENT = '".$service_id."'"); $services_add = 0; while( $res = $this->db->fetch_object() ) { $this_user = array( "RES_TABLE" => $this->table_res_x, "RES_ID" => $this->res_id, "USER_ID" => $res->USER_ID, "BY_USER_ID" => $this->my_user_id, "VIEWED" => $viewed, "SEEN" => 0, "SERVICE_ID" => $service_id ); if( !empty($mail_action) ) $this_user["MAIL_ACTION"] = $mail_action; $this->diff_list_copy[] = $this_user; $services_add++; } if( $services_add > 0){ return true; } return false; } public function add_copy_list($list_id,$mail_action=null,$viewed=0) { $this->db->connect(); //Recuperer la liste des utilisateurs pour cette liste de diffusion $this->db->query("SELECT u.USER_ID FROM ".$this->table_users." u, ".$this->table_listmodel." l WHERE l.ID = '".$list_id."' AND l.USER_ID = u.USER_ID "); $services_add = 0; while( $res = $this->db->fetch_object() ) { $this_user = array( "RES_TABLE" => $this->table_res_x, "RES_ID" => $this->res_id, "USER_ID" => $res->USER_ID, "BY_USER_ID" => $this->my_user_id, "VIEWED" => $viewed, "SEEN" => 0, "SERVICE_ID" => $service_id ); if( !empty($mail_action) ) $this_user["MAIL_ACTION"] = $mail_action; $this->diff_list_copy[] = $this_user; $services_add++; } if( $services_add > 0){ return true; } return false; } public function delete_user($user_id) { if( !$this->can_delete_user($user_id) ) return false; else { if( $this->dest_user == $user_id ) { $this->dest_user = null; } $user_found = array(); for( $i=0;$idiff_list_copy);$i++ ) if( $this->diff_list_copy[$i]['USER_ID'] == $user_id ) $user_found[] = $i; foreach( $user_found as $uf ) unset($this->diff_list_copy[$uf]); if( count($user_found) > 0 ) { $this->diff_list_copy = array_values($this->diff_list_copy); } } return false; } /*This function deletes a service from the diffusion list * @parameter string identifier of the service * return bool */ public function delete_service($service_id) { if( !$this->can_delete_service($service_id) ) return false; else { $service_found = array(); for( $i=0;$idiff_list_copy);$i++ ) if( $this->diff_list_copy[$i]['SERVICE_ID'] == $service_id ) $service_found[] = $i; foreach( $service_found as $sf ) unset($this->diff_list_copy[$sf]); if( count($service_found) > 0 ) { $this->diff_list_copy = array_values($this->diff_list_copy); return true; } } return false; } public function set_mailaction_user($user_id,$mail_action) { if( $this->dest_user == $user_id ) { $this->mail_action = $mail_action; return true; } for( $index=0; $index < count($this->diff_list_copy); $index++ ) if( !isset($this->diff_list_copy[$index]['SERVICE_ID']) AND $this->diff_list_copy[$index]['USER_ID'] == $user_id ) $this->diff_list_copy[$index]["MAIL_ACTION"] = $mail_action; return true; } public function set_mailaction_service($service_id,$mail_action) { if( $this->destination == $service_id ) { $this->mail_action = $mail_action; return true; } for( $index=0; $index < count($this->diff_list_copy); $index++ ) if( isset($this->diff_list_copy[$index]['SERVICE_ID']) AND $this->diff_list_copy[$index]['SERVICE_ID'] == $service_id ) $this->diff_list_copy[$index]["MAIL_ACTION"] = $mail_action; return true; } public function redirect_to_user($user_id,$mail_action=null) { if( $user_id == $this->dest_user ) { if( $this->mail_action == null && $this->mail_action == $mail_action ) { return false; } else { $this->set_mailaction_user($user_id,$mail_action); //Load informations for user $this->user_info($user_id); $this->history = array("action" => "redirect_to_user","user_id" => $user_id,"user_info" => $this->cache_users_list[$user_id],"mail_action" => $mail_action); return true; } } if( $this->redirect_list ) { $index = $this->user_exists($user_id); //User already exists in diff list if( $index > -1 ) { unset($this->diff_list_copy[$index]); $this->diff_list_copy = array_values($this->diff_list_copy); } $index = $this->user_exists($this->dest_user); //Old primary user doesn't exists in diff list if( $index == -1 && strcasecmp($this->dest_user,'courrier') != 0 ) { $old_modify_copy_list = $this->modify_copy_list; $this->modify_copy_list = true; if( $this->tag100_for_copy ) $this->add_copy_user($this->dest_user,$this->mail_action,100); else $this->add_copy_user($this->dest_user,$this->mail_action); $this->modify_copy_list = $old_modify_copy_list; } } //Redirect to user $this->dest_user = $user_id; if( !empty($mail_action) ) $this->mail_action = $mail_action; $this->user_info($user_id); $this->history = array("action" => "redirect_to_user","user_id" => $user_id,"user_info" => $this->cache_users_list[$user_id],"mail_action" => $mail_action); return true; } public function redirect_to_service($service_id,$mail_action=null) { /* if( $service_id == $this->destination ) { $this->set_mailaction_service($service_id,$mail_action); $this->service_info($service_id); $this->history = array("action" => "redirect_to_service","service_id" => $service_id,"service_info" => $this->cache_services_list[$service_id],"mail_action" => $mail_action); return true; } */ $mail_action = $_SESSION['mail_action']['default_to']; if( strcasecmp($this->dest_user,'courrier') != 0 ) $old_dest_user = $this->dest_user; $old_destination = $this->destination; $old_mail_action = $this->mail_action; //Full rights to delete copy $old_delete_copy_rights = $this->delete_copy_rights; $this->delete_copy_rights = true; $this->delete_service($service_id); $this->destination = $service_id; $this->mail_action = $mail_action; $this->dest_user = null; //MODELS $models = $this->get_model($service_id); if( isset($models[0]["USER"]) ) { $this->delete_user($models[0]["USER"]); $this->dest_user = $models[0]["USER"]; } //Restore right to delete copy $this->delete_copy_rights = $old_delete_copy_rights; if( $this->redirect_list ) { $old_modify_copy_list = $this->modify_copy_list; $this->modify_copy_list = true; //OLD DESTINATION OR DEST_USER if( isset($old_dest_user) && $this->user_exists($old_dest_user) == -1) { if($this->tag100_for_copy) $this->add_copy_user($old_dest_user,$old_mail_action,100); else $this->add_copy_user($old_dest_user,$old_mail_action); } else if( $this->service_exists($old_destination) == -1 ) { if($this->tag100_for_copy) $this->add_copy_service($old_destination,$old_mail_action,100); else $this->add_copy_service($old_destination,$old_mail_action); } $this->modify_copy_list = $old_modify_copy_list; } for( $i=1; $i < count($models); $i++ ) { if( isset($models["SERVICE"]) && $this->service_exists($models["SERVICE"]) == -1 ) $this->add_copy_service($models[$i]["SERVICE"]); else if( $this->user_exists($models["USER"]) == -1 ) $this->add_copy_user($models[$i]["USER"]); } $this->service_info($service_id); $this->history = array("action" => "redirect_to_service","service_id" => $service_id,"service_info" => $this->cache_services_list[$service_id],"mail_action" => $mail_action); return true; } /* This function redirects a resource to a free list * @parameter integer list Identifier * @parameter string mail action */ public function redirect_to_free_list($free_list_id,$mail_action=null) { $mail_action = $_SESSION['mail_action']['default_to']; if( strcasecmp($this->dest_user,'courrier') != 0 ) $old_dest_user = $this->dest_user; $old_destination = $this->destination; $old_mail_action = $this->mail_action; //Full rights to delete copy $old_delete_copy_rights = $this->delete_copy_rights; $this->delete_copy_rights = true; /* * Pas besoin de modifier la destination dans la liste de diffusion libre $this->delete_service($free_list_id); $this->destination = $free_list_id; */ $this->mail_action = $mail_action; $this->dest_user = null; //MODELS $models = $this->get_free_model($free_list_id); if( isset($models[0]["USER"]) ) { $this->delete_user($models[0]["USER"]); $this->dest_user = $models[0]["USER"]; } //Restore right to delete copy $this->delete_copy_rights = $old_delete_copy_rights; if( $this->redirect_list ) { $old_modify_copy_list = $this->modify_copy_list; $this->modify_copy_list = true; //OLD DESTINATION OR DEST_USER if( isset($old_dest_user) && $this->user_exists($old_dest_user) == -1) { if($this->tag100_for_copy) $this->add_copy_user($old_dest_user,$old_mail_action,100); else $this->add_copy_user($old_dest_user,$old_mail_action); } else if( $this->service_exists($old_destination) == -1 ) { if($this->tag100_for_copy) $this->add_copy_service($old_destination,$old_mail_action,100); else $this->add_copy_service($old_destination,$old_mail_action); } $this->modify_copy_list = $old_modify_copy_list; } for( $i=1; $i < count($models); $i++ ) { if( $this->user_exists($models["USER"]) == -1 ) $this->add_copy_user($models[$i]["USER"]); } //$this->service_info($free_list_id); //$this->history = array("action" => "redirect_to_free_diffusion_list","free_list_id" => $free_list_id,"service_info" => $this->cache_services_list[$service_id],"mail_action" => $mail_action); return true; } public function show() { echo "DEST_USER : ".$this->dest_user."
"; echo "DESTINATION : ".$this->destination."
"; echo "MAIL_ACTION : ".$this->mail_action."
"; $this->db->show_array($this->diff_list_copy); } public function get_diffusion() { $return_diff = $this->diff_list_copy; if( !empty($this->dest_user) ) { $primary = array( "RES_TABLE" => $this->table_res_x, "RES_ID" => $this->res_id, "USER_ID" => $this->dest_user ); if( !empty($this->mail_action) ) $primary["MAIL_ACTION"] = $this->mail_action; array_unshift($return_diff,$primary); } else { $primary = array( "RES_TABLE" => $this->table_res_x, "RES_ID" => $this->res_id, "SERVICE_ID" => $this->destination ); if( !empty($this->mail_action) ) $primary["MAIL_ACTION"] = $this->mail_action; array_unshift($return_diff,$primary); } $tmp = $return_diff; $return_diff = array(); for( $i=0; $i < count($tmp); $i++ ) { if( isset($tmp[$i]["SERVICE_ID"]) ) { if( !$this->service_info($tmp[$i]["SERVICE_ID"]) ) continue; $return_diff[$tmp[$i]["SERVICE_ID"]]["SERVICE"] = array("SERVICE" => $this->cache_services_list[$tmp[$i]["SERVICE_ID"]]); if( isset($tmp[$i]["MAIL_ACTION"]) ) $return_diff[$tmp[$i]["SERVICE_ID"]]["SERVICE"]["MAIL_ACTION"] = $tmp[$i]["MAIL_ACTION"]; } else { if( !$this->user_info($tmp[$i]["USER_ID"]) ) continue; $return_diff[$tmp[$i]["USER_ID"]]["USER"] = $this->cache_users_list[$tmp[$i]["USER_ID"]]; if( isset($tmp[$i]["MAIL_ACTION"]) ) $return_diff[$tmp[$i]["USER_ID"]]["USER"]["MAIL_ACTION"] = $tmp[$i]["MAIL_ACTION"]; } } return $return_diff; } public function user_info($user_id) { $this->db->connect(); if( isset($this->cache_users_list[$user_id]) ) { return true; } else { $this->db->query("SELECT USER_ID,FIRSTNAME, LASTNAME, u.DEPARTMENT, s.SERVICE FROM users u, services s WHERE u.DEPARTMENT = s.ID AND u.USER_ID ='".$user_id."'"); if( $res = $this->db->fetch_object() ) { $this->db->connect(); $this->cache_users_list[$res->USER_ID] = array( "FIRSTNAME" => $res->FIRSTNAME, "LASTNAME" => $res->LASTNAME, "DEPARTMENT" => $res->DEPARTMENT, "SERVICE" => $res->SERVICE ); return true; } else { if( strcasecmp($user_id,'courrier') == 0 ) { $this->cache_users_list[$user_id] = array( "FIRSTNAME" => "-", "LASTNAME" => "-", "DEPARTMENT" => "-", "SERVICE" => "-"); return true; } return false; } } } public function service_info($service_id) { $this->db->connect(); if( isset($this->cache_services_list[$service_id]) ) { return true; } else { $this->db->connect(); $this->db->query("SELECT ID,SERVICE FROM services WHERE ID = '".$service_id."'"); if( $res = $this->db->fetch_object() ) { $this->cache_services_list[$res->ID] = $res->SERVICE; return true; } else { return false; } } } public function store($mailerarguments=null) { require_once($_SESSION['mailer']['path_to_mailer']."/class_mailer.php"); $phpmailer = new Mailer("."); $this->db->connect(); //Afin de comparer et d'eviter des anomalies, on charge localement le dest_user, destination et les diff_list_coopy dans une variable pour effectuer des test par la suite $old_values = array(); $verif_request = "select destination, dest_user from ".$this->table_res_x." where res_id ='".$this->res_id."'"; if ($this->db->query($verif_request)){ $john_henry = $this->db->fetch_object(); $old_values['dest_user'] = $john_henry->dest_user; $old_values['destination'] = $john_henry->destination; } //On récupère aussi l'ancienne listinstance $verif_list_request = "select user_id from ".$this->table_listinstance." where res_id ='".$this->res_id."' and user_id <> '' "; if ($this->db->query($verif_list_request)){ $hl = 0; $old_values['users_list_instance'] = array(); while ($makeachange = $this->db->fetch_object()){ $old_values['users_list_instance'][$hl] = $makeachange->user_id; $hl++; } } //UPDATE RES_X $request = "UPDATE ".$this->table_res_x." SET DESTINATION = '".$this->destination."'"; if( !empty($this->dest_user) ) $request .= ", DEST_USER = '".$this->dest_user."'"; else $request .= ", DEST_USER = NULL"; if( !empty($this->mail_action) ) $request .= ", MAIL_ACTION = '".$this->mail_action."'"; $request .= " WHERE RES_ID = '".$this->res_id."'"; $this->db->query($request); //Envoi des mails pour le destinataire principal //Seulement dans le cas ou le dstinataire principal est diffirent de l'ancien if ($old_values['dest_user'] <> $this->dest_user && $mailerarguments <> "mailerdisable" ){ //Envoi d'un mail pour notification nouveau destinataire principal $mailer_debug = $phpmailer-> send_and_save($this->table_res_x,$this->res_id,$this->dest_user,1); } //On effectue la comparaison de l'ancienne et de la nouvelle liste pour envoyer les mails aux personnes supprimées $a = $old_values['users_list_instance']; $b = array(); $b['users_list_instance'] = array(); foreach ($this->diff_list_copy as $elem){ array_push($b['users_list_instance'], $elem['USER_ID']); } //Envoi de mail pour les utilisateurs supprimés foreach ($a as $old_cpy_usr){ //Par défaut, on envoie le mail de suppression, sauf pour le cas ou l'on retrouve le user_id dans la nouvelle liste $action_delete_notification = true; $to_delete = ""; foreach ($b['users_list_instance'] as $cpy_usr){ if ($cpy_usr == $old_cpy_usr){ //Cela signifie que l'on peut alors eviter d'envoyer un mail de suppression $action_delete_notification = false; } } //On lance alors la notification if (($action_delete_notification) && ($old_cpy_usr <> $this->dest_user) && $mailerarguments <> "mailerdisable"){ $phpmailer-> send_and_save($this->table_res_x,$this->res_id,$old_cpy_usr,3); } } //UPDATE LISTINSTANCE $this->db->query("DELETE FROM ".$this->table_listinstance." WHERE RES_TABLE = '".$this->table_res_x."' AND RES_ID ='".$this->res_id."'"); for( $index=0; $index < count($this->diff_list_copy); $index++ ) { $request = "INSERT INTO ".$this->table_listinstance." (RES_TABLE,RES_ID,SEQUENCE,USER_ID,SERVICE_ID,VIEWED,SEEN,BY_USER_ID,MAIL_ACTION) VALUES ('".$this->table_res_x."','".$this->res_id."',".($index+2); $null_fields = array("USER_ID","SERVICE_ID","VIEWED","SEEN","BY_USER_ID"); foreach( $null_fields as $field ) { if( isset($this->diff_list_copy[$index][$field]) ) $request .= ",'".$this->diff_list_copy[$index][$field]."'"; else $request .= ",NULL"; } //Envoi des mails pour les personnes en copie if (isset($this->diff_list_copy[$index]['MAIL_ACTION'])) $request .= ",'".$this->diff_list_copy[$index]['MAIL_ACTION']."'"; else $request .= ",'".$_SESSION['mail_action']['default_cc']."'"; $request .= ")"; $this->db->query($request); $action_launch_notification = true; foreach ($a as $old_cpy_usr2){ if ($this->diff_list_copy[$index]['USER_ID'] == $old_cpy_usr2){ $action_launch_notification = false; } } if (isset($this->diff_list_copy[$index]['USER_ID']) && ($action_launch_notification) && $mailerarguments <> "mailerdisable"){ $phpmailer-> send_and_save($this->table_res_x,$this->res_id,$this->diff_list_copy[$index]['USER_ID'],2); } } //UPDATE HISTORY require_once("class_history.php"); $hist = new history(); if( is_array($this->history) && count($this->history) > 0 ) $hist->add_from_diffusion( $this->table_res_x, $this->res_id,$this->history,$this->get_diffusion()); } /* This function loads the diffusion list from the database related to validation mode * @parameter $res_table table which contains the ressource * @parameter $res_id identifier of the ressource * @parameter $listinstance_table table pre or post * returns the list in a array * */ public function load_from_db_val($res_table,$res_id, $listinstance_table) { $this->diff_list_copy = array(); $this->res_id = $res_id; $this->table_res_x = $res_table; $this->table_listinstance = $listinstance_table; $this->db->query("SELECT DEST_USER, DESTINATION, MAIL_ACTION FROM ".$this->table_res_x." WHERE RES_ID = ".$this->res_id); if( $res = $this->db->fetch_object() ) { $this->dest_user = $res->DEST_USER; $this->destination = $res->DESTINATION; $this->mail_action = $res->MAIL_ACTION; } $this->db->query("SELECT RES_TABLE, RES_ID, USER_ID, SERVICE_ID, BY_USER_ID, VIEWED, SEEN, MAIL_ACTION FROM ".$this->table_listinstance." WHERE RES_TABLE = '".$this->table_res_x."' AND RES_ID = '".$this->res_id."' AND SEQUENCE > 1 ORDER BY SEQUENCE ASC"); while( $res = $this->db->fetch_object() ) { $this_diff = array( "RES_TABLE" => $res->RES_TABLE, "RES_ID" => $res->RES_ID, "USER_ID" => $res->USER_ID, "BY_USER_ID" => $res->BY_USER_ID ); if( !empty($res->SERVICE_ID) ) $this_diff['SERVICE_ID'] = $res->SERVICE_ID; if( is_numeric($res->VIEWED) ) $this_diff['VIEWED'] = $res->VIEWED; if( is_numeric($res->SEEN) ) $this_diff['SEEN'] = $res->SEEN; if( $res->MAIL_ACTION ) $this_diff['MAIL_ACTION'] = $res->MAIL_ACTION; $this->diff_list_copy[] = $this_diff; } $this->history = array(); } } ?>