WebsiteBaker Support (2.13.x) > General Help & Support

need some code help

(1/1)

crnogorac081:
I am writing some code, and I need to get data from loged in user, like


--- Code: ---
$this->oReg->getUserId();


--- End code ---
but it is not working. The code is inside the class, so it possible to get loged in user data without using $admin or Session ?

crnogorac081:
I found this in oApp - $this->oApp->->getUserId();


Also would like to report to add timezone to Login class, in lines 419 AND 577 I believe

from

--- Code: ---                             . 'SET `login_when`='.\time().', '

--- End code ---
to


--- Code: ---                             . 'SET `login_when`='.\time() + $this->oReg->DefaultTimezone.', '

--- End code ---

where origianal code is


--- Code: ---                        $sql = 'UPDATE `'.TABLE_PREFIX.'users` '
                             . 'SET `login_when`='.\time().', '
                             .     '`login_ip`=\''.$sRemoteAddress.'\' '
                             . 'WHERE `user_id`=\''.$user_id.'\'';

--- End code ---


sternchen8875:
to the timezone (the old theme...)

normalize, all times are stored in the database in UTC (that's London time). for account-specific datas, the system search everytime, when needed, for the timezone of the logged user and add this timezone to the utc-time. in other, no-user-timezone-specific, it use the DefaultTimezone from the WB-Settings, for example: the date of the last modification in the frontend.

to understand all this, we need an example:

i was for a long time the admin of a charter boot service homepage in the caribic, the page was hosted in germany, because, the owner was a german. so the server-time was utc. as admin, i use utc+1 in winter and utc+2 in summertime. DefaultTimezone in Wb-Settings was UTC +5 and the page-owner has also utc +5 in his profile, because, he live's there in the caribic. If the two of us, the owner and I, log in at the same time, with the "private timezone-settings" from the user-profile, his login time will be 4:30 p.m. (UTC +5) and mine will be 1:30 p.m. (UTC +2), but we are online at the same time. if we use the globale DefaultTimezone from the WB-Settings, the database say's: i'm online at 4.30 p.m., but here it is 0.30 p.m.
If we only use time(), everyone has the same time in the database and WB then uses the profile data to calculate the correct time


DarkViper:
It is definitely not a good idea to change the kind of table column value. Other modules and also the core trust on the fact that they find a time in UTC here and not values ​​that are distorted by any time zone information.
Note: Never change other modules without really knowing all the side effects that can be triggered!
Time zone information should only be used for input and display purposes. All internal time calculations are always carried out in UTC.
This is the only way to ensure stable handling across all time zones.

Example:
--- Code: ---Input : Local_time - Timezone = UTC
Output: UTC + Timezone        = Local_time
--- End code ---

have a nice day
Manuela

crnogorac081:
Thank you both I understand now

Navigation

[0] Message Index

Go to full version