activityReport/_install.php

64 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
*
* @package Dotclear
* @subpackage Plugin
*
* @author Jean-Christian Denis and contributors
*
* @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/
2021-09-02 22:51:23 +00:00
if (!defined('DC_CONTEXT_ADMIN')) {
return null;
}
2021-09-02 22:51:23 +00:00
$new_version = $core->plugins->moduleInfo('activityReport', 'version');
$old_version = $core->getVersion('activityReport');
2021-09-02 22:51:23 +00:00
if (version_compare($old_version, $new_version, '>=')) {
return null;
}
2021-09-02 22:51:23 +00:00
try {
$s = new dbStruct($core->con, $core->prefix);
2021-09-02 22:18:08 +00:00
$s->activity
2021-09-02 22:51:23 +00:00
->activity_id ('bigint', 0, false)
->activity_type ('varchar', 32, false, "'activityReport'")
->blog_id ('varchar', 32, true)
->activity_group('varchar', 32, false)
->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
$s->activity_setting
2021-09-02 22:51:23 +00:00
->setting_id('varchar', 64, false)
->blog_id ('varchar', 32, true)
->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
2021-09-02 22:51:23 +00:00
$si = new dbStruct($core->con, $core->prefix);
2021-09-02 22:18:08 +00:00
$changes = $si->synchronize($s);
2021-09-02 22:51:23 +00:00
$core->setVersion('activityReport', $new_version);
2021-09-02 22:18:08 +00:00
return true;
2021-09-02 22:51:23 +00:00
} catch (Exception $e) {
2021-09-02 22:18:08 +00:00
$core->error->add($e->getMessage());
}
2021-09-02 22:18:08 +00:00
return false;