/[drupal]/contributions/modules/phpbb/phpbb.module
ViewVC logotype

Diff of /contributions/modules/phpbb/phpbb.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.13, Thu Sep 14 05:05:10 2006 UTC revision 1.14, Tue Oct 24 22:48:30 2006 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: phpbb.module,v 1.12 2006/09/06 00:26:45 arkepp Exp $  // $Id: phpbb.module,v 1.13 2006/09/14 05:05:10 arkepp Exp $
3    
4  /**  /**
5   * http://drupal.org/node/32818   * http://drupal.org/node/32818
# Line 277  function phpbb_block($op = 'list', $delt Line 277  function phpbb_block($op = 'list', $delt
277  function _phpbb_db() {  function _phpbb_db() {
278          $phpbb_root_path = variable_get('phpbb_dir', 'phpBB2/');          $phpbb_root_path = variable_get('phpbb_dir', 'phpBB2/');
279          include($phpbb_root_path.'config.php');          include($phpbb_root_path.'config.php');
280            if ($dbms) {
281          if ($dbms == 'mysql4'|| $dbms == 'mysql3' || $dbms == 'mysql') {          //if ($dbms == 'mysql4'|| $dbms == 'mysql3' || $dbms == 'mysql') {
282                  $dbms = 'mysql';                  $dbms = 'mysql';
283          } else {          } else {
284                  die('Only MySQL is currently supported for phpBB integration. $dbms: ' . $dbms);                  die('Could not open '. $phpbb_root_path.'config.php for inclusion');
285          }          }
286    
287          //$phpbb_dbc=db_connect($dbms.'://'.$dbuser.':'.$dbpasswd.'@'.$dbhost.'/'.$dbname);          //$phpbb_dbc=db_connect($dbms.'://'.$dbuser.':'.$dbpasswd.'@'.$dbhost.'/'.$dbname);
# Line 461  function _phpbb_display_block_0() { Line 461  function _phpbb_display_block_0() {
461          $phpbb_dbc = _phpbb_db();          $phpbb_dbc = _phpbb_db();
462          $prefix = _phpbb_prefix();          $prefix = _phpbb_prefix();
463          // auth_read = 0  -> we only include public forums          // auth_read = 0  -> we only include public forums
464          $phpbb_query =          $phpbb_query =  'SELECT '.$prefix.'topics.topic_id, '.$prefix.'topics.topic_title, '.$prefix.'topics.topic_last_post_id FROM '
465          "SELECT " . $prefix . "posts.post_id, " . $prefix . "posts.post_time, " . $prefix                                                                          .$prefix.'topics LEFT JOIN '.$prefix.'forums ON '.$prefix.'topics.forum_id = '.$prefix.'forums.forum_id WHERE '
466          . "topics.topic_id, " . $prefix . "topics.topic_title, " . $prefix . "topics.forum_id "                                                                          .$prefix.'forums.auth_view = 0 ORDER BY topic_last_post_id DESC LIMIT 10;';
         . " FROM ". $prefix . "posts "  
         . " INNER JOIN " . $prefix . "topics ON " . $prefix . "topics.topic_id = ". $prefix . "posts.topic_id "  
         . " INNER JOIN " . $prefix . "forums ON " . $prefix . "topics.forum_id = ". $prefix . "forums.forum_id "  
         . " WHERE " . $prefix . "forums.auth_read = 0"  
         . " ORDER BY ". $prefix . "posts.post_id DESC LIMIT 100;";  
467    
468          $result = mysql_query($phpbb_query, $phpbb_dbc) or die('Query failed: ' . mysql_error() . " \n</br></br>" . $phpbb_query . "\n");          $result = mysql_query($phpbb_query, $phpbb_dbc) or die('Query failed: ' . mysql_error() . " \n</br></br>" . $phpbb_query . "\n");
469    
         $tracker = array();  
         $counter = 0;  
470          $list = array();          $list = array();
471    
472          while ($a_row = mysql_fetch_assoc($result) ){          while ($a_row = mysql_fetch_assoc($result) ){
                 if($tracker[ $a_row['topic_id'] ] != 1) {  
473                          $descstr = _phpbb_decode($a_row['topic_title']);                          $descstr = _phpbb_decode($a_row['topic_title']);
474                          $origdescstr = $descstr;                          $origdescstr = $descstr;
475    
# Line 485  function _phpbb_display_block_0() { Line 477  function _phpbb_display_block_0() {
477                                  $descstr = substr($descstr,0,29) . "...";                                  $descstr = substr($descstr,0,29) . "...";
478    
479                          $topic_urlstr = variable_get('phpbb_www_path', '/phpBB2/') ."viewtopic.php?t=" . $a_row['topic_id'];                          $topic_urlstr = variable_get('phpbb_www_path', '/phpBB2/') ."viewtopic.php?t=" . $a_row['topic_id'];
480        $post_urlstr =  variable_get('phpbb_www_path', '/phpBB2/') ."viewtopic.php?p=" . $a_row['post_id'] . "#" . $a_row['post_id'];        $post_urlstr =  variable_get('phpbb_www_path', '/phpBB2/') ."viewtopic.php?p=" . $a_row['topic_last_post_id'] . "#" . $a_row['topic_last_post_id'];
   
                         $list[] =  
                         date("G:i", $a_row['post_time']) . '&nbsp;&nbsp;<a href="' . $post_urlstr  
                         .'"><img src="misc/arrow.gif" alt=">>" height="12" width="12" /></a> <a href="'  
                         . $topic_urlstr .'" title="' . $origdescstr . '">&nbsp;&nbsp;' . $descstr . '</a>';  
                         $counter++;  
                 }  
481    
482                  if($counter == 10) {                          $list[] = '<a href="' . $post_urlstr .'"><img src="misc/arrow.gif" alt=">>" height="12" width="12" /></a> <a href="'. $topic_urlstr .'" title="'. $origdescstr . '">&nbsp;&nbsp;' . $descstr . '</a>';
                         break;  
                 } else {  
                         $tracker[ $a_row['topic_id'] ] = 1;  
                 }  
483          }          }
484          return theme('item_list', $list);          return theme('item_list', $list);
485  }  }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

  ViewVC Help
Powered by ViewVC 1.1.2