mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-25 17:57:28 +08:00
9779c1a357
Put together an initial notification. Started logic to query and identify watchers.
62 lines
1.2 KiB
PHP
62 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace BookStack\Activity;
|
|
|
|
class WatchLevels
|
|
{
|
|
/**
|
|
* Default level, No specific option set
|
|
* Typically not a stored status
|
|
*/
|
|
const DEFAULT = -1;
|
|
|
|
/**
|
|
* Ignore all notifications.
|
|
*/
|
|
const IGNORE = 0;
|
|
|
|
/**
|
|
* Watch for new content.
|
|
*/
|
|
const NEW = 1;
|
|
|
|
/**
|
|
* Watch for updates and new content
|
|
*/
|
|
const UPDATES = 2;
|
|
|
|
/**
|
|
* Watch for comments, updates and new content.
|
|
*/
|
|
const COMMENTS = 3;
|
|
|
|
/**
|
|
* Get all the possible values as an option_name => value array.
|
|
*/
|
|
public static function all(): array
|
|
{
|
|
$options = [];
|
|
foreach ((new \ReflectionClass(static::class))->getConstants() as $name => $value) {
|
|
$options[strtolower($name)] = $value;
|
|
}
|
|
|
|
return $options;
|
|
}
|
|
|
|
public static function levelNameToValue(string $level): int
|
|
{
|
|
return static::all()[$level] ?? -1;
|
|
}
|
|
|
|
public static function levelValueToName(int $level): string
|
|
{
|
|
foreach (static::all() as $name => $value) {
|
|
if ($level === $value) {
|
|
return $name;
|
|
}
|
|
}
|
|
|
|
return 'default';
|
|
}
|
|
}
|