...Человеческий поиск в разработке...
- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/control/templatemember.php
- Класс: BitrixTasksControlTemplateMember
- Вызов: TemplateMember::set
public function set(array $data): void { $this->loadByTemplate(); $members = $this->getCurrentMembers(); $changed = false; if (array_key_exists(self::FIELD_CREATED_BY, $data)) { $members[TemplateMemberTable::MEMBER_TYPE_ORIGINATOR] = []; $members[TemplateMemberTable::MEMBER_TYPE_ORIGINATOR][] = [ 'USER_ID' => $data[self::FIELD_CREATED_BY], 'TYPE' => TemplateMemberTable::MEMBER_TYPE_ORIGINATOR, ]; $changed = true; } if (array_key_exists(self::FIELD_RESPONSIBLES, $data)) { $members[TemplateMemberTable::MEMBER_TYPE_RESPONSIBLE] = []; foreach ($data[self::FIELD_RESPONSIBLES] as $userId) { $members[TemplateMemberTable::MEMBER_TYPE_RESPONSIBLE][] = [ 'USER_ID' => $userId, 'TYPE' => TemplateMemberTable::MEMBER_TYPE_RESPONSIBLE, ]; } $changed = true; } if (array_key_exists(self::FIELD_ACCOMPLICES, $data)) { $members[TemplateMemberTable::MEMBER_TYPE_ACCOMPLICE] = []; foreach ($data[self::FIELD_ACCOMPLICES] as $userId) { $members[TemplateMemberTable::MEMBER_TYPE_ACCOMPLICE][] = [ 'USER_ID' => $userId, 'TYPE' => TemplateMemberTable::MEMBER_TYPE_ACCOMPLICE, ]; } $changed = true; } if (array_key_exists(self::FIELD_AUDITORS, $data)) { $members[TemplateMemberTable::MEMBER_TYPE_AUDITOR] = []; foreach ($data[self::FIELD_AUDITORS] as $userId) { $members[TemplateMemberTable::MEMBER_TYPE_AUDITOR][] = [ 'USER_ID' => $userId, 'TYPE' => TemplateMemberTable::MEMBER_TYPE_AUDITOR, ]; } $changed = true; } if (!$changed) { return; } $this->deleteByTemplate(); if (empty($members)) { return; } $insertRows = []; foreach ($members as $type => $list) { $insertRows = array_merge( $insertRows, array_map(function($el) { $implode = (int) $el['USER_ID']; $implode .= ','.$this->templateId; $implode .= ',''.$el['TYPE'].'''; return $implode; }, $list) ); } $sql = " INSERT IGNORE INTO ". TemplateMemberTable::getTableName() ." (`USER_ID`, `TEMPLATE_ID`, `TYPE`) VALUES (". implode("),(", $insertRows) .") "; Application::getConnection()->query($sql); }