Skip to content

Commit fdfc5a2

Browse files
author
Dmytro Voskoboinikov
committed
MAGETWO-34359: Move last logged in block to Customer module
1 parent 00c625b commit fdfc5a2

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

app/code/Magento/Customer/Block/Adminhtml/Edit/Tab/View/PersonalInfo.php

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,8 @@ private function getGroup($groupId)
287287
}
288288

289289
/**
290+
* Returns timezone of the store to which customer assigned.
291+
*
290292
* @return string
291293
*/
292294
public function getStoreLastLoginDateTimezone()
@@ -301,20 +303,31 @@ public function getStoreLastLoginDateTimezone()
301303
/**
302304
* Get customer's current status.
303305
*
306+
* Customer considered 'Offline' in the next cases:
307+
*
308+
* - customer has never been logged in;
309+
* - customer clicked 'Log Out' link\button;
310+
* - predefined interval has passed since customer's last activity.
311+
*
312+
* In all other cases customer considered 'Online'.
313+
*
304314
* @return \Magento\Framework\Phrase
305315
*/
306316
public function getCurrentStatus()
307317
{
318+
// Customer has never been logged in.
308319
if (!$this->getCustomerLog()->getLastLoginAt()) {
309320
return __('Offline');
310321
}
311322

323+
// Customer clicked 'Log Out' link\button.
312324
if ($this->getCustomerLog()->getLastLogoutAt() &&
313325
strtotime($this->getCustomerLog()->getLastLogoutAt()) > strtotime($this->getCustomerLog()->getLastLoginAt())
314326
) {
315327
return __('Offline');
316328
}
317329

330+
// Predefined interval has passed since customer's last activity.
318331
$interval = $this->getOnlineMinutesInterval();
319332

320333
if ($this->getCustomerLog()->getLastVisitAt() &&
@@ -333,28 +346,36 @@ public function getCurrentStatus()
333346
*/
334347
public function getLastLoginDate()
335348
{
336-
if ($date = $this->getCustomerLog()->getLastLoginAt()) {
349+
$date = $this->getCustomerLog()->getLastLoginAt();
350+
351+
if ($date) {
337352
return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true);
338353
}
354+
339355
return __('Never');
340356
}
341357

342358
/**
359+
* Returns customer last login date in store's timezone.
360+
*
343361
* @return \Magento\Framework\Phrase|string
344362
*/
345363
public function getStoreLastLoginDate()
346364
{
347-
if ($date = strtotime($this->getCustomerLog()->getLastLoginAt())) {
365+
$date = strtotime($this->getCustomerLog()->getLastLoginAt());
366+
367+
if ($date) {
348368
$date = $this->_localeDate->scopeDate($this->getCustomer()->getStoreId(), $date, true);
349369
return $this->formatDate($date, TimezoneInterface::FORMAT_TYPE_MEDIUM, true);
350370
}
371+
351372
return __('Never');
352373
}
353374

354375
/**
355-
* Return online minutes interval.
376+
* Returns interval that shows how long customer will be considered 'Online'.
356377
*
357-
* @return int Minutes Interval
378+
* @return int Interval in minutes
358379
*/
359380
protected function getOnlineMinutesInterval()
360381
{

0 commit comments

Comments
 (0)