Welcome Guest, Not a member yet? Register   Sign In
Community Auth
#11

[eluser]kacyblack[/eluser]
Thanks I was able to fix the last question I asked on my own, But I have a new question and what am trying to achieve this time around is to display a certain DASHBOARD WITH CHART if a user with the Customer role logs in, then another type of DASHBOARD WITHOUT CHART will also display when a user with an Admin Role logs in and this is what i tried and it did not work: AM USING SKUNKBAD'S COMMUNITY-AUTH.

CONTROLLER: if ( ! function_exists('admin_side_menu'))
{

function admin_side_menu($menu_array) {

$CI =& get_instance();

echo '<ul>'; // Open the menu container

//go through each top level menu item
foreach($menu_array as $item) {

$admin_group = $CI->config->item('admin_group', 'ion_auth');

$item['access'] = array_key_exists('access', $item) ? $item['access'] : $admin_group;

if($CI->ion_auth->FALSE){

echo '<li><a href="'.$item['link'].'">'.$item['label'].'</a>';
//see if this menu has children
if(array_key_exists('children', $item)) {
echo '<ul>';
//echo the child menu
admin_side_menu($item['children']);
echo '</ul>';
}
echo '</li>';

}// end if
} // end foreach

echo '</ul>';
}

}




VIEW:


$menu = array(

array(

'label' => 'Dashboard',
'link' => 'admin/dashboard',
'access' => array('system_admin', 'hr', 'guest'),
'children' => array(
array(
'label' => 'Admin Can See',
'link' => 'http://google.com',
'access' => array('system_admin', 'hr', 'guest'),
),
array(
'label' => 'Guest Can See',
'link' => 'http://google.com',
'access' => array('system_admin', 'hr', 'guest'),
)
)
),
);

echo '<nav id="page-leftbar" role="navigation">';
echo admin_side_menu($menu);
echo '</nav>';



Please help me out asap, Thanks Skunkbad you deserve a tip!
#12

[eluser]skunkbad[/eluser]
kacyblack, What are these references to ion auth in your code?
#13

[eluser]kacyblack[/eluser]
Sorry Skunkbad, I made a mistake, this is the simple approach i finally implementate, but I don't know if its safe and okay: I implemented it on user_index.php


Code:
&lt;?php




           // If a customer is logged in
      if( isset( $auth_level ) && $auth_level == 1 )
      {
       echo '<h1>User Index</h1>
<p>This is special content only seen when logged in.
This page could hold any number of things that logged in
users should see or do. Special downloads, videos, information, and top secret stuff...
THIS IS FOR CUSTOMERS ROLE</p>';

      }
      
      // If an admin is logged in
      if( isset( $auth_level ) && $auth_level == 9 )
      {
       echo '<h1>User Index</h1>
<p>This is special content only seen when logged in.
This page could hold any number of things that logged in users should see or do.
Special downloads, videos, information, and top secret stuff...
THIS IS FOR ADMINISTRATORS ROLE</p>';
      }



?&gt;



Please Respond, Thanks
#14

[eluser]kacyblack[/eluser]
Though it worked and its working right now on my application, but is it the right way? and is it safe? Thanks
#15

[eluser]skunkbad[/eluser]
[quote author="kacyblack" date="1393489820"]Though it worked and its working right now on my application, but is it the right way? and is it safe? Thanks[/quote]

Yes, this is how you would do it in a view. Easy, eh? Community Auth is meant to be easy, and I think when you get a little more familiar with everything it offers, it will meet all of your auth needs.
#16

[eluser]kacyblack[/eluser]
Yes its the best, Please where in the Community-Auth official page can one donate for the project at least to show some appreciation, Am using it to build my application and it's really really making Life easier for me. Once again Thanks Skunkbad.
#17

[eluser]kacyblack[/eluser]
Another one is here, Am trying to alter the database table colums in other for it to contain more information like Phone, Language, Date of Birth etc and firstly I added more form fields in the Registration Form php file that is
Code:
registeration_form.php
like this:

Code:
&lt;?php
      // DATE OF BIRTH LABEL AND INPUT ***********************************
      echo form_label('Date Of Birth','dob',array('class'=>'form_label'));
#      echo input_requirement('*');
      $input_data = array(
       'name'  => 'dob',
       'id'  => 'dob',
       'class'  => 'rform_input dob',
       'value'  => set_value('dob'),
       'placeholder'  => ('Date Of Birth: Day/Month/Year'),
       'required'  => ('required'),
       'maxlength' => '20',
      );

      echo form_input($input_data);

     ?&gt;
                    
                    
                    
                                             &lt;?php
      // LANGUAGE LABEL AND INPUT ***********************************
      echo form_label('Language','language',array('class'=>'form_label'));
#      echo input_requirement('*');
      $input_data = array(
       'name'  => 'language',
       'id'  => 'language',
       'class'  => 'rform_input language',
       'value'  => set_value('language'),
       'placeholder'  => ('Language'),
       'required'  => ('required'),
       'maxlength' => '20',
      );

      echo form_input($input_data);

     ?&gt;
                    
                    
                    
                         &lt;?php
      // PHONE NUMBER LABEL AND INPUT ***********************************
      echo form_label('Phone Number','user_phone',array('class'=>'form_label'));
#      echo input_requirement('*');
      $input_data = array(
       'name'  => 'user_phone',
       'id'  => 'user_phone',
       'class'  => 'rform_input user_phone',
       'value'  => set_value('user_phone'),
       'placeholder'  => ('Phone Number'),
       'required'  => ('required'),
       'maxlength' => '20',
      );

      echo form_input($input_data);

     ?&gt;



SECONDLY I ALSO ALTERED
Code:
registration_model.php
like this:


Code:
// Create insert array for registration record
   $insert_array = array(
    'reg_id'         => $registration_id,
    'reg_time'       => time(),
    'user_name'      => set_value('user_name'),
    'user_pass'      => $this->encrypt->encode( $user_salt . set_value('user_pass') ),
    'user_salt'      => $user_salt,
    'user_email'     => set_value('user_email'),
    'first_name'     => set_value('first_name'),
    'last_name'      => set_value('last_name'),
    'street_address' => set_value('street_address'),
    'city'           => set_value('city'),
    'state'          => set_value('state'),
    'zip'            => set_value('zip'),
    'user_phone'     => set_value('user_phone'),
    'dob'            => set_value('dob'),
    'language'       => set_value('language'),
    'user_amount'    => set_value('user_amount'),
   );

   // Insert record
   $this->db->insert( config_item('temp_reg_data_table'), $insert_array );

   if( $this->db->affected_rows() > 0 )
   {
    return $registration_id;
   }
  }



AND LASTLY I UPDATED THE DATABASE TABLE TO INCLUDE THESE VARIABLES ALSO: Like this:


1. temp_registration_data table

2. user table


and I tried to register a new user and the registration was successful but the newly entered data did not show up in the tables after a successful registration, please what am I missing or what am I doing wrong or what am i not doing?

Thanks
#18

[eluser]skunkbad[/eluser]
Kacyblack , I've answered this before and provided a detailed example somewhere here in the forum. If you search around you'll find it. As for the donation, if you'll private message me I'll give you more information.




Theme © iAndrew 2016 - Forum software by © MyBB