- Модуль: disk
- Путь к файлу: ~/bitrix/modules/disk/lib/rightsmanager.php
- Класс: BitrixDiskRightsSetter
- Вызов: RightsSetter::appendOnePositive
private function appendOnePositive(array $right, $hadOppositeRight = false)
{
//May we have to add record to b_disk_right in final.
$right['OBJECT_ID'] = $this->object->getId();
$result = RightTable::add($right);
if (!$result->isSuccess())
{
$this->errorCollection->addFromResult($result);
return false;
}
$rightsManager = Driver::getInstance()->getRightsManager();
if(!$rightsManager->containsOperationInTask($rightsManager::OP_READ, $right['TASK_ID']))
{
return true;
}
$conflictRightsInSubTree = $this->getConflictRightsInSubTree($right['ACCESS_CODE'], $right['TASK_ID']);
$accessCode = $this->sqlHelper->forSql($right['ACCESS_CODE']);
if(empty($conflictRightsInSubTree))
{
//we have to add simple right to all descendants and to current OBJECT_ID
$this->connection->queryExecute("
INSERT INTO b_disk_simple_right (OBJECT_ID, ACCESS_CODE)
SELECT OBJECT_ID, '{$accessCode}' FROM b_disk_object_path
WHERE PARENT_ID = {$this->object->getId()}
");
}
else
{
$objectIds = array();
foreach($conflictRightsInSubTree as $conflictRight)
{
$objectIds[] = $conflictRight['OBJECT_ID'];
}
unset($conflictRight);
//we have to add simple right to all descendants and to current OBJECT_ID without nodes with conflict rights in path.
//when I write conflict I mean right with same ACCESS_CODE and same TASK_ID
$this->connection->queryExecute("
INSERT INTO b_disk_simple_right (OBJECT_ID, ACCESS_CODE)
SELECT OBJECT_ID, '{$accessCode}' FROM b_disk_object_path
WHERE PARENT_ID = {$this->object->getId()} AND
NOT EXISTS(
SELECT 'x' FROM b_disk_object_path pp
WHERE pp.OBJECT_ID = p.OBJECT_ID AND
pp.PARENT_ID IN (" . implode(',', $objectIds) . ") )
");
}
$this->removeDuplicates($this->object->getId());
return true;
}