function analysis_update($values, $other_fields = "") { global $dbh, $pmb_notice_img_folder_id, $opac_url_base, $pmb_notice_img_pics_max_size; global $pmb_map_activate, $pmb_newrecord_timeshift; // clean des vieilles nouveautés if ($pmb_newrecord_timeshift) { $req_old = "UPDATE notices SET notice_date_is_new ='', notice_is_new=0, update_date=update_date where notice_date_is_new !='0000-00-00 00:00:00' and (notice_date_is_new < now() - interval {$pmb_newrecord_timeshift} day )"; mysql_query($req_old, $dbh); } if (is_array($values)) { $this->analysis_biblio_level = 'a'; $this->analysis_hierar_level = '2'; $this->analysis_typdoc = $values['typdoc']; $this->analysis_statut = $values['statut']; $this->analysis_commentaire_gestion = $values['f_commentaire_gestion']; $this->analysis_thumbnail_url = $values['f_thumbnail_url']; $this->analysis_tit1 = $values['f_tit1']; $this->analysis_tit2 = $values['f_tit2']; $this->analysis_tit3 = $values['f_tit3']; $this->analysis_tit4 = $values['f_tit4']; $this->analysis_n_gen = $values['f_n_gen']; $this->analysis_n_contenu = $values['f_n_contenu']; $this->analysis_n_resume = $values['f_n_resume']; $this->analysis_indexint = $values['f_indexint_id']; $this->analysis_index_l = $values['f_indexation']; $this->analysis_lien = $values['f_lien']; $this->analysis_eformat = $values['f_eformat']; $this->analysis_pages = $values['pages']; $this->analysis_signature = $values['signature']; $this->analysis_indexation_lang = $values['indexation_lang']; $this->notice_is_new = $values['notice_is_new']; // insert de year à partir de la date de parution du bulletin if ($this->date_date) { $this->analysis_year = substr($this->date_date, 0, 4); } $this->date_parution_perio = $this->date_date; // construction de la requête : $data = "typdoc='" . $this->analysis_typdoc . "'"; $data .= ", statut='" . $this->analysis_statut . "'"; $data .= ", tit1='" . $this->analysis_tit1 . "'"; $data .= ", tit3='" . $this->analysis_tit3 . "'"; $data .= ", tit4='" . $this->analysis_tit4 . "'"; $data .= ", year='" . $this->analysis_year . "'"; $data .= ", npages='" . $this->analysis_pages . "'"; $data .= ", n_contenu='" . $this->analysis_n_contenu . "'"; $data .= ", n_gen='" . $this->analysis_n_gen . "'"; $data .= ", n_resume='{$this->analysis_n_resume}'"; $data .= ", lien='" . $this->analysis_lien . "'"; $data .= ", eformat='" . $this->analysis_eformat . "'"; $data .= ", indexint='" . $this->analysis_indexint . "'"; $data .= ", index_l='" . clean_tags($this->analysis_index_l) . "'"; $data .= ", niveau_biblio='" . $this->analysis_biblio_level . "'"; $data .= ", niveau_hierar='" . $this->analysis_hierar_level . "'"; $data .= ", commentaire_gestion='" . $this->analysis_commentaire_gestion . "'"; $data .= ", thumbnail_url='" . $this->analysis_thumbnail_url . "'"; $data .= ", signature='" . $this->analysis_signature . "'"; $data .= ", date_parution='" . $this->date_parution_perio . "'"; $data .= ", indexation_lang='" . $this->analysis_indexation_lang . "'"; $data .= ", notice_is_new='" . $this->notice_is_new . "' \n\t\t\t{$other_fields}"; $result = 0; if (!$this->analysis_id) { // si c'est une création // fabrication de la requête finale $requete = "INSERT INTO notices SET {$data} , create_date=sysdate(), update_date=sysdate() "; $myQuery = pmb_mysql_query($requete, $dbh); $this->analysis_id = pmb_mysql_insert_id($dbh); if ($myQuery) { $result = $this->analysis_id; } // si l'insertion est OK, il faut créer l'entrée dans la table 'analysis' if ($this->analysis_id) { // autorité personnalisées $authperso = new authperso_notice($this->analysis_id); $authperso->save_form(); // map if ($pmb_map_activate) { $map = new map_edition_controler(TYPE_RECORD, $this->analysis_id); $map->save_form(); $map_info = new map_info($this->analysis_id); $map_info->save_form(); } // Mise à jour des index de la notice notice::majNoticesTotal($this->analysis_id); audit::insert_creation(AUDIT_NOTICE, $this->analysis_id); $requete = 'INSERT INTO analysis SET'; $requete .= ' analysis_bulletin=' . $this->id_bulletinage; $requete .= ', analysis_notice=' . $this->analysis_id; $myQuery = pmb_mysql_query($requete, $dbh); } } else { $requete = "UPDATE notices SET {$data} , update_date=sysdate() WHERE notice_id='" . $this->analysis_id . "' LIMIT 1"; $myQuery = pmb_mysql_query($requete, $dbh); // autorité personnalisées $authperso = new authperso_notice($this->analysis_id); $authperso->save_form(); // map if ($pmb_map_activate) { $map = new map_edition_controler(TYPE_RECORD, $this->analysis_id); $map->save_form(); $map_info = new map_info($this->analysis_id); $map_info->save_form(); } // Mise à jour des index de la notice notice::majNoticesTotal($this->analysis_id); audit::insert_modif(AUDIT_NOTICE, $this->analysis_id); if ($myQuery) { $result = $this->analysis_id; } } // vignette de la notice uploadé dans un répertoire $id = $this->analysis_id; if ($_FILES['f_img_load']['name'] && $pmb_notice_img_folder_id) { $poids_fichier_max = 1024 * 1024; //Limite la taille de l'image à 1 Mo $req = "select repertoire_path from upload_repertoire where repertoire_id ='" . $pmb_notice_img_folder_id . "'"; $res = pmb_mysql_query($req, $dbh); if (pmb_mysql_num_rows($res)) { $rep = pmb_mysql_fetch_object($res); $filename_output = $rep->repertoire_path . "img_" . $id; } if (($fp = @fopen($_FILES['f_img_load']['tmp_name'], "rb")) && $filename_output) { $image = ""; $size = 0; $flag = true; while (!feof($fp)) { $image .= fread($fp, 4096); $size = strlen($image); if ($size > $poids_fichier_max) { $flag = false; break; } } if ($flag) { if ($img = imagecreatefromstring($image)) { if (!($pmb_notice_img_pics_max_size * 1)) { $pmb_notice_img_pics_max_size = 100; } $redim = false; if (imagesx($img) >= imagesy($img)) { if (imagesx($img) <= $pmb_notice_img_pics_max_size) { $largeur = imagesx($img); $hauteur = imagesy($img); } else { $redim = true; $largeur = $pmb_notice_img_pics_max_size; $hauteur = $largeur * imagesy($img) / imagesx($img); } } else { if (imagesy($img) <= $pmb_notice_img_pics_max_size) { $hauteur = imagesy($img); $largeur = imagesx($img); } else { $redim = true; $hauteur = $pmb_notice_img_pics_max_size; $largeur = $hauteur * imagesx($img) / imagesy($img); } } if ($redim) { $dest = imagecreatetruecolor($largeur, $hauteur); imagecopyresampled($dest, $img, 0, 0, 0, 0, $largeur, $hauteur, imagesx($img), imagesy($img)); imagepng($dest, $filename_output); imagedestroy($dest); } else { imagepng($img, $filename_output); } imagedestroy($img); $thumbnail_url = $opac_url_base . "getimage.php?noticecode=&vigurl=¬ice_id=" . $id; $req = "update notices set thumbnail_url='" . $thumbnail_url . "' where notice_id ='" . $id . "'"; $res = pmb_mysql_query($req, $dbh); } } } } return $result; } //if(is_array($values)) }
$requete .= ", notice_is_new='{$t_notice['notice_is_new']}'"; $requete .= $req_notice_date_is_new; $requete .= $postrequete; $result = pmb_mysql_query($requete, $dbh); //traitement audit if (!$id) { $sav_id = 0; $id = pmb_mysql_insert_id($dbh); audit::insert_creation(AUDIT_NOTICE, $id); } else { $sav_id = $id; audit::insert_modif(AUDIT_NOTICE, $id); } // autorité personnalisées $authperso = new authperso_notice($id); $authperso->save_form(); // map global $pmb_map_activate; if ($pmb_map_activate) { $map = new map_edition_controler(TYPE_RECORD, $id); $map->save_form(); $map_info = new map_info($id); $map_info->save_form(); } // vignette de la notice uploadé dans un répertoire if ($_FILES['f_img_load']['name'] && $pmb_notice_img_folder_id) { $poids_fichier_max = 1024 * 1024; //Limite la taille de l'image à 1 Mo $req = "select repertoire_path from upload_repertoire where repertoire_id ='" . $pmb_notice_img_folder_id . "'"; $res = pmb_mysql_query($req, $dbh); if (pmb_mysql_num_rows($res)) {