Acces aux données de ma variable $CONFIG_INVITATION [Réglé]
Problème d'acces aux données
Créations de Modules
wmkheops Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre wmkheops
- Inscrit le : 11/06/2008
Tout fonctionne correctement sauf que lorsque je veux accéder aux données des propriétés de mon $CONFIG_INVITATION les dites données renvoyées sont toujours nulles
Voici la partie de code SQL de l'installation concernée :
Code SQL :
INSERT INTO `phpboost_configs` (`name`, `value`) VALUES ('invitation', 'a:5:{s:18:"invitation_subject";s:47:"%user% vous invite a rejoindre le site : %site%";s:14:"invitation_msg";s:61:"Felicitations, %user% vous a invite a nous rejoindre : %site%";s:6:"limite";i:10;s:2:"id";i:1;s:11:"active_dups";i:0;}');
Et voila mon fichier admin_invitation.php
Caché :
Code PHP :
<?php /*################################################## * invitation_mini.php * ------------------- * begin : June 13, 2008 * copyright : (C) 2008 J.Delauney * email : wmkheops@free.fr * * version : 0.3 ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ include_once('../includes/admin_begin.php'); include_once('../invitation/lang/' . $CONFIG['lang'] . '/invitation_' . $CONFIG['lang'] . '.php'); //Chargement de la langue du module. define('TITLE', $LANG['title_administration']); include_once('../includes/admin_header.php'); //On recupère les variables. if( !empty($_POST['valid']) ) { $config_invitation = array(); //$config_invitation['invitation_auth'] $config_invitation['invitation_subject'] = !empty($_POST['subject']) ? stripslashes(parse($_POST['subject'])) : ''; $config_invitation['invitation_msg'] = !empty($_POST['msg']) ? stripslashes(parse($_POST['msg'])) : ''; $config_invitation['id'] = !empty($_POST['iid']) ? numeric($_POST['iid']) : 1; $config_invitation['limite'] = isset($_POST['lim']) ? numeric($_POST['lim']) : 10; $config_invitation['active_dups'] = isset($_POST['activ_dups']) ? numeric($_POST['activ_dups']) : 0; $sql->query_inject("UPDATE ".PREFIX."configs SET value = '" . addslashes(serialize($config_invitation)) . "' WHERE name = 'invitation'", __LINE__, __FILE__); ###### Régénération du cache ####### $cache->generate_module_file('invitation'); header('location:' . HOST . SCRIPT); exit; } else //Sinon on rempli le formulaire { $template->set_filenames(array( 'admin_invitation' => '../templates/' . $CONFIG['theme'] . '/invitation/admin_invitation.tpl' )); //Chargement du cache $cache->load_file('invitation'); $template->assign_vars(array( 'V_SUBJECT' => !empty($CONFIG_INVITATION['invitation_subject']) ? ($CONFIG_INVITATION['invitation_subject']) : '', 'V_MESSAGE' => !empty($CONFIG_INVITATION['invitation_msg']) ? ($CONFIG_INVITATION['invitation_msg']) : '', 'V_LIM' => !empty($CONFIG_INVITATION['limite']) ? $CONFIG_INVITATION['limite'] : '10', 'DUPS_ENABLED' => ($CONFIG_INVITATION['active_dups'] == '1') ? 'checked="checked"' : '', 'DUPS_DISABLED' => ($CONFIG_INVITATION['active_dups'] == '0') ? 'checked="checked"' : '', 'L_MESSAGE' => $LANG['message'], 'L_SUBJECT' => $LANG['subject'], 'L_SENDLIMIT' => $LANG['send_limit'], 'L_ALLOWDUPS' => $LANG['allow_duplicates'], 'L_YES' => $LANG['yes'], 'L_NO' => $LANG['no'], 'L_SUBMIT' => $LANG['send_button'], 'L_RESET' => $LANG['reset'], 'L_TITLE' => $LANG['title_administration'], 'L_CONFIG_INVITATION' => $LANG['configuration_invitation'], 'L_MODULE_MANAGEMENT' => $LANG['invitation_management'], 'L_QUICKHELP' => $LANG['quick_help_tags'], 'L_USERDISPLAY' => $LANG['user_display'], 'L_SITEDISPLAY' => $LANG['site_display'] )); $template->pparse('admin_invitation'); // traitement du modele } include_once('../includes/admin_footer.php'); ?>
Nb : L'envoi des données et la mise à jour, s'effectue correctement.
et celui du mini-module :
Caché :
Code PHP :
<?php /*################################################## * invitation_mini.php * ------------------- * begin : June 13, 2008 * copyright : (C) 2008 J.Delauney * email : wmkheops@free.fr * * version : 0.3 ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ if( defined('PHP_BOOST') !== true ) exit; //Chargement du template $template->set_filenames(array( 'invitation_mini' => '../templates/' . $CONFIG['theme'] . '/invitation/invitation_mini.tpl' )); //Chargement de la langue du module. @include_once('../invitation/lang/' . $CONFIG['lang'] . '/invitation_' . $CONFIG['lang'] . '.php'); //Chargement du cache $cache->load_file('invitation'); global $sql; // Fonctions internes $curdate = date("Y-m-d", time() ); //+decalage gmt*60*60 $result=$sql->query("SELECT count(id) as cnt from ".PREFIX."invitation where user_id = '".$sender_id."' and date_sent = '" . $curdate . "'", __LINE__, __FILE__); $tup = $result; $sql->close($result); $lims =$CONFIG_INVITATION['limite'];// $result; $invites =$lims;// -$tup; //nombre d'invitation valable //Assignation des variables internes pour le template $template->assign_vars(array( 'L_TITLE' => $LANG['title_Invitation'], 'L_CHECK' => $LANG['check_invites'], 'L_SENDBUTTON' => $LANG['send_button'], 'L_SENDTO' => $LANG['send_invites_to'], 'L_INVITELEFT' => str_replace("%nb_invites%", $invites, $LANG["invites_left"]), 'F_ACTION' =>'../invitation/invitation'.transid('.php', '','') )); //Affichage du module $template->pparse('invitation_mini'); ?>
Si vous avez des suggestion d'optimisation je suis preneur
Merci
CrowkaiT Membre non connecté
-
Modérateur
- Voir le profil du membre CrowkaiT
- Inscrit le : 17/06/2005
- Site internet
- Groupes :
-
Equipe Historique
Le $sql->close($result); aussi, il n'est utilisé qu'après l'utilisation de la méthode sql_while
Pourrais-tu nous montrer le contenu du fichier nomdetonmodule_cache.php. Si tu ne l'as pas crée c'est normal que ça ne marche pas, car c'est avec ce fichier que le cache est généré. De plus le config.ini de ton module doit avec la valeur à 1 pour la clé cache (cache=1).
Pas de support par messages privés! Pensez à mettre vos messages en réglé en cliquant sur le bouton réglé!
wmkheops Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre wmkheops
- Inscrit le : 11/06/2008
Citation :
Le global $sql est en trop.
Le $sql->close($result); aussi, il n'est utilisé qu'après l'utilisation de la méthode sql_while
Le $sql->close($result); aussi, il n'est utilisé qu'après l'utilisation de la méthode sql_while
Ok.
et voila mon fichier cache
Caché :
[code=text][/code]Code PHP :
<?php /*################################################## * invitation_cache.php * ------------------- * begin : June 13, 2008 * copyright : (C) 2008 J.Delauney * email : wmkheops@free.fr * * version : 0.3 ################################################### * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * ###################################################*/ if( defined('PHP_BOOST') !== true) exit; //Configuration des news function generate_module_file_invitation() { global $sql; $invitation_config = 'global $CONFIG_INVITATION;' . "n"; //Récupération du tableau linéarisé dans la bdd. $CONFIG_NEWS = unserialize($sql->query("SELECT value FROM ".PREFIX."configs WHERE name = 'invitation'", __LINE__, __FILE__)); foreach($CONFIG_INVITATION as $key => $value) $invitation_config .= '$CONFIG_INVITATION['' . $key . ''] = ' . var_export($value, true) . ';' . "n"; return $invitation_config; } ?>
et le config.ini
Caché :
name="Invitation"
author="wmKheops"
author_mail="wmkheops@free.fr"
author_link="http://www.phpboost.com"
version=0.3
info="Ce module vous procure un système d'invitation, permettant aux utilisateurs de votre site de vous recommander à un ami."
date="13/06/08"
compatibility=2.0
admin=1
css=0
cache=1
sql_table=1
starteable_page="invitation.php"
moderation_panel=0
config=1
com=invitation
mini_module=1
url_rewrite=""
author="wmKheops"
author_mail="wmkheops@free.fr"
author_link="http://www.phpboost.com"
version=0.3
info="Ce module vous procure un système d'invitation, permettant aux utilisateurs de votre site de vous recommander à un ami."
date="13/06/08"
compatibility=2.0
admin=1
css=0
cache=1
sql_table=1
starteable_page="invitation.php"
moderation_panel=0
config=1
com=invitation
mini_module=1
url_rewrite=""
wmkheops Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre wmkheops
- Inscrit le : 11/06/2008
Quel imbecile !!!
Merci
wmkheops Membre non connecté
Booster Bazooka
-
Booster Bazooka
- Voir le profil du membre wmkheops
- Inscrit le : 11/06/2008
Merci, a toute
CrowkaiT Membre non connecté
-
Modérateur
- Voir le profil du membre CrowkaiT
- Inscrit le : 17/06/2005
- Site internet
- Groupes :
-
Equipe Historique
Pas de support par messages privés! Pensez à mettre vos messages en réglé en cliquant sur le bouton réglé!
Répondre
Vous n'êtes pas autorisé à écrire dans cette catégorie