• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Vbulletin and CodeIgniter integration issues..

#1
[eluser]Unknown[/eluser]
Note: This is a solution to a problem I ran into.

I've been working on integrating some data from my VBulletin forums to work in CI; mostly I needed the $vbulletin->session->userinfo var to validate against. I used the solution from this thread -> http://ellislab.com/forums/viewthread/110010/ which is to require VB's global.php in CI's index.php. This works great but it will cause problems with the Form Validation class.

The problem I had was that VBulletin edits the POST vars in global.php and therefor trips the Form Validation class too early. This is my version of the code in the post I linked above to fix this problem (You will have to make a small edit to the global.php file):

index.php
Add this after the error reporting declaration.
Code:
define('CODEIGNITER', TRUE);
    $dir = getcwd();

    chdir('forums/');
    require './global.php';

    chdir($dir);


I am using the library method rather than hooking it.

libraries/vb_bridge.php
I auto-load this library since I use the data all over my site.
Code:
<?php

class vb_bridge
{
    function __construct()
    {
        $CI =& get_instance();
        $CI->vbulletin = $GLOBALS['vbulletin'];

        unset($GLOBALS['vbulletin']);
    }
}


And this is the fix for global.php..

In global.php find (around line 33):
Code:
$vbulletin->input->clean_array_gpc('p', array(
    'ajax' => TYPE_BOOL,
));

replace with:

Code:
if(!defined('CODEIGNITER'))
{
    $vbulletin->input->clean_array_gpc('p', array(
        'ajax' => TYPE_BOOL,
    ));
}


And just for kicks here's a nice test controller:

Code:
<?php

class Test extends Controller
{
    function __construct()
    {
        parent::Controller();
        $this->load->library('vb_bridge');
    }

    function index()
    {
        print_r($this->vbulletin->session->userinfo);
    }


This is a pretty easy way to avoid the issue without breaking your forums or editing core CI files. Hope this helps someone.


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.