PEEL Shopping
Open source ecommerce : PEEL Shopping
configuration.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: configuration.php 46935 2015-09-18 08:49:48Z gboussin $
14 define('IN_PEEL_ADMIN', true);
15 include("../configuration.inc.php");
17 necessite_priv("admin_content", true, true);
18 $id = vn($_GET['id']);
19 
20 $GLOBALS['DOC_TITLE'] = $GLOBALS['STR_ADMIN_CONFIGURATION_TITLE'];
21 include($GLOBALS['repertoire_modele'] . "/admin_haut.php");
22 
23 $frm = $_POST;
25 
26 switch (vb($_REQUEST['mode'])) {
27  case "ajout" :
29  break;
30 
31  case "modif" :
33  break;
34 
35  case "suppr" :
38  break;
39 
40  case "generate" :
41  // Pour migrer le contenu d'une table peel_sites :
42  // appeler /administrer/configuration.php?mode=generate&migrate=1&full=1
43  if(!empty($_GET['migrate'])) {
44  $configuration_fields = get_table_field_names('peel_sites', null, true);
45  if(!empty($configuration_fields)) {
46  // La table peel_sites pour d'anciens sites existe => on charge son contenu pour ensuite mettre les informations dans peel_configuration
47  $query = query("SELECT ps.*, pd.devise, pd.conversion, pd.symbole, pd.symbole_place, pd.code
48  FROM peel_sites ps
49  LEFT JOIN peel_devises pd ON pd.id = ps.devise_defaut AND " . get_filter_site_cond('devises') . "
50  WHERE ps.id = '1'");
52  }
53  } else {
54  $configuration_fields = $GLOBALS['site_parameters'];
55  }
56  if(!empty($configuration_fields)) {
57  foreach($configuration_fields as $this_key => $this_value) {
58  if(!in_array($this_key, array('id', 'devise', 'conversion', 'symbole', 'symbole_place', 'code'))) {
59  // On crée la configuration
60  $frm['etat'] = 1;
61  $frm['technical_code'] = $this_key;
62  $frm['string'] = $this_value;
63  $frm['origin'] = 'auto';
64  $frm['lang'] = '';
65  $frm['site_id'] = 1;
66  if(is_array($this_value)) {
67  $frm['type'] = 'array';
68  $frm['string'] = get_string_from_array($this_value);
69  }elseif(is_bool($this_value)) {
70  $frm['type'] = 'boolean';
71  if($this_value){
72  $frm['string'] = 'true';
73  } else {
74  $frm['string'] = 'false';
75  }
76  }elseif(is_int($this_value)) {
77  $frm['type'] = 'integer';
78  }elseif(is_float($this_value)) {
79  $frm['type'] = 'float';
80  }else {
81  $frm['type'] = 'string';
82  }
83  $qid = query("SELECT *
84  FROM peel_configuration
85  WHERE technical_code = '" . real_escape_string($this_key) . "' AND " . get_filter_site_cond('configuration', null, true) . "");
86  $select = fetch_assoc($qid);
87  if (!$select) {
89  echo 'INSERTED '.$frm['technical_code'].'<br />';
90  } elseif(!empty($_GET['full'])) {
91  unset($frm['type']);
92  update_configuration_variable($select['id'], $frm);
93  echo 'UPDATED '.$frm['technical_code'].'<br />';
94  }
95  }
96  }
97  }
98  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => 'Generate OK'))->fetch();
99  break;
100 
101  case "insere" :
102  if (!verify_token($_SERVER['PHP_SELF'] . $frm['mode'] . $frm['id'])) {
103  $form_error_object->add('token', $GLOBALS['STR_INVALID_TOKEN']);
104  }
105  if (!$form_error_object->count()) {
107  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_CONFIGURATION_MSG_CREATED'], vb($_POST['technical_code']))))->fetch();
109  } else {
110  if ($form_error_object->has_error('token')) {
111  echo $form_error_object->text('token');
112  }
114  }
115  break;
116 
117  case "maj" :
118  if (!verify_token($_SERVER['PHP_SELF'] . $frm['mode'] . $frm['id'])) {
119  $form_error_object->add('token', $GLOBALS['STR_INVALID_TOKEN']);
120  }
121  if (!$form_error_object->count()) {
122  update_configuration_variable($_POST['id'], $_POST);
123  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_CONFIGURATION_MSG_UPDATED'], vn($_POST['id']))))->fetch();
125  } else {
126  if ($form_error_object->has_error('token')) {
127  echo $form_error_object->text('token');
128  }
130  }
131  break;
132 
133  default :
135  break;
136 }
137 
138 include($GLOBALS['repertoire_modele'] . "/admin_bas.php");
139 
151 {
152  /* Default value*/
153  if(empty($frm)) {
154  $frm['etat'] = 1;
155  $frm['technical_code'] = "";
156  $frm['origin'] = "";
157  $frm['string'] = "";
158  $frm['type'] = "";
159  $frm['lang'] = "";
160  $frm['site_id'] = "";
161  }
162  $frm['nouveau_mode'] = "insere";
163  $frm['id'] = "";
164  $frm['titre_bouton'] = $GLOBALS['STR_ADMIN_ADD'];
165 
167 }
168 
177 {
178  if(empty($frm)){
179  // Pas de données venant de validation de formulaire, donc on charge le contenu de la base de données
180  /* Charge les informations du produit */
181  $qid = query("SELECT *
182  FROM peel_configuration
183  WHERE id = '" . intval($id) . "' AND " . get_filter_site_cond('configuration', null, true) . "");
184  if ($frm = fetch_assoc($qid)) {
185  } else {
186  echo $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => $GLOBALS['STR_ADMIN_CONFIGURATION_ERR_NOT_FOUND']))->fetch();
187  return false;
188  }
189  }
190  $frm['id'] = $id;
191  $frm["nouveau_mode"] = "maj";
192  $frm["titre_bouton"] = $GLOBALS['STR_ADMIN_FORM_SAVE_CHANGES'];
193 
195 }
196 
204 {
205  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_formulaire_configuration.tpl');
206  $tpl->assign('action', get_current_url(false) . '?start=0');
207  $tpl->assign('form_token', get_form_token_input($_SERVER['PHP_SELF'] . $frm['nouveau_mode'] . intval($frm['id'])));
208  $tpl->assign('mode', $frm["nouveau_mode"]);
209  $tpl->assign('id', intval($frm['id']));
210  $tpl_langs = array();
211  $tpl_langs[] = array('lng' => '',
212  'issel' => vb($frm['lang']) == '',
213  'name' => $GLOBALS['STR_ALL']
214  );
215  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
216  $tpl_langs[] = array('lng' => $lng,
217  'issel' => vb($frm['lang']) == $lng,
218  'name' => $GLOBALS['lang_names'][$lng]
219  );
220  }
221  if(String::strpos(vb($frm['string']), "\r") !== false || String::strpos(vb($frm['string']), "\n") !== false || String::strpos(vb($frm['technical_code']), "tag_") !== false || String::strpos(vb($frm['technical_code']), "_tag") !== false) {
222  $tpl->assign('string_as_textarea', true);
223  }
224  $tpl->assign('langs', $tpl_langs);
225  $tpl->assign('etat', $frm["etat"]);
226  $tpl->assign('site_id_select_options', get_site_id_select_options(vb($frm['site_id'])));
227  $tpl->assign('site_id_select_multiple', !empty($GLOBALS['site_parameters']['multisite_using_array_for_site_id']));
228  $tpl->assign('origin', vb($frm['origin']));
229  $tpl->assign('type', vb($frm['type']));
230  $tpl->assign('technical_code', vb($frm['technical_code']));
231  $tpl->assign('string', vb($frm['string']));
232  $tpl->assign('explain', vb($frm['explain']));
233  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
234  $tpl->assign('STR_ADMIN_WEBSITE', $GLOBALS['STR_ADMIN_WEBSITE']);
235  $tpl->assign('STR_ADMIN_CONFIGURATION_FORM_TITLE', $GLOBALS['STR_ADMIN_CONFIGURATION_FORM_TITLE']);
236  $tpl->assign('STR_ADMIN_LANGUAGE', $GLOBALS['STR_ADMIN_LANGUAGE']);
237  $tpl->assign('STR_STATUS', $GLOBALS['STR_STATUS']);
238  $tpl->assign('STR_ADMIN_ONLINE', $GLOBALS['STR_ADMIN_ONLINE']);
239  $tpl->assign('STR_ADMIN_OFFLINE', $GLOBALS['STR_ADMIN_OFFLINE']);
240  $tpl->assign('STR_ADMIN_TECHNICAL_CODE', $GLOBALS['STR_ADMIN_TECHNICAL_CODE']);
241  $tpl->assign('STR_TYPE', $GLOBALS['STR_TYPE']);
242  $tpl->assign('STR_ADMIN_CONFIGURATION_TEXT', $GLOBALS['STR_ADMIN_CONFIGURATION_TEXT']);
243  $tpl->assign('STR_ADMIN_CONFIGURATION_ORIGIN', $GLOBALS['STR_ADMIN_CONFIGURATION_ORIGIN']);
244  $tpl->assign('STR_VALIDATE', $GLOBALS['STR_VALIDATE']);
245  $tpl->assign('STR_COMMENTS', $GLOBALS['STR_COMMENTS']);
246  echo $tpl->fetch();
247 }
248 
256 {
257  query("DELETE FROM peel_configuration
258  WHERE id='" . intval($id) . "' AND " . get_filter_site_cond('configuration', null, true) . "");
259  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => $GLOBALS['STR_ADMIN_CONFIGURATION_MSG_DELETED']))->fetch();
260 }
261 
268 {
269  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_liste_configuration.tpl');
270  $tpl->assign('add_src', $GLOBALS['administrer_url'] . '/images/add.png');
271  $tpl->assign('add_href', get_current_url(false) . '?mode=ajout');
272  $tpl->assign('drop_src', $GLOBALS['administrer_url'] . '/images/b_drop.png');
273  $tpl->assign('edit_src', $GLOBALS['administrer_url'] . '/images/b_edit.png');
274  $sql = "SELECT *
275  FROM peel_configuration
276  WHERE " . get_filter_site_cond('configuration', null, true) . "";
277  $Links = new Multipage($sql, 'produits');
278  $HeaderTitlesArray = array($GLOBALS['STR_ADMIN_ACTION'], 'lang' => $GLOBALS['STR_ADMIN_LANGUAGE'], 'type' => $GLOBALS['STR_TYPE'], 'technical_code' => $GLOBALS['STR_ADMIN_TECHNICAL_CODE'], 'string' => $GLOBALS['STR_VALUE'], 'last_update' => $GLOBALS['STR_DATE'], 'origin' => $GLOBALS['STR_ADMIN_CONFIGURATION_ORIGIN'], 'etat' => $GLOBALS['STR_STATUS'], 'site_id' => $GLOBALS['STR_ADMIN_SITE_ID']);
279  $Links->HeaderTitlesArray = $HeaderTitlesArray;
280  $Links->OrderDefault = "site_id, technical_code, lang";
281  $Links->SortDefault = "ASC";
282  $results_array = $Links->Query();
283  if (!empty($results_array)) {
284  $tpl_results = array();
285  $i = 0;
286  foreach ($results_array as $ligne) {
287  $string = $ligne['string'];
288  $comment = '';
289  $tpl->assign('HeaderRow', $Links->getHeaderRow());
290  if(String::substr($ligne['technical_code'], 0, 4) != 'STR_' && $string != vb($GLOBALS['site_parameters'][$ligne['technical_code']]) && get_string_from_array(get_array_from_string($string)) != get_string_from_array(vb($GLOBALS['site_parameters'][$ligne['technical_code']])) && (empty($_POST['technical_code']) || $_POST['technical_code'] != $ligne['technical_code']) && (!is_bool($GLOBALS['site_parameters'][$ligne['technical_code']]) || !in_array($string, array('false', 'true')))){
291  $comment .= '<br /><span class="text-danger">(Current : ' . str_replace(array("Array,", "),", "(,", ",)"), array("Array ", ")", "(", ")"), str_replace(array("\r\n", "\n"), ',', String::textEncode(print_r(vb($GLOBALS['site_parameters'][$ligne['technical_code']]), true)))).')</span>';
292  }
293  $tpl_results[] = array('tr_rollover' => tr_rollover($i, true),
294  'technical_code' => String::str_shorten_words($ligne['technical_code'], 50),
295  'drop_href' => get_current_url(false) . '?mode=suppr&id=' . $ligne['id'],
296  'edit_href' => get_current_url(false) . '?mode=modif&id=' . $ligne['id'],
297  'lang' => $ligne['lang'],
298  'date' => get_formatted_date($ligne['last_update'], 'short', 'long'),
299  'origin' => $ligne['origin'],
300  'site_id' => $ligne['site_id'],
301  'type' => $ligne['type'],
302  'string' => String::str_shorten_words($string, 50),
303  'comment' => String::str_shorten_words($comment, 50),
304  'etat_onclick' => 'change_status("configuration", "' . $ligne['id'] . '", this, "'.$GLOBALS['administrer_url'] . '")',
305  'etat_src' => $GLOBALS['administrer_url'] . '/images/' . (empty($ligne['etat']) ? 'puce-blanche.gif' : 'puce-verte.gif')
306  );
307  $i++;
308  }
309  $tpl->assign('results', $tpl_results);
310  }
311  $tpl->assign('Multipage', $Links->GetMultipage());
312  if (check_if_module_active('welcome_ad')) {
313  $tpl->assign('is_welcome_ad_module_active', true);
314  unset($_SESSION['session_info_inter_set']);
315  } else {
316  $tpl->assign('is_welcome_ad_module_active', false);
317  }
318  $tpl->assign('STR_ADMIN_CONFIGURATION_TITLE', $GLOBALS['STR_ADMIN_CONFIGURATION_TITLE']);
319  $tpl->assign('STR_ADMIN_CONFIGURATION_CREATE', $GLOBALS['STR_ADMIN_CONFIGURATION_CREATE']);
320  $tpl->assign('STR_ADMIN_CONFIGURATION_EXPLAIN', $GLOBALS['STR_ADMIN_CONFIGURATION_EXPLAIN']);
321  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
322  $tpl->assign('STR_NOTA_BENE', $GLOBALS['STR_NOTA_BENE']);
323  $tpl->assign('STR_ADMIN_ACTION', $GLOBALS['STR_ADMIN_ACTION']);
324  $tpl->assign('STR_ADMIN_LANGUAGE', $GLOBALS['STR_ADMIN_LANGUAGE']);
325  $tpl->assign('STR_ADMIN_TECHNICAL_CODE', $GLOBALS['STR_ADMIN_TECHNICAL_CODE']);
326  $tpl->assign('STR_DATE', $GLOBALS['STR_DATE']);
327  $tpl->assign('STR_VALIDATE', $GLOBALS['STR_VALIDATE']);
328  $tpl->assign('STR_STATUS', $GLOBALS['STR_STATUS']);
329  $tpl->assign('STR_VALUE', $GLOBALS['STR_VALUE']);
330  $tpl->assign('STR_ADMIN_CONFIGURATION_ORIGIN', $GLOBALS['STR_ADMIN_CONFIGURATION_ORIGIN']);
331  $tpl->assign('STR_ADMIN_DELETE_WARNING', $GLOBALS['STR_ADMIN_DELETE_WARNING']);
332  $tpl->assign('STR_DELETE', $GLOBALS['STR_DELETE']);
333  $tpl->assign('STR_ADMIN_CONFIGURATION_UPDATE', $GLOBALS['STR_ADMIN_CONFIGURATION_UPDATE']);
334  $tpl->assign('STR_TYPE', $GLOBALS['STR_TYPE']);
335  echo $tpl->fetch();
336 }
337 
supprime_configuration($id)
Supprime la variable de configuration spécifiée par $id.
static textEncode($string, $suppr_endline=false, $encode_only_isolated_amperstands=false)
Méthode de compatibilité avec anciennes versions de PEEL utilisant textEncode au lieu de htmlentities...
Definition: String.php:468
static strpos($haystack, $needle, $offset=0)
Returns the numeric position of the first occurrence of needle in the haystack string.
Definition: String.php:54
get_current_url($with_get=true, $get_short_url=false, $take_away_get_args_array=null)
get_current_url()
Definition: fonctions.php:1743
$configuration_fields
Definition: update.php:46
affiche_formulaire_configuration(&$frm)
affiche_formulaire_configuration()
get_string_from_array($array, $disable_ad_quote=false)
Convertit un tableau en chaine de caractère simple à gérer par un utilisateur.
Definition: format.php:973
$tpl_langs
get_site_id_select_options($selected_site_id=null, $selected_site_name=null, $display_first_option=null, $select_current_site_id_by_default=false)
Créer les options pour le select qui liste les noms de sites configurés en back office.
$results_array
$form_error_object
$frm
real_escape_string($value)
real_escape_string()
Definition: database.php:374
static str_shorten_words($string, $length_limit=100, $separator=" ", $force_shorten_if_special_content=false, $add_separator_instead_of_cutting=true)
On rajoute des espaces à l'intérieur des mots trop longs => à utiliser pour éviter de casser une mise...
Definition: String.php:305
necessite_priv($priv, $demo_allowed=true, $configuration_modification=false)
Cette fonction vérifie si l'utilisateur a les privilèges de $priv.
Definition: fonctions.php:1575
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
$GLOBALS['DOC_TITLE']
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
necessite_identification()
Si l'utilisateur n'est pas connecté à un compte, on affiche une page d'identification et arrête le sc...
Definition: fonctions.php:1596
affiche_liste_configuration()
Affiche la liste des variables de configuration pour tous les sites.
get_table_field_names($table_name, $link_identifier=null, $silent_if_error=false)
get_table_field_names()
Definition: database.php:495
affiche_formulaire_ajout_configuration(&$frm)
FONCTIONS.
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
get_array_from_string($string)
Convertit une chaine de caractère simple à gérer par un utilisateur en un tableau PHP...
Definition: format.php:1011
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
update_configuration_variable($id_or_technical_code, $frm, $delete=false)
update_configuration_variable()
Definition: fonctions.php:4273
get_form_token_input($name= 'general', $use_existing_token=true, $return_as_input_form=true)
get_form_token_input()
Definition: fonctions.php:94
affiche_formulaire_modif_configuration($id, &$frm)
Affiche le formulaire de modification pour la zone HTML sélectionnée.
vn(&$var, $default=0)
Variable nulle if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:110
set_configuration_variable($frm, $update_if_technical_code_exists=false, $allow_create=true)
Ajoute la zone HTML dans la table peel_configuration.
Definition: fonctions.php:4199
verify_token($name= 'general', $delay_in_minutes=60, $check_referer_if_set_by_server=true, $cancel_token=true, $minimum_wait_in_seconds_before_use=0)
Vérification de la validité d'un token Par défaut, un token est valide 1h, et utilisable 1 seule fois...
Definition: fonctions.php:118
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
Definition: String.php:112
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:29:04 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.