1

I am working with custom module of activecollab, I need to know how can I fetch logged in user data with the help of below object

$this->logged_user 

or if anyone have another method to grab logged in user then please letme know, I just want to print logged in user info/data on my page

Modified:

When I use this object in model it couldn't work for me, So anyone have idea of any object of logged in user? by that I can grab logged user id or other stuff; and can work with that object in model as well ?

Shadman
  • 755
  • 2
  • 11
  • 19

4 Answers4

2

ah finaly got a solution ...

in activecollab you can get a logged in user object by this line in everywhere where you dont have user object $this->logged_user

$this->logged_user = Authentication::getLoggedUser();

and to get logged in user other basic informations you can use:

$this->logged_user->getId()
$this->logged_user->getName()
$this->logged_user->getDisplayName()
$this->logged_user->getEmail()
$this->logged_user->getCompany()
$this->logged_user->isAdministrator()
$this->logged_user->getLanguage()
Shadman
  • 755
  • 2
  • 11
  • 19
1

This appears to be resolve. Still, here's clarification in case someone else stumbles upon this question:

  1. $this->logged_user is available only in controllers, but not in model
  2. $logged_user is available in views, so you can use something like: {$logged_user->getFirstName(true)|clean}
  3. Everywhere else, use Authentication::getLoggedUser()
Ilija
  • 4,105
  • 4
  • 32
  • 46
0

I assume you have code to store logged in user information.

In which case you should just echo it.

For example:

echo $this->logged_user; 

If you have not implemented the code to run behind this then it will not work. Please include more code if you need more information.

Revised answer in light of new information

Now that I know this for an active collab project I will explain in that context.

object ActiveCollab::findUserById( int $user_id)

This will get a user object based on the userID but all the methods for this are set not get that is they write and don't read.

To read you could use the API. Details of how to do this are found here: http://www.activecollab.com/docs/manuals/developers/api/companies-and-users

The API requests are able to handle both read and write actions.

Brett
  • 3,296
  • 5
  • 29
  • 45
  • $this->logged_user is predefine object of activecollab and contains logged in user information, so its not just a simple string or any value, it is an object and a typical object – Shadman May 18 '12 at 06:26
  • @ShadmanJamil thanks for the extra info. I will look it up in activecollab. Do you know what extra logged in user data you wanted? – Brett May 18 '12 at 06:45
  • thanks for reviewing .. I really appreciate your answer, but tell me one thing, if i have already loaded all information of logged in user then why I need to execute query again? and have you any idea about logged in user object? how can i grab information form already set logged in user object? and in addition I am also facing problem to get user id on model file.. – Shadman May 18 '12 at 07:48
0

use

echo $this->logged_user;

To print the variable.

Bhavesh G
  • 3,000
  • 4
  • 39
  • 66
  • $this->logged_user is predefine object of activecollab and contains logged in user information, so its not just a simple string or any value, it is an object and a typical object – Shadman May 18 '12 at 06:27