PEEL Shopping
Open source ecommerce : PEEL Shopping
plan.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: plan.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');
18 
19 $GLOBALS['DOC_TITLE'] = $GLOBALS['STR_ADMIN_PLAN_TITLE'];
20 
21 $id = intval(vn($_REQUEST['id']));
22 
23 if (!isset($form_error_object)) {
25 }
26 $output = '';
27 switch (vb($_REQUEST['mode'])) {
28  case "suppr" :
29  $output .= supprime_contacts($_GET['id']);
31  break;
32 
33  case "insere" :
34  if (!verify_token($_SERVER['PHP_SELF'] . $_POST['mode'] . $_POST['id'])) {
35  $form_error_object->add('token', $GLOBALS['STR_INVALID_TOKEN']);
36  }
37  if (!$form_error_object->count()) {
38  $output .= insere_contacts($_POST);
39  $output .= $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_CONTACTS_CREATED'], vb($_POST['nom_' . $_SESSION["session_langue"]]))))->fetch();
41  } else {
42  if ($form_error_object->has_error('token')) {
43  $output .= $form_error_object->text('token');
44  }
46  }
47  break;
48 
49  case "ajout" :
51  break;
52 
53  case "modif" :
55  break;
56 
57  case "maj" :
58  if (!empty($_POST)) {
59  $frm = $_POST;
60  $empty_field_messages_array['map_tag'] = $GLOBALS['STR_ADMIN_PLAN_ERR_TAG_VALID_NEEDED'];
61  $empty_field_messages_array['token'] = $GLOBALS['STR_INVALID_TOKEN'];
62  $form_error_object->valide_form($frm, $empty_field_messages_array);
63  }
64  if (!verify_token($_SERVER['PHP_SELF'] . $frm['mode'] . $frm['id'])) {
65  $form_error_object->add('token', $GLOBALS['STR_INVALID_TOKEN']);
66  }
67  if (!$form_error_object->count()) {
68  $output .= maj_contacts($frm['id'], $_POST);
69  $output .= $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => $GLOBALS['STR_ADMIN_PLAN_MSG_UPDATED_OK']))->fetch();
70  } else {
71  if ($form_error_object->has_error('token')) {
72  $output .= $form_error_object->text('token');
73  } else {
74  $output .= $GLOBALS['tplEngine']->createTemplate('global_error.tpl', array('message' => $GLOBALS['STR_ADMIN_ERR_FORM_INCOMPLETE']))->fetch();
75  }
76  }
78  break;
79 
80  default :
82  break;
83 }
84 include($GLOBALS['repertoire_modele'] . "/admin_haut.php");
85 echo $output;
86 include($GLOBALS['repertoire_modele'] . "/admin_bas.php");
87 
101 {
102  if(empty($frm)){
103  // Pas de données venant de validation de formulaire, donc on charge le contenu de la base de données
104  $qid = query("SELECT *
105  FROM peel_access_map
106  WHERE id = " . intval($id) . " AND " . get_filter_site_cond('access_map', null, true));
107  $frm = fetch_assoc($qid);
108  }
109  if (!empty($frm)) {
110  $frm['nouveau_mode'] = "maj";
111  $frm['normal_bouton'] = $GLOBALS['STR_ADMIN_FORM_SAVE_CHANGES'];
113  } else {
114  redirect_and_die(get_current_url(false).'?mode=ajout');
115  }
116 }
117 
126 {
127  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_plan_formulaire_contact.tpl');
128  $tpl->assign('action', get_current_url(false) . '?start=0');
129  $tpl->assign('form_token', get_form_token_input($_SERVER['PHP_SELF'] . $frm['nouveau_mode'] . intval(vn($frm['id']))));
130  $tpl->assign('mode', $frm["nouveau_mode"]);
131  $tpl->assign('id', intval(vn($frm['id'])));
132 
133  $tpl_langs = array();
134  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
135  $tpl_langs[] = array('lng' => $lng,
136  'text_te' => getTextEditor('text_' . $lng, '100%', 500, String::html_entity_decode_if_needed(vb($frm['text_' . $lng]))),
137  );
138  }
139  $tpl->assign('langs', $tpl_langs);
140 
141  $tpl->assign('site_id_select_options', get_site_id_select_options(vb($frm['site_id'])));
142  $tpl->assign('error', $form_error_object->text('map_tag'));
143  $tpl->assign('map_tag', vb($frm['map_tag']));
144  $tpl->assign('normal_bouton', $frm['normal_bouton']);
145  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
146  $tpl->assign('STR_ADMIN_WEBSITE', $GLOBALS['STR_ADMIN_WEBSITE']);
147  $tpl->assign('STR_ADMIN_PLAN_UPDATE', $GLOBALS['STR_ADMIN_PLAN_UPDATE']);
148  $tpl->assign('STR_ADMIN_PLAN_TAG_EXPLAIN', $GLOBALS['STR_ADMIN_PLAN_TAG_EXPLAIN']);
149  $tpl->assign('STR_ADMIN_LANGUAGES_SECTION_HEADER', $GLOBALS['STR_ADMIN_LANGUAGES_SECTION_HEADER']);
150  $tpl->assign('STR_ADMIN_HEADER_HTML_TEXT', $GLOBALS['STR_ADMIN_HEADER_HTML_TEXT']);
151  $tpl->assign('STR_ADMIN_VARIOUS_INFORMATION_HEADER', $GLOBALS['STR_ADMIN_VARIOUS_INFORMATION_HEADER']);
152  $tpl->assign('STR_ADMIN_PLAN_TAG_CODE', $GLOBALS['STR_ADMIN_PLAN_TAG_CODE']);
153  return $tpl->fetch();
154 }
155 
163 {
164  $sql = 'UPDATE peel_access_map SET
165  site_id = "' . nohtml_real_escape_string(get_site_id_sql_set_value($frm['site_id'])) . '"
166  , map_tag = "' . real_escape_string($frm['map_tag']) . '"
167  , date_maj = "' . date('Y-m-d H:i:s', time()) . '" ';
168  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
169  $sql .= '
170  , text_' . $lng . ' = "' . real_escape_string($frm['text_' . $lng]) . '"';
171  }
172  $sql .= "
173  WHERE id = " . intval($id) . " AND " . get_filter_site_cond('access_map', null, true);
174  query($sql);
175 }
176 
184 {
185  /* Valeurs par défaut */
186  if(empty($frm)) {
187  $frm = array();
188  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
189  $frm['nom_' . $lng] = "";
190  }
191  $frm['position'] = "";
192  $frm['tarif'] = 0;
193  $frm['tarif_percent'] = 0;
194  $frm['tva'] = 0;
195  $frm['technical_code'] = '';
196  $frm['retour_possible'] = 1;
197  $frm['totalmin'] = 0;
198  $frm['totalmax'] = 0;
199  $frm['site_id'] = 0;
200  }
201  $frm['nouveau_mode'] = "insere";
202  $frm['id'] = "";
203  $frm['normal_bouton'] = $GLOBALS['STR_ADMIN_ADD'];
205 }
206 
207 
215 {
216  /* Efface le contact */
217  $qid = query("DELETE FROM peel_access_map
218  WHERE id=" . intval($id) . " AND " . get_filter_site_cond('access_map', null, true));
219  return $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => $GLOBALS['STR_ADMIN_CONTACTS_MSG_DELETED_OK']))->fetch();
220 }
221 
229 {
230  $sql = 'INSERT INTO peel_access_map SET
231  site_id = "' . nohtml_real_escape_string(get_site_id_sql_set_value($frm['site_id'])) . '"
232  , map_tag = "' . real_escape_string($frm['map_tag']) . '"
233  , date_maj = "' . date('Y-m-d H:i:s', time()) . '" ';
234  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
235  $sql .= '
236  , text_' . $lng . ' = "' . real_escape_string($frm['text_' . $lng]) . '"';
237  }
238  query($sql);
239 }
246 {
247  $tpl = $GLOBALS['tplEngine']->createTemplate('admin_liste_contacts.tpl');
248 
249  $tpl->assign('add_src', $GLOBALS['administrer_url'] . '/images/add.png');
250  $tpl->assign('add_href', get_current_url(false) . '?mode=ajout');
251  $tpl->assign('drop_src', $GLOBALS['administrer_url'] . '/images/b_drop.png');
252  $tpl->assign('edit_src', $GLOBALS['administrer_url'] . '/images/b_edit.png');
253 
254  $sql = "SELECT *
255  FROM peel_access_map
256  WHERE " . get_filter_site_cond('access_map', null, true);
257  $result = query($sql);
258  if (!(num_rows($result) == 0)) {
259  $tpl_results = array();
260  $i = 0;
261  while ($ligne = fetch_assoc($result)) {
262  $tpl_results[] = array('tr_rollover' => tr_rollover($i, true),
263  'nom' => (!empty($ligne['titre_' . $_SESSION['session_langue']])?$ligne['titre_' . $_SESSION['session_langue']]:'['.$ligne['id'].']'),
264  'drop_href' => get_current_url(false) . '?mode=suppr&id=' . $ligne['id'],
265  'edit_href' => get_current_url(false) . '?mode=modif&id=' . $ligne['id'],
266  'site_name' => get_site_name($ligne['site_id'])
267  );
268  }
269  $tpl->assign('results', $tpl_results);
270  }
271 
272  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
273  $tpl->assign('STR_ADMIN_CONTACTS_ADD', $GLOBALS['STR_ADMIN_CONTACTS_ADD']);
274  $tpl->assign('STR_DELETE', $GLOBALS['STR_DELETE']);
275  $tpl->assign('STR_ADMIN_ACTION', $GLOBALS['STR_ADMIN_ACTION']);
276  $tpl->assign('STR_ADMIN_CONTACTS_TITLE', $GLOBALS['STR_ADMIN_CONTACTS_TITLE']);
277  $tpl->assign('STR_ADMIN_CONTACTS_UPDATE', $GLOBALS['STR_ADMIN_CONTACTS_UPDATE']);
278  $tpl->assign('STR_ADMIN_CONTACTS_NO_FOUND', $GLOBALS['STR_ADMIN_CONTACTS_NO_FOUND']);
279  $tpl->assign('STR_ADMIN_DELETE_WARNING', $GLOBALS['STR_ADMIN_DELETE_WARNING']);
280  $tpl->assign('STR_ADMIN_WEBSITE', $GLOBALS['STR_ADMIN_WEBSITE']);
281  return $tpl->fetch();
282 }
283 
get_site_name($site_ids, $skip_rights_check=false)
Retourne le nom d'un ou de plusieurs sites à partir de l'id.
Definition: fonctions.php:4763
getTextEditor($instance_name, $width, $height, $default_text, $default_path=null, $type_html_editor=0, $compter_char_max_if_enabled=255, $placeholder= '')
getTextEditor()
Definition: fonctions.php:4055
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
$GLOBALS['DOC_TITLE']
Definition: plan.php:19
get_current_url($with_get=true, $get_short_url=false, $take_away_get_args_array=null)
get_current_url()
Definition: fonctions.php:1743
redirect_and_die($url, $permanent_redirection=false, $avoid_loop=false)
Redirige vers l'URL demandée et arrête le programme.
Definition: fonctions.php:1551
$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.
static html_entity_decode_if_needed($string)
String::html_entity_decode_if_needed()
Definition: String.php:533
if(!isset($form_error_object)) $output
Definition: plan.php:26
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
maj_contacts($id, $frm)
Met à jour le contact $id avec de nouvelles valeurs.
Definition: plan.php:162
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
real_escape_string($value)
real_escape_string()
Definition: database.php:374
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
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
affiche_liste_contacts()
affiche_liste_contacts()
Definition: plan.php:245
affiche_formulaire_contact(&$frm, &$form_error_object)
affiche_formulaire_contact()
Definition: plan.php:125
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
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
num_rows($query_result)
num_rows()
Definition: database.php:321
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
supprime_contacts($id)
Supprime le contact spécifié par $id.
Definition: plan.php:214
insere_contacts(&$frm)
Ajoute les informations dans la table access_map.
Definition: plan.php:228
affiche_formulaire_ajout_contacts(&$frm, $form_error_object)
Affiche un formulaire vierge pour ajouter un contacts.
Definition: plan.php:183
get_form_token_input($name= 'general', $use_existing_token=true, $return_as_input_form=true)
get_form_token_input()
Definition: fonctions.php:94
vn(&$var, $default=0)
Variable nulle if $var n'est pas défini, retourne $default, sinon retourne $var.
Definition: format.php:110
affiche_formulaire_modif_contacts($id, &$frm, &$form_error_object)
FONCTIONS.
Definition: plan.php:100
get_site_id_sql_set_value($site_ids)
Retourne la valeur SQL d'un champ INT ou SET suivant que ce soit un entier ou un tableau.
Definition: fonctions.php:4747
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
$id
Definition: plan.php:21
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:20 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.