S'enregistrer Album Photos Rechercher Accueil FAQ Liste des Membres Groupes d'utilisateurs Connexion  
Image
Répondre au sujet [MOD] Resume and Bookmark mod
[MOD] Resume and Bookmark mod
Nicolas
Admin

Inscrit le: 10 Oct 2005
Messages: 2289
Localisation: 77 - Bussy Saint-Georges
Voiture: Seat Leon TDI 150 Jaune Ovni
Répondre en citantRépondre en reprenant le texte
Voilà, la nouvelle version de ce mod vient tout juste de sortir dans le but d'optimiser au maximum les resources serveurs. Cela a entraîné des petites modifications.

D'abord pour rassurer tous les membres, l'état de tous vos "resume" et "bookmark" ont été tous gardés.

Le changement principal se situe sur les pages viewforum et search (ces pages affichent la listes des sujets d'une rubrique ou les sujets correspondants aux critères de recherche). Pour limiter le nombre de requêtes SQL dans la base de données, l'icône n'a plus l'information du derniers messages lu du sujet correspondant et donc, cet icône est affiché automatiquement en face de chaque sujet, même si vous ne l'avez pas lu.
En revanche, en cliquant sur ces icône, la recherche du dernier post lu se fera bien à ce moment. Ceci permet de divier par 50 le nombre de requêtes (car viewforum et search affiche 50 sujets par page).

Les icônes ne s'afficheront plus dans les pages viewforum et search car en raison de l'optimisation, on ne savoir si ces sujets ont été placés dans vos favoris ou non. Ces icônes s'afficheront bien dans la page du topic juste à droite du titre.

Si vous rencontrez des bugs, n'hésitez pas à les signaler.


Dernière édition par Nicolas le 16 Nov 2006 22:22; édité 3 fois
Voir le profil de l'utilisateurGalerie privée de NicolasTrouver tous les messages de NicolasEnvoyer un message privéEnvoyer un e-mailVisiter le site web de l'utilisateur
Floflo
Admin

Inscrit le: 11 Oct 2005
Messages: 4703
Localisation: 95 - roissy CDG
Voiture: Bora Trendline Variant 130
Répondre en citantRépondre en reprenant le texte
Je vous assure que l'utilisation de ce mod est beaucoup simple que sa programmation d'oh!
Voir le profil de l'utilisateurGalerie privée de FlofloTrouver tous les messages de FlofloEnvoyer un message privéVisiter le site web de l'utilisateur
Nicolas
Admin

Inscrit le: 10 Oct 2005
Messages: 2289
Localisation: 77 - Bussy Saint-Georges
Voiture: Seat Leon TDI 150 Jaune Ovni
Répondre en citantRépondre en reprenant le texte
La nouvelle version de ce mod vient de sortir hello

Je mettrais publiquement le code pour les webmaster désirant l'installer sur leur forum d'ici quelques jours, le temps de bien tester les optimisations Wink

_________________
http://www.dv-racing.com

Voir le profil de l'utilisateurGalerie privée de NicolasTrouver tous les messages de NicolasEnvoyer un message privéEnvoyer un e-mailVisiter le site web de l'utilisateur
Floflo
Admin

Inscrit le: 11 Oct 2005
Messages: 4703
Localisation: 95 - roissy CDG
Voiture: Bora Trendline Variant 130
Répondre en citantRépondre en reprenant le texte
Nicolas a écrit:
... Le but principal de cette version est d'utiliser le moins de ressources possible du côté serveur.
Actuellement, l'icône s'affichant dans viewforum ou search entraîne parfois une bonne centaine de requêtes SQL (2 par topics, donc avec 50 topics par page cela fait donc 100).

La nouvelle version, n'effectuera aucune requête dans viewforum ou search, du coup, cet icône sera systématiquement affiché même si l'utilisateur n'aura pas lu le topic. De plus, les icônes ne seront donc pas affichés sur ces pages puisque sans ces requêtes, l'information n'est pas disponible.

La requête se fera donc uniquement lorsque l'utilisateur ouvrira le topic en question et entraînera donc seulement 2 demandes de requête SQL supplémentaires comparé à la centaine actuellement, le gain est énorme. Et bien sûr, on trouvera donc l'icône permettant de mettre en favoris uniquement dans la lecture du topic.


Nicolas a écrit:
Il n'y aura aucune perte des topics favoris, ni du resume puisque la structure de la table dans la base est la même Wink

_________________
N'oubliez pas de remplir vos Galeries Perso hello
Elles sont illimitées sur VAG-Forum.com Dancing

Voir le profil de l'utilisateurGalerie privée de FlofloTrouver tous les messages de FlofloEnvoyer un message privéVisiter le site web de l'utilisateur
Mickski
Modo

Inscrit le: 17 Avr 2006
Messages: 1589
Localisation: Noisy-le-Grand - 93
Voiture: Leon 1.8 20VT MRC
Répondre en citantRépondre en reprenant le texte
Floflo a écrit:
Je vous assure que l'utilisation de ce mod est beaucoup simple que sa programmation d'oh!
C'est une Loi en informatique : la facilité d'utilisation et inversement proportionnelle à la complexité de développement. Wink

_________________
Rencontre à Torcy le 23 juillet : inscription
Voir le profil de l'utilisateurGalerie privée de MickskiTrouver tous les messages de MickskiEnvoyer un message privéEnvoyer un e-mailNuméro ICQ
Nicolas
Admin

Inscrit le: 10 Oct 2005
Messages: 2289
Localisation: 77 - Bussy Saint-Georges
Voiture: Seat Leon TDI 150 Jaune Ovni
Répondre en citantRépondre en reprenant le texte
Vous pouvez télécharger le mod ici : http://www.vag-forum.com/mods/resume_0.9.2.zip

Voici le code:

Code:
##############################################################
## MOD Title: Resume and Bookmark MOD
## MOD Author: vag-forum <webmaster> (Nicolas) http://www.VAG-Forum.com
## MOD Description:
##   When you follow one or more topics and you connect or disconnect several times from your forum, if any new messages are posted you can no longer tell which was the last message that you actually read.
##   The phpBB shows the new messages only since you last connected, so you have to go back in each topic to find the last message actually read.
##   So this mod allows you to get rid of this annoying chore by clicking on the "Resume" icon
##   It stores the information in the new phpbb_resume table.
##   The bookmark feature comes as an extra bonus, because it also uses the phpbb_resume table by adding only one tiny column - smallint(1) - to manage the members' bookmarks.
##   So the "Bookmark" icon adds or removes the topic from the list of the bookmarked topics.
##   The users can view the bookmarked topics by clicking on the link added on the index page.
## MOD Version: 0.9.2
##
## Installation Level: (Intermediate)
## Installation Time: 20 Minutes
## Files To Edit:
##      includes/constants.php,
##      includes/page_header.php,
##      language/lang_english/lang_main.php,
##      templates/subSilver/index_body.tpl,
##      templates/subSilver/search_results_topics.tpl,
##      templates/subSilver/subSilver.cfg,
##      templates/subSilver/overall_footer.tpl,
##      templates/subSilver/viewforum_body.tpl,
##      templates/subSilver/viewtopic_body.tpl,
##      search.php,
##      viewforum.php,
##      viewtopic.php
## Included Files:
##      phpbb_root/templates/subSilver/images/icon_bookmark_in.gif,
##      phpbb_root/templates/subSilver/images/icon_bookmark_out.gif,
##      phpbb_root/templates/subSilver/images/icon_resume.gif
## License: http://opensource.org/licenses/gpl-license.php GNU General Public License v2
##############################################################
## Author Notes: You need to create a new table in the phpbb database (phpbb_resume, if necessary replace the prefix phpbb_) in order to store the user data.
##               Do not hesitate to post your comments either in english or french on the topic as follows :
##               http://www.vag-forum.com/forum/resume-and-bookmark-mod-vt116.html
##############################################################
## MOD History:
##
##   2006-11-11 - Version 0.9.2
##      - optimizations
##   2005-09-23 - Version 0.9.1
##      - initial release
##
##############################################################
## Before Adding This MOD To Your Forum, You Should Back Up All Files Related To This MOD
##############################################################

#
#-----[ SQL ]---------------------------------
#
CREATE TABLE `phpbb_resume` (
  `user_id` mediumint(8) NOT NULL default '0',
  `topic_id` mediumint(8) unsigned NOT NULL default '0',
  `post_id` mediumint(8) unsigned NOT NULL default '0',
  `bookmark` smallint(1) default '0',
  KEY `user_id` (`user_id`,`topic_id`)
);

#
#-----[ COPY ]------------------------------------------
#
copy phpbb_root/templates/subSilver/images/*.gif to templates/subSilver/images/*.gif

#
#-----[ OPEN ]------------------------------------------
#
includes/constants.php

#
#-----[ FIND ]---------------------------------
#

?>
#
#-----[ BEFORE, ADD ]---------------------------------------
#
define('RESUME_TABLE', $table_prefix.'resume');

#
#-----[ OPEN ]------------------------------------------
#
includes/page_header.php

#
#-----[ FIND ]---------------------------------
#
   'L_SEARCH_SELF' => $lang['Search_your_posts'],
#
#-----[ AFTER, ADD ]------------------------------------------
#
   'L_SEARCH_BOOKMARK' => $lang['Search_bookmark'],
#
#-----[ FIND ]---------------------------------
#
   'U_SEARCH_NEW' => append_sid('search.'.$phpEx.'?search_id=newposts'),
#
#-----[ AFTER, ADD ]------------------------------------------
#
   'U_SEARCH_BOOKMARK' => append_sid('search.'.$phpEx.'?search_id=bookmark'),

#
#-----[ OPEN ]------------------------------------------
#
language/lang_english/lang_main.php

#
#-----[ FIND ]---------------------------------
#
//
// That's all, Folks!
// -------------------------------------------------

#
#-----[ BEFORE, ADD ]---------------------------------------
#

$lang['Resume_topic']        = 'View topic resume';
$lang['Resume_bookmark_in']  = 'Add the topic to the bookmarks';
$lang['Resume_bookmark_out'] = 'Remove the topic from the bookmarks';
$lang['Search_bookmark']     = 'See the favorite topics';

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/index_body.tpl

#
#-----[ FIND ]---------------------------------
#
      <a>{L_SEARCH_UNANSWERED}</a></td>
#
#-----[ REPLACE WITH ]---------------------------------------------------------------
#
      <a>{L_SEARCH_UNANSWERED}</a><br>
      <a>{L_SEARCH_BOOKMARK}</a></td>
#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/search_results_topics.tpl

#
#-----[ FIND ]---------------------------------
#
  <td><span>{searchresults.NEWEST_POST_IMG}{searchresults.TOPIC_TYPE}<a>{searchresults.TOPIC_TITLE}</a></span><br><span>{searchresults.GOTO_PAGE}</span></td>
#
#-----[ IN-LINE FIND ]---------------------------------
#
{searchresults.TOPIC_TITLE}</a>
#
#-----[ IN-LINE AFTER, ADD  ]---------------------------------
#
&nbsp;{searchresults.RESUME}

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/subSilver.cfg

#
#-----[ FIND ]---------------------------------
#

?>
#
#-----[ BEFORE, ADD ]---------------------------------------
#

$images['icon_resume']       = "$current_template_images/icon_resume.gif";
$images['icon_bookmark_in']  = "$current_template_images/icon_bookmark_in.gif";
$images['icon_bookmark_out'] = "$current_template_images/icon_bookmark_out.gif";
#
#-----[ OPEN ]------------------------------------------
# Note : the modification in overall_footer.tpl is not mandatory, so apply it only if you want to thank me ;)
templates/subSilver/overall_footer.tpl

#
#-----[ FIND ]---------------------------------
#
Powered by <a>phpBB</a> &copy; 2001, 2005 phpBB Group<br>
#
#-----[ IN-LINE FIND ]---------------------------------
#
<br>
#
#-----[ IN-LINE AFTER, ADD ]---------------------------------------
#

<a>Resume Mod</a> by <a>VAG-Forum</a><br>

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewforum_body.tpl

#
#-----[ FIND ]---------------------------------
# Line containing this code
<a>{topicrow.TOPIC_TITLE}</a></span>
#
#-----[ IN-LINE FIND ]---------------------------------
#
</span>
#
#-----[ IN-LINE AFTER, ADD  ]---------------------------------
#
&nbsp;{topicrow.RESUME}

#
#-----[ OPEN ]------------------------------------------
#
templates/subSilver/viewtopic_body.tpl

#
#-----[ FIND ]---------------------------------
#
   <td><a>{TOPIC_TITLE}</a><br>
#
#-----[ IN-LINE FIND ]---------------------------------
#
</a>
#
#-----[ IN-LINE AFTER, ADD  ]---------------------------------
#
&nbsp;{BOOKMARK_IMG}

#
#-----[ OPEN ]------------------------------------------
#
search.php

#
#-----[ FIND ]---------------------------------
#
   if ( $search_id == 'newposts' || $search_id == 'egosearch' || $search_id == 'unanswered' || $search_keywords != '' || $search_author != '' )
#
#-----[ IN-LINE FIND ]---------------------------------
#
$search_author != ''
#
#-----[ IN-LINE AFTER, ADD  ]---------------------------------
#
 || $search_id == 'bookmark'
#
#-----[ FIND ]---------------------------------
#
      if ( $search_id == 'newposts' || $search_id == 'egosearch' || ( $search_author != '' && $search_keywords == '' )  )
#
#-----[ IN-LINE FIND ]---------------------------------
#
( $search_author != '' && $search_keywords == '' )
#
#-----[ IN-LINE AFTER, ADD  ]---------------------------------
#
 || $search_id == 'bookmark'
#
#-----[ FIND ]---------------------------------
#
            else
            {
               redirect(append_sid("login.$phpEx?redirect=search.$phpEx&search_id=egosearch", true));
            }

            $show_results = 'topics';
            $sort_by = 0;
            $sort_dir = 'DESC';
         }
#
#-----[ AFTER, ADD ]------------------------------------------
#
         else if ( $search_id == 'bookmark' )
         {
            if ( $userdata['session_logged_in'] )
            {
               $sql = "SELECT post_id
                  FROM " . RESUME_TABLE . "
                  WHERE user_id = " . $userdata['user_id'] . "
                  AND bookmark = 1";
            }
            else
            {
               redirect(append_sid("login.$phpEx?redirect=search.$phpEx&search_id=bookmark", true));
            }

            $show_results = 'topics';
            $sort_by = 0;
            $sort_dir = 'DESC';
         }
#
#-----[ FIND ]---------------------------------
#
            else
            {
               $goto_page = '';
            }
#
#-----[ AFTER, ADD ]------------------------------------------
#

            if ($userdata['session_logged_in']) {
               $resume = '<a><img></a>';
            }

#
#-----[ FIND ]---------------------------------
#
               'GOTO_PAGE' => $goto_page,
#
#-----[ AFTER, ADD ]------------------------------------------
#
               'RESUME' => $resume,

#
#-----[ OPEN ]------------------------------------------
#
viewforum.php

#
#-----[ FIND ]---------------------------------
#
      $view_topic_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id");
#
#-----[ AFTER, ADD ]------------------------------------------
#

      if ($userdata['session_logged_in']) {
         $resume_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;view=resume");
         $resume = '<a><img></a>';
      }

#
#-----[ FIND ]---------------------------------
#
         'GOTO_PAGE' => $goto_page,
#
#-----[ AFTER, ADD ]------------------------------------------
#
         'RESUME' => $resume,

#
#-----[ OPEN ]------------------------------------------
#
viewtopic.php

#
#-----[ FIND ]---------------------------------
#
if ( isset($HTTP_GET_VARS[POST_POST_URL]))
{
   $post_id = intval($HTTP_GET_VARS[POST_POST_URL]);
}
#
#-----[ AFTER, ADD ]------------------------------------------
#

if ( isset($HTTP_GET_VARS['bookmark']))
{
   $bookmark = intval($HTTP_GET_VARS['bookmark']);
}

#
#-----[ FIND ]---------------------------------
#
      else
      {
         $message = ( $HTTP_GET_VARS['view'] == 'next' ) ? 'No_newer_topics' : 'No_older_topics';
         message_die(GENERAL_MESSAGE, $message);
      }
   }
#
#-----[ AFTER, ADD ]------------------------------------------
#
   // Resume Mod BEGIN
   else if ( $HTTP_GET_VARS['view'] == 'resume' )
   {
      if ( isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) || isset($HTTP_GET_VARS['sid']) )
      {
         $session_id = isset($HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid']) ? $HTTP_COOKIE_VARS[$board_config['cookie_name'] . '_sid'] : $HTTP_GET_VARS['sid'];

         if (!preg_match('/^[A-Za-z0-9]*$/', $session_id))
         {
            $session_id = '';
         }

         if ( $session_id )
         {
           $sql = "SELECT post_id FROM " . RESUME_TABLE . " r, " . SESSIONS_TABLE . " s
               WHERE s.session_id = '$session_id'
               AND   r.user_id = s.session_user_id
               AND   topic_id = $topic_id";

            if ( !($result = $db->sql_query($sql)) )
            {
               message_die(GENERAL_ERROR, 'Could not obtain resume information', '', __LINE__, __FILE__, $sql);
            }

            if ( ($row = $db->sql_fetchrow($result)) ) {
               // Is the post_id exist ?
               $post_id = $row['post_id'];
               $sql = "SELECT post_id FROM " . POSTS_TABLE . "
                       WHERE post_id = $post_id";
               if ( !($result = $db->sql_query($sql)) )
               {
                  message_die(GENERAL_ERROR, 'Could not obtain posts information', '', __LINE__, __FILE__, $sql);
               }
               // Is the post_id deleted ?
               if (!($row = $db->sql_fetchrow($result))) {
                  // Yes, so select the previous post_id
                  $sql = "SELECT post_id FROM " . POSTS_TABLE . "
                               WHERE topic_id = $topic_id
                               AND   post_id < $post_id
                               ORDER BY post_id DESC";
                  if ( !($result = $db->sql_query($sql)) )
                  {
                     message_die(GENERAL_ERROR, 'Could not obtain posts information', '', __LINE__, __FILE__, $sql);
                  }
                  $row = $db->sql_fetchrow($result);
                  if ($row) {
                     $post_id = $row['post_id'];
                  } else {
                     $post_id = '';
                  }
               }
               if (isset($HTTP_GET_VARS['sid']))
               {
                  redirect("viewtopic.$phpEx?sid=$session_id&" . POST_POST_URL . "=$post_id#$post_id");
               }
               else
               {
                  redirect("viewtopic.$phpEx?" . POST_POST_URL . "=$post_id#$post_id");
               }
            }
         }
      }
   }
   // Resume Mod END

#
#-----[ FIND ]---------------------------------
#
$pagination = ( $highlight != '' ) ? generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order&amp;highlight=$highlight", $total_replies, $board_config['posts_per_page'], $start) : generate_pagination("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;postdays=$post_days&amp;postorder=$post_order", $total_replies, $board_config['posts_per_page'], $start);
#
#-----[ AFTER, ADD ]------------------------------------------
#
// Update the resume and bookmark table BEGIN
if ($userdata['session_logged_in']) {
   $resume = $postrow[$total_posts-1]['post_id'];
   $sql = "SELECT post_id,bookmark from " . RESUME_TABLE . "
      WHERE user_id = " . $userdata['user_id'] . " AND topic_id = $topic_id";

   if ( !($result = $db->sql_query($sql)) )
   {
      message_die(GENERAL_ERROR, 'Could not obtain resume information', '', __LINE__, __FILE__, $sql);
   }

   if ( ($row = $db->sql_fetchrow($result)) )
   {
      if ($resume > $row['post_id'] || isset($bookmark)) {
         if ($resume > $row['post_id']) $resume_sql = " post_id = $resume";
         if (isset($bookmark))
         {
            $bookmark_sql = ($resume_sql ? ", ":"") . "bookmark = $bookmark";
         }
         $sql = "UPDATE " . RESUME_TABLE . "
            SET $resume_sql $bookmark_sql
            WHERE user_id = " . $userdata['user_id'] . " AND topic_id = $topic_id";
         if ( !$db->sql_query($sql) )
         {
            message_die(GENERAL_ERROR, "Could not update resume.", '', __LINE__, __FILE__, $sql);
         }
      }
      if (!isset($bookmark))
      {
         $bookmark = $row['bookmark'];
      }
   } else {
      $sql = "INSERT INTO " . RESUME_TABLE . "
         (post_id, user_id, topic_id, bookmark) VALUES($resume," . $userdata['user_id'] . ", $topic_id, 0)";
      if ( !$db->sql_query($sql) )
      {
         message_die(GENERAL_ERROR, "Could not insert resume.", '', __LINE__, __FILE__, $sql);
      }
   }

   // Bookmark
   $bookmark_value = ($bookmark == 1 )? 0:1;
   $bookmark_icon  = ($bookmark == 1 )? "out":"in";
   $bookmark_url = append_sid("viewtopic.$phpEx?" . POST_TOPIC_URL . "=$topic_id&amp;bookmark=" . $bookmark_value);
   $bookmark_img = '<a><img></a>';
}
// Update the resume and bookmark table END
#
#-----[ FIND ]---------------------------------
#
   'U_VIEW_FORUM' => $view_forum_url,
#
#-----[ AFTER, ADD ]------------------------------------------
#
   'BOOKMARK_IMG' => $bookmark_img,

#
#-----[ SAVE/CLOSE ALL FILES ]------------------------------------------
#
# EoM

_________________
http://www.dv-racing.com

Voir le profil de l'utilisateurGalerie privée de NicolasTrouver tous les messages de NicolasEnvoyer un message privéEnvoyer un e-mailVisiter le site web de l'utilisateur
[MOD] Resume and Bookmark mod
Vous ne pouvez pas poster de nouveaux sujets dans ce forum
Vous ne pouvez pas répondre aux sujets dans ce forum
Vous ne pouvez pas éditer vos messages dans ce forum
Vous ne pouvez pas supprimer vos messages dans ce forum
Vous ne pouvez pas voter dans les sondages de ce forum
Vous pouvez joindre des fichiers
Vous pouvez télécharger des fichiers
Toutes les heures sont au format GMT + 1 Heure  
Page 1 sur 1  

  
  
 Répondre au sujet  
Effacer les cookies du forum

Debug: page generation = 1.63403 seconds, sql queries = 11
Powered by phpBB © phpBB Group
phpBB SEO
Design by phpBBStyles.com | Styles Database.
www.forumannonce.fr
Resume Mod by VAG-Forum
Content © www.VAG-Forum.com