activityReport/_install.php

63 lines
2.1 KiB
PHP
Raw Normal View History

<?php
2021-09-02 22:18:08 +00:00
/**
* @brief activityReport, a plugin for Dotclear 2
2022-11-18 20:24:30 +00:00
*
2021-09-02 22:18:08 +00:00
* @package Dotclear
* @subpackage Plugin
2022-11-18 20:24:30 +00:00
*
2021-09-02 22:18:08 +00:00
* @author Jean-Christian Denis and contributors
2022-11-18 20:24:30 +00:00
*
2021-09-02 22:18:08 +00:00
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
2022-11-18 20:24:30 +00:00
if (!defined('DC_CONTEXT_ADMIN')) {
2021-09-02 22:51:23 +00:00
return null;
}
2022-12-10 13:46:17 +00:00
if (!dcCore::app()->newVersion(
2022-12-20 19:55:48 +00:00
basename(__DIR__),
2022-12-10 13:46:17 +00:00
dcCore::app()->plugins->moduleInfo(basename(__DIR__), 'version')
2022-12-07 22:57:05 +00:00
)) {
2021-09-02 22:51:23 +00:00
return null;
}
2021-09-02 22:51:23 +00:00
try {
2022-11-18 20:24:30 +00:00
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
2022-11-30 21:35:28 +00:00
$s->{initActivityReport::ACTIVITY_TABLE_NAME}
2022-11-18 20:24:30 +00:00
->activity_id('bigint', 0, false)
2022-12-15 23:32:15 +00:00
->activity_type('varchar', 32, false, "'" . basename(__DIR__) . "'")
2022-11-18 20:24:30 +00:00
->blog_id('varchar', 32, true)
2021-09-02 22:51:23 +00:00
->activity_group('varchar', 32, false)
2022-11-18 20:24:30 +00:00
->activity_action('varchar', 32, false)
->activity_logs('text', 0, false)
->activity_dt('timestamp', 0, false, 'now()')
->activity_blog_status('smallint', 0, false, 0)
->activity_super_status('smallint', 0, false, 0)
2021-09-02 22:51:23 +00:00
->primary('pk_activity', 'activity_id')
->index('idx_activity_type', 'btree', 'activity_type')
->index('idx_activity_blog_id', 'btree', 'blog_id')
->index('idx_activity_action', 'btree', 'activity_group', 'activity_action')
->index('idx_activity_blog_status', 'btree', 'activity_blog_status')
->index('idx_activity_super_status', 'btree', 'activity_super_status');
2021-09-02 22:18:08 +00:00
2022-11-30 21:35:28 +00:00
$s->{initActivityReport::SETTING_TABLE_NAME}
2021-09-02 22:51:23 +00:00
->setting_id('varchar', 64, false)
2022-11-18 20:24:30 +00:00
->blog_id('varchar', 32, true)
2021-09-02 22:51:23 +00:00
->setting_type('varchar', 32, false)
->setting_value('text', 0, false)
2021-09-02 22:18:08 +00:00
2021-09-02 22:51:23 +00:00
->unique('uk_activity_setting', 'setting_id', 'blog_id', 'setting_type')
->index('idx_activity_setting_blog_id', 'btree', 'blog_id')
->index('idx_activity_setting_type', 'btree', 'setting_type');
2021-09-02 22:18:08 +00:00
2022-11-18 20:24:30 +00:00
$si = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
2021-09-02 22:18:08 +00:00
$changes = $si->synchronize($s);
return true;
2021-09-02 22:51:23 +00:00
} catch (Exception $e) {
2022-11-18 20:24:30 +00:00
dcCore::app()->error->add($e->getMessage());
}
2022-11-18 20:24:30 +00:00
return false;