object_id = $object_id*1; if(!isset($this->object_type)) $this->object_type = 0; $this->set_object_string_type($this->object_type); } public function get_object_string_type() { return $this->object_string_type; } public function set_object_string_type($type) { $this->object_string_type = ''; switch ($type) { case AVIS_RECORDS : $this->object_string_type = 'notice'; break; case AVIS_ARTICLES : $this->object_string_type = 'article'; break; case AVIS_SECTIONS : $this->object_string_type = 'section'; break; default: $this->object_string_type = ''; break; } } protected function get_filters_display() { global $msg; global $montrerquoi; $display = "
  
"; return $display; } protected function _get_select_query() { } protected function _get_join_query() { } protected function _get_restrict_query() { global $montrerquoi; $restrict = ""; switch ($montrerquoi) { case 'all': $restrict = " 1 " ; break; case 'valid' : $restrict = " valide='1' " ; break; default: case 'novalid' : $restrict = " valide='0' " ; break; } if($this->object_id) { $restrict .= " and num_notice = ".$this->object_id." " ; } return $restrict; } protected function _get_sort_query() { } public function get_query() { global $msg; global $debut; global $nb_per_page; $query = "select avis.note, avis.sujet, avis.commentaire, avis.id_avis, DATE_FORMAT(avis.dateAjout,'".$msg['format_date']."') as ladate, "; $query .= "empr_login, empr_nom, empr_prenom, valide "; $query .= $this->_get_select_query(); $query .= "from avis "; $query .= "left join empr on empr.id_empr=avis.num_empr "; $query .= $this->_get_join_query(); $query .= "where ".$this->_get_restrict_query()." "; $query .= "and avis.type_object = ".$this->object_type." and avis_private = 0 "; if(!$this->nbr_lignes) { $result = pmb_mysql_query($query); $this->nbr_lignes = pmb_mysql_num_rows($result); } $query .= $this->_get_sort_query(); $query .= "limit $debut, $nb_per_page"; return $query; } public static function get_display_review($avis) { global $msg, $charset; global $pmb_avis_note_display_mode; $display = "
" ; if($pmb_avis_note_display_mode){ if($pmb_avis_note_display_mode!=1){ $categ_avis=$msg['avis_detail_note_'.$avis->note]; } else { $categ_avis=''; } if($pmb_avis_note_display_mode!=2){ $etoiles="";$cpt_star = 4; for ($i = 1; $i <= $avis->note; $i++) { $etoiles.=""; } for ( $j = round($avis->note);$j <= $cpt_star ; $j++) { $etoiles .= ""; } } if($pmb_avis_note_display_mode==3 || $pmb_avis_note_display_mode==5)$note=$etoiles."
".$categ_avis; else if($pmb_avis_note_display_mode==4)$note=$etoiles; else $note=$etoiles.$categ_avis; } else $note=""; if (!$avis->valide) $display .= "$note".htmlentities($avis->sujet,ENT_QUOTES,$charset).""; else $display .= "$note".htmlentities($avis->sujet,ENT_QUOTES,$charset).""; if($charset != "utf-8") $avis->commentaire=cp1252Toiso88591($avis->commentaire); $display .= ", ".htmlentities($avis->ladate,ENT_QUOTES,$charset)." ".htmlentities($avis->empr_prenom." ".$avis->empr_nom,ENT_QUOTES,$charset)."
".do_bbcode($avis->commentaire)."
"; return $display; } protected function pagination() { global $montrerquoi, $nb_per_page, $page; $pagination = ''; if($this->nbr_lignes) { $url_base = "./catalog.php?categ=avis&montrerquoi=$montrerquoi"; $pagination = aff_pagination ($url_base, $this->nbr_lignes, $nb_per_page, $page, 10, false, true); } return $pagination; } public function get_display_list_form() { global $msg; global $current_module; $form = "

".$msg['avis_titre_form']."

"; $form .= $this->get_filters_display(); $form .= $this->get_display_list(); $form .= $this->pagination(); $form .= "
       
 
"; return $form; } public static function validate($id) { $query = "update avis set valide=1 where id_avis='".$id."' "; pmb_mysql_query($query); } public static function unvalidate($id) { $query = "update avis set valide=0 where id_avis='".$id."' "; pmb_mysql_query($query); } public static function delete($id) { $query = "delete from avis where id_avis='".$id."' "; pmb_mysql_query($query); } public static function delete_from_object($id) { } public function get_data() { global $msg, $charset; $memo_avis = array(); $query = "SELECT id_avis,note,sujet,commentaire,DATE_FORMAT(dateajout,'".$msg['format_date']."') as ladate,empr_login,empr_nom, empr_prenom, valide from avis left join empr on id_empr=num_empr where num_notice='".$this->object_id."' and type_object='".$this->object_type."' and valide=1 order by avis_rank, dateajout desc"; $result = pmb_mysql_query($query); if ($result) { while ($avis = pmb_mysql_fetch_object($result)) { $avis->note_textuelle = $msg['avis_detail_note_'.$avis->note]; if($charset != "utf-8") $avis->commentaire=cp1252Toiso88591($avis->commentaire); $avis->commentaire = do_bbcode($avis->commentaire); $memo_avis[]=$avis; } } return $memo_avis; } public function get_notes_avg() { $query = "SELECT avg(note) as moyenne, count(*) as combien FROM avis WHERE avis_private = 0 and num_notice = '".$this->object_id."' and type_object = '".$this->object_type."'"; $result = pmb_mysql_query($query); $row=pmb_mysql_fetch_object($result); return $row->combien."|".$row->moyenne; } }