No cache version.

Caching disabled. Default setting for this page:enabled (code DEF204)
If the display is too slow, you can disable the user mode to view the cached version.

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 sur phpbb-fr, j'ai tenté de retrouver les modifications que j'avais apporté au forum pour intégrer ces fonctions, et les voici à titre d'info pour s'en inspirer.

La structure de la DB PhpBB

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

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 InfobrolSvr


 Structure SQL Exporter Rechercher Requête 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 InfobrolSvr

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]

 

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.

Le code pour PhpBB

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.

  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<] - https://www.gaudry.be
  9. ## Démonstration : https://www.gaudry.be/forum/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.  
  56. SELECT `group_id` FROM `phpbb_groups` WHERE `group_name` = 'News'
  57. */
  58.  
  59.  
  60. #
  61. #-----[ OUVRIR ]----------------------------------------
  62. #
  63.  
  64. admin/admin_users.php
  65.  
  66. #
  67. #-----[ TROUVER ]----------------------------------------
  68. #
  69.  
  70. $viewemail = ( isset( $HTTP_POST_VARS['viewemail']) ) ? ( ( $HTTP_POST_VARS['viewemail'] ) ? TRUE : 0 ) : 0;
  71.  
  72. #
  73. #-----[ AJOUTER AVANT ]----------------------------------
  74. #
  75.  
  76. $infobrol_upd = ( isset( $HTTP_POST_VARS['infobrol_upd']) ) ? ( ( $HTTP_POST_VARS['infobrol_upd'] ) ? TRUE : 0 ) : 0;
  77.  
  78. #
  79. #-----[ TROUVER ]----------------------------------------
  80. #
  81.  
  82. 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,
  83.  
  84. #
  85. #-----[ AJOUTER APRES ]----------------------------------
  86. #
  87.  
  88. user_infobrol_upd = $infobrol_upd,
  89.  
  90. #
  91. #-----[ TROUVER ]----------------------------------------
  92. #
  93.  
  94. $viewemail = $this_userdata['user_viewemail'];
  95.  
  96. #
  97. #-----[ AJOUTER AVANT ]----------------------------------
  98. #
  99.  
  100. $infobrol_upd = $this_userdata['infobrol_upd'];
  101.  
  102. #
  103. #-----[ TROUVER ]----------------------------------------
  104. #
  105.  
  106. $s_hidden_fields .= '<input type="hidden" name="viewemail" value="' . $viewemail . '" />';
  107.  
  108. #
  109. #-----[ AJOUTER AVANT ]----------------------------------
  110. #
  111.  
  112. $s_hidden_fields .= '<input type="hidden" name="infobrol_upd" value="' . $infobrol_upd . '" />';
  113.  
  114.  
  115. #
  116. #-----[ TROUVER ]----------------------------------------
  117. #
  118.  
  119. 'VIEW_EMAIL_YES' => ($viewemail) ? 'checked="checked"' : '',
  120.  
  121. #
  122. #-----[ AJOUTER AVANT ]----------------------------------
  123. #
  124.  
  125. 'INFOBROL_UPD_YES' => ($infobrol_upd) ? 'checked="checked"' : '',
  126. 'INFOBROL_UPD_NO' => (!$infobrol_upd) ? 'checked="checked"' : '',
  127.  
  128. #
  129. #-----[ TROUVER ]----------------------------------------
  130. #
  131.  
  132. 'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'],
  133.  
  134. #
  135. #-----[ AJOUTER AVANT ]----------------------------------
  136. #
  137.  
  138. 'L_INFOBROL_UPD' => $lang['Infobrol_upd'],
  139.  
  140. #
  141. #-----[ OUVRIR ]----------------------------------------
  142. #
  143.  
  144. includes/usercp_register.php
  145.  
  146. #
  147. #-----[ TROUVER ]----------------------------------------
  148. #
  149.  
  150. $viewemail = ( isset($HTTP_POST_VARS['viewemail']) ) ? ( ($HTTP_POST_VARS['viewemail']) ? TRUE : 0 ) : 0;
  151.  
  152. #
  153. #-----[ AJOUTER AVANT ]----------------------------------
  154. #
  155.  
  156. $infobrol_upd = ( isset($HTTP_POST_VARS['infobrol_upd']) ) ? ( ($HTTP_POST_VARS['infobrol_upd']) ? TRUE : 0 ) : TRUE;
  157.  
  158. #
  159. #-----[ TROUVER ]----------------------------------------
  160. #
  161.  
  162. 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,
  163.  
  164. #
  165. #-----[ AJOUTER APRES ]----------------------------------
  166. #
  167.  
  168. user_infobrol_upd = $infobrol_upd,
  169.  
  170. #
  171. #-----[ TROUVER ]----------------------------------------
  172. #
  173.  
  174. if ( !$user_active )
  175. {
  176. //
  177. // The users account has been deactivated, send them an email with a new activation key
  178. //
  179.  
  180. #
  181. #-----[ AJOUTER AVANT ]----------------------------------
  182. #
  183.  
  184. // infobrol_upd : entrée ou retrait du groupe de news
  185.  
  186. if ($infobrol_upd==1)
  187. {
  188. $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) VALUES (".$groupe_news_no.", $user_id, 0)";
  189. if ( !($db->sql_query($sql)) )
  190. {
  191. message_die(GENERAL_ERROR, 'Erreur : impossible de vous ajouter au groupe news ', '', __LINE__, __FILE__, $sql);
  192. }
  193. }
  194. else
  195. {
  196. $sql = "DELETE FROM " . USER_GROUP_TABLE . " WHERE group_id = ".$groupe_news_no." AND user_id = $user_id";
  197. if ( !($db->sql_query($sql)) )
  198. {
  199. message_die(GENERAL_ERROR, 'Erreur : impossible de modifier le groupe news ', '', __LINE__, __FILE__, $sql);
  200. }
  201. }
  202. // fin infobrol_upd
  203.  
  204. #
  205. #-----[ TROUVER ]----------------------------------------
  206. #
  207.  
  208. 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,
  209.  
  210. #
  211. #-----[ AJOUTER APRES ]----------------------------------
  212. #
  213.  
  214. user_infobrol_upd,
  215.  
  216. #
  217. #-----[ TROUVER ]----------------------------------------
  218. #
  219.  
  220. 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,
  221.  
  222. #
  223. #-----[ AJOUTER APRES ]----------------------------------
  224. #
  225.  
  226. $infobrol_upd,
  227.  
  228. #
  229. #-----[ TROUVER ]----------------------------------------
  230. #
  231.  
  232. include($phpbb_root_path . 'includes/emailer.'.$phpEx);
  233.  
  234. #
  235. #-----[ AJOUTER AVANT ]----------------------------------
  236. #
  237.  
  238. // infobrol_upd : ajout automatique dans le groupe
  239. if ($infobrol_upd==1)
  240. {
  241. $sql = "INSERT INTO " . USER_GROUP_TABLE . " (group_id, user_id, user_pending) VALUES (".$groupe_news_no.", $user_id, 0)";
  242. if ( !($db->sql_query($sql)) )
  243. {
  244. message_die(GENERAL_ERROR, 'Erreur : impossible de rentrer automatiquement dans le groupe news ', '', __LINE__, __FILE__, $sql);
  245. }
  246. }
  247. // fin infobrol_upd
  248.  
  249. #
  250. #-----[ TROUVER ]----------------------------------------
  251. #
  252.  
  253. $viewemail = $userdata['user_viewemail'];
  254.  
  255. #
  256. #-----[ AJOUTER AVANT ]----------------------------------
  257. #
  258.  
  259. $infobrol_upd = $userdata['user_infobrol_upd'];
  260.  
  261. #
  262. #-----[ TROUVER ]----------------------------------
  263. #
  264.  
  265. 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,
  266.  
  267. #
  268. #-----[ AJOUTER APRES ]----------------------------------
  269. #
  270.  
  271. $infobrol_upd,
  272.  
  273. #
  274. #-----[ TROUVER ]----------------------------------
  275. #
  276.  
  277. 'VIEW_EMAIL_YES' => ( $viewemail ) ? 'checked="checked"' : '',
  278.  
  279. #
  280. #-----[ AJOUTER AVANT ]----------------------------------
  281. #
  282.  
  283. 'INFOBROL_UPD_YES' => ( $infobrol_upd ) ? 'checked="checked"' : '',
  284. 'INFOBROL_UPD_NO' => ( !$infobrol_upd ) ? 'checked="checked"' : '',
  285.  
  286. #
  287. #-----[ TROUVER ]----------------------------------
  288. #
  289.  
  290. 'L_PUBLIC_VIEW_EMAIL' => $lang['Public_view_email'],
  291.  
  292. #
  293. #-----[ AJOUTER AVANT ]----------------------------------
  294. #
  295.  
  296. 'L_INFOBROL_UPD' => $lang['Infobrol_upd'],
  297.  
  298. #
  299. #-----[ OUVRIR ]----------------------------------------
  300. #
  301.  
  302. language/lang_english/lang_main.php
  303.  
  304. #
  305. #-----[ TROUVER ]----------------------------------
  306. #
  307.  
  308. $lang['Public_view_email'] = 'Always show my e-mail address';
  309.  
  310. #
  311. #-----[ AJOUTER AVANT ]----------------------------------
  312. #
  313.  
  314. $lang['Infobrol_upd'] = 'Notify (e-mail) on news from infobrol';
  315.  
  316. #
  317. #-----[ Début mail html ]-------------------------------
  318. #-----[ OUVRIR ]----------------------------------------
  319. #
  320.  
  321. includes/emailer.php
  322.  
  323. #
  324. #-----[ TROUVER ]----------------------------------
  325. #
  326.  
  327. // Build header
  328. $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" : '');
  329.  
  330. #
  331. #-----[ REMPLACER ]----------------------------------------
  332. #
  333.  
  334. Content-type: text/plain;
  335.  
  336. #
  337. #-----[ PAR ]----------------------------------------
  338. #
  339.  
  340. Content-type: text/html;
  341.  
  342. #
  343. #-----[ OUVRIR ]----------------------------------------
  344. #
  345.  
  346. language/lang_french/email/admin_send_email.tpl
  347. language/lang_english/email/admin_send_email.tpl
  348.  
  349. #
  350. #-----[ REMPLACER le contenu par un contenu html]--------
  351. #-----[ Fin mail html ]----------------------------------
  352. #
  353.  
  354.  
  355. #
  356. #-----[ OUVRIR ]----------------------------------------
  357. #
  358.  
  359. language/lang_french/lang_main.php
  360.  
  361. #
  362. #-----[ TROUVER ]----------------------------------
  363. #
  364.  
  365. $lang['Public_view_email'] = 'Toujours montrer son adresse e-mail';
  366.  
  367. #
  368. #-----[ AJOUTER AVANT ]----------------------------------
  369. #
  370.  
  371. $lang['Infobrol_upd'] = 'M\'avertir par e-mail des nouvelles du site (nouvelles pages, etc.)';
  372.  
  373. #
  374. #-----[ OUVRIR ]----------------------------------------
  375. #
  376.  
  377. templates/subSilver/profile_add_body.tpl
  378.  
  379. #
  380. #-----[ TROUVER ]----------------------------------
  381. #
  382.  
  383. <tr>
  384. <th class="thSides" colspan="2" height="25" valign="middle">{L_PREFERENCES}</th>
  385. </tr>
  386.  
  387. #
  388. #-----[ AJOUTER APRES ]----------------------------------
  389. #
  390.  
  391. <tr>
  392. <td class="row1"><span class="gen">{L_INFOBROL_UPD}:</span></td>
  393. <td class="row2">
  394. <input type="radio" name="infobrol_upd" value="1" {INFOBROL_UPD_YES} />
  395. <span class="gen">{L_YES}</span>  
  396. <input type="radio" name="infobrol_upd" value="0" {INFOBROL_UPD_NO} />
  397. <span class="gen">{L_NO}</span>
  398. </td>
  399. </tr>
  400. ?>

Ce code ne reprend pas 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 le souhaitent, 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.

English translation

You have asked to visit this site in English. For now, only the interface is translated, but not all the content yet.

If you want to help me in translations, your contribution is welcome. All you need to do is register on the site, and send me a message asking me to add you to the group of translators, which will give you the opportunity to translate the pages you want. A link at the bottom of each translated page indicates that you are the translator, and has a link to your profile.

Thank you in advance.

Document created the 11/12/2003, last modified the 27/10/2018
Source of the printed document:https://www.gaudry.be/en/phpbb-modnews.html

The infobrol is a personal site whose content is my sole responsibility. The text is available under CreativeCommons license (BY-NC-SA). More info on the terms of use and the author.