Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
letter.php
1
<?php
2
namespace
Bitrix\Forum\BadWords
;
3
4
use
Bitrix\Main
;
5
use \Bitrix\Main\Localization\Loc;
6
use
Bitrix\Main\ORM\Data\Result
;
7
use
Bitrix\Main\ORM\Data\UpdateResult
;
8
use
Bitrix\Main\ORM\Fields\IntegerField
;
9
use
Bitrix\Main\ORM\Fields\StringField
;
10
11
Loc::loadMessages
(__FILE__);
12
29
class
LetterTable
extends
Main\Entity\DataManager
30
{
31
public
static
function
getTableName
()
32
{
33
return
'b_forum_letter'
;
34
}
35
36
public
static
function
getMap
()
37
{
38
return
[
39
(
new
IntegerField
(
"ID"
, [
"primary"
=>
true
,
"autocomplete"
=>
true
])),
40
(
new
IntegerField
(
"DICTIONARY_ID"
, [
"required"
=>
true
])),
41
(
new
StringField
(
"LETTER"
, [
"required"
=>
true
,
"size"
=> 50])),
42
(
new
StringField
(
"REPLACEMENT"
, [
"size"
=> 255]))];
43
}
44
45
public
static
function
checkFields
(
Result
$result, $primary, array $data)
46
{
47
parent::checkFields($result, $primary, $data);
48
49
if
($result->
isSuccess
())
50
{
51
if
(isset($data[
"LETTER"
]) || isset($data[
"DICTIONARY_ID"
]))
52
{
53
$filter = [
54
"DICTIONARY_ID"
=> isset($data[
"DICTIONARY_ID"
]) ? $data[
"DICTIONARY_ID"
] :
null
,
55
"LETTER"
=> isset($data[
"LETTER"
]) ? $data[
"LETTER"
] : null
56
];
57
58
if
($result instanceof
UpdateResult
)
59
{
60
if
(
61
($filter[
"DICTIONARY_ID"
] ===
null
|| $filter[
"LETTER"
] ===
null
) &&
62
($letter = self::getById($primary[
"ID"
])->fetch())
63
)
64
{
65
if
($filter[
"LETTER"
] ===
null
)
66
$filter[
"LETTER"
] = $letter[
"LETTER"
];
67
if
($filter[
"DICTIONARY_ID"
] ===
null
)
68
$filter[
"DICTIONARY_ID"
] = $letter[
"DICTIONARY_ID"
];
69
}
70
$filter[
"!=ID"
] = $primary[
"ID"
];
71
}
72
if
($res = self::getList([
"select"
=> [
"ID"
],
"filter"
=> $filter])->fetch())
73
{
74
$result->
addError
(
new
Main\
Error
(
Loc::getMessage
(
"FLT_ALREADY_EXIST"
),
"doubleLetter"
));
75
}
76
}
77
}
78
}
79
}
Bitrix\Forum\BadWords\LetterTable
Definition
letter.php:30
Bitrix\Forum\BadWords\LetterTable\getMap
static getMap()
Definition
letter.php:36
Bitrix\Forum\BadWords\LetterTable\checkFields
static checkFields(Result $result, $primary, array $data)
Definition
letter.php:45
Bitrix\Forum\BadWords\LetterTable\getTableName
static getTableName()
Definition
letter.php:31
Bitrix\Main\Error
Definition
error.php:14
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Main\ORM\Data\Result
Definition
result.php:16
Bitrix\Main\ORM\Data\Result\isSuccess
isSuccess($internalCall=false)
Definition
result.php:52
Bitrix\Main\ORM\Data\UpdateResult
Definition
updateresult.php:14
Bitrix\Main\ORM\Fields\IntegerField
Definition
integerfield.php:20
Bitrix\Main\ORM\Fields\StringField
Definition
stringfield.php:20
Bitrix\Main\Result\addError
addError(Error $error)
Definition
result.php:50
Bitrix\Forum\BadWords
Definition
dictionary.php:2
Bitrix\Main
modules
forum
lib
badwords
letter.php
Создано системой
1.10.0