Question

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 ?

Was it helpful?

Solution

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()

OTHER TIPS

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()

use

echo $this->logged_user;

To print the variable.

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top