id=$id+0; $this->fetch_data(); } function fetch_data() { global $include_path; global $PMBuserid; $this->info=array(); $this->users=array(); $requete_users = "SELECT userid, username FROM users order by username "; $res_users = mysql_query($requete_users); $this->all_users=array(); while (list($this->all_userid,$all_username)=mysql_fetch_row($res_users)) { $this->all_users[]=array($this->all_userid,$all_username); } if(!$this->id){ $this->users[]=$PMBuserid; return; } $req="select * from mailtpl where id_mailtpl=". $this->id; $resultat=mysql_query($req); if (mysql_num_rows($resultat)) { $r=mysql_fetch_object($resultat); $this->info['id']= $r->id_mailtpl; $this->info['name']= $r->mailtpl_name; $this->info['objet']= $r->mailtpl_objet; $this->info['tpl']= $r->mailtpl_tpl; $this->info['users']= $r->mailtpl_users; } $this->users= explode(" ",$this->info['users']); // printr($this->info[28]); } function get_mailtpl(){ global $charset; $ajax_send=$this->info; if($charset != 'utf-8'){ // cause: json_encode veut de l'utf8 $ajax_send['id'] =utf8_encode($this->info['id']); $ajax_send['name']=utf8_encode($this->info['name']); $ajax_send['objet'] =utf8_encode($this->info['objet']); $ajax_send['tpl'] =utf8_encode($this->info['tpl']); $ajax_send['users'] =utf8_encode($this->info['users']); } return($ajax_send); } function get_selvars(){ global $msg,$mailtpl_form_selvars; return $mailtpl_form_selvars; } function get_sel_img(){ global $msg,$mailtpl_form_sel_img, $pmb_img_folder,$pmb_img_url; if(!$pmb_img_folder) return ''; $tpl=$mailtpl_form_sel_img; $img=new files_gestion($pmb_img_folder,$pmb_img_url); if(!$img->get_count_file()) return ''; $select=$img->get_sel('select_file',"!!path!!!!name!!","!!name!!"); $tpl=str_replace('!!select_file!!',$select,$tpl); return $tpl; } function get_form() { global $mailtpl_form_tpl,$msg,$charset; $tpl=$mailtpl_form_tpl; if($this->id){ $tpl=str_replace('!!msg_title!!',$msg['admin_mailtpl_form_edit'],$tpl); $tpl=str_replace('!!delete!!',"", $tpl); $name=$this->info['name']; $tpl_objet=$this->info['objet']; $tpl_contens=$this->info['tpl']; }else{ $tpl=str_replace('!!msg_title!!',$msg['admin_mailtpl_form_add'],$tpl); $tpl_objet=""; $tpl=str_replace('!!delete!!',"",$tpl); $name=""; $tpl_contens=""; } $id_check_list=""; foreach($this->all_users as $a_user) { $id_check="auto_".$a_user[0]; if($a_user[0]==1){ $checked=" checked readonly "; }else{ if(in_array( $a_user[0],$this->users)){ $checked=" checked "; }else $checked=""; if($id_check_list)$id_check_list.='|'; $id_check_list.=$id_check; } $autorisations_users.=" "; } $tpl=str_replace('!!name!!',htmlentities($name, ENT_QUOTES, $charset),$tpl); $tpl=str_replace('!!selvars!!',$this->get_selvars(),$tpl); $sel_img_tpl=""; $sel_img=$this->get_sel_img(); if($sel_img)$sel_img_tpl="