EllisLab text mark
Advanced Search
1 of 7
1
   
phpBB3 library
Posted: 05 August 2009 02:53 PM   [ Ignore ]
Avatar
Joined: 2008-09-03
69 posts

A few months ago I needed a library which would offer basic communication between CodeIgniter and phpBB3, so I searched this forum and I found some libraries but most of them were old or lacking features so I decided to create a new one which would satisfy all my needs (thanks Sarre).

Anyway, here is a “public” version with comments.

http://codeigniter.com/wiki/phpBB3_library/

I think method and variable names are pretty self-explanatory so I don’t need to post any more details.

If you have any questions feel free to ask.

Oh, and if you use CodeIgniter’s URL helper, you need to change the redirect function name, because it interferes with the redirect function already declared in phpBB3 (you could as well make a slight modification in phpBB includes/functions.php file using function_exists()).

 Signature 

Open Blog
Kick-ass Blog application built using the CodeIgniter PHP Framework

Official website | My website | Demo | Getting started

 
Posted: 31 August 2009 06:26 PM   [ Ignore ]   [ # 1 ]   [ Rating: 0 ]
Joined: 2007-10-29
36 posts

Kami_, thanks for making this public.  I’ve had a phpbb3 forum for some time now, and I’m writing a community site to compliment it.  Having looked at the library, I do agree that the methods are mostly self explanatory, but I think it would be nice to have some documentation to go along with the library.  I wasn’t able to find any (perhaps I just missed it).  If not extensively documented, just an example showing how to use the library would be nice.

 
Posted: 02 September 2009 04:16 AM   [ Ignore ]   [ # 2 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-03
69 posts

No problem.

I’ll put a few examples on codeigniter.com wiki today.

If you have any more questions regarding the library, feel free to ask.

 Signature 

Open Blog
Kick-ass Blog application built using the CodeIgniter PHP Framework

Official website | My website | Demo | Getting started

 
Posted: 11 September 2009 04:40 AM   [ Ignore ]   [ # 3 ]   [ Rating: 0 ]
Joined: 2009-08-22
4 posts

hi where should i install the phpb3 forum ??

 
Posted: 11 September 2009 08:41 AM   [ Ignore ]   [ # 4 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-11
2985 posts

Good library. Good to see the mess that is phpBB procedural code being brought into an OOP world.

One thing:

public function isModerator()
    
{
        
if ($this->isGroupMember('moderators'))
        
{
            
return TRUE;
        
}
        
else
        
{
            
return FALSE;
        
}
    } 

Why not just:

public function isModerator()
    
{
        
return $this->isGroupMember('moderators');
    

It does the same thing. If you are worried about readability, just do:

public function isModerator()
    
{
        
return (bool) $this->isGroupMember('moderators');
    

The same applies to a few of your methods.

 Signature 

————————
Blog | Twitter | GitHub | BitBucket
————————-
PyroCMS - open source modular CMS built with CodeIgniter
PancakeApp - Simple, hosted invoicing/w project management

 
Posted: 11 September 2009 12:37 PM   [ Ignore ]   [ # 5 ]   [ Rating: 0 ]
Joined: 2008-11-02
106 posts

Just checked your wiki page, and how about changing:

$phpEx substr(strrchr(__FILE__'.'), 1);

// Include needed files
include($phpbb_root_path 'common.' $phpEx);
include(
$phpbb_root_path 'config.' $phpEx);
include(
$phpbb_root_path 'includes/functions_user.' $phpEx);
include(
$phpbb_root_path 'includes/functions_display.' $phpEx);
include(
$phpbb_root_path 'includes/functions_privmsgs.' $phpEx);
include(
$phpbb_root_path 'includes/functions_posting.' $phpEx); 

To this:

$phpEx strrchr(__FILE__'.');

// Include needed files
include($phpbb_root_path 'common' $phpEx);
include(
$phpbb_root_path 'config' $phpEx);
include(
$phpbb_root_path 'includes/functions_user' $phpEx);
include(
$phpbb_root_path 'includes/functions_display' $phpEx);
include(
$phpbb_root_path 'includes/functions_privmsgs' $phpEx);
include(
$phpbb_root_path 'includes/functions_posting' $phpEx); 

I think $phpEx should be ‘.php’ and not ‘php’, you’d get less code, and less dots to write in your variables =)

Edit, you can also merge these two:

public function getUserById($userId)
{
    
global $table_prefix;

    
$this->CI->db->select('*');
    
$this->CI->db->from($table_prefix 'users');
    
$this->CI->db->where('user_id'$userId);
    
$this->CI->db->limit(1);

    
$query $this->CI->db->get();

    if (
$query->num_rows() == 1)
    
{
        
return $query->row_array();
    
}
    
else
    
{
        
return FALSE;
    
}
}

public function getUserByName($username)
{
    
global $table_prefix;

    
$this->CI->db->select('*');
    
$this->CI->db->from($table_prefix 'users');
    
$this->CI->db->where('username'$username);
    
$this->CI->db->limit(1);

    
$query $this->CI->db->get();

    if (
$query->num_rows() == 1)
    
{
        
return $query->row_array();
    
}
    
else
    
{
        
return FALSE;
    
}

To:

public function getUser($data)
{
    
global $table_prefix;

    
$this->CI->db->from($table_prefix 'users');

    if (
is_int($data))
    
{
        $this
->CI->db->where('user_id'$data);
    
}
    
else
    
{
        $this
->CI->db->where('username'$data);
    
}

    $this
->CI->db->limit(1);

    
$query $this->CI->db->get();

    if (
$query->num_rows() == 1)
    
{
        
return $query->row_array();
    
}
    
else
    
{
        
return FALSE;
    
}

$this->db->select(’*’) and nothing is the same thing =)

 
Posted: 13 September 2009 10:12 AM   [ Ignore ]   [ # 6 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-03
69 posts
Phil Sturgeon - 11 September 2009 12:41 PM

Good library. Good to see the mess that is phpBB procedural code being brought into an OOP world.

One thing:

public function isModerator()
    
{
        
if ($this->isGroupMember('moderators'))
        
{
            
return TRUE;
        
}
        
else
        
{
            
return FALSE;
        
}
    } 

Why not just:

public function isModerator()
    
{
        
return $this->isGroupMember('moderators');
    

It does the same thing. If you are worried about readability, just do:

public function isModerator()
    
{
        
return (bool) $this->isGroupMember('moderators');
    

The same applies to a few of your methods.

Thank you Phil Sturgeon.

Sometimes, I guess I’m too worried about the readability and this leads to un-needed and duplicated code.

Anyway, I updaded the Wiki with the new version and very short example how you could use the library.

 Signature 

Open Blog
Kick-ass Blog application built using the CodeIgniter PHP Framework

Official website | My website | Demo | Getting started

 
Posted: 14 September 2009 05:45 AM   [ Ignore ]   [ # 7 ]   [ Rating: 0 ]
Avatar
Joined: 2007-06-11
2985 posts

You missed a spot!

if (in_array($group$groups))
        
{
            
return TRUE;
        
}
        
else
        
{
            
return FALSE;
        

could be:

return in_array($group$groups); 

raspberry

 Signature 

————————
Blog | Twitter | GitHub | BitBucket
————————-
PyroCMS - open source modular CMS built with CodeIgniter
PancakeApp - Simple, hosted invoicing/w project management

 
Posted: 23 September 2009 03:19 PM   [ Ignore ]   [ # 8 ]   [ Rating: 0 ]
Joined: 2009-04-19
8 posts

Could you add a function to add a user to the phpbb database?

 
Posted: 24 September 2009 12:55 PM   [ Ignore ]   [ # 9 ]   [ Rating: 0 ]
Avatar
Joined: 2009-04-04
194 posts

Ugh.. This is exactly opposite of what I need.

I need my custom auth lib to SSO into phpBB3… I guess I’ll roll my own.

 Signature 

Postmark Library
CloudIgniter—Legit CodeIgniter Hosting
Seriously Awesome MojoMotor Addons

 
Posted: 13 October 2009 07:26 AM   [ Ignore ]   [ # 10 ]   [ Rating: 0 ]
Joined: 2009-10-13
5 posts

The Library is too good. But is all about getting info from phpbb session to CI, I had requirement where in backend of my application i need a single login for phpbb admin and CI user sesion data. Can any one help me?.. or has anybody tried out this..

 Signature 
 
Posted: 13 October 2009 12:21 PM   [ Ignore ]   [ # 11 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-03
69 posts

If I understand you correctly, you need to verify a user based on his phpBB account and then set a CodeIgniter user session data?

If that is the case, it shouldn’t be too hard.

You need to verify the user credentials (check how phpBB3 hashes user passwords and build query which checks the user credentials and if the user belongs to the group “Administrators”) and if the query returns a row, set the CodeIgniter user session data.

 Signature 

Open Blog
Kick-ass Blog application built using the CodeIgniter PHP Framework

Official website | My website | Demo | Getting started

 
Posted: 16 October 2009 03:13 AM   [ Ignore ]   [ # 12 ]   [ Rating: 0 ]
Joined: 2009-10-13
5 posts

Thanks to you for replying…...

Basically what i want is maintain the same account for my back end of site which is in CI and BB administrator. So when admin is logged in back end of site ,He also gets access to PhpBB administrator panel with same account. Any way am trying it, mean while if any suggestions .. Please post it.

 Signature 
 
Posted: 16 October 2009 05:16 AM   [ Ignore ]   [ # 13 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-03
69 posts

Yes, and the logical solution would be to use the phpBB user system.

It is a bad idea to have the same data in two places (phpBB user table and separate table for your application) - database should be non-redundant.

You can also create new tables to store additional user information (adding new fields to phpBB user table can cause problem with the future phpBB updates) but you should reference the phpBB user table.

 Signature 

Open Blog
Kick-ass Blog application built using the CodeIgniter PHP Framework

Official website | My website | Demo | Getting started

 
Posted: 22 October 2009 05:38 AM   [ Ignore ]   [ # 14 ]   [ Rating: 0 ]
Avatar
Joined: 2009-07-27
3 posts

I’ve got an error like this:

Fatal errorCannot redeclare redirect() 
(
previously declared in /var/www/portal/system/helpers/url_helper.php:530
in /var/www/portal/forum/includes/functions.php on line 2184 

any idea what went wrong?
i’m auto-loading the url helper, could it be that’s the problem?
if it is, how can i fix this?

 Signature 

Don’t waste time or time will waste you

 
Posted: 22 October 2009 07:45 AM   [ Ignore ]   [ # 15 ]   [ Rating: 0 ]
Avatar
Joined: 2008-09-03
69 posts

Yes, URL helper is causing the problem.

One solution would be to rename the redirect function in the URL helper (for example to something like CI_redirect()).

 Signature 

Open Blog
Kick-ass Blog application built using the CodeIgniter PHP Framework

Official website | My website | Demo | Getting started

 
1 of 7
1