PEEL Shopping
Open source ecommerce : PEEL Shopping
fonctions.php
Go to the documentation of this file.
1 <?php
2 // This file should be in UTF8 without BOM - Accents examples: éèê
3 // +----------------------------------------------------------------------+
4 // | Copyright (c) 2004-2015 Advisto SAS, service PEEL - contact@peel.fr |
5 // +----------------------------------------------------------------------+
6 // | This file is part of PEEL Shopping 8.0.0, which is subject to an |
7 // | opensource GPL license: you are allowed to customize the code |
8 // | for your own needs, but must keep your changes under GPL |
9 // | More information: https://www.peel.fr/lire/licence-gpl-70.html |
10 // +----------------------------------------------------------------------+
11 // | Author: Advisto SAS, RCS 479 205 452, France, https://www.peel.fr/ |
12 // +----------------------------------------------------------------------+
13 // $Id: fonctions.php 46935 2015-09-18 08:49:48Z gboussin $
14 if (!defined('IN_PEEL')) {
15  die();
16 }
17 
24 function avis_hook_admin_menu_items($params) {
25  $result['menu_items']['webmastering_marketing'][$GLOBALS['wwwroot_in_admin'] . '/modules/avis/administrer/avis.php'] = $GLOBALS["STR_ADMIN_MENU_WEBMASTERING_OPINIONS"];
26  return $result;
27 }
28 
36 {
37  if(empty($frm)){
38  // Pas de données venant de validation de formulaire, donc on charge le contenu de la base de données
39  /* Charge les infos de la avis. */
40  $qid = query("SELECT *
41  FROM peel_avis
42  WHERE id = " . intval($id));
43  $frm = fetch_assoc($qid);
44  }
45  $frm["nouveau_mode"] = "maj";
46  $frm["titre_soumet"] = $GLOBALS['STR_ADMIN_FORM_SAVE_CHANGES'];
47 
48  if (!empty($frm['id_produit'])) {
50  } elseif (!empty($frm['ref'])) {
52  }
53 }
54 
63 function supprime_avis($id)
64 {
65  /* Réaffecte toutes les sous-avis de cette avis à la avis parente */
66  query("DELETE FROM peel_avis WHERE id = " . intval($id));
67  $message = $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => $GLOBALS['STR_MODULE_AVIS_ADMIN_MSG_DELETED_OK']))->fetch();
68 
69  echo $message;
70 }
71 
78 {
79  $sql = "SELECT *
80  FROM peel_avis
81  ORDER BY datestamp DESC";
82  $Links = new Multipage($sql, 'avis');
83  $results_array = $Links->Query();
84 
85  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/avisAdmin_liste.tpl');
86  $tpl->assign('is_annonce_module_active', check_if_module_active('annonces'));
87  $tpl->assign('add_src', $GLOBALS['administrer_url'] . '/images/add.png');
88  $tpl->assign('add_prod_href', get_current_url(false) . '?mode=ajout&type=produit');
89  $tpl->assign('add_annonce_href', get_current_url(false) . '?mode=ajout&type=annonce');
90  $tpl->assign('drop_src', $GLOBALS['administrer_url'] . '/images/b_drop.png');
91  $tpl->assign('edit_src', $GLOBALS['administrer_url'] . '/images/b_edit.png');
92  $tpl->assign('star_src', get_url('/images/star1.gif'));
93 
94  $tpl_results = array();
95  if (!empty($results_array)) {
96  $i = 0;
97  foreach ($results_array as $this_result) {
98  $tpl_results[] = array('tr_rollover' => tr_rollover($i, true),
99  'drop_href' => get_current_url(false) . '?mode=suppr&id=' . $this_result['id'],
100  'edit_href' => get_current_url(false) . '?mode=modif&id=' . $this_result['id'],
101  'reference' => $this_result['id'],
102  'nom' => $this_result['nom_produit'],
103  'note' => $this_result['note'],
104  'date' => get_formatted_date($this_result['datestamp'], 'short', 'long'),
105  'etat_onclick' => 'change_status("avis", "' . $this_result['id'] . '", this, "'.$GLOBALS['administrer_url'] . '")',
106  'etat_src' => $GLOBALS['administrer_url'] . '/images/' . (empty($this_result['etat']) ? 'puce-blanche.gif' : 'puce-verte.gif'),
107  'util_href' => $GLOBALS['administrer_url'] . '/utilisateurs.php?id_utilisateur=' . $this_result['id_utilisateur'] . '&mode=modif',
108  'prenom' => $this_result['prenom'],
109  'email' => $this_result['email']
110  );
111  $i++;
112  }
113  }
114  $tpl->assign('results', $tpl_results);
115  $tpl->assign('links_multipage', $Links->GetMultipage());
116  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
117  $tpl->assign('STR_MODULE_AVIS_ADMIN_LIST', $GLOBALS['STR_MODULE_AVIS_ADMIN_LIST']);
118  $tpl->assign('STR_MODULE_AVIS_ADMIN_ADD_ON_PRODUCT', $GLOBALS['STR_MODULE_AVIS_ADMIN_ADD_ON_PRODUCT']);
119  $tpl->assign('STR_MODULE_AVIS_ADMIN_ADD_ON_AD', $GLOBALS['STR_MODULE_AVIS_ADMIN_ADD_ON_AD']);
120  $tpl->assign('STR_ADMIN_ACTION', $GLOBALS['STR_ADMIN_ACTION']);
121  $tpl->assign('STR_REFERENCE', $GLOBALS['STR_REFERENCE']);
122  $tpl->assign('STR_ADMIN_SUBJECT', $GLOBALS['STR_ADMIN_SUBJECT']);
123  $tpl->assign('STR_ADMIN_NOTE', $GLOBALS['STR_ADMIN_NOTE']);
124  $tpl->assign('STR_DATE', $GLOBALS['STR_DATE']);
125  $tpl->assign('STR_STATUS', $GLOBALS['STR_STATUS']);
126  $tpl->assign('STR_BY', $GLOBALS['STR_BY']);
127  $tpl->assign('STR_ADMIN_DELETE_WARNING', $GLOBALS['STR_ADMIN_DELETE_WARNING']);
128  $tpl->assign('STR_DELETE', $GLOBALS['STR_DELETE']);
129  $tpl->assign('STR_MODULE_AVIS_ADMIN_UPDATE', $GLOBALS['STR_MODULE_AVIS_ADMIN_UPDATE']);
130  $tpl->assign('STR_MODULE_AVIS_ADMIN_NOTHING_FOUND', $GLOBALS['STR_MODULE_AVIS_ADMIN_NOTHING_FOUND']);
131  echo $tpl->fetch();
132 }
133 
140 {
141  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/avisAdmin_formulaire.tpl');
142  $tpl->assign('star_src', get_url('/images/star1.gif'));
143  $tpl->assign('action', get_current_url(false));
144  $tpl->assign('type', $type);
145  $tpl->assign('modif_href', $GLOBALS['administrer_url'] . '/utilisateurs.php?id_utilisateur=' . $frm['id_utilisateur'] . '&mode=modif');
146  $tpl->assign('mode', $frm["nouveau_mode"]);
147  $tpl->assign('id', intval($frm['id']));
148  $tpl->assign('nom_produit', $frm['nom_produit']);
149  $tpl->assign('email', $frm['email']);
150  $tpl->assign('pseudo', $frm['pseudo']);
151  $tpl->assign('etat', $frm['etat']);
152  $tpl->assign('avis', $frm['avis']);
153  $tpl->assign('note', $frm['note']);
154  $tpl->assign('note_max', $GLOBALS['site_parameters']['rating_max_value']);
155  $tpl->assign('titre_soumet', $frm['titre_soumet']);
156  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
157  $tpl->assign('STR_MODULE_AVIS_ADMIN_FORM_TITLE', $GLOBALS['STR_MODULE_AVIS_ADMIN_FORM_TITLE']);
158  $tpl->assign('STR_BY', $GLOBALS['STR_BY']);
159  $tpl->assign('STR_PSEUDO', $GLOBALS['STR_PSEUDO']);
160  $tpl->assign('STR_STATUS', $GLOBALS['STR_STATUS']);
161  $tpl->assign('STR_ADMIN_ONLINE', $GLOBALS['STR_ADMIN_ONLINE']);
162  $tpl->assign('STR_ADMIN_OFFLINE', $GLOBALS['STR_ADMIN_OFFLINE']);
163  $tpl->assign('STR_ADMIN_AVIS', $GLOBALS['STR_ADMIN_AVIS']);
164  $tpl->assign('STR_ADMIN_NOTE', $GLOBALS['STR_ADMIN_NOTE']);
165  echo $tpl->fetch();
166 }
167 
174 {
175  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/avisAdmin_formulaire_ajout.tpl');
176  $tpl->assign('star_src', get_url('/images/star1.gif'));
177  $tpl->assign('type', $type);
178  $tpl->assign('action', get_current_url(true));
179  $tpl->assign('prenom', vb($_SESSION['session_utilisateur']['prenom']));
180  $tpl->assign('nom_famille', vb($_SESSION['session_utilisateur']['nom_famille']));
181  $tpl->assign('email', vb($_SESSION['session_utilisateur']['email']));
182  $tpl->assign('pseudo', vb($frm['pseudo']));
183  $tpl->assign('avis', vb($frm['avis']));
184  $tpl->assign('error_avis', $form_error_object->text('avis'));
185  $tpl->assign('error_note', $form_error_object->text('note'));
186  $tpl->assign('id_utilisateur', intval($_SESSION['session_utilisateur']['id_utilisateur']));
187  $tpl->assign('langue', $_SESSION['session_langue']);
188  $tpl->assign('note_max', $GLOBALS['site_parameters']['rating_max_value']);
189  if ($type == 'produit') {
190  $tpl->assign('is_product_select_list', product_select_list() != "");
191  if(product_select_list() != "") {
192  $tpl->assign('product_error', $form_error_object->text('produit'));
193  $tpl->assign('product_select_list', product_select_list(vb($frm["produit"])));
194  }
195  $tpl->assign('STR_MODULE_AVIS_ADMIN_NO_PRODUCT_FOUND', $GLOBALS['STR_MODULE_AVIS_ADMIN_NO_PRODUCT_FOUND']);
196  } elseif ($type == 'annonce') {
197  $tpl->assign('is_annonce_select_list', annonce_select_list() != "");
198  if(annonce_select_list() != "") {
199  $tpl->assign('annonce_error', $form_error_object->text('annonce'));
200  $tpl->assign('annonce_select_list', annonce_select_list(vb($frm["produit"])));
201  }
202  $tpl->assign('STR_MODULE_ANNONCES_AD', $GLOBALS['STR_MODULE_ANNONCES_AD']);
203  $tpl->assign('STR_MODULE_ANNONCES_ADMIN_NO_AD_FOUND', $GLOBALS['STR_MODULE_ANNONCES_ADMIN_NO_AD_FOUND']);
204  }
205  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
206  $tpl->assign('STR_YOU_ARE', $GLOBALS['STR_YOU_ARE']);
207  $tpl->assign('STR_PSEUDO', $GLOBALS['STR_PSEUDO']);
208  $tpl->assign('STR_YOUR_OPINION', $GLOBALS['STR_YOUR_OPINION']);
209  $tpl->assign('STR_REMINDING_CHAR', $GLOBALS['STR_REMINDING_CHAR']);
210  $tpl->assign('STR_YOUR_NOTE', $GLOBALS['STR_YOUR_NOTE']);
211  $tpl->assign('STR_MODULE_AVIS_SEND_YOUR_OPINION', $GLOBALS['STR_MODULE_AVIS_SEND_YOUR_OPINION']);
212  $tpl->assign('STR_MODULE_AVIS_ADMIN_FORM_TITLE', $GLOBALS['STR_MODULE_AVIS_ADMIN_FORM_TITLE']);
213  $tpl->assign('STR_MODULE_AVIS_ADMIN_GIVE_OPINION', $GLOBALS['STR_MODULE_AVIS_ADMIN_GIVE_OPINION']);
214  $tpl->assign('STR_BY', $GLOBALS['STR_BY']);
215  $tpl->assign('STR_STATUS', $GLOBALS['STR_STATUS']);
216  $tpl->assign('STR_ADMIN_ONLINE', $GLOBALS['STR_ADMIN_ONLINE']);
217  $tpl->assign('STR_ADMIN_OFFLINE', $GLOBALS['STR_ADMIN_OFFLINE']);
218  $tpl->assign('STR_ADMIN_AVIS', $GLOBALS['STR_ADMIN_AVIS']);
219  $tpl->assign('STR_ADMIN_NOTE', $GLOBALS['STR_ADMIN_NOTE']);
220  $tpl->assign('STR_PRODUCT', $GLOBALS['STR_PRODUCT']);
221 
222  echo $tpl->fetch();
223 }
224 
225 /*
226  * Contruction du select des produits
227  */
228 
229 function product_select_list($default = null)
230 {
231  $output = "";
232  $sql = "SELECT id,nom_" . $_SESSION['session_langue'] . " AS nom
233  FROM peel_produits
234  WHERE " . get_filter_site_cond('produits', null, true) . "
235  LIMIT 1000";
236  $qid = query($sql);
237  if (num_rows($qid) > 0) {
238  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/avisAdmin_product_select_list.tpl');
239  $tpl_options = array();
240  while ($result = fetch_assoc($qid)) {
241  $value = $result["id"] . "~" . $result["nom"];
242  $tpl_options[] = array('value' => $value,
243  'issel' => vb($default) == $value,
244  'name' => $result["nom"]
245  );
246  }
247  $tpl->assign('options', $tpl_options);
248  $tpl->assign('select_product_txt', $GLOBALS['STR_MODULE_AVIS_ADMIN_SELECT_PRODUCT']);
249  $output .= $tpl->fetch();
250  }
251  return $output;
252 }
253 
254 /*
255  * Contruction du select des annonces
256  */
257 function annonce_select_list($default = null)
258 {
259  $output = "";
260  $sql = "SELECT ref, titre_".$_SESSION['session_langue']." AS titre
261  FROM peel_lot_vente
262  WHERE " . get_filter_site_cond('lot_vente', null, true) . "
263  LIMIT 1000";
264  $qid = query($sql);
265  if (num_rows($qid) > 0) {
266  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/avisAdmin_product_select_list.tpl');
267  $tpl_options = array();
268  while ($result = fetch_assoc($qid)) {
269  $value = $result["ref"] . "~" . $result["titre"];
270  $tpl_options[] = array('value' => $value,
271  'issel' => vb($default) == $value,
272  'name' => $result["titre"]
273  );
274  }
275  $tpl->assign('options', $tpl_options);
276  $tpl->assign('select_product_txt', $GLOBALS['STR_MODULE_AVIS_ADMIN_SELECT_AD']);
277  $output .= $tpl->fetch();
278  }
279 
280  return $output;
281 }
282 
289 function ajout_avis($frm)
290 {
291  $produit = explode("~", $frm["produit"]);
292 
293  if (!empty($produit) && !empty($produit[0])) {
294  $sql = "INSERT INTO peel_avis (";
295  if ($frm['type'] == 'produit') {
296  $sql .= " id_produit";
297  } elseif ($frm['type'] == 'annonce') {
298  $sql .= " ref";
299  }
300  $sql .= "
301  , nom_produit
302  , id_utilisateur
303  , email
304  , prenom
305  , pseudo
306  , avis
307  , note
308  , datestamp
309  , etat
310  , lang
311  ) VALUES (
312  '" . intval($produit[0]) . "'
313  , '" . nohtml_real_escape_string($produit[1]) . "'
314  , '" . intval($frm['id_utilisateur']) . "'
315  , '" . nohtml_real_escape_string($frm['email']) . "'
316  , '" . nohtml_real_escape_string(String::strtolower($frm['prenom'])) . "'
317  , '" . nohtml_real_escape_string($frm['pseudo']) . "'
318  , '" . nohtml_real_escape_string($frm['avis']) . "'
319  , '" . intval($frm['note']) . "'
320  , '" . date('Y-m-d H:i:s', time()) . "'
321  , '1'
322  , '" . nohtml_real_escape_string($frm['langue']) . "'
323  )";
324  $qid = query($sql);
325  if (!$qid) {
326  return false;
327  }
328  $custom_template_tags['PRENOM'] = vb($_SESSION['session_utilisateur']['prenom']);
329  $custom_template_tags['NOM_FAMILLE'] = vb($_SESSION['session_utilisateur']['nom_famille']);
330  $custom_template_tags['NOM_PRODUIT'] = String::html_entity_decode_if_needed($produit[1]);
331  $custom_template_tags['AVIS'] = $frm['avis'];
332  send_email($GLOBALS['support_sav_client'], '', '', 'insere_avis', $custom_template_tags, null, $GLOBALS['support'], true, false, true, $frm['email']);
333  return true;
334  }
335  return false;
336 }
337 
if(!empty($GLOBALS['site_parameters']['order_specific_field_titles'])) if(check_if_module_active('socolissimo')&&!empty($_REQUEST)&&!empty($_REQUEST['PUDOFOID'])&&!empty($_REQUEST['CEEMAIL'])&&!empty($_REQUEST['SIGNATURE'])&&!empty($_REQUEST['ORDERID'])) elseif(!empty($_POST)) elseif(check_if_module_active('socolissimo')&&!empty($_SESSION['session_commande']['is_socolissimo_order'])) foreach(array('bill'=> 1, 'ship'=> 2) as $address_type=> $session_commande_address_id) $frm['societe1']
$result
get_current_url($with_get=true, $get_short_url=false, $take_away_get_args_array=null)
get_current_url()
Definition: fonctions.php:1743
ajout_avis($frm)
Ajoute les infos dans la table avis.
Definition: fonctions.php:289
static html_entity_decode_if_needed($string)
String::html_entity_decode_if_needed()
Definition: String.php:533
static strtolower($string)
Returns string with all alphabetic characters converted to lowercase.
Definition: String.php:135
nohtml_real_escape_string($value, $allowed_tags=null)
Protège les données pour insertion dans MySQL ET supprime les tags HTML pour protéger de toute sorte ...
Definition: database.php:400
$results_array
if(!empty($_GET['id'])) if(isset($_POST['form_name'], $_POST['form_subject'], $_POST['form_text'], $_POST['form_lang'])&&empty($_GET['id'])) if(empty($_GET['id'])) $tpl
if(!defined('IN_PEEL')) $GLOBALS['page_types_array']
Definition: fonctions.php:19
if(isset($_POST['pays_zone'])) elseif(empty($_SESSION['session_caddie']->zoneId)&&!empty($GLOBALS['site_parameters']['default_delivery_zone_id'])) if(isset($_POST['type'])) elseif(empty($_SESSION['session_caddie']->typeId)&&!empty($GLOBALS['site_parameters']['default_delivery_type_id'])) if(!empty($_POST['code_promo'])) if(!empty($_GET['code_promo'])&&$_GET['code_promo']== 'delete') $form_error_object
product_select_list($default=null)
Definition: fonctions.php:229
$tpl_options
affiche_liste_avis()
affiche_liste_avis()
Definition: fonctions.php:77
get_filter_site_cond($table_technical_code, $table_alias=null, $use_strict_rights_if_in_admin=false, $specific_site_id=null, $exclude_public_items=false, $admin_force_multisite_if_allowed=false)
Retourne la condition SQL permettant de filtrer les données pour une table.
Definition: fonctions.php:4643
query($query, $die_if_error=false, $database_object=null, $silent_if_error=false, $security_sql_filter=true)
The query() function is meant to be called anywhere you want to make a query.
Definition: database.php:158
vb(&$var, $default=null)
Variable blanche if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:97
if(strlen($date2)== '10') if($type== 'users-by-age'&&a_priv('admin_users', true)) elseif($type== 'forums-count'&&a_priv('admin_content', true)) elseif($type== 'forums-categories'&&a_priv('admin_content', true)) elseif($type== 'users-count'&&a_priv('admin_users', true)) elseif($type== 'product-categories'&&a_priv('admin_products', true)) elseif($type== 'users-by-sex'&&a_priv('admin_users', true)) elseif($type== 'users-by-country'&&a_priv('admin_users', true)) elseif($type== 'sales'&&a_priv('admin_sales', true))
Definition: chart-data.php:160
num_rows($query_result)
num_rows()
Definition: database.php:321
if(!defined('IN_PEEL')) send_email($to, $mail_subject= '', $mail_content= '', $template_technical_code=null, $template_tags=null, $format=null, $sender=null, $html_add_structure=true, $html_correct_conformity=false, $html_convert_url_to_links=true, $reply_to=null, $attached_files_infos_array=null, $lang=null, $additional_infos_array=array(), $attachment_not_sent_by_email=false)
Envoi d'un email à un utilisateur.
Definition: emails.php:38
affiche_formulaire_avis(&$frm, &$form_error_object, $type)
affiche_formulaire_avis()
Definition: fonctions.php:139
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
get_formatted_date($datetime_or_timestamp=null, $mode= 'short', $hour_minute=false)
Afficher une date formatée, en évitant les problèmes liés aux noms de mois sur les serveurs qui ne so...
Definition: format.php:440
supprime_avis($id)
supprime_avis()
Definition: fonctions.php:63
formulaire_ajout_avis(&$frm, &$form_error_object, $type)
formulaire_ajout_avis()
Definition: fonctions.php:173
annonce_select_list($default=null)
Definition: fonctions.php:257
if(!defined('IN_PEEL')) avis_hook_admin_menu_items($params)
Renvoie les éléments de menu affichables.
Definition: fonctions.php:24
$id
Definition: articles.php:22
affiche_formulaire_modif_avis($id, &$frm, &$form_error_object)
Affiche le formulaire de modification de avis.
Definition: fonctions.php:35
check_if_module_active($module_name, $specific_file_name=null)
Renvoie si un module est présent et activé ou non - Peut être appelé avant ou après le chargement d'u...
if(defined('IN_PEEL_ADMIN')||IN_INSTALLATION) $_SESSION['session_langue']

This documentation for Open ecommerce PEEL Shopping and PEEL.fr has been generated by Doxygen on Thu Oct 15 2015 14:30:50 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.