Rewrote permissions system.

This commit is contained in:
flash 2023-08-30 22:37:21 +00:00
parent 0d90b6576b
commit 349cc237c5
63 changed files with 1286 additions and 989 deletions

View file

@ -81,7 +81,8 @@ msz_sched_task_func('Recount forum topics and posts.', true, function() use ($ms
msz_sched_task_sql('Clean up expired 2fa tokens.', false,
'DELETE FROM msz_auth_tfa WHERE tfa_created < NOW() - INTERVAL 15 MINUTE');
// make sure this one remains last
// very heavy stuff that should
msz_sched_task_func('Resync statistics counters.', true, function() use ($msz) {
$dbConn = $msz->getDbConn();
$counters = $msz->getCounters();
@ -139,6 +140,15 @@ msz_sched_task_func('Resync statistics counters.', true, function() use ($msz) {
}
});
msz_sched_task_func('Recalculate permissions (maybe)...', false, function() use ($msz) {
$needsRecalc = $msz->getConfig()->getBoolean('perms.needsRecalc');
if(!$needsRecalc)
return;
$msz->getConfig()->removeValues('perms.needsRecalc');
$msz->getPerms()->precalculatePermissions($msz->getForum());
});
echo 'Running ' . count($schedTasks) . ' tasks...' . PHP_EOL;
$dbConn = $msz->getDbConn();

8
tools/recalc-perms Normal file
View file

@ -0,0 +1,8 @@
#!/usr/bin/env php
<?php
namespace Misuzu;
require_once __DIR__ . '/../misuzu.php';
$msz->getConfig()->removeValues('perms.needsRecalc');
$msz->getPerms()->precalculatePermissions($msz->getForum());