- Модуль: tasks
- Путь к файлу: ~/bitrix/modules/tasks/lib/access/model/templatemodel.php
- Класс: BitrixTasksAccessModelTemplateModel
- Вызов: TemplateModel::createFromArray
static function createFromArray(array $fields): AccessibleItem
{
$model = new self();
$templateId = array_key_exists('ID', $fields) ? (int)$fields['ID'] : 0;
$model->setId($templateId);
$groupId = array_key_exists('GROUP_ID', $fields) ? (int)$fields['GROUP_ID'] : 0;
$model->setGroupId($groupId);
$members = [];
$members[RoleDictionary::ROLE_DIRECTOR] = [];
if (array_key_exists('CREATED_BY', $fields))
{
$members[RoleDictionary::ROLE_DIRECTOR][] = (int) $fields['CREATED_BY'];
}
$members[RoleDictionary::ROLE_RESPONSIBLE] = [];
if (array_key_exists('RESPONSIBLES', $fields))
{
if (is_string($fields['RESPONSIBLES']))
{
$members[RoleDictionary::ROLE_RESPONSIBLE] = unserialize($fields['RESPONSIBLES'], ['allowed_classes' => false]);
}
elseif (is_array($fields['RESPONSIBLES']))
{
$members[RoleDictionary::ROLE_RESPONSIBLE] = $fields['RESPONSIBLES'];
}
}
if (array_key_exists('RESPONSIBLE_ID', $fields))
{
$members[RoleDictionary::ROLE_RESPONSIBLE][] = (int) $fields['RESPONSIBLE_ID'];
}
$members[RoleDictionary::ROLE_RESPONSIBLE] = array_unique(array_values($members[RoleDictionary::ROLE_RESPONSIBLE]));
$members[RoleDictionary::ROLE_ACCOMPLICE] = [];
if (array_key_exists('ACCOMPLICES', $fields))
{
if (is_string($fields['ACCOMPLICES']))
{
$members[RoleDictionary::ROLE_ACCOMPLICE] = unserialize($fields['ACCOMPLICES'], ['allowed_classes' => false]);
}
elseif (is_array($fields['ACCOMPLICES']))
{
$members[RoleDictionary::ROLE_ACCOMPLICE] = $fields['ACCOMPLICES'];
}
}
$members[RoleDictionary::ROLE_AUDITOR] = [];
if (array_key_exists('AUDITORS', $fields))
{
if (is_string($fields['AUDITORS']))
{
$members[RoleDictionary::ROLE_AUDITOR] = unserialize($fields['AUDITORS'], ['allowed_classes' => false]);
}
elseif (is_array($fields['AUDITORS']))
{
$members[RoleDictionary::ROLE_AUDITOR] = $fields['AUDITORS'];
}
}
$model->setMembers($members);
$regular = array_key_exists('REPLICATE', $fields) && $fields['REPLICATE'] === 'Y';
$model->setRegular($regular);
return $model;
}