⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Capture and Display session of last row editor



Adriana

Adriana
  • profile picture
  • Member

Posted 22 July 2015 - 23:50 PM

Hello All,

Is anyone able to help me on how to display session of last editor per row in grocery crud? Is this done by using callback column? I really appreciate if someone can help me?

Thank you


Paul Savostin

Paul Savostin
  • profile picture
  • Member

Posted 23 July 2015 - 11:42 AM

hi! u mean save last user who modified the row in this row?


Adriana

Adriana
  • profile picture
  • Member

Posted 23 July 2015 - 23:00 PM

Yes, that is correct. Thank you :)


Paul Savostin

Paul Savostin
  • profile picture
  • Member

Posted 24 July 2015 - 00:35 AM

First of all u need to user_id in row of this record, in callback_update / insert set this user_id from session and in callback_column show this user


Adriana

Adriana
  • profile picture
  • Member

Posted 24 July 2015 - 00:49 AM

Thank you Paul. I have the session started. So How would you pass the user in session?. For example I have $_SESSION["user"], if I echo this it will give the person in session. but if if I use user_id will it be initialized? Would you please the above a bit better? I am so sorry for disturbing you and thank you again.


Paul Savostin

Paul Savostin
  • profile picture
  • Member

Posted 24 July 2015 - 01:14 AM

if u using codeigniter than u need to use auth library, for example, i am using ion_auth - pretty cool library. and in this library u can easily get user_id like $this->ion_auth->get_user_id()

unfortunately, i dont know how u handle users in your application :(


Adriana

Adriana
  • profile picture
  • Member

Posted 24 July 2015 - 01:55 AM

I have add the library now how would you show the user's id on for example add_field_callback?

I really appreciate your help on this.


Adriana

Adriana
  • profile picture
  • Member

Posted 24 July 2015 - 02:02 AM

Following last post.

Would that be like this?

I have add the following to my controller:

 

$this->load->library('ion_auth'); //In my constructor

 

After this then:

public function example() // Grocery Crud Function
    {

      .........

      .......

 

    $crud->callback_add_field('confirm',array($this,'add_field_callback_sessions'));

    $output = $crud->render();
                       
                        $this->_example_output($output);

     }

 

After the above the I create a function like this:

 

 function add_field_callback_sessions()
        {
        return '<input type="text" maxlength="50" value='.$this->ion_auth->get_user_id().' name="g_status" style="width:100%">';
        }

However, this still does not show user currently on session.

 

Thank you.


Adriana

Adriana
  • profile picture
  • Member

Posted 24 July 2015 - 02:05 AM

I have done some corrections but still it doesn't show session:

I have add the following to my controller:

 

$this->load->library('ion_auth'); //In my constructor

 

After this then:

public function example() // Grocery Crud Function
    {

      .........

      .......

 

    $crud->callback_add_field('confirm',array($this,'add_field_callback_sessions'));

    $output = $crud->render();
                       
                        $this->_example_output($output);

     }

 

After the above the I create a function like this:

 

 

  function add_field_callback_sessions()
        {
        return '<input type="text" maxlength="50" value="'.$this->ion_auth->get_user_id().'" name="confirm" style="width:100%">';
        }

 

Thank you


Adriana

Adriana
  • profile picture
  • Member

Posted 24 July 2015 - 02:11 AM

Last thing I am  using adLDAP for users but don't know how to use this in grocery crud :)


Paul Savostin

Paul Savostin
  • profile picture
  • Member

Posted 24 July 2015 - 09:52 AM

sorry but i dont know how to use adLDAP in GC.

U need to write all from beginning to the end

1)How u manage user authorization in your app (for example, i am using ion_auth lib, where i have 3 tables users,groups,users_groups, with this lib i register people)

2)In table where set last modifier need filed user_id render to the user table from ion_auth

3) Why u need to show user_id in add? show it in list state - with callback_column

I need more information because i dont understand what u want to achieve, step by step, very closely, if u dont mind