Welcome Guest, Not a member yet? Register   Sign In
Integrate with joomla 3 auth. system
#3

Now I can copy some lines of code from joomla's index.php file and pase then into codeigniter's index.php and get logined joomla user info:

CI3's index.php file :
PHP Code:
...
// joooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooomla
if (version_compare(PHP_VERSION'5.3.1''<'))
{
die(
'Your host needs to use PHP 5.3.1 or higher to run this version of Joomla!');
}
 
define('_JEXEC'1);

if (
file_exists(realpath(__DIR__ '/..') . '/defines.php'))
{
include_once 
realpath(__DIR__ '/..') . '/defines.php';
}
 
if (!
defined('_JDEFINES'))
{
define('JPATH_BASE'realpath(__DIR__ '/..'));
require_once 
JPATH_BASE '/includes/defines.php';
}
 
require_once 
JPATH_BASE '/includes/framework.php';
// jooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooooomla


/*
 * --------------------------------------------------------------------
 * LOAD THE BOOTSTRAP FILE
 * --------------------------------------------------------------------
 *
 * And away we go...
 */
... 

and in any index function of default welcome.php controller :
PHP Code:
...
    public function 
index()
    {
            
$this->output->enable_profiler(TRUE);

            
$this->joomla_app JFactory::getApplication('site');
            
$this->joomla_app->initialise();
            
$this->user JFactory::getUser();
            if(
$this->user->id 0)
            {
                
$this->user_groups $this->user->getAuthorisedGroups();
            }
            
            
print_r($this->user->id);
            echo 
'<br/>';

            
print_r($this->user_groups);
            echo 
'<br/>';
            
            
print_r($this->user->getAuthorisedViewLevels());
            
            
            
        
$this->load->view('welcome_message');
    }
... 

i wondered how it add extra resource usage to normal ci application? i activated ci's profiler and here is some memory usage in different cases:

Just unchanged CI3 welcome page :
~269,000 bytes

Just copied require_once JPATH_BASE . '/includes/framework.php' line into CI's index.php file:
~330,000 bytes

Copies required include file and some lines of code for retrieve user's id and groups (above second code block):
~761,000 bytes

now is it good choice to use this method (checking joomla user) in every page/controller/function? (my application need to check user's access almost in every action)

in real web application/or website, this solution can make issues?
ressan.ir
CI is nice Heart
Reply


Messages In This Thread
RE: Integrate with joomla 3 auth. system - by nasser.man - 08-09-2015, 10:59 AM



Theme © iAndrew 2016 - Forum software by © MyBB