Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
subscribeaccess.php
1<?php
2namespace Bitrix\Catalog;
3
7
24class SubscribeAccessTable extends Entity\DataManager
25{
26 const TOKEN_LIFE_TIME = 3600;
27
33 public static function getTableName()
34 {
35 return 'b_catalog_subscribe_access';
36 }
37
43 public static function getMap()
44 {
45 return array(
46 'ID' => array(
47 'data_type' => 'integer',
48 'primary' => true,
49 'autocomplete' => true,
50 ),
51 'DATE_FROM' => array(
52 'data_type' => 'datetime',
53 'required' => true,
54 'default_value' => new DateTime(),
55 ),
56 'USER_CONTACT' => array(
57 'data_type' => 'string',
58 'required' => true,
59 ),
60 'SUBSCRIBE' => array(
61 'data_type' => 'Bitrix\Catalog\SubscribeTable',
62 'reference' => array('=this.USER_CONTACT' => 'ref.USER_CONTACT'),
63 ),
64 'TOKEN' => array(
65 'data_type' => 'string',
66 'required' => true,
67 'validation' => array(__CLASS__, 'validateToken'),
68 ),
69 );
70 }
71
77 public static function validateToken()
78 {
79 return array(
80 new Entity\Validator\Length(null, 6),
81 );
82 }
83
89 public static function clearOldRows()
90 {
91 $connection = Application::getConnection();
92 $helper = $connection->getSqlHelper();
93 $connection->queryExecute('delete from '.$helper->quote(static::getTableName()).' where '
94 .$helper->quote('DATE_FROM').' < '.$helper->addSecondsToDateTime(-(static::TOKEN_LIFE_TIME))
95 );
96 }
97}
static getConnection($name="")