Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
userrelations.php
1<?php
9
11
28class UserRelationsTable extends Entity\DataManager
29{
30 const RELATION_FRIEND = SONET_RELATIONS_FRIEND;
31 const RELATION_REQUEST = SONET_RELATIONS_REQUEST;
32 const RELATION_BAN = SONET_RELATIONS_BAN;
33
34 const INITIATED_BY_FIRST = 'F';
36
37 public static function getFilePath()
38 {
39 return __FILE__;
40 }
41
42 public static function getTableName()
43 {
44 return 'b_sonet_user_relations';
45 }
46
47 public static function getMap()
48 {
49 return array(
50 'ID' => array(
51 'data_type' => 'integer',
52 'primary' => true,
53 'autocomplete' => true,
54 ),
55 'FIRST_USER_ID' => array(
56 'data_type' => 'integer',
57 ),
58 'SECOND_USER_ID' => array(
59 'data_type' => 'integer',
60 ),
61 'RELATION' => array(
62 'data_type' => 'enum',
63 'required' => true,
64 'values' => array(self::RELATION_FRIEND, self::RELATION_REQUEST, self::RELATION_BAN),
65 ),
66 'INITIATED_BY' => array(
67 'data_type' => 'enum',
68 'required' => true,
69 'values' => array(self::INITIATED_BY_FIRST, self::INITIATED_BY_SECOND)
70 ),
71 'DATE_CREATE' => array(
72 'data_type' => 'datetime',
73 ),
74 'DATE_UPDATE' => array(
75 'data_type' => 'datetime',
76 ),
77 'MESSAGE' => array(
78 'data_type' => 'text',
79 ),
80 'FIRST_USER' => array(
81 'data_type' => 'Bitrix\Main\UserTable',
82 'reference' => array('=this.FIRST_USER_ID' => 'ref.ID'),
83 ),
84 'SECOND_USER' => array(
85 'data_type' => 'Bitrix\Main\UserTable',
86 'reference' => array('=this.SECOND_USER_ID' => 'ref.ID'),
87 ),
88 );
89 }
90
91 public static function getUserFilter($operation, $field, $filter)
92 {
93 return array(
94 'LOGIC' => 'OR',
95 $operation.preg_replace('/^USER/', 'FIRST_USER', $field) => $filter,
96 $operation.preg_replace('/^USER/', 'SECOND_USER', $field) => $filter,
97 );
98 }
99}
static getUserFilter($operation, $field, $filter)