http://www.gaudry.be/���dimanche 27 mai 2012 ������������L'infobrol




  • Accueil
  • Sommaire
  • Rechercher
  • Contact
  • Forum
  • Niouzes
  • Astuces
  • NewsBrol

Pr�c�denteSuivante

�

PhpBB forums : Groupe de news

Pourquoi un groupe de news ? Simplement pour profiter des options ofertes par phpBB pour pouvoir informer les membres qui le désirent des nouveautés sur le site.
Une option dans le profil des membres est ajoutée, qui leur permet de déterminer à tout moment s'ils désirent recevoir les infos ou non.
Le fait de sélectionner cette option les ajoute automatiquement dans un groupe que nous allons nommer "News", ce qui nous permettra d'envoyer via l'administration phpBB un message à tout les membres de ce groupe.
Tout nouveau membre est par défaut ajouté dans ce groupe.

Suite à la demande de Doctor Z, j'ai tenté de retrouver les modifications que j'avais apporté au forum pour intégrer ces fonctions, et je vous les livre telles quelles.

Remarque :

Ne travaillant pas avec les noms de champs par défaut dans la base de données, je les ai remplacés ici par le préfixe prévu (phpbb_).
Si vous êtes dans le même cas que moi, vous pouvez indiquer ici votre préfixe, et la page sera adaptée à vos besoins.

 



Haut de la page

 

La structure

La première chose à faire est de créer un nouveau groupe qui acceuillera les membres désireux d'être informés des nouvelles du site. Cette opération peut se faire par l'administration phpBB.

Ensuite, nous devons déterminer l'identifiant du nouveau groupe par cette requête :

phpMyAdmin
Accueil

Infobrol
Afficher: (XX Enregistrements) phpbb_auth_access
Afficher: (XX Enregistrements) phpbb_banlist
Afficher: (XX Enregistrements) phpbb_categories
Afficher: (XX Enregistrements) phpbb_config
Afficher: (XX Enregistrements) phpbb_confirm
Afficher: (XX Enregistrements) phpbb_disallow
Afficher: (XX Enregistrements) phpbb_forum_prune
Afficher: (XX Enregistrements) phpbb_forums
Afficher: (XX Enregistrements) phpbb_groups
Afficher: (XX Enregistrements) phpbb_posts
Afficher: (XX Enregistrements) phpbb_posts_text
Afficher: (XX Enregistrements) phpbb_privmsgs
Afficher: (XX Enregistrements) phpbb_privmsgs_text
Afficher: (XX Enregistrements) phpbb_ranks
Afficher: (XX Enregistrements) phpbb_search_results
Afficher: (XX Enregistrements) phpbb_search_wordlist
Afficher: (XX Enregistrements) phpbb_search_wordmatch
Afficher: (XX Enregistrements) phpbb_sessions
Afficher: (XX Enregistrements) phpbb_smilies
Afficher: (XX Enregistrements) phpbb_themes
Afficher: (XX Enregistrements) phpbb_themes_name
Afficher: (XX Enregistrements) phpbb_topics
Afficher: (XX Enregistrements) phpbb_topics_watch
Afficher: (XX Enregistrements) phpbb_user_group
Afficher: (XX Enregistrements) phpbb_users
Afficher: (XX Enregistrements) phpbb_vote_desc
Afficher: (XX Enregistrements) phpbb_vote_results
Afficher: (XX Enregistrements) phpbb_vote_voters
Afficher: (XX Enregistrements) phpbb_words

Base de données Infobrol - Table phpbb_groups sur le serveur localhost


 Structure Afficher SQL Sélectionner Insérer Exporter Opérations Vider Supprimer 

Affichage des enregistrements 0 - 1 (1 total, traitement: 0.0008 sec.)
requête SQL : [Modifier]  [Expliquer SQL]  [Créer source PHP]
SELECT`group_id`
FROM`phpbb_groups`
  WHERE`group_id `=  'News'

   
ligne(s) à partir de l'enregistrement n°
en mode et répéter les en-têtes à chaque groupe de
   
Textes réduits group_id
ModifierSupprimer324

   
ligne(s) à partir de l'enregistrement n°
en mode et répéter les en-têtes à chaque groupe de
   

Insérer un nouvel enregistrement
Version imprimable

Exporter

Nous devons ensuite ajouter un champ user_infobrol_upd dans la table phpbb_users

Base de données Infobrol - Table phpbb_users sur le serveur localhost

ChampType
[Documentation]
Taille/Valeurs*AttributsNullD�faut**Extra


*  Les différentes valeurs des champs de type enum/set sont à spécifier sous la forme 'a','b','c'...
Pour utiliser un caractère "\" ou "'" dans l'une de ces valeurs, faites-le précéder du caractère d'échappement "\" (par exemple '\\xyz' ou 'a\'b').
**  Pour les valeurs par défaut, veuillez n'entrer qu'une seule valeur, sans caractère d'échappement ou apostrophes, sous la forme: a

[Documentation]

 



Haut de la page

 

Le code

J'ai repris l'idée des mods, mais tant qu'à présent cela ne reste qu'une manière de vous présenter les différents codes. Plus tard, il est possible que je réalise un mod.

 

Code php (mod_news.php):
Cliquez ici pour afficher/masquer le code
  1. <?php
  2. ########################################################
  3. ##
  4. ## MOD Title: Newsgroup
  5. ## MOD Version: 0.0.2 ;-)
  6. ## PhpBB Version : 2.0.8
  7. ## MOD Date : 11.12.2003
  8. ## Auteur : Steph [>Infobrol<] - http://www.gaudry.be
  9. ## Démonstration : http://www.gaudry.be/f/index.php
  10. ##
  11. ## Difficulté d'installation : Moyen
  12. ## Temps d'installation : 20 Minutes
  13. ##
  14. ## Fichier a editer : 8
  15. ##
  16. ## - config.php
  17. ## - admin/admin_users.php
  18. ## - includes/usercp_register.php
  19. ## - includes/emailer.php
  20. ## - templates/nom_du template/profile_add_body.tpl
  21. ## - language/lang_english/lang_main.php
  22. ## - language/lang_french/lang_main.php
  23. ## - language/lang_english/admin_send_email.tpl
  24. ## - language/lang_french/admin_send_email.tpl
  25. ##
  26. ## Fichiers inclus : 0
  27. ##
  28. ## Historique :
  29. ## - 30 Mars 2004 : adaptation du mail html à la version phpBB 2.08
  30. ##
  31. ########################################################
  32.  
  33. #
  34. #-----[ OUVRIR ]----------------------------------------
  35. #
  36.  
  37. config.php
  38.  
  39. #
  40. #-----[ TROUVER ]----------------------------------------
  41. #
  42.  
  43. define('PHPBB_INSTALLED', true);
  44.  
  45. #
  46. #-----[ AJOUTER APRES ]----------------------------------
  47. #
  48.  
  49. $groupe_news_no = 324;
  50.  
  51. /*
  52. REMARQUE :
  53. 324 est le numéro du groupe dans la table phpbb_groups.
  54. Nous pouvons le trouver par cette requête :
  55. SELECT `group_id` FROM `phpbb_groups` WHERE `group_name` = 'News'
  56. */
  57.  
  58.  
  59. #
  60. #-----[ OUVRIR ]----------------------------------------
  61. #
  62.  
  63. admin/admin_users.php
  64.  
  65. #
  66. #-----[ TROUVER ]----------------------------------------
  67. #
  68.  
  69. $viewemail = ( isset( $HTTP_POST_VARS['viewemail']) ) ? ( ( $HTTP_POST_VARS['viewemail'] ) ? TRUE : 0 ) : 0;
  70.  
  71. #
  72. #-----[ AJOUTER AVANT ]----------------------------------
  73. #
  74.  
  75. $infobrol_upd = ( isset( $HTTP_POST_VARS['infobrol_upd']) ) ? ( ( $HTTP_POST_VARS['infobrol_upd'] ) ? TRUE : 0 ) : 0;
  76.  
  77. #
  78. #-----[ TROUVER ]----------------------------------------
  79. #
  80.  
  81. SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) . "', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_viewemail = $viewemail,
  82.  
  83. #
  84. #-----[ AJOUTER APRES ]----------------------------------
  85. #
  86.  
  87. user_infobrol_upd = $infobrol_upd,
  88.  
  89. #
  90. #-----[ TROUVER ]----------------------------------------
  91. #
  92.  
  93. $viewemail = $this_userdata['user_viewemail'];
  94.  
  95. #
  96. #-----[ AJOUTER AVANT ]----------------------------------
  97. #
  98.  
  99. $infobrol_upd = $this_userdata['infobrol_upd'];
  100.  
  101. #
  102. #-----[ TROUVER ]----------------------------------------
  103. #
  104.  
  105. $s_hidden_fields .= '<input type="hidden" name="viewemail" value="' . $viewemail . '" />';
  106.  
  107. #
  108. #-----[ AJOUTER AVANT ]----------------------------------
  109. #
  110.  
  111. $s_hidden_fields .= '<input type="hidden" name="infobrol_upd" value="' . $infobrol_upd . '" />';
  112.  
  113.  
  114. #
  115. #-----[ TROUVER ]----------------------------------------
  116. #
  117.  
  118. 'VIEW_EMAIL_YES' => ($viewemail) ? 'checked="checked"' : '',
  119.  
  120. #
  121. #-----[ AJOUTER AVANT ]----------------------------------
  122. #
  123.  
  124. 'INFOBROL_UPD_YES' => ($infobrol_upd) ? 'checked="checked"' : '',
  125. 'INFOBROL_UPD_NO' => (!$infobrol_upd) ? 'checked="checked"' : '',
  126.  
  127. #
  128. #-----[ TROUVER ]----------------------------------------
  129. #
  130.  
  131. 'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'],
  132. #
  133. #-----[ AJOUTER AVANT ]----------------------------------
  134. #
  135.  
  136. 'L_INFOBROL_UPD' => $lang['Infobrol_upd'],
  137.  
  138. #
  139. #-----[ OUVRIR ]----------------------------------------
  140. #
  141.  
  142. includes/usercp_register.php
  143.  
  144. #
  145. #-----[ TROUVER ]----------------------------------------
  146. #
  147.  
  148. $viewemail = ( isset($HTTP_POST_VARS['viewemail']) ) ? ( ($HTTP_POST_VARS['viewemail']) ? TRUE : 0 ) : 0;
  149. #
  150. #-----[ AJOUTER AVANT ]----------------------------------
  151. #
  152.  
  153. $infobrol_upd = ( isset($HTTP_POST_VARS['infobrol_upd']) ) ? ( ($HTTP_POST_VARS['infobrol_upd']) ? TRUE : 0 ) : TRUE;
  154.  
  155. #
  156. #-----[ TROUVER ]----------------------------------------
  157. #
  158.  
  159. SET " . $username_sql . $passwd_sql . "user_email = '" . str_replace("\'", "''", $email) ."', user_icq = '" . str_replace("\'", "''", $icq) . "', user_website = '" . str_replace("\'", "''", $website) . "', user_occ = '" . str_replace("\'", "''", $occupation) . "', user_from = '" . str_replace("\'", "''", $location) . "', user_interests = '" . str_replace("\'", "''", $interests) . "', user_sig = '" . str_replace("\'", "''", $signature) . "', user_sig_bbcode_uid = '$signature_bbcode_uid', user_viewemail = $viewemail,
  160.  
  161. #
  162. #-----[ AJOUTER APRES ]----------------------------------
  163. #
  164.  
  165. user_infobrol_upd = $infobrol_upd,
  166.  
  167. #
  168. #-----[ TROUVER ]----------------------------------------
  169. #
  170.  
  171. if ( !$user_active )
  172. {
  173. //
  174. // The users account has been deactivated, send them an email with a new activation key
  175. //
  176. #
  177. #-----[ AJOUTER AVANT ]----------------------------------
  178. #
  179.  
  180. // infobrol_upd : entrée ou retrait du groupe de news
  181.  
  182. if ($infobrol_upd==1)
  183. {
  184. $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) VALUES (".$groupe_news_no.", $user_id, 0)";
  185. if ( !($db->sql_query($sql)) )
  186. {
  187. message_die(GENERAL_ERROR, 'Erreur : impossible de vous ajouter au groupe news ', '', __LINE__, __FILE__, $sql);
  188. }
  189. }
  190. else
  191. {
  192. $sql = "DELETE FROM " . USER_GROUP_TABLE . " WHERE group_id = ".$groupe_news_no." AND user_id = $user_id";
  193. if ( !($db->sql_query($sql)) )
  194. {
  195. message_die(GENERAL_ERROR, 'Erreur : impossible de modifier le groupe news ', '', __LINE__, __FILE__, $sql);
  196. }
  197. }
  198. // fin infobrol_upd
  199.  
  200. #
  201. #-----[ TROUVER ]----------------------------------------
  202. #
  203.  
  204. INSERT INTO " . USERS_TABLE . " (user_id, username, user_regdate, user_password, user_email, user_icq, user_website, user_occ, user_from, user_interests, user_sig, user_sig_bbcode_uid, user_avatar, user_avatar_type, user_viewemail,
  205.  
  206. #
  207. #-----[ AJOUTER APRES ]----------------------------------
  208. #
  209.  
  210. user_infobrol_upd,
  211.  
  212. #
  213. #-----[ TROUVER ]----------------------------------------
  214. #
  215.  
  216. VALUES ($user_id, '" . str_replace("\'", "''", $username) . "', " . time() . ", '" . str_replace("\'", "''", $new_password) . "', '" . str_replace("\'", "''", $email) . "', '" . str_replace("\'", "''", $icq) . "', '" . str_replace("\'", "''", $website) . "', '" . str_replace("\'", "''", $occupation) . "', '" . str_replace("\'", "''", $location) . "', '" . str_replace("\'", "''", $interests) . "', '" . str_replace("\'", "''", $signature) . "', '$signature_bbcode_uid', $avatar_sql, $viewemail,
  217.  
  218. #
  219. #-----[ AJOUTER APRES ]----------------------------------
  220. #
  221.  
  222. $infobrol_upd,
  223.  
  224. #
  225. #-----[ TROUVER ]----------------------------------------
  226. #
  227.  
  228. include($phpbb_root_path . 'includes/emailer.'.$phpEx);
  229.  
  230. #
  231. #-----[ AJOUTER AVANT ]----------------------------------
  232. #
  233.  
  234. // infobrol_upd : ajout automatique dans le groupe
  235. if ($infobrol_upd==1)
  236. {
  237. $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) VALUES (".$groupe_news_no.", $user_id, 0)";
  238. if ( !($db->sql_query($sql)) )
  239. {
  240. message_die(GENERAL_ERROR, 'Erreur : impossible de rentrer automatiquement dans le groupe news ', '', __LINE__, __FILE__, $sql);
  241. }
  242. }
  243. // fin infobrol_upd
  244.  
  245. #
  246. #-----[ TROUVER ]----------------------------------------
  247. #
  248.  
  249. $viewemail = $userdata['user_viewemail'];
  250.  
  251. #
  252. #-----[ AJOUTER AVANT ]----------------------------------
  253. #
  254.  
  255. $infobrol_upd = $userdata['user_infobrol_upd'];
  256.  
  257. #
  258. #-----[ TROUVER ]----------------------------------
  259. #
  260.  
  261. display_avatar_gallery($mode, $avatar_category, $user_id, $email, $current_email, $coppa, $username, $email, &$new_password, &$cur_password, $password_confirm, $icq, $aim, $msn, $yim, $website, $location, $occupation, $interests, $signature, $viewemail,
  262.  
  263. #
  264. #-----[ AJOUTER APRES ]----------------------------------
  265. #
  266.  
  267. $infobrol_upd,
  268.  
  269. #
  270. #-----[ TROUVER ]----------------------------------
  271. #
  272.  
  273. 'VIEW_EMAIL_YES' => ( $viewemail ) ? 'checked="checked"' : '',
  274.  
  275. #
  276. #-----[ AJOUTER AVANT ]----------------------------------
  277. #
  278.  
  279. 'INFOBROL_UPD_YES' => ( $infobrol_upd ) ? 'checked="checked"' : '',
  280. 'INFOBROL_UPD_NO' => ( !$infobrol_upd ) ? 'checked="checked"' : '',
  281.  
  282. #
  283. #-----[ TROUVER ]----------------------------------
  284. #
  285.  
  286. 'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'],
  287.  
  288. #
  289. #-----[ AJOUTER AVANT ]----------------------------------
  290. #
  291.  
  292. 'L_INFOBROL_UPD' => $lang['Infobrol_upd'],
  293.  
  294. #
  295. #-----[ OUVRIR ]----------------------------------------
  296. #
  297.  
  298. language/lang_english/lang_main.php
  299.  
  300. #
  301. #-----[ TROUVER ]----------------------------------
  302. #
  303.  
  304. $lang['Public_view_email'] = 'Always show my e-mail address';
  305.  
  306. #
  307. #-----[ AJOUTER AVANT ]----------------------------------
  308. #
  309.  
  310. $lang['Infobrol_upd'] = 'Notify (e-mail) on news from infobrol';
  311.  
  312. #
  313. #-----[ Début mail html ]-------------------------------
  314. #-----[ OUVRIR ]----------------------------------------
  315. #
  316.  
  317. includes/emailer.php
  318.  
  319. #
  320. #-----[ TROUVER ]----------------------------------
  321. #
  322.  
  323. // Build header
  324. $this->extra_headers = (($this->reply_to != '') ? "Reply-to: $this->reply_to\n" : '') . (($this->from != '') ? "From: $this->from\n" : "From: " . $board_config['board_email'] . "\n") . "Return-Path: " . $board_config['board_email'] . "\nMessage-ID: <" . md5(uniqid(time())) . "@" . $board_config['server_name'] . ">\nMIME-Version: 1.0\nContent-type: text/plain; charset=" . $this->encoding . "\nContent-transfer-encoding: 8bit\nDate: " . date('r', time()) . "\nX-Priority: 3\nX-MSMail-Priority: Normal\nX-Mailer: PHP\nX-MimeOLE: Produced By phpBB2\n" . $this->extra_headers . (($cc != '') ? "Cc: $cc\n" : '') . (($bcc != '') ? "Bcc: $bcc\n" : '');
  325.  
  326. #
  327. #-----[ REMPLACER ]----------------------------------------
  328. #
  329.  
  330. Content-type: text/plain;
  331.  
  332. #
  333. #-----[ PAR ]----------------------------------------
  334. #
  335.  
  336. Content-type: text/html;
  337.  
  338. #
  339. #-----[ OUVRIR ]----------------------------------------
  340. #
  341.  
  342. language/lang_french/email/admin_send_email.tpl
  343. language/lang_english/email/admin_send_email.tpl
  344.  
  345. #
  346. #-----[ REMPLACER le contenu par un contenu html]--------
  347. #-----[ Fin mail html ]----------------------------------
  348. #
  349.  
  350.  
  351. #
  352. #-----[ OUVRIR ]----------------------------------------
  353. #
  354.  
  355. language/lang_french/lang_main.php
  356.  
  357. #
  358. #-----[ TROUVER ]----------------------------------
  359. #
  360.  
  361. $lang['Public_view_email'] = 'Toujours montrer son adresse e-mail';
  362.  
  363. #
  364. #-----[ AJOUTER AVANT ]----------------------------------
  365. #
  366.  
  367. $lang['Infobrol_upd'] = 'M\'avertir par e-mail des nouvelles du site (nouvelles pages, etc.)';
  368.  
  369. #
  370. #-----[ OUVRIR ]----------------------------------------
  371. #
  372.  
  373. templates/subSilver/profile_add_body.tpl
  374.  
  375. #
  376. #-----[ TROUVER ]----------------------------------
  377. #
  378.  
  379. <tr>
  380. <th class="thSides" colspan="2" height="25" valign="middle">{L_PREFERENCES}</th>
  381. </tr>
  382.  
  383. #
  384. #-----[ AJOUTER APRES ]----------------------------------
  385. #
  386.  
  387. <tr>
  388. <td class="row1"><span class="gen">{L_INFOBROL_UPD}:</span></td>
  389. <td class="row2">
  390. <input type="radio" name="infobrol_upd" value="1" {INFOBROL_UPD_YES} />
  391. <span class="gen">{L_YES}</span>  
  392. <input type="radio" name="infobrol_upd" value="0" {INFOBROL_UPD_NO} />
  393. <span class="gen">{L_NO}</span>
  394. </td>
  395. </tr>
  396. ?>
Retourner au début du code

Je n'ai pas encore retrouvé les modifications à apporter aux templates, vu que je ne travaille pas de la même manière que phpBB (le style est indépendant des templates, car il est géré pour l'ensemble du site).
Pour ceux qui ne peuvent attendre, il suffit de rechercher dans les templates toutes les références à l'option montrer son adresse e-mail, et d'ajouter la nouvelle option.

Pr�c�denteSuivante

�



[signaler une erreur, une fote d'ortograf, consulter ou �crire un commentaire]

� Ce document issu de l′infobrol est enregistr� sous le certificat Cyber PrInterDeposit Digital Numberection. Enregistrement IDDN n� 5329
St.Gaudry�07.01.02 : Document cr�� le 11/12/2003 (derni�re modification le 17/06/2011)
Source du document imprim� : http://www.gaudry.be/_pge/bb-modnews.php
, affich� 4 fois ce mois de mai._

Recherche :

��
  • Navigation
  • Services
  • Le site
  • Matériel informatique
  • Généralités Informatique
  • Généralités OS
  • Systèmes d'exploitation
  • UNIX - Linux
  • Windows NT
  • Windows 2000
  • Programmes
  • Office
  • VBA - VBS
  • Généralités réseau
  • Normes et standards
  • Modèle OSI
  • Stat - Proba
  • Logique
  • Matrices
  • Graphes
  • Analyse
  • SGBD
  • Cryptologie
  • Compilateurs
  • Programmer
  • Programmation déclarative
  • Java
  • API Java
  • C & C++
  • C Sharp
  • Visual Studio
  • .NET
  • SGML HTML XML
  • CSS
  • Optimisation Web
  • Fun Web
  • PHP - MySQL
  • Manuel PHP
  • Le Web en vrac
    • Au tableau...
    • Protocole HTTP
    • Codes d'état HTTP
    • ASP : introduction
    • Mod News PhpBB
    • .htaccess
    • Démo htaccess
    • htaccess:apparence
  • Introduction au JavaScript
  • Objets JavaScript
  • JavaScript en vrac
  • Le brol du brol
  • Glossaire
  • Divertissement
  • �

    Apparence :

    Membres :

    Connexion

    Nouveaux :

    S'enregistrer

�

Infos :

15180 documents (?)
452 astuces.
549 niouzes.
3099 d�finitions.
1899 membres.
7463 messages.
Document g�n�r� en :
0.7998 seconde