fetching logged in user data in activecollab by $this->logged_user

笑着哭i 提交于 2019-12-24 06:58:47

问题


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 ?


回答1:


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



回答2:


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



回答3:


use

echo $this->logged_user;

To print the variable.




回答4:


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.



来源:https://stackoverflow.com/questions/10633593/fetching-logged-in-user-data-in-activecollab-by-this-logged-user

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!