Welcome Guest, Not a member yet? Register   Sign In
I am creating a new library to codeignighter, seem i cannot use/load helper i've created
#1

[eluser]netameta1[/eluser]
basically i have a helper file with several function.
I auto load the helper in the config file so theoretically reloading it is not required.

However when i try to use the function that i created(from this helper) within a new library that i am working on it will through this error:

Code:
"Parse error: syntax error, unexpected '(', expecting ',' or ';' in /home/techwork/public_html/giverhub/application/libraries/Udetails.php on line 7"


Whenever i use that function anywhere else(module,controller,views) it works fine.

I then read and thought maybe i should try loading the helper after following instructions at:
http://ellislab.com/codeigniter/user-gui...aries.html

and try referencing and loading but that also through an error:

Code:
"Parse error: syntax error, unexpected T_VARIABLE, expecting T_FUNCTION in /home/techwork/public_html/giverhub/application/libraries/Udetails.php on line 5"


Here is the library:
Code:
class Udetails{

$CI =& get_instance();// referencing as described in their website
$CI->load->helper('mylogin_helper');// loading the helper
public $member_session = is_member(); // using the function
public $username = $member_session['username'];
public $current_uID = $member_session['id'];
public $member_status = $member_session['status'];
    }

Here is the function within the helper:
Code:
if ( ! function_exists('is_member'))
    {
     function is_member(){
      $CI =& get_instance();
  $is_logged_in = $CI->session->userdata('is_logged_in');
  $username = $CI->session->userdata('username');
  $capabilities = $CI->session->userdata('capabilities');
  $user_id = $CI->session->userdata('id');
  switch ($capabilities){
   case 'registered':
     $level = 1;
     break;
   case 'confirmed':
     $level = 2;
     break;
   case 'charity_admin':
     $level = 3;
     break;
   case 'admin':
     $level = 4;
     break;
   case 'super_admin':
     $level = 5;
     break;
   default:
     $level = 0;
  }
  
  $userdetails = array();
  if(isset($is_logged_in) && $is_logged_in == true){
   if($level > 1){
    $userdetails['username'] = $username;
    $userdetails['status'] = TRUE;
    $userdetails['id'] = $user_id;
    return $userdetails;
   }
    
  }

}  
    }

Thanks in advanced.


Messages In This Thread
I am creating a new library to codeignighter, seem i cannot use/load helper i've created - by El Forum - 10-19-2012, 09:07 AM



Theme © iAndrew 2016 - Forum software by © MyBB