id=intval($id); $this->fetch_data(); } public function fetch_data() { global $PMBuserid; $this->info=array( 'id' => $this->id, 'name' => '', 'objet' => '', 'tpl' => '', 'users' => array() ); $this->users=array(); $requete_users = "SELECT userid, username FROM users order by username "; $res_users = pmb_mysql_query($requete_users); $this->all_users=array(); while (list($this->all_userid,$all_username)=pmb_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=pmb_mysql_query($req); if (pmb_mysql_num_rows($resultat)) { $r=pmb_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]); } public 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); } public static function get_selvars() { global $mailtpl_form_selvars, $msg, $charset, $class_path; $selvars = [ 'empr_group_empr' => [ 'empr_name', 'empr_first_name', 'empr_sexe', 'empr_cb', 'empr_login', 'empr_mail', 'empr_loans', 'empr_loans_late', 'empr_resas', 'empr_resa_confirme', 'empr_resa_not_confirme', 'empr_name_and_adress', 'empr_dated', 'empr_datef', 'empr_nb_days_before_expiration', 'empr_all_information', 'empr_auth_opac', 'empr_auth_opac_subscribe_link', 'empr_last_loan_date', 'empr_auth_opac_change_password_link', ], 'empr_group_loc' => [ 'empr_loc_name', 'empr_loc_adr1', 'empr_loc_adr2', 'empr_loc_cp', 'empr_loc_town', 'empr_loc_phone', 'empr_loc_email', 'empr_loc_website', ], 'empr_group_misc' => [ 'empr_day_date', ] ]; $options_selvars = ''; foreach ($selvars as $optgroup => $options) { $options_selvars .= ""; } require_once($class_path.'/event/events/event_mailing.class.php'); $event = new event_mailing('mailing', 'get_selvars'); $evth = events_handler::get_instance(); $evth->send($event); $additionnal_selvars = $event->get_selvars(); if (!empty($additionnal_selvars)) { foreach ($additionnal_selvars as $libelle_optgroup => $options) { $options_selvars .= ""; } } $mailtpl_form_selvars = str_replace('!!options_selvars!!', $options_selvars, $mailtpl_form_selvars); return $mailtpl_form_selvars; } public static function get_resavars(){ global $mailtpl_form_resavars; return $mailtpl_form_resavars; } public static function get_sel_img(){ global $mailtpl_form_sel_img, $pmb_img_folder; if(!$pmb_img_folder) return ''; $tpl=$mailtpl_form_sel_img; $img=new files_gestion('img'); if(!$img->get_count_file()) return ''; $select=$img->get_sel('select_file',"!!path!!!!name!!","!!name!!"); $tpl=str_replace('!!select_file!!',$select,$tpl); return $tpl; } public function get_form() { global $mailtpl_content_form,$msg,$charset; global $pdflettreresa_resa_prolong_email; $content_form = $mailtpl_content_form; $content_form = str_replace('!!id!!', $this->id, $content_form); $interface_form = new interface_admin_form('mailtpl'); if(!$this->id){ $interface_form->set_label($msg['admin_mailtpl_form_add']); }else{ $interface_form->set_label($msg['admin_mailtpl_form_edit']); } $autorisations_users=""; $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.=" "; } $content_form=str_replace('!!name!!',htmlentities($this->info['name'], ENT_QUOTES, $charset),$content_form); $content_form=str_replace('!!selvars!!',mailtpl::get_selvars(),$content_form); if($pdflettreresa_resa_prolong_email){ $content_form=str_replace('!!resavars!!',mailtpl::get_resavars(),$content_form); } $sel_img_tpl=""; $sel_img=mailtpl::get_sel_img(); if($sel_img)$sel_img_tpl="