[image_view_counter] use a proper DB version counter
This commit is contained in:
parent
7150af6b9e
commit
d7f0f17fea
2 changed files with 18 additions and 2 deletions
10
ext/image_view_counter/config.php
Normal file
10
ext/image_view_counter/config.php
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Shimmie2;
|
||||
|
||||
abstract class ImageViewCounterConfig
|
||||
{
|
||||
public const VERSION = 'ext_image_view_counter';
|
||||
}
|
|
@ -6,6 +6,8 @@ namespace Shimmie2;
|
|||
|
||||
use function MicroHTML\{TD,TH,TR};
|
||||
|
||||
require_once "config.php";
|
||||
|
||||
class ImageViewCounter extends Extension
|
||||
{
|
||||
/** @var ImageViewCounterTheme */
|
||||
|
@ -78,14 +80,18 @@ class ImageViewCounter extends Extension
|
|||
{
|
||||
global $database, $config;
|
||||
|
||||
if ($config->get_bool("image_viewcounter_installed") == false) { //todo
|
||||
if ($config->get_bool("image_viewcounter_installed")) {
|
||||
$this->set_version(ImageViewCounterConfig::VERSION, 1);
|
||||
$config->delete("image_viewcounter_installed");
|
||||
}
|
||||
if ($this->get_version(ImageViewCounterConfig::VERSION) < 1) {
|
||||
$database->create_table("image_views", "
|
||||
id SCORE_AIPK,
|
||||
image_id INTEGER NOT NULL,
|
||||
user_id INTEGER NOT NULL,
|
||||
timestamp INTEGER NOT NULL,
|
||||
ipaddress SCORE_INET NOT NULL");
|
||||
$config->set_bool("image_viewcounter_installed", true);
|
||||
$this->set_version(ImageViewCounterConfig::VERSION, 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Reference in a new issue