mirror of
https://github.com/OPSnet/Gazelle.git
synced 2026-01-16 18:04:34 -05:00
34 lines
975 B
PHP
34 lines
975 B
PHP
<?php
|
|
|
|
namespace Gazelle\User\Notification;
|
|
|
|
class Blog extends AbstractNotification {
|
|
public function className(): string {
|
|
return 'information';
|
|
}
|
|
|
|
public function clear(): int {
|
|
return (int)new \Gazelle\WitnessTable\UserReadBlog()->witness($this->user);
|
|
}
|
|
|
|
public function load(): bool {
|
|
$blogMan = new \Gazelle\Manager\Blog();
|
|
$latest = $blogMan->latest();
|
|
if (is_null($latest)) {
|
|
return false;
|
|
}
|
|
$lastRead = new \Gazelle\WitnessTable\UserReadBlog()->lastRead($this->user);
|
|
|
|
// You must be new around here.
|
|
$newJoiner = is_null($lastRead) && $latest->createdEpoch() > strtotime($this->user->created());
|
|
|
|
if ($newJoiner || $latest->id > $lastRead) {
|
|
$this->title = "Blog: " . $latest->title();
|
|
$this->url = $latest->url();
|
|
$this->context = $latest->id;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
}
|