use database namespace
This commit is contained in:
parent
2c6764c95c
commit
dae88e0407
@ -15,11 +15,13 @@ declare(strict_types=1);
|
||||
namespace Dotclear\Plugin\activityReport;
|
||||
|
||||
use ArrayObject;
|
||||
use cursor;
|
||||
use dcBlog;
|
||||
use dcCore;
|
||||
use dcRecord;
|
||||
use dcUtils;
|
||||
use Dotclear\Database\{
|
||||
Cursor,
|
||||
MetaRecord
|
||||
};
|
||||
use Dotclear\Helper\Network\Http;
|
||||
|
||||
/**
|
||||
@ -270,7 +272,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog(My::id(), 'message', $logs);
|
||||
}
|
||||
|
||||
public static function blogUpdate(cursor $cur, string $blog_id): void
|
||||
public static function blogUpdate(Cursor $cur, string $blog_id): void
|
||||
{
|
||||
$logs = [(string) dcCore::app()->auth?->getInfo('user_cn')];
|
||||
ActivityReport::instance()->addLog('blog', 'update', $logs);
|
||||
@ -285,7 +287,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog('blog', 'p404', $logs);
|
||||
}
|
||||
|
||||
public static function postCreate(cursor $cur, int $post_id): void
|
||||
public static function postCreate(Cursor $cur, int $post_id): void
|
||||
{
|
||||
$type = $cur->getField('post_type') ?? 'post';
|
||||
$post_url = dcCore::app()->blog?->getPostURL('', $cur->getField('post_dt'), $cur->getField('post_title'), $post_id);
|
||||
@ -297,7 +299,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog('post', 'create', $logs);
|
||||
}
|
||||
|
||||
public static function postUpdate(cursor $cur, int $post_id): void
|
||||
public static function postUpdate(Cursor $cur, int $post_id): void
|
||||
{
|
||||
$type = $cur->getField('post_type') ?? 'post';
|
||||
$post_url = dcCore::app()->blog?->getPostURL('', $cur->getField('post_dt'), $cur->getField('post_title'), $post_id);
|
||||
@ -334,7 +336,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog('post', 'protection', $logs);
|
||||
}
|
||||
|
||||
public static function commentCreate(dcBlog $blog, cursor $cur): void
|
||||
public static function commentCreate(dcBlog $blog, Cursor $cur): void
|
||||
{
|
||||
if ($cur->getField('comment_trackback')) {
|
||||
return;
|
||||
@ -355,7 +357,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog('comment', 'create', $logs);
|
||||
}
|
||||
|
||||
public static function commentUpdate(dcBlog $blog, cursor $cur, dcRecord $old): void
|
||||
public static function commentUpdate(dcBlog $blog, Cursor $cur, MetaRecord $old): void
|
||||
{
|
||||
$posts = dcCore::app()->blog?->getPosts(
|
||||
['post_id' => $old->f('post_id'), 'limit' => 1]
|
||||
@ -373,7 +375,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog('comment', 'update', $logs);
|
||||
}
|
||||
|
||||
public static function trackbackCreate(dcBlog $blog, cursor $cur): void
|
||||
public static function trackbackCreate(dcBlog $blog, Cursor $cur): void
|
||||
{
|
||||
if (!$cur->getField('comment_trackback')) {
|
||||
return;
|
||||
@ -396,7 +398,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog('comment', 'trackback', $logs);
|
||||
}
|
||||
|
||||
public static function categoryCreate(cursor $cur, int $cat_id): void
|
||||
public static function categoryCreate(Cursor $cur, int $cat_id): void
|
||||
{
|
||||
$logs = [
|
||||
(string) $cur->getField('cat_title'),
|
||||
@ -406,7 +408,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog('category', 'create', $logs);
|
||||
}
|
||||
|
||||
public static function categoryUpdate(cursor $cur, int $cat_id): void
|
||||
public static function categoryUpdate(Cursor $cur, int $cat_id): void
|
||||
{
|
||||
$logs = [
|
||||
(string) $cur->getField('cat_title'),
|
||||
@ -416,7 +418,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog('category', 'update', $logs);
|
||||
}
|
||||
|
||||
public static function userCreate(cursor $cur, string $user_id): void
|
||||
public static function userCreate(Cursor $cur, string $user_id): void
|
||||
{
|
||||
$user_cn = dcUtils::getUserCN(
|
||||
$cur->getField('user_id'),
|
||||
@ -431,7 +433,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog('user', 'create', $logs);
|
||||
}
|
||||
|
||||
public static function userUpdate(cursor $cur, string $user_id): void
|
||||
public static function userUpdate(Cursor $cur, string $user_id): void
|
||||
{
|
||||
$user_cn = dcUtils::getUserCN(
|
||||
$cur->getField('user_id'),
|
||||
@ -446,7 +448,7 @@ class ActivityBehaviors
|
||||
ActivityReport::instance()->addLog('user', 'update', $logs);
|
||||
}
|
||||
|
||||
public static function userPreference(cursor $cur, string $user_id): void
|
||||
public static function userPreference(Cursor $cur, string $user_id): void
|
||||
{
|
||||
$user = dcCore::app()->getUser($user_id);
|
||||
if ($user->isEmpty()) {
|
||||
|
@ -18,7 +18,7 @@ use ArrayObject;
|
||||
use dcAuth;
|
||||
use dcBlog;
|
||||
use dcCore;
|
||||
use dcRecord;
|
||||
use Dotclear\Database\MetaRecord;
|
||||
use Dotclear\Database\Statement\{
|
||||
DeleteStatement,
|
||||
JoinStatement,
|
||||
@ -61,6 +61,7 @@ class ActivityReport
|
||||
/** @var ActivityReport $instance ActivityReport instance */
|
||||
private static $instance;
|
||||
|
||||
/** @var null|resource $lock File lock for update */
|
||||
private $lock = null;
|
||||
|
||||
/**
|
||||
@ -100,9 +101,9 @@ class ActivityReport
|
||||
* @param bool $count_only Count only
|
||||
* @param null|SelectStatement $ext_sql The sql select statement
|
||||
*
|
||||
* @return null|dcRecord The logs record
|
||||
* @return null|MetaRecord The logs record
|
||||
*/
|
||||
public function getLogs(ArrayObject $params = null, bool $count_only = false, ?SelectStatement $ext_sql = null): ?dcRecord
|
||||
public function getLogs(ArrayObject $params = null, bool $count_only = false, ?SelectStatement $ext_sql = null): ?MetaRecord
|
||||
{
|
||||
if (is_null($params)) {
|
||||
$params = new ArrayObject();
|
||||
@ -271,11 +272,11 @@ class ActivityReport
|
||||
/**
|
||||
* Parse logs using a format.
|
||||
*
|
||||
* @param dcRecord $rs The logs record
|
||||
* @param MetaRecord $rs The logs record
|
||||
*
|
||||
* @return string The parsed logs
|
||||
*/
|
||||
private function parseLogs(dcRecord $rs): string
|
||||
private function parseLogs(MetaRecord $rs): string
|
||||
{
|
||||
$from = time();
|
||||
$to = 0;
|
||||
|
@ -14,9 +14,9 @@ declare(strict_types=1);
|
||||
|
||||
namespace Dotclear\Plugin\activityReport;
|
||||
|
||||
use dbStruct;
|
||||
use dcCore;
|
||||
use dcNsProcess;
|
||||
use Dotclear\Database\Structure;
|
||||
use Dotclear\Database\Statement\{
|
||||
DropStatement,
|
||||
TruncateStatement
|
||||
@ -46,16 +46,16 @@ class Install extends dcNsProcess
|
||||
try {
|
||||
self::beforeGrowUp();
|
||||
|
||||
$s = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$s->{My::ACTIVITY_TABLE_NAME}
|
||||
->activity_id('bigint', 0, false)
|
||||
->activity_type('varchar', 32, false, "'" . My::id() . "'")
|
||||
->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_status('smallint', 0, false, 0)
|
||||
$s = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$s->__get(My::ACTIVITY_TABLE_NAME)
|
||||
->field('activity_id', 'bigint', 0, false)
|
||||
->field('activity_type', 'varchar', 32, false, "'" . My::id() . "'")
|
||||
->field('blog_id', 'varchar', 32, true)
|
||||
->field('activity_group', 'varchar', 32, false)
|
||||
->field('activity_action', 'varchar', 32, false)
|
||||
->field('activity_logs', 'text', 0, false)
|
||||
->field('activity_dt', 'timestamp', 0, false, 'now()')
|
||||
->field('activity_status', 'smallint', 0, false, 0)
|
||||
|
||||
->primary('pk_activity', 'activity_id')
|
||||
->index('idx_activity_type', 'btree', 'activity_type')
|
||||
@ -63,7 +63,7 @@ class Install extends dcNsProcess
|
||||
->index('idx_activity_action', 'btree', 'activity_group', 'activity_action')
|
||||
->index('idx_activity_status', 'btree', 'activity_status');
|
||||
|
||||
(new dbStruct(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
|
||||
(new Structure(dcCore::app()->con, dcCore::app()->prefix))->synchronize($s);
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
@ -82,7 +82,7 @@ class Install extends dcNsProcess
|
||||
|
||||
// sorry not sorry we restart from scratch
|
||||
if ($current && version_compare($current, '3.0', '<')) {
|
||||
$struct = new dbStruct(dcCore::app()->con, dcCore::app()->prefix);
|
||||
$struct = new Structure(dcCore::app()->con, dcCore::app()->prefix);
|
||||
|
||||
if ($struct->tableExists('activity')) {
|
||||
(new TruncateStatement())->from(dcCore::app()->prefix . 'activity')->truncate();
|
||||
|
Loading…
Reference in New Issue
Block a user