? phpbb_v5.patch
Index: phpbb.info
===================================================================
RCS file: phpbb.info
diff -N phpbb.info
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ phpbb.info	19 Mar 2007 07:48:27 -0000
@@ -0,0 +1,3 @@
+; $Id$
+name = phpbb
+description = Integration with phpBB
\ No newline at end of file
Index: phpbb.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/phpbb/phpbb.module,v
retrieving revision 1.16
diff -u -p -r1.16 phpbb.module
--- phpbb.module	2 Mar 2007 01:13:36 -0000	1.16
+++ phpbb.module	19 Mar 2007 07:48:27 -0000
@@ -1,5 +1,5 @@
 <?php
-// $Id: phpbb.module,v 1.16 2007/03/02 01:13:36 arkepp Exp $
+// $Id: phpbb.module,v 1.15 2007/02/10 19:38:49 arkepp Exp $
 
 /** 
  * http://drupal.org/node/32818
@@ -10,18 +10,10 @@
 /**
  * Implementation of hook_help
  */
-function phpbb_help($section) {
-	switch($section) {
-	case 'admin/modules#description':
-		return t('Integration with phpBB');
-	}
-}
-
-/**
- * Implementation of hook_settings
- */
-function phpbb_settings() {
-		$form['phpbb_dir'] = array(
+ 
+ 
+function phpbb_admin_settings() {
+  $form['phpbb_dir'] = array(
 		'#type' => 'textfield',
 		'#title' => t('Location of phpbb'),
 		'#default_value' => variable_get('phpbb_dir', 'phpBB2/'),
@@ -29,6 +21,7 @@ function phpbb_settings() {
 		'#maxlength' => 64,
 		'#description' => t('relative path to your phpBB2 directory. Please include a trailing slash ("/").'),
 	);
+  
 	$form['phpbb_www_path'] = array(
 		'#type' => 'textfield',
 		'#title' => t('Absolute path to phpbb'),
@@ -46,6 +39,7 @@ function phpbb_settings() {
 		'#maxlength' => 64,
 		'#description' => t('Title to use for the "recent topics" sidebar'),
 	);
+  
 	$form['phpbb_forum_enc'] = array(
 		'#type' => 'textfield',
 		'#title' => t('Character encoding used in phpBB'),
@@ -54,6 +48,7 @@ function phpbb_settings() {
 		'#maxlength' => 64,
 		'#description' => t('Usually ISO-8859-1'),
 	);
+  
 	$form['phpbb_drupal_enc'] = array(
 		'#type' => 'textfield',
 		'#title' => t('Character encoding used in Drupal'),
@@ -63,7 +58,7 @@ function phpbb_settings() {
 		'#description' => t('Usually UTF-8'),
 	);
 
-  return $form;
+  return system_settings_form($form);
 }
 
 /**
@@ -102,7 +97,7 @@ function phpbb_user($op, &$edit, &$user,
 				$res = mysql_query($query, $phpbb_dbc) or die('Query failed: ' . mysql_error() . " \n" . $query . "\n");
 
 			/* Go through the user defined fields in Drupal*/
-			if(module_exist('profile'))
+			if(module_exists('profile'))
 				_phpbb_update_profile_fields($edit, $user,$phpbb_dbc, $prefix);
 		break;
    
@@ -134,7 +129,7 @@ function phpbb_user($op, &$edit, &$user,
 			}
 
 		/* Go through the user defined fields in Drupal */
-			if(module_exist('profile'))
+			if(module_exists('profile'))
 				_phpbb_update_profile_fields($edit, $user, $phpbb_dbc, $prefix);
 		break;
 
@@ -192,29 +187,29 @@ function phpbb_user($op, &$edit, &$user,
 		_phpbb_unset_cookies($phpbb_cookie_name);
 	break;
 
-case 'view':
-	$form = array();
-	$output = array();
-	$query = "SELECT post_id FROM " . $prefix ."posts WHERE `poster_id`= ". $user->uid ;
-	$post_res = mysql_query($query, $phpbb_dbc) or die('Query failed: ' . mysql_error() . " \n" . $query . "\n");
-	
-	$query = "SELECT topic_id FROM " . $prefix ."topics WHERE `topic_poster`= ". $user->uid ;
-	$topic_res = mysql_query($query, $phpbb_dbc) or die('Query failed: ' . mysql_error() . " \n" . $query . "\n");
-
-	$items['no_topics'] = array('title' => t('Antall tr&aring;der startet:'),
-      'value' => mysql_num_rows($topic_res),
-      'class' => 'member'
-    );
-		$items['no_posts'] = array('title' => t('Antall innlegg:'),
+  case 'view':
+    $form = array();
+    $output = array();
+    $query = "SELECT post_id FROM " . $prefix ."posts WHERE `poster_id`= ". $user->uid ;
+    $post_res = mysql_query($query, $phpbb_dbc) or die('Query failed: ' . mysql_error() . " \n" . $query . "\n");
+
+    $query = "SELECT topic_id FROM " . $prefix ."topics WHERE `topic_poster`= ". $user->uid ;
+    $topic_res = mysql_query($query, $phpbb_dbc) or die('Query failed: ' . mysql_error() . " \n" . $query . "\n");
+
+    $items['no_topics'] = array('title' => t('Antall tr&aring;der startet:'),
+        'value' => mysql_num_rows($topic_res),
+        'class' => 'member'
+      );
+    $items['no_posts'] = array('title' => t('Antall innlegg:'),
       'value' => mysql_num_rows($post_res),
       'class' => 'member'
     );
 
     return array(t('Forum') => $items);
 
-break;
+  break;
  }
-	return $output;  
+ return $output;  
 }
 /**
  * Implementation of hook_perm().
@@ -229,21 +224,22 @@ function phpbb_perm() {
  *
  */
 function phpbb_block($op = 'list', $delta = 0, $edit = array() ) {
-  switch ($op) {
-    case 'list':
-      $blocks[0]['info'] = t(variable_get('phpbb_block0_title','phpBB Topics'));
-      return $blocks;
-    case 'configure':
-      $form = array();
-      return $form;
-    case 'save':
-      // stub, no special data to save
-      return;
-    case 'view':  // fall through
-    default:
-      $block['subject'] = t(variable_get('phpbb_block0_title','phpBB Topics'));
-      $block['content'] = _phpbb_display_block_0();
-      return $block;
+  if ($op == 'list') {
+    $blocks[0]['info'] = variable_get('phpbb_block0_title', t('phpBB Topics'));
+	 return $blocks;
+  }
+  else {
+    switch ($delta) {
+      case 0:
+			$block['subject'] = variable_get('phpbb_block0_title', t('phpBB Topics'));
+			$block['content'] = _phpbb_display_block_0();
+      break;
+
+      case 1:
+			//Not used
+		break;
+    }
+	 return $block;
   }
 }
 
@@ -251,32 +247,46 @@ function phpbb_block($op = 'list', $delt
  * Implementation of hook_menu().
  */
 function phpbb_menu($may_cache) {
-  $items = array();
-
   if ($may_cache) {
-    $items[] = array('path' => 'phpbb', 'title' => t('phpbb'),
+    $items[] = array(
+      'path' => 'phpbb', 
+      'title' => t('phpbb'),
       'callback' => 'phpbb_view',
       'access' => TRUE,
-		'type' => MENU_SUGGESTED_ITEM);
+		  'type' => MENU_SUGGESTED_ITEM
+    );
+    
+    $items[] = array(
+      'path' => 'admin/settings/phpbb',
+      'title' => t('phpBB settings'),
+      'description' => t('Configure phpBB integration'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('phpbb_admin_settings'),
+      'access' => user_access('administer site configuration'),
+      'type' => MENU_NORMAL_ITEM,
+    );
   }
+  
+  
   return $items;
 }
 
 /**
  * Menu callback; presents the phpbbsup form and/or phpbbsup results.
+ * Doesn't this interfere with hook_view? At least it's confusing
  */
 function phpbb_view() {
 	global $user;
 
 	if($user->uid == 0) {
 		//echo $forum_goto . " " . arg(2);
-		watchdog('user', t('phpBB bounce for %name.', array('%name' => theme('placeholder', $user->name))));
+		watchdog('user', t('phpBB bounce for %name.', array('%name' => $user->name)));
 		session_destroy();
 	  	$user = user_load(array('uid' => 0));
 		drupal_goto('user/login?destination=' . variable_get('phpbb_dir', 'phpBB2/') . arg(1));
 	} else {
 		// We know who this is, create session and send them back
-		watchdog('user', t('phpBB rebuffed %name.', array('%name' => theme('placeholder', $user->name))));
+		watchdog('user', t('phpBB rebuffed %name.', array('%name' => $user->name)));
 		$edit = array();
 		phpbb_user('logout',$edit, $user);
 		phpbb_user('login',$edit, $user);
@@ -357,9 +367,9 @@ function _phpbb_update_profile_field($ak
 function _phpbb_get_profile_value($akey) {
 	// This code does not honor table-prefixes!
 	global $user;
-	$result = db_query(	"SELECT profile_values.value AS value FROM profile_values, profile_fields
-								WHERE profile_fields.fid = profile_values.fid AND profile_fields.name = 'phpbb_".$akey."'
-								AND profile_values.uid = '".$user->uid."'");
+	$result = db_query(	"SELECT {profile_values}.value AS value FROM {profile_values}, {profile_fields}
+								WHERE {profile_fields}.fid = {profile_values}.fid AND {profile_fields}.name = 'phpbb_%s'
+								AND {profile_values}.uid = '%d'",$akey, $user->uid );
 	
 	if (db_num_rows($result) == 1) {
 		$arow = db_fetch_array($result);
