set_mode($mode); $this->_init_recipients(); $this->fetch_data(); } /** * Initialisation */ protected function _init_recipients() { $this->recipients = array( 'by_persons' => array(), 'by_objects' => array(), 'by_locations' => array() ); } /** * Données provenant de la base de données */ protected function fetch_data() { $query = 'select valeur_param from parametres where type_param="pmb" and sstype_param="contact_form_recipients_lists"'; $result = pmb_mysql_query($query); if($result && pmb_mysql_num_rows($result)) { $row = pmb_mysql_fetch_object($result); if($row->valeur_param) { $this->recipients = unserialize($row->valeur_param); } } } protected function _get_recipients_lines($id) { global $msg, $charset; return " ".htmlentities($msg['admin_opac_contact_form_recipient_name'], ENT_QUOTES, $charset)." recipients[$this->mode][$id]['name'] : '')."' /> ".htmlentities($msg['admin_opac_contact_form_recipient_email'], ENT_QUOTES, $charset)." recipients[$this->mode][$id]['email'] : '')."' /> ".htmlentities($msg['admin_opac_contact_form_recipient_copy_email'], ENT_QUOTES, $charset)." recipients[$this->mode][$id]['copy_email'] : '')."' /> ".htmlentities($msg['admin_opac_contact_form_recipient_transmitter_email'], ENT_QUOTES, $charset)." recipients[$this->mode][$id]['transmitter_email'] : '')."' /> "; } protected function _get_display_content_list_by_objects() { $display = ""; $contact_form_objects=new contact_form_objects(); if(count($contact_form_objects->get_objects())) { foreach ($contact_form_objects->get_objects() as $object) { $display .= " "; $display .= $this->_get_recipients_lines($object->get_id()); $display .= "
".$object->get_label()."
"; } } return $display; } protected function _get_display_content_list_by_locations() { $display = ""; $query = "select idlocation, location_libelle from docs_location order by location_libelle"; $result = pmb_mysql_query($query); while($row = pmb_mysql_fetch_object($result)) { $display .= " "; $display .= $this->_get_recipients_lines($row->idlocation); $display .= "
".$row->location_libelle."
"; } return $display; } protected function _get_display_content_list_by_persons() { global $msg, $charset; global $base_path; $display = "".htmlentities($msg['admin_opac_contact_form_recipient_add'], ENT_QUOTES, $charset)." mode."';\" />"; if(count($this->recipients['by_persons'])) { foreach ($this->recipients['by_persons'] as $id=>$person) { $display .= " "; $display .= $this->_get_recipients_lines($id); $display .= "
".($this->recipients[$this->mode][$id]['name'] ? $this->recipients[$this->mode][$id]['name'] : htmlentities($msg['admin_opac_contact_form_recipient_without_name'], ENT_QUOTES, $charset))."
mode."&id=".$id."';\" />
"; } } return $display; } /** * Liste des destinataires par mode */ public function get_display_content_list() { global $msg, $charset; $display = ""; switch ($this->mode) { case 'by_persons': $display .= $this->_get_display_content_list_by_persons(); break; case 'by_objects': $display .= $this->_get_display_content_list_by_objects(); break; case 'by_locations': $display .= $this->_get_display_content_list_by_locations(); break; } return $display; } /** * Header de la liste */ public function get_display_header_list() { global $msg, $charset; $display = " ".htmlentities($msg['admin_opac_contact_form_parameter_label'],ENT_QUOTES,$charset)." ".htmlentities($msg['admin_opac_contact_form_parameter_value'],ENT_QUOTES,$charset)." "; return $display; } /** * Affiche la liste */ public function get_display_list() { global $base_path, $msg, $charset; global $current_module; $display = "
".contact_form_parameters::gen_recipients_mode_selector($this->mode, "document.location='".$base_path."/admin.php?categ=contact_form&sub=recipients&mode='+this.value")."
 
"; //Affichage de la liste des destinataires selon le mode $display .= ""; $display .= $this->get_display_header_list(); if(count($this->recipients)) { $display .= $this->get_display_content_list(); } $display .= "
"; return $display; } public static function is_incomplete($recipient) { if((trim($recipient['name']) == '') || (trim($recipient['email']) == '')) { return true; } else { return false; } } public function set_properties_from_form() { global $recipients; $this->recipients[$this->mode] = stripslashes_array($recipients[$this->mode]); } public function save() { $query = "update parametres set valeur_param = '".addslashes(serialize($this->recipients))."' where type_param='pmb' and sstype_param='contact_form_recipients_lists'"; pmb_mysql_query($query); } public function add() { $this->recipients[$this->mode][] = array(); } public function delete($id) { if(isset($this->recipients[$this->mode][$id])) { unset($this->recipients[$this->mode][$id]); } } public function unset_recipient($mode, $id) { if(is_array($this->recipients[$mode][$id])) { unset($this->recipients[$mode][$id]); } } public function get_recipients() { return $this->recipients; } public function get_mode() { return $this->mode; } public function set_mode($mode) { if(!$mode) { $contact_form_parameters = new contact_form_parameters(); $parameters = $contact_form_parameters->get_parameters(); $mode = $parameters['recipients_mode']; } $this->mode = $mode; } }