[eluser]Sawariya[/eluser]
Hi Friends
How can call a library class in anothor library..
i created two libraries
i have one library name abcd and abcd is bcd
class CI_abcd {
var $obj;
function CI_abcd ()
{
$this->obj =& get_instance();
$this->obj->load->library('ua_abcd ');
log_message('debug',
'User Authentication Class Initialised via '.get_class($this->obj));
}
}
this is correct way to call ??
[eluser]xwero[/eluser]
Yes. A library where you use the get_instance function isn't that much different from a model or controller.
[eluser]Sawariya[/eluser]
but i am getting this error..
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Front::$authorize
Filename: controllers/front.php
Line Number: 44
Fatal error: Call to a member function roleCheck() on a non-object in E:\xampp\htdocs\userauth\system\application\controllers\front.php on line 44
[eluser]Sawariya[/eluser]
Anybody can help me
[eluser]Sawariya[/eluser]
Thanks for your reply ...
i have already tried this ..
but its not working...
any other solution from your side???
[eluser]Sawariya[/eluser]
one library is---Userauth
class CI_Userauth {
var $obj;
function CI_Userauth()
{
$this->obj =& get_instance();
$this->obj->load->model('user_group_model', '', TRUE);
$this->obj->load->model('remember_me', '', TRUE);
$this->obj->load->library('ua_authorize');
log_message('debug',
'User Authentication Class Initialised via '.get_class($this->obj));
}
}
another one is
class Ua_authorize {
// ACL variables
var $allowed_users = array(); // Allowed Groups and users
var $denied_users = array(); // Denied Groups and users
var $allowed_set = FALSE; // Has set_allowed() been used
var $denied_set = FALSE; // Has set_denied() been used
var $allow = FALSE; // Cuurent status of permission
function Ua_authorize()
{
$this->obj =& get_instance();
}
}
[eluser]tonanbarbarian[/eluser]
I do not see the method roleCheck nor the place where it is called in the code you have provided
please be a bit more complete with the code
if you can show the full code and indicate where exactly the error is occuring maybe we can help
[eluser]Sawariya[/eluser]
Thanks for your reply here is library..
<?php if (!defined('BASEPATH')) exit('No direct script access allowed');
class Ua_authorize {
var $allowed_users = array(); // Allowed Groups and users
var $denied_users = array(); // Denied Groups and users
var $allowed_set = FALSE; // Has set_allowed() been used
var $denied_set = FALSE; // Has set_denied() been used
var $allow = FALSE; // Cuurent status of permission
function Ua_authorize()
{
$this->obj =& get_instance();
}
function roleCheck($role = 'guest', $uri = '')
{
If ( $role != 'guest' ) {
$list = 'ua_role_'.$role.'_allow';
$list = $this->obj->config->item($list);
if( !empty($list) ) { $this->set_allow($list); }
$list = 'ua_role_'.$role.'_deny';
$list = $this->obj->config->item($list);
if( !empty($list) ) { $this->set_deny($list); }
}
$this->obj->session->set_flashdata('uri', $uri);
log_message('debug','roleCheck: Role = '.$role);
if(!$this->obj->userauth->check('', TRUE)) {
redirect('user/auth_error');
}
}