Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
senderconnector.php
1<?php
9namespace Bitrix\Main;
10
12
13Loc::loadMessages(__FILE__);
14
16{
21 public static function onConnectorListUser($data)
22 {
23 $data['CONNECTOR'] = 'Bitrix\Main\SenderConnectorUser';
24
25 return $data;
26 }
27}
28
29if (Loader::includeModule('sender'))
30{
31 class SenderConnectorUser extends \Bitrix\Sender\Connector
32 {
36 public function getName()
37 {
38 return Loc::getMessage('sender_connector_user_name');
39 }
40
44 public function getCode()
45 {
46 return "user";
47 }
48
50 public function getData()
51 {
52 $groupId = $this->getFieldValue('GROUP_ID', null);
53 $dateRegister = $this->getFieldValue('DATE_REGISTER', null);
54 $active = $this->getFieldValue('ACTIVE', null);
55
56 $filter = array();
57 if($groupId)
58 $filter['GROUP_ID'] = $groupId;
59
60 if($dateRegister <> '')
61 {
62 if(\Bitrix\Main\Type\Date::isCorrect($dateRegister))
63 {
65 $filter['><USER.DATE_REGISTER'] = array($dateRegister->toString(), $dateRegister->add('1 DAY')->toString());
66 }
67 else
68 {
69 $result = new \CDBResult();
70 $result->InitFromArray(array());
71 return $result;
72 }
73 }
74
75 if($active=='Y')
76 $filter['USER.ACTIVE'] = $active;
77 elseif($active=='N')
78 $filter['USER.ACTIVE'] = $active;
79
80 $userDb = \Bitrix\Main\UserGroupTable::getList(array(
81 'select' => array('NAME' => 'USER.NAME', 'EMAIL' => 'USER.EMAIL', 'USER_ID'),
82 'filter' => $filter,
83 'group' => array('NAME', 'EMAIL', 'USER_ID'),
84 'order' => array('USER_ID' => 'ASC'),
85 ));
86
87 return new \CDBResult($userDb);
88 }
89
94 public function getForm()
95 {
96 $groupInput = '<select name="'.$this->getFieldName('GROUP_ID').'">';
97 $groupDb = \Bitrix\Main\GroupTable::getList(array(
98 'select' => array('ID', 'NAME',),
99 'filter' => array('!=ID' => 2),
100 'order' => array('C_SORT' => 'ASC', 'NAME' => 'ASC')
101 ));
102 while($group = $groupDb->fetch())
103 {
104 $inputSelected = ($group['ID'] == $this->getFieldValue('GROUP_ID') ? 'selected' : '');
105 $groupInput .= '<option value="'.$group['ID'].'" '.$inputSelected.'>';
106 $groupInput .= htmlspecialcharsbx($group['NAME']);
107 $groupInput .= '</option>';
108 }
109 $groupInput .= '</select>';
110
111
113 '' => Loc::getMessage('sender_connector_user_all'),
114 'Y' => Loc::getMessage('sender_connector_user_y'),
115 'N' => Loc::getMessage('sender_connector_user_n'),
116 );
117
118 $activeInput = '<select name="'.$this->getFieldName('ACTIVE').'">';
119 foreach($booleanValues as $k => $v)
120 {
121 $inputSelected = ($k == $this->getFieldValue('ACTIVE') ? 'selected' : '');
122 $activeInput .= '<option value="'.$k.'" '.$inputSelected.'>';
124 $activeInput .= '</option>';
125 }
126 $activeInput .= '</select>';
127
128
130 $this->getFieldName('DATE_REGISTER'),
131 $this->getFieldValue('DATE_REGISTER'),
132 $this->getFieldFormName()
133 );
134
135 return '
136 <table>
137 <tr>
138 <td>'.Loc::getMessage('sender_connector_user_group').'</td>
139 <td>'.$groupInput.'</td>
140 </tr>
141 <tr>
142 <td>'.Loc::getMessage('sender_connector_user_datereg').'</td>
143 <td>'.$dateRegInput.'</td>
144 </tr>
145 <tr>
146 <td>'.Loc::getMessage('sender_connector_user_active').'</td>
147 <td>'.$activeInput.'</td>
148 </tr>
149 </table>
150 ';
151 }
152 }
153}
static includeModule($moduleName)
Definition loader.php:69
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29