1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
RecentlyUsedTable.php
См. документацию.
1<?php
2namespace Bitrix\UI\Avatar\Model;
3
4use Bitrix\Main;
5use Bitrix\Main\ORM\Fields\DatetimeField;
6use Bitrix\Main\ORM\Fields\IntegerField;
7use Bitrix\Main\ORM\Fields\Relations\Reference;
8use Bitrix\Main\ORM\Query\Join;
9use Bitrix\Main\Type\DateTime;
10use Bitrix\UI\Avatar;
11
13{
14 public static function getTableName(): string
15 {
16 return 'b_ui_avatar_mask_recently_used';
17 }
18
19 public static function getMap(): array
20 {
21 return array(
22 (new IntegerField('ID'))
23 ->configurePrimary()
24 ->configureAutocomplete(),
25
26 (new IntegerField('ITEM_ID'))->configureRequired(),
27 (new IntegerField('USER_ID', []))->configureRequired(),
28
29 (new DatetimeField('TIMESTAMP_X'))
30 ->configureDefaultValue(function() {
31 return new DateTime();
32 }),
33
34 (new Reference(
35 'MASK',
36 ItemTable::class,
37 Join::on('this.ITEM_ID', 'ref.ID')
38 ))->configureJoinType(Join::TYPE_INNER),
39 );
40 }
41
42 public static function addFromUser($itemId, $userId)
43 {
44 $entity = static::getEntity();
45 $sqlTableName = static::getTableName();
46 $sqlHelper = $entity->getConnection()->getSqlHelper();
47 $filter = ['ITEM_ID' => $itemId, 'USER_ID' => $userId];
48
50 if ($where !== '')
51 {
52 $sql = "DELETE FROM {$sqlHelper->quote($sqlTableName)} WHERE " . $where;
53 $entity->getConnection()->queryExecute($sql);
54 }
55 static::add($filter);
56 //Delete excessive data
57 $counter = 10;
58 $filter = ['=USER_ID' => $userId];
59 $records = static::getList([
60 'select' => ['ID'],
61 'filter' => $filter,
62 'limit' => $counter + 1,
63 'order' => [
64 'ID' => 'ASC'
65 ]
66 ])->fetchAll();
67 if (count($records) > $counter)
68 {
69 $lastRecord = end($records);
70 $filter['<ID'] = $lastRecord['ID'];
72 if ($where !== '')
73 {
74 $sql = "DELETE FROM {$sqlHelper->quote($sqlTableName)} WHERE " . $where;
75 $entity->getConnection()->queryExecute($sql);
76 }
77 }
78 }
79}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static buildFilterSql(Entity $entity, $filter)
Определения query.php:3913
static addFromUser($itemId, $userId)
Определения RecentlyUsedTable.php:42
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$filter
Определения iblock_catalog_list.php:54
$counter
Определения options.php:5
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
Определения waybill.php:936