Skip to content

Commit 1b57497

Browse files
author
Tatiana
committed
6.14.61.0
2 parents 2313713 + 5a5f9cd commit 1b57497

14 files changed

+138
-456
lines changed

bin/totum

+2
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ use totum\commands\SchemaBackup;
2929
use totum\commands\SchemaUserUnblock;
3030
use totum\commands\ServiceNotifications;
3131
use totum\commands\SetHiddenHost;
32+
use totum\commands\SwitchOffExtraNotifications;
3233
use totum\commands\Vacuum;
3334
use totum\common\configs\MultiTrait;
3435
use totum\config\Conf;
@@ -55,6 +56,7 @@ if (class_exists(Conf::class)) {
5556
$app->add(new CodeExec());
5657
$app->add(new SchemaUserUnblock());
5758
$app->add(new ServiceNotifications());
59+
$app->add(new SwitchOffExtraNotifications());
5860

5961
if (key_exists(MultiTrait::class, class_uses(Conf::class, false))) {
6062
$app->add(new SchemasCrons());

http/js/functions.js

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
<?php
2+
3+
4+
namespace totum\commands;
5+
6+
use Symfony\Component\Console\Command\Command;
7+
use Symfony\Component\Console\Input\InputInterface;
8+
use Symfony\Component\Console\Input\InputOption;
9+
use Symfony\Component\Console\Output\OutputInterface;
10+
use totum\common\configs\ConfParent;
11+
use totum\common\configs\MultiTrait;
12+
use totum\common\Services\Services;
13+
use totum\config\Conf;
14+
15+
class SwitchOffExtraNotifications extends Command
16+
{
17+
protected function configure()
18+
{
19+
$this->setName('switch-off-extra-notifications')
20+
->setDescription('Set off status for older notifications more than max argument')
21+
->addArgument('max', InputOption::VALUE_REQUIRED, 'Max limit for notifications');
22+
if (key_exists(MultiTrait::class, class_uses(Conf::class, false))) {
23+
$this->addArgument('schema', InputOption::VALUE_REQUIRED, 'Enter schema name');
24+
}
25+
}
26+
27+
protected function execute(InputInterface $input, OutputInterface $output): int
28+
{
29+
$Conf = new Conf();
30+
31+
if (is_callable([$Conf, 'setHostSchema'])) {
32+
if ($schema = $input->getArgument('schema')) {
33+
}
34+
}
35+
if (empty($schema)) {
36+
$schema = $Conf->getSchema(true);
37+
}
38+
39+
40+
$sql = $Conf->getSql(true, false);
41+
42+
$max = $input->getArgument('max') ?? '';
43+
if (!ctype_digit($max)){
44+
throw new \Exception('Argument max must be integer');
45+
}
46+
$max = (int)$max;
47+
if ($max < 1){
48+
throw new \Exception('Argument max must be > 0');
49+
}
50+
51+
$sql->exec('WITH ranked_entries AS (
52+
SELECT
53+
id,
54+
ROW_NUMBER() OVER (PARTITION BY user_id->>\'v\' ORDER BY active_dt_from->>\'v\' DESC) AS rnk
55+
FROM
56+
notifications
57+
WHERE active->>\'v\' = \'true\'
58+
)
59+
UPDATE notifications set active = \'{"v":false}\'
60+
WHERE id IN (
61+
SELECT id FROM ranked_entries WHERE rnk > '.$max.'
62+
)');
63+
64+
return 0;
65+
}
66+
67+
}

totum/common/Totum.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
*/
2828
class Totum
2929
{
30-
public const VERSION = '5.14.61.0';
30+
public const VERSION = '6.14.61.0';
3131

3232

3333
public const TABLE_CODE_PARAMS = ['row_format', 'table_format', 'on_duplicate', 'default_action'];

totum/common/calculates/CalculateAction.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ function ($match) use ($params) {
104104
return match ($match[1]) {
105105
'Title_of_notification' => $params['title'],
106106
'Text' => $params['eml'],
107-
'domen' => $this->Table->getTotum()->getConfig()->getFullHostName(),
107+
'domen', 'domain' => $this->Table->getTotum()->getConfig()->getFullHostName(),
108108
default => null,
109109
};
110110
},

totum/fieldTypes/Comments.php

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
use totum\common\Auth;
1212
use totum\common\calculates\Calculate;
13+
use totum\common\configs\ConfParent;
1314
use totum\common\criticalErrorException;
1415
use totum\common\errorException;
1516
use totum\common\Field;
@@ -34,9 +35,10 @@ protected function __construct($fieldData, aTable $table)
3435
}
3536
}
3637

37-
public static function removeViewedForField($table_id, $field_name, $Config)
38+
public static function removeViewedForField($table_id, $field_name, ConfParent $Config)
3839
{
39-
$Config->getSql()->exec('delete from ' . static::table_viewed . ' where table_id=' . $table_id . ' AND field_name=\'' . $field_name . '\'');
40+
$prepared = $Config->getSql()->getPrepared('delete from ' . static::table_viewed . ' where table_id=? AND field_name=?');
41+
$prepared->execute([$table_id, $field_name]);
4042
}
4143

4244
public function getValueFromCsv($val)

totum/models/TablesCalcsConnects.php

+10-6
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,16 @@ public function addConnects($tableId, array $sourceTableIds, $cycle_id = 0, $cyc
4343

4444
public function duplicateCycleSources($tables, $cycleBaseId, $cycleNewId)
4545
{
46-
$this->exec('insert into ' . $this->table . ' (table_id, cycle_id, cycles_table_id, source_table_id) ' .
47-
'(select table_id, ' . $cycleNewId . ', cycles_table_id, source_table_id from ' .
48-
$this->table . ' where cycle_id IN (' . implode(
49-
',',
50-
$tables
51-
) . ') AND cycle_id=' . $cycleBaseId . ')');
46+
47+
if (count($tables)){
48+
49+
$prepared = $this->Sql->getPrepared('insert into ' . $this->table . ' (table_id, cycle_id, cycles_table_id, source_table_id) ' .
50+
'(select table_id, ?, cycles_table_id, source_table_id from ' .
51+
$this->table . ' where table_id IN (' . str_repeat('?, ', count($tables) - 1) . '?) AND cycle_id=?)');
52+
53+
$prepared->execute([$cycleNewId, ...$tables, $cycleBaseId]);
54+
}
55+
5256
}
5357

5458
public function getReceiverTables($table_id, $cycle_id/*=0*/, $cycles_table_id/*=0*/)

totum/moduls/Table/WriteTableActions.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ public function duplicate()
205205
if ($ids) {
206206
$this->Table->checkIsUserCanViewIds('web', $ids);
207207

208-
if (preg_match('/^\s*(a\d+)?=\s*:\s*[^\s]/', $this->Table->getTableRow()['on_duplicate'])) {
208+
if (preg_match('/^\s*(a\d+)?=\s*:\s*[^\s]/', $this->Table->getTableRow()['on_duplicate']??'')) {
209209
try {
210210
$Calc = new CalculateAction($this->Table->getTableRow()['on_duplicate']);
211211
$Calc->execAction(

0 commit comments

Comments
 (0)