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 
15 if (!defined('IN_PEEL')) {
16  die();
17 }
18 
25 function profil_hook_admin_menu_items($params) {
26  $result['menu_items']['manage_general'][$GLOBALS['wwwroot_in_admin'] . '/modules/profil/administrer/profil.php'] = $GLOBALS["STR_ADMIN_MENU_MANAGE_PROFIL"];
27  return $result;
28 }
29 
37 {
38  /* Valeurs par défaut */
39  if(empty($frm)) {
40  $frm = array();
41  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
42  $frm['name_' . $lng] = "";
43  $frm['description_document_' . $lng] = "";
44  $frm['document_' . $lng] = "";
45  }
46  $frm['priv'] = "";
47  }
48  $frm['nouveau_mode'] = "insere";
49  $frm['id'] = "";
50  $frm['titre_bouton'] = $GLOBALS['STR_MODULE_PROFIL_ADMIN_CREATE'];
52 }
53 
62 {
63  if(empty($frm)){
64  // Pas de données venant de validation de formulaire, donc on charge le contenu de la base de données
65  /* Charge les informations du produit */
66  $qid = query("SELECT *
67  FROM peel_profil
68  WHERE id = " . intval($id) . " AND " . get_filter_site_cond('profil', null, true) . "");
69  $frm = fetch_assoc($qid);
70  }
71  $frm['id'] = $id;
72  $frm["nouveau_mode"] = "maj";
73  $frm["titre_bouton"] = $GLOBALS['STR_ADMIN_FORM_SAVE_CHANGES'];
75 }
76 
84 {
85  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/profilAdmin_formulaire_profil.tpl');
86  $tpl->assign('action', get_current_url(false) . '?start=0');
87  $tpl->assign('mode', $frm["nouveau_mode"]);
88  $tpl->assign('id', intval($frm['id']));
89 
90  $tpl_langs = array();
91  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
92  $tpl_langs[] = array('lng' => $lng,
93  'name' => $frm['name_' . $lng],
94  'description_document' => vb($frm['description_document_' . $lng]),
95  'document' => get_uploaded_file_infos('document_' . $lng, vb($frm['document_' . $lng]), get_current_url(false) . '?mode=supprfile&id=' . vb($frm['id']) . '&file=document_' . $lng)
96  );
97  }
98  $tpl->assign('langs', $tpl_langs);
99 
100  $tpl->assign('site_id_select_options', get_site_id_select_options(vb($frm['site_id'])));
101  $tpl->assign('priv', $frm["priv"]);
102  $tpl->assign('document_delete_icon_src', $GLOBALS['administrer_url'] . '/images/b_drop.png');
103  $tpl->assign('titre_bouton', $frm["titre_bouton"]);
104  $tpl->assign('STR_ADMIN_WEBSITE', $GLOBALS['STR_ADMIN_WEBSITE']);
105  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
106  $tpl->assign('STR_MODULE_PROFIL_ADMIN_TITLE', $GLOBALS['STR_MODULE_PROFIL_ADMIN_TITLE']);
107  $tpl->assign('STR_MODULE_PROFIL_ADMIN_EXPLAIN', $GLOBALS['STR_MODULE_PROFIL_ADMIN_EXPLAIN']);
108  $tpl->assign('STR_ADMIN_LANGUAGES_SECTION_HEADER', $GLOBALS['STR_ADMIN_LANGUAGES_SECTION_HEADER']);
109  $tpl->assign('STR_ADMIN_NAME', $GLOBALS['STR_ADMIN_NAME']);
110  $tpl->assign('STR_ADMIN_DESCRIPTION', $GLOBALS['STR_ADMIN_DESCRIPTION']);
111  $tpl->assign('STR_MODULE_PROFIL_ADMIN_DESCRIPTION_EXPLAIN', $GLOBALS['STR_MODULE_PROFIL_ADMIN_DESCRIPTION_EXPLAIN']);
112  $tpl->assign('STR_MODULE_PROFIL_ADMIN_UPLOAD_DOCUMENT', $GLOBALS['STR_MODULE_PROFIL_ADMIN_UPLOAD_DOCUMENT']);
113  $tpl->assign('STR_FILE', $GLOBALS['STR_FILE']);
114  $tpl->assign('STR_ADMIN_FILE_NAME', $GLOBALS['STR_ADMIN_FILE_NAME']);
115  $tpl->assign('STR_MODULE_PROFIL_ADMIN_ABBREVIATE', $GLOBALS['STR_MODULE_PROFIL_ADMIN_ABBREVIATE']);
116  $tpl->assign('STR_DELETE_THIS_FILE', $GLOBALS['STR_DELETE_THIS_FILE']);
117  echo $tpl->fetch();
118 }
119 
126 function insere_profil(&$frm)
127 {
128  $sql = "INSERT INTO peel_profil (
129  priv
130  , site_id";
131  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
132  $sql .= "
133  , name_" . $lng."
134  , document_" . $lng."
135  , description_document_" . $lng."
136  ";
137  }
138  $sql .= "
139  ) VALUES (
140  '" . nohtml_real_escape_string($frm['priv']) . "'
142  ";
143  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
144  $sql .= "
145  , '" . nohtml_real_escape_string(vb($frm['name_' . $lng])) . "'
146  , '" . nohtml_real_escape_string(vb($frm['document_' . $lng])) . "'
147  , '" . real_escape_string(vb($frm['description_document_' . $lng])) . "'
148  ";
149  }
150  $sql .= "
151  )";
152  $qid = query($sql);
153 }
154 
162 function maj_profil($id, &$frm)
163 {
164  $sql = "UPDATE peel_profil SET
165  priv = '" . nohtml_real_escape_string($frm['priv']) . "'
166  , site_id = '" . nohtml_real_escape_string(get_site_id_sql_set_value($frm['site_id'])) . "'
167  ";
168  foreach ($GLOBALS['admin_lang_codes'] as $lng) {
169  $sql .= "
170  , name_" . $lng." = '" . nohtml_real_escape_string($frm['name_' . $lng]) . "'
171  , document_" . $lng." = '" . nohtml_real_escape_string(vb($frm['document_' . $lng])) . "'
172  , description_document_" . $lng." = '" . real_escape_string(vb($frm['description_document_' . $lng])) . "'
173  ";
174  }
175  $sql .= "
176  WHERE id = '" . intval($id) . "'";
177  query($sql);
178 }
179 
187 {
188 
189  $tpl = $GLOBALS['tplEngine']->createTemplate('modules/profilAdmin_liste.tpl');
190  $tpl->assign('add_src', $GLOBALS['administrer_url'] . '/images/add.png');
191  $tpl->assign('add_href', get_current_url(false) . '?mode=ajout');
192  $tpl->assign('edit_src', $GLOBALS['administrer_url'] . '/images/b_edit.png');
193 
194  $result = query("SELECT id, name_".$_SESSION['session_langue']." AS name, priv, site_id
195  FROM peel_profil
196  WHERE " . get_filter_site_cond('profil', null, true) . "
197  ORDER BY name");
198  if (!(num_rows($result) == 0)) {
199  $tpl_results = array();
200  $i = 0;
201  while ($ligne = fetch_assoc($result)) {
202  $tpl_results[] = array(
203  'tr_rollover' => tr_rollover($i, true),
204  'edit_href' => get_current_url(false) . '?mode=modif&id=' . $ligne['id'],
205  'name' => $ligne['name'],
206  'priv' => $ligne['priv'],
207  'site_name' => get_site_name($ligne['site_id'])
208  );
209  $i++;
210  }
211  $tpl->assign('results', $tpl_results);
212  }
213  $tpl->assign('STR_ADMIN_WEBSITE', $GLOBALS['STR_ADMIN_WEBSITE']);
214  $tpl->assign('STR_BEFORE_TWO_POINTS', $GLOBALS['STR_BEFORE_TWO_POINTS']);
215  $tpl->assign('STR_MODULE_PROFIL_ADMIN_TITLE', $GLOBALS['STR_MODULE_PROFIL_ADMIN_TITLE']);
216  $tpl->assign('STR_MODULE_PROFIL_ADMIN_CREATE', $GLOBALS['STR_MODULE_PROFIL_ADMIN_CREATE']);
217  $tpl->assign('STR_MODULE_PROFIL_ADMIN_LIST_EXPLAIN', $GLOBALS['STR_MODULE_PROFIL_ADMIN_LIST_EXPLAIN']);
218  $tpl->assign('STR_ADMIN_ACTION', $GLOBALS['STR_ADMIN_ACTION']);
219  $tpl->assign('STR_ADMIN_PROFIL', $GLOBALS["STR_ADMIN_PROFIL"]);
220  $tpl->assign('STR_MODULE_PROFIL_ADMIN_ABBREVIATE', $GLOBALS['STR_MODULE_PROFIL_ADMIN_ABBREVIATE']);
221  $tpl->assign('STR_MODULE_PROFIL_ADMIN_UPDATE', $GLOBALS['STR_MODULE_PROFIL_ADMIN_UPDATE']);
222  $tpl->assign('STR_MODULE_PROFIL_ADMIN_NOTHING_FOUND', $GLOBALS['STR_MODULE_PROFIL_ADMIN_NOTHING_FOUND']);
223  echo $tpl->fetch();
224 }
225 
233 function supprime_fichier_profil($id, $file) {
234  if(String::substr($file, 0, String::strlen('document_'))=='document_') {
235  $sql = "SELECT " . word_real_escape_string($file) . "
236  FROM peel_profil
237  WHERE id='" . intval($id) . "' AND " . get_filter_site_cond('profil', null, true) . "";
238  $res = query($sql);
239  if ($file_infos = fetch_assoc($res)) {
240  query("UPDATE peel_profil
241  SET `" . word_real_escape_string($file) . "`=''
242  WHERE id='" . intval($id) . "' AND " . get_filter_site_cond('profil', null, true));
243  }
244  }
245  if (!empty($file_infos) && delete_uploaded_file_and_thumbs($file_infos[$file])) {
246  echo $GLOBALS['tplEngine']->createTemplate('global_success.tpl', array('message' => sprintf($GLOBALS['STR_ADMIN_RUBRIQUES_MSG_DELETED_OK'], $file_infos[$file])))->fetch();
247  }
248 }
249 
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
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
insere_profil(&$frm)
ajoute le profil dans la table profil
Definition: fonctions.php:126
get_current_url($with_get=true, $get_short_url=false, $take_away_get_args_array=null)
get_current_url()
Definition: fonctions.php:1743
$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.
word_real_escape_string($value)
Applique real_escape_string dans le cas où on n'insère qu'un seul mot, de moins de 30 caractères...
Definition: database.php:424
static strlen($string)
Returns the length of the given string.
Definition: String.php:36
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
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
$start
Definition: attributs.php:22
real_escape_string($value)
real_escape_string()
Definition: database.php:374
affiche_formulaire_profil(&$frm)
affiche_formulaire_profil()
Definition: fonctions.php:83
affiche_formulaire_modif_profil($id, &$frm)
Affiche le formulaire de modification pour le profil sélectionné
Definition: fonctions.php:61
affiche_formulaire_ajout_profil(&$frm)
Affiche un formulaire vierge pour ajouter un profil.
Definition: fonctions.php:36
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
get_uploaded_file_infos($field_name, $file, $delete_url, $logo_width=100, $logo_height=100)
Remplit un tableau d'informations pour le template d'upload HTML.
Definition: fonctions.php:3601
num_rows($query_result)
num_rows()
Definition: database.php:321
delete_uploaded_file_and_thumbs($filename)
delete_uploaded_file_and_thumbs()
Definition: fonctions.php:3417
supprime_fichier_profil($id, $file)
Supprime le fichier lié au produit spécifié par $id, au nom de file.
Definition: fonctions.php:233
if(!defined('IN_PEEL')) profil_hook_admin_menu_items($params)
Renvoie les éléments de menu affichables.
Definition: fonctions.php:25
fetch_assoc($query_result)
fetch_assoc()
Definition: database.php:283
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
$id
Definition: articles.php:22
static substr($string, $start, $length=null)
Returns the portion of string specified by the start and length parameters.
Definition: String.php:112
maj_profil($id, &$frm)
Met à jour le profil $id avec de nouvelles valeurs.
Definition: fonctions.php:162
affiche_liste_profil($start)
affiche_liste_profil()
Definition: fonctions.php:186
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:31:02 - Peel ecommerce is a product of Agence web Advisto SAS. All rights reserved.