1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
AddFeatureHandler.php
См. документацию.
1<?php
2
3declare(strict_types=1);
4
6
11use CSocNetAllowed;
12use CSocNetFeatures;
13use CSocNetFeaturesPerms;
14
16{
17 public function add(AddCommand $command, Workgroup $entity): HandlerResult
18 {
19 $handlerResult = new HandlerResult();
20
21 $features = $command->getFeatures()->getValue();
22
23 $activeSetFeatures = [];
24
25 foreach ($features as $featureName => $isActive)
26 {
27 $featureId = CSocNetFeatures::setFeature(
29 $entity->getId(),
30 $featureName,
31 $isActive,
32 false,
33 ['isCollab' => true]
34 );
35
36 if (!$featureId)
37 {
38 $handlerResult->addApplicationError(['ERROR_NO_FEATURE_ID']);
39 }
40
41 if ($isActive)
42 {
43 $activeSetFeatures[$featureName] = $featureId;
44 }
45 }
46
47 if (!empty($features))
48 {
49 $handlerResult->setGroupChanged();
50 }
51
52 $permissions = $command->getPermissions()->getValue()?? [];
53 if (empty($permissions))
54 {
55 return $handlerResult;
56 }
57
58 foreach ($activeSetFeatures as $featureName => $featureId)
59 {
60 $operations = $permissions[$featureName] ?? [];
61 if (empty($operations))
62 {
63 continue;
64 }
65
66 foreach ($operations as $operationName => $operationValue)
67 {
68 $operationId = CSocNetFeaturesPerms::SetPerm(
69 $featureId,
70 $operationName,
71 $operationValue
72 );
73
74 if (!$operationId)
75 {
76 $handlerResult->addApplicationError();
77 }
78 }
79 }
80
81 return $handlerResult;
82 }
83}
Определения error.php:15
add(AddCommand $command, Workgroup $entity)
Определения AddFeatureHandler.php:17
$entity
const SONET_ENTITY_GROUP
Определения include.php:117