New field to show the day of the last activity
This commit is contained in:
parent
fbcc56d42d
commit
f905220923
8 changed files with 50 additions and 4 deletions
|
@ -260,6 +260,17 @@ class Relation
|
|||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the cached suggestion is outdated
|
||||
*
|
||||
* @param integer $uid
|
||||
* @return boolean
|
||||
*/
|
||||
static public function areSuggestionsOutdated(int $uid): bool
|
||||
{
|
||||
return DI::pConfig()->get($uid, 'suggestion', 'last_update') + 3600 < time();
|
||||
}
|
||||
|
||||
/**
|
||||
* Update contact suggestions for a given user
|
||||
*
|
||||
|
@ -268,7 +279,7 @@ class Relation
|
|||
*/
|
||||
static public function updateCachedSuggestions(int $uid)
|
||||
{
|
||||
if (DI::pConfig()->get($uid, 'suggestion', 'last_update') + 3600 > time()) {
|
||||
if (!self::areSuggestionsOutdated($uid)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -665,6 +665,22 @@ class User
|
|||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the day of the last activity of the given user
|
||||
*
|
||||
* @param integer $uid
|
||||
* @return void
|
||||
*/
|
||||
public static function updateLastActivity(int $uid)
|
||||
{
|
||||
$user = User::getById($uid, ['last-activity']);
|
||||
$current_day = date('Y-m-d');
|
||||
|
||||
if ($user['last-activity'] != $current_day) {
|
||||
User::update(['last-activity' => $current_day], $uid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a human-readable random password
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue