14use Bitrix\Main\Entity\Query;
23use Bitrix\Socialnetwork\EO_WorkgroupPin;
37 static $result =
null;
41 $oneWeek = \DateInterval::createFromDateString(
'1 week')->format(
'%d') * 86400;
42 $twoWeek = \DateInterval::createFromDateString(
'2 weeks')->format(
'%d') * 86400;
43 $threeWeek = \DateInterval::createFromDateString(
'3 weeks')->format(
'%d') * 86400;
44 $fourWeek = \DateInterval::createFromDateString(
'4 weeks')->format(
'%d') * 86400;
48 'TITLE' =>
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_SPRINT_DURATION_ONE_WEEK'),
51 'TITLE' =>
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_SPRINT_DURATION_TWO_WEEK'),
55 'TITLE' =>
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_SPRINT_DURATION_THREE_WEEK'),
58 'TITLE' =>
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_SPRINT_DURATION_FOUR_WEEK'),
68 $list = static::getSprintDurationList();
71 foreach ($list as $key => $item)
73 $result[$key] = $item[
'TITLE'];
81 $list = static::getSprintDurationList();
82 $result = array_key_first($list);
83 foreach ($list as $key => $item)
86 isset($item[
'DEFAULT'])
87 && $item[
'DEFAULT'] ===
true
101 'A' =>
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_TASK_RESPONSIBLE_AUTHOR'),
102 'M' =>
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_TASK_RESPONSIBLE_MASTER')
110 if (empty($params[
'fields']))
116 !empty($params[
'typesList'])
117 ? $params[
'typesList']
118 : self::getTypes($params)
121 foreach ($typesList as $code => $type)
125 !isset($params[
'fields'][
'OPENED'])
126 || $params[
'fields'][
'OPENED'] === $type[
'OPENED']
129 !isset($params[
'fields'][
'VISIBLE'])
130 || $params[
'fields'][
'VISIBLE'] === $type[
'VISIBLE']
132 && $params[
'fields'][
'PROJECT'] === $type[
'PROJECT']
133 && $params[
'fields'][
'EXTERNAL'] === $type[
'EXTERNAL']
135 !isset($params[
'fields'][
'SCRUM_PROJECT'])
137 isset($type[
'SCRUM_PROJECT'])
138 && $params[
'fields'][
'SCRUM_PROJECT'] === $type[
'SCRUM_PROJECT']
155 if (empty($params[
'fields']))
161 !empty($params[
'typesList'])
162 ? $params[
'typesList']
163 : static::getProjectPresets($params)
166 foreach ($typesList as $code => $type)
169 ($params[
'fields'][
'PROJECT'] ??
'') === ($type[
'PROJECT'] ??
'')
170 && $params[
'fields'][
'SCRUM_PROJECT'] === $type[
'SCRUM_PROJECT']
185 if (empty($params[
'fields']))
191 !empty($params[
'typesList'])
192 ? $params[
'typesList']
193 : self::getConfidentialityPresets($params)
196 foreach ($typesList as $code => $type)
199 ($params[
'fields'][
'OPENED'] ??
'') === ($type[
'OPENED'] ??
'')
201 isset($params[
'fields'][
'VISIBLE'])
202 && $params[
'fields'][
'VISIBLE'] === $type[
'VISIBLE']
204 && ($params[
'fields'][
'PROJECT'] ??
'') === ($type[
'PROJECT'] ??
'')
221 || empty($params[
'code'])
227 $code = $params[
'code'];
229 !empty($params[
'typesList'])
230 ? $params[
'typesList']
231 : self::getTypes($params)
236 && is_array($typesList)
237 && !empty($typesList[$code])
240 $result = $typesList[$code];
248 static $result =
null;
250 if ($result !==
null)
257 if (!ModuleManager::isModuleInstalled(
'bitrix24'))
262 if (\CBitrix24::isNfrLicense())
267 if (\CBitrix24::isDemoLicense())
273 \CBitrix24::getLicenseType() !==
'project'
274 || !Option::get(
'socialnetwork',
'demo_edit_features',
false)
292 global $USER, $CACHE_MANAGER;
296 $feature = (string)($params[
'feature'] ??
'');
297 $operation = (string)($params[
'operation'] ??
'');
299 isset($params[
'userId'])
300 ? (int)$params[
'userId']
301 : (is_object($USER) && $USER instanceof \CUser ? $USER->getId() : 0)
313 $featuresSettings = \CSocNetAllowed::getAllowedFeatures();
315 empty($featuresSettings)
316 || empty($featuresSettings[$feature])
317 || empty($featuresSettings[$feature][
'allowed'])
318 || empty($featuresSettings[$feature][
'operations'])
319 || empty($featuresSettings[$feature][
'operations'][$operation])
327 $cacheTTL = 3600 * 24 * 30;
329 $cacheId = implode(
' ', [
'entities_list', $feature, $operation, $userId ]);
331 $cache = new \CPHPCache();
332 if ($cache->initCache($cacheTTL, $cacheId, $cacheDir))
334 $cacheValue = $cache->getVars();
335 if (is_array($cacheValue))
337 $result = $cacheValue;
342 $cache->startDataCache();
343 $CACHE_MANAGER->startTagCache($cacheDir);
345 $CACHE_MANAGER->registerTag(
'sonet_group');
346 $CACHE_MANAGER->registerTag(
'sonet_features');
347 $CACHE_MANAGER->registerTag(
'sonet_features2perms');
348 $CACHE_MANAGER->registerTag(
'sonet_user2group');
352 $query = new \Bitrix\Main\Entity\Query(WorkgroupTable::getEntity());
353 $query->addFilter(
'=ACTIVE',
'Y');
357 !is_array($featuresSettings[$feature][
'minoperation'])
358 || !in_array($operation, $featuresSettings[$feature][
'minoperation'],
true)
360 && Option::get(
'socialnetwork',
'work_with_closed_groups',
'N') !==
'Y'
363 $query->addFilter(
'!=CLOSED',
'Y');
366 $query->addSelect(
'ID');
368 $query->registerRuntimeField(
371 FeatureTable::getEntity(),
374 '=ref.ENTITY_ID' =>
'this.ID',
377 [
'join_type' =>
'LEFT' ]
380 $query->addSelect(
'F.ID',
'FEATURE_ID');
382 $query->registerRuntimeField(
385 FeaturePermTable::getEntity(),
387 '=ref.FEATURE_ID' =>
'this.FEATURE_ID',
390 [
'join_type' =>
'LEFT' ]
395 'PERM_ROLE_CALCULATED',
396 'CASE WHEN %s IS NULL THEN \''.$defaultRole.
'\' ELSE %s END
',
397 [ 'FP.ROLE
', 'FP.ROLE
' ]
400 $query->registerRuntimeField(
402 new \Bitrix\Main\Entity\ReferenceField('UG
',
403 UserToGroupTable::getEntity(),
405 '=ref.GROUP_ID
' => 'this.ID
',
406 '=ref.USER_ID
' => new SqlExpression($userId),
408 [ 'join_type
' => 'LEFT
' ]
412 $query->registerRuntimeField(new \Bitrix\Main\Entity\ExpressionField(
423 'PERM_ROLE_CALCULATED',
424 'PERM_ROLE_CALCULATED',
'UG.ROLE',
428 $query->addFilter(
'=HAS_ACCESS',
'Y');
430 $res = $query->exec();
432 while ($row = $res->fetch())
435 'ID' => (int) $row[
'ID']
439 $CACHE_MANAGER->endTagCache();
440 $cache->endDataCache($result);
453 $res = WorkgroupTable::getList([
459 'select' => [
'ID' ],
472 global $USER, $APPLICATION;
476 $userId = (int)($params[
'userId'] ?? (is_object($USER) ? $USER->getId() : 0));
477 $groupId = (int)($params[
'groupId'] ?? 0);
480 $APPLICATION->throwException(
'Empty workgroup Id',
'SONET_HELPER_WORKGROUP_EMPTY_GROUP');
484 empty($result[$userId] ??
null)
485 || !($result[$userId][$groupId] ??
null)
488 $group = Item\Workgroup::getById($groupId);
491 return self::getEmptyPermissions();
493 $groupFields = $group->getFields();
494 if (empty($groupFields))
496 return self::getEmptyPermissions();
499 $result[$userId][$groupId] = \CSocNetUserToGroup::initUserPerms(
502 \CSocNetUser::isCurrentUserModuleAdmin(),
506 if (is_array($result[$userId][$groupId]))
508 return $result[$userId][$groupId];
511 return self::getEmptyPermissions();
517 'Operations' =>
false,
519 'UserIsMember' =>
false,
520 'UserIsAutoMember' =>
false,
521 'InitiatedByType' =>
false,
522 'InitiatedByUserId' =>
false,
523 'UserIsOwner' =>
false,
524 'UserIsScrumMaster' =>
false,
525 'UserCanInitiate' =>
false,
526 'UserCanProcessRequestsIn' =>
false,
527 'UserCanViewGroup' =>
false,
528 'UserCanAutoJoinGroup' =>
false,
529 'UserCanModifyGroup' =>
false,
530 'UserCanModerateGroup' =>
false,
531 'UserCanSpamGroup' =>
false,
538 !ModuleManager::isModuleInstalled(
'bitrix24')
540 Loader::includeModule(
'bitrix24')
541 && \Bitrix\Bitrix24\Feature::isFeatureEnabled(
'socnet_group_copy')
550 if (!isset($fields[
'archive']))
555 $groupId = (int)($fields[
'groupId'] ?? 0);
556 $archive = (bool)$fields[
'archive'];
568 $isCurrentUserAdmin = static::isCurrentUserModuleAdmin();
570 if (!$isCurrentUserAdmin)
572 $filter[
'CHECK_PERMISSIONS'] = $currentUserId;
575 $res = \CSocNetGroup::getList([], $filter);
576 if (!($groupFields = $res->fetch()))
582 'groupId' => $groupId,
588 if (!\CSocNetGroup::update($groupId, [
'CLOSED' => ($archive ?
'Y' :
'N') ],
false,
true,
false))
590 if ($ex = $APPLICATION->getException())
592 $errorMessage = $ex->getString();
593 $errorCode = $ex->getId();
597 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
607 public static function setOwner(array $fields = []): bool
611 $groupId = (int) ($fields[
'groupId'] ?? 0);
612 $newOwnerId = (int) ($fields[
'userId'] ?? 0);
620 if ($newOwnerId <= 0)
629 $isCurrentUserAdmin = static::isCurrentUserModuleAdmin();
631 if (!$isCurrentUserAdmin)
633 $filter[
'CHECK_PERMISSIONS'] = $currentUserId;
636 $res = \CSocNetGroup::getList([], $filter);
637 if (!($groupFields = $res->fetch()))
642 $groupPerms = static::getPermissions([
643 'groupId' => $groupId,
646 if (!$groupPerms[
'UserCanModifyGroup'])
651 if (!\CSocNetUserToGroup::setOwner($newOwnerId, $groupFields[
'ID'], $groupFields))
653 if ($ex = $APPLICATION->getException())
655 $errorMessage = $ex->getString();
659 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
662 throw new \Exception($errorMessage, 100);
670 $groupId = (int)($fields[
'groupId'] ?? 0);
671 $newScrumMasterId = (int)($fields[
'userId'] ?? 0);
679 if ($newScrumMasterId <= 0)
685 'userId' => $newScrumMasterId,
686 'groupId' => $groupId,
692 if (!\CSocNetGroup::Update($groupId, [
693 'SCRUM_MASTER_ID' => $newScrumMasterId,
696 throw new \Exception(
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'), 100);
699 $relation = UserToGroupTable::getList([
701 'USER_ID' => $newScrumMasterId,
702 'GROUP_ID' => $groupId,
704 'select' => [
'ID',
'ROLE' ]
711 && !\CSocNetUserToGroup::Update($relation->getId(), [
716 throw new \Exception(
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'), 100);
721 static $helper =
null;
725 $helper = $connection->getSqlHelper();
728 if (!\CSocNetUserToGroup::Add([
729 'AUTO_MEMBER' =>
'N',
730 'USER_ID' => $newScrumMasterId,
731 'GROUP_ID' => $groupId,
734 'INITIATED_BY_USER_ID' => $currentUserId,
735 '=DATE_CREATE' => $helper->getCurrentDateTimeFunction(),
736 '=DATE_UPDATE' => $helper->getCurrentDateTimeFunction(),
739 throw new \RuntimeException(
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'), 100);
750 $groupId = (int)($fields[
'groupId'] ?? 0);
751 $userId = (int)($fields[
'userId'] ?? 0);
766 $relation = static::getRelation([
767 '=GROUP_ID' => $groupId,
768 '=USER_ID' => $userId,
771 catch (\Exception $e)
773 throw new \Exception($e->getMessage(), $e->getCode());
778 'groupId' => $groupId,
784 if (!\CSocNetUserToGroup::transferMember2Moderator(
787 [ $relation->getId() ]
790 if ($ex = $APPLICATION->getException())
792 $errorMessage = $ex->getString();
796 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
799 throw new \Exception($errorMessage, 100);
809 $groupId = (int)($fields[
'groupId'] ?? 0);
810 $userId = (int)($fields[
'userId'] ?? 0);
825 $relation = static::getRelation([
826 '=GROUP_ID' => $groupId,
827 '=USER_ID' => $userId,
830 catch (\Exception $e)
832 throw new \Exception($e->getMessage(), $e->getCode());
837 'groupId' => $groupId,
843 if (!\CSocNetUserToGroup::TransferModerator2Member(
846 [ $relation->getId() ]
849 if ($ex = $APPLICATION->getException())
851 $errorMessage = $ex->getString();
855 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
858 throw new \Exception($errorMessage, 100);
866 $groupId = (int)($fields[
'groupId'] ?? 0);
867 $userIds = array_map(
'intval', array_filter($fields[
'userIds'] ?? []));
875 $isCurrentUserModuleAdmin = static::isCurrentUserModuleAdmin();
877 $groupPerms = static::getPermissions([
'groupId' => $groupId]);
878 if (!$groupPerms || (!$groupPerms[
'UserCanModifyGroup'] && !$isCurrentUserModuleAdmin))
883 $currentModeratorRelations = static::getCurrentModeratorRelations($groupId);
884 $moderatorsToAdd = array_diff($userIds, array_keys($currentModeratorRelations));
885 $moderatorsToRemove = array_diff_key($currentModeratorRelations, array_fill_keys($userIds,
true));
887 if (!empty($moderatorsToRemove))
889 \CSocNetUserToGroup::TransferModerator2Member(
896 if (!empty($moderatorsToAdd))
898 [$ownerRelations, $memberRelations, $otherRelations] = static::getUserRelations($groupId, $moderatorsToAdd);
900 if (!empty($memberRelations))
902 \CSocNetUserToGroup::transferMember2Moderator(
909 $moderatorsToAdd = array_diff($moderatorsToAdd, array_keys($memberRelations), array_keys($ownerRelations));
910 foreach ($moderatorsToAdd as $userId)
912 if (array_key_exists($userId, $otherRelations))
914 $relationId = static::transferToModerators($otherRelations[$userId]);
918 $relationId = static::addToModerators($userId, $groupId);
923 static::sendNotifications($userId, $groupId, $relationId);
931 private static function getCurrentModeratorRelations(
int $groupId): array
933 $currentModeratorRelations = [];
935 $relationResult = UserToGroupTable::getList([
936 'select' => [
'ID',
'USER_ID'],
938 'GROUP_ID' => $groupId,
942 while ($relation = $relationResult->fetch())
944 $currentModeratorRelations[$relation[
'USER_ID']] = $relation[
'ID'];
947 return $currentModeratorRelations;
950 private static function getUserRelations(
int $groupId, array $userIds): array
952 $ownerRelations = [];
953 $memberRelations = [];
954 $otherRelations = [];
956 $relationResult = UserToGroupTable::getList([
957 'select' => [
'ID',
'USER_ID',
'ROLE'],
959 'GROUP_ID' => $groupId,
960 '@USER_ID' => $userIds,
963 while ($relation = $relationResult->fetch())
965 $id = $relation[
'ID'];
966 $userId = $relation[
'USER_ID'];
968 switch ($relation[
'ROLE'])
971 $ownerRelations[$userId] = $id;
975 $memberRelations[$userId] = $id;
979 $otherRelations[$userId] = $id;
984 return [$ownerRelations, $memberRelations, $otherRelations];
987 private static function transferToModerators(
int $relationId)
989 return \CSocNetUserToGroup::update(
993 '=DATE_UPDATE' => \CDatabase::CurrentTimeFunction(),
998 private static function addToModerators(
int $userId,
int $groupId)
1000 return \CSocNetUserToGroup::add([
1001 'USER_ID' => $userId,
1002 'GROUP_ID' => $groupId,
1004 '=DATE_CREATE' => \CDatabase::CurrentTimeFunction(),
1005 '=DATE_UPDATE' => \CDatabase::CurrentTimeFunction(),
1013 private static function sendNotifications(
int $userId,
int $groupId,
int $relationId): void
1015 \CSocNetUserToGroup::notifyModeratorAdded([
1017 'groupId' => $groupId,
1018 'relationId' => $relationId,
1020 Item\UserToGroup::addInfoToChat([
1021 'group_id' => $groupId,
1022 'user_id' => $userId,
1023 'action' => Item\UserToGroup::CHAT_ACTION_IN,
1024 'sendMessage' =>
false,
1029 public static function join(array $fields = []): bool
1031 $groupId = (int)($fields[
'groupId'] ?? 0);
1045 'userId' => $userId,
1046 'groupId' => $groupId,
1052 $relation = UserToGroupTable::getList([
1054 'USER_ID' => $userId,
1055 'GROUP_ID' => $groupId,
1057 'select' => [
'ID',
'ROLE',
'INITIATED_BY_TYPE' ],
1066 if (!\CSocNetUserToGroup::userConfirmRequestToBeMember($userId, $relation->getId(),
false))
1068 throw new \RuntimeException(
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
1071 $confirmationNeeded =
false;
1075 $requestConfirmUrl = \CComponentEngine::MakePathFromTemplate(
Path::get(
'group_requests_path_template'), [
'group_id' => $groupId ]);
1076 if (!\CSocNetUserToGroup::sendRequestToBeMember($userId, $groupId,
'', $requestConfirmUrl,
false))
1078 throw new \RuntimeException(
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
1081 $confirmationNeeded = !(WorkgroupTable::getList([
1085 'select' => [
'OPENED' ]
1086 ])->fetchObject()->getOpened());
1089 return $confirmationNeeded;
1092 public static function leave(array $fields = []): bool
1094 $groupId = (int)($fields[
'groupId'] ?? 0);
1098 'userId' => $userId,
1099 'groupId' => $groupId,
1105 if (!\CSocNetUserToGroup::deleteRelation($userId, $groupId))
1107 throw new \RuntimeException(
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
1115 $groupId = (int)($fields[
'groupId'] ?? 0);
1116 $userId = (int)($fields[
'userId'] ?? 0);
1130 $relation = static::getRelation([
1131 '=GROUP_ID' => $groupId,
1132 '=USER_ID' => $userId,
1135 catch (\Exception $e)
1137 throw new \Exception($e->getMessage(), $e->getCode());
1141 'userId' => $userId,
1142 'groupId' => $groupId,
1150 self::deleteRelation([
1151 'relationId' => $relation->getId(),
1154 catch (\Exception $e)
1156 throw new \Exception($e->getMessage(), $e->getCode());
1164 $groupId = (int)($fields[
'groupId'] ?? 0);
1165 $userId = (int)($fields[
'userId'] ?? 0);
1179 $relation = static::getRelation([
1180 '=GROUP_ID' => $groupId,
1181 '=USER_ID' => $userId,
1184 catch (\Exception $e)
1186 throw new \Exception($e->getMessage(), $e->getCode());
1190 'userId' => $userId,
1191 'groupId' => $groupId,
1199 self::deleteRelation([
1200 'relationId' => $relation->getId(),
1203 catch (\Exception $e)
1205 throw new \Exception($e->getMessage(), $e->getCode());
1211 public static function exclude(array $fields = []): bool
1213 global $APPLICATION;
1215 $groupId = (int)($fields[
'groupId'] ?? 0);
1216 $userId = (int)($fields[
'userId'] ?? 0);
1230 $relation = static::getRelation([
1231 '=GROUP_ID' => $groupId,
1232 '=USER_ID' => $userId,
1235 catch (\Exception $e)
1237 throw new \Exception($e->getMessage(), $e->getCode());
1241 'userId' => $userId,
1242 'groupId' => $groupId,
1248 if (!\CSocNetUserToGroup::delete($relation->getId(),
true))
1250 if ($ex = $APPLICATION->getException())
1252 $errorMessage = $ex->getString();
1256 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1259 throw new \Exception($errorMessage, 100);
1267 global $APPLICATION;
1269 $relationId = (int)($fields[
'relationId'] ?? 0);
1271 if ($relationId <= 0)
1278 $relation = static::getRelation([
1279 '=ID' => $relationId,
1282 catch (\Exception $e)
1284 throw new \Exception($e->getMessage(), $e->getCode());
1287 if (!\CSocNetUserToGroup::delete($relation->getId()))
1289 if ($ex = $APPLICATION->getException())
1291 $errorMessage = $ex->getString();
1295 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1298 throw new \Exception($errorMessage, 100);
1306 global $APPLICATION;
1308 $groupId = (int)($fields[
'groupId'] ?? 0);
1309 $userId = (int)($fields[
'userId'] ?? 0);
1323 $relation = static::getRelation([
1324 '=GROUP_ID' => $groupId,
1325 '=USER_ID' => $userId,
1328 catch (\Exception $e)
1330 throw new \Exception($e->getMessage(), $e->getCode());
1334 'userId' => $userId,
1335 'groupId' => $groupId,
1341 if (!\CSocNetUserToGroup::confirmRequestToBeMember(
1344 [ $relation->getId() ]
1347 if ($ex = $APPLICATION->getException())
1349 $errorMessage = $ex->getString();
1353 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1356 throw new \Exception($errorMessage, 100);
1364 global $APPLICATION;
1366 $groupId = (int) ($fields[
'groupId'] ?? 0);
1367 $userId = (int) ($fields[
'userId'] ?? 0);
1381 $relation = static::getRelation([
1382 '=GROUP_ID' => $groupId,
1383 '=USER_ID' => $userId,
1386 catch (\Exception $e)
1388 throw new \Exception($e->getMessage(), $e->getCode());
1391 if (!\CSocNetUserToGroup::UserConfirmRequestToBeMember($userId, $relation->getId()))
1393 if ($ex = $APPLICATION->getException())
1395 $errorMessage = $ex->getString();
1399 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1402 throw new \Exception($errorMessage, 100);
1410 global $APPLICATION;
1412 $groupId = (int) ($fields[
'groupId'] ?? 0);
1413 $userId = (int) ($fields[
'userId'] ?? 0);
1427 $relation = static::getRelation([
1428 '=GROUP_ID' => $groupId,
1429 '=USER_ID' => $userId,
1432 catch (\Exception $e)
1434 throw new \Exception($e->getMessage(), $e->getCode());
1437 if (!\CSocNetUserToGroup::userRejectRequestToBeMember($userId, $relation->getId()))
1439 if ($ex = $APPLICATION->getException())
1441 $errorMessage = $ex->getString();
1445 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1448 throw new \Exception($errorMessage, 100);
1456 global $APPLICATION;
1458 $groupId = (int)($fields[
'groupId'] ?? 0);
1459 $userId = (int)($fields[
'userId'] ?? 0);
1473 $relation = static::getRelation([
1474 '=GROUP_ID' => $groupId,
1475 '=USER_ID' => $userId,
1478 catch (\Exception $e)
1480 throw new \Exception($e->getMessage(), $e->getCode());
1484 'userId' => $userId,
1485 'groupId' => $groupId,
1491 if (!\CSocNetUserToGroup::rejectRequestToBeMember(
1494 [ $relation->getId() ]
1497 if ($ex = $APPLICATION->getException())
1499 $errorMessage = $ex->getString();
1503 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1506 throw new \Exception($errorMessage, 100);
1514 global $APPLICATION;
1516 $departmentId = (int)($fields[
'departmentId'] ?? 0);
1517 $groupId = (int)($fields[
'groupId'] ?? 0);
1524 if ($departmentId <= 0)
1529 if (!ModuleManager::isModuleInstalled(
'intranet'))
1534 $workgroup = Item\Workgroup::getById($groupId);
1540 if (!isset($workgroup->getFields()[
'UF_SG_DEPT']))
1542 throw new \Exception(
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
1545 $workgroupFields = $workgroup->getFields();
1546 $currentDepartmentsList = $workgroupFields[
'UF_SG_DEPT'][
'VALUE'];
1549 !is_array($currentDepartmentsList)
1550 || empty($currentDepartmentsList)
1553 throw new \Exception(
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
1556 $currentDepartmentsList = array_map(
'intval', array_unique($currentDepartmentsList));
1558 if (!\CSocNetGroup::update(
1561 'NAME' => $workgroupFields[
'NAME'],
1562 'UF_SG_DEPT' => array_diff($currentDepartmentsList, [ $departmentId ]),
1566 if ($ex = $APPLICATION->getException())
1568 $errorMessage = $ex->getString();
1572 $errorMessage =
Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1575 throw new \Exception($errorMessage, 100);
1583 $res = UserToGroupTable::getList([
1584 'filter' => $filter,
1585 'select' => [
'ID',
'USER_ID',
'GROUP_ID',
'ROLE',
'INITIATED_BY_TYPE',
'INITIATED_BY_USER_ID',
'AUTO_MEMBER' ]
1588 if (!$result = $res->fetchObject())
1601 return Helper\Workgroup\Access::canCreate($params);
1607 if ($result ===
null)
1609 $result = \CSocNetUser::isCurrentUserModuleAdmin(SITE_ID, $checkSession);
1625 static $useProjects =
null;
1626 static $extranetInstalled =
null;
1628 if ($extranetInstalled ===
null)
1630 $extranetInstalled = self::isExtranetInstalled();
1633 $entityOptions = [];
1634 if (!empty($params[
'entityOptions']) && is_array($params[
'entityOptions']))
1636 $entityOptions = $params[
'entityOptions'];
1642 if ($useProjects ===
null)
1645 ModuleManager::isModuleInstalled(
'intranet')
1646 && self::checkEntityOption([
'project' ], $entityOptions)
1652 if (self::checkEntityOption([
'!landing',
'!scrum' ], $entityOptions))
1654 $result[
'project'] = [
1655 'SORT' => $sort += 10,
1656 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_PROJECT'),
1657 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_PROJECT_DESC'),
1661 'SCRUM_PROJECT' =>
'N',
1666 if (self::checkEntityOption([
'scrum',
'!extranet',
'!landing' ], $entityOptions))
1668 $result[
'scrum'] = [
1669 'SORT' => $sort += 10,
1670 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_SCRUM'),
1671 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_SCRUM_DESC'),
1675 'SCRUM_PROJECT' =>
'Y',
1681 if (self::checkEntityOption([
'!scrum' ], $entityOptions))
1683 $result[
'group'] = [
1684 'SORT' => $sort += 10,
1685 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_GROUP'),
1686 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_GROUP_DESC'),
1690 'SCRUM_PROJECT' =>
'N',
1700 static $useProjects =
null;
1702 $currentExtranetSite = (
1704 && isset($params[
'currentExtranetSite'])
1705 && $params[
'currentExtranetSite']
1709 !empty($params[
'entityOptions'])
1710 && is_array($params[
'entityOptions'])
1711 ? $params[
'entityOptions']
1718 if ($useProjects ===
null)
1721 ModuleManager::isModuleInstalled(
'intranet')
1722 && self::checkEntityOption([
'project' ], $entityOptions)
1726 if (!$currentExtranetSite)
1728 if (self::checkEntityOption([
'open',
'!extranet',
'!landing' ], $entityOptions))
1731 'SORT' => $sort += 10,
1732 'NAME' => ($useProjects ?
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_OPEN') :
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_OPEN')),
1733 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_OPEN_DESC3'),
1740 if (self::checkEntityOption([
'!open',
'!extranet',
'!landing' ], $entityOptions))
1742 $result[
'closed'] = [
1743 'SORT' => $sort += 10,
1744 'NAME' => ($useProjects ?
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED') :
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED')),
1745 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_DESC3'),
1752 if (self::checkEntityOption([
'!open',
'!extranet',
'!landing' ], $entityOptions))
1754 $result[
'secret'] = [
1755 'SORT' => $sort += 10,
1756 'NAME' => ($useProjects ?
1760 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_SECRET_DESC3_1'),
1775 foreach ($keysList as $key)
1778 !empty($entityOptions)
1781 isset($entityOptions[$key])
1782 && !$entityOptions[$key]
1785 preg_match(
'/^\!(\w+)$/', $key, $matches)
1786 && isset($entityOptions[$matches[1]])
1787 && $entityOptions[$matches[1]]
1802 static $useProjects =
null;
1803 static $extranetInstalled =
null;
1804 static $landingInstalled =
null;
1806 if ($extranetInstalled ===
null)
1808 $extranetInstalled = self::isExtranetInstalled();
1811 if ($landingInstalled ===
null)
1813 $landingInstalled = ModuleManager::isModuleInstalled(
'landing');
1816 $currentExtranetSite = (
1818 && isset($params[
'currentExtranetSite'])
1819 && $params[
'currentExtranetSite']
1824 && is_array($params[
'entityOptions'])
1825 && !empty($params[
'entityOptions'])
1826 ? $params[
'entityOptions']
1832 && isset($params[
'fullMode'])
1833 && $params[
'fullMode']
1839 if ($useProjects ===
null)
1842 ModuleManager::isModuleInstalled(
'intranet')
1843 && self::checkEntityOption([
'project' ], $entityOptions)
1847 if (!$currentExtranetSite)
1849 if (self::checkEntityOption([
'open',
'!extranet',
'!landing' ], $entityOptions))
1851 $result[
'project-open'] = [
1852 'SORT' => $sort += 10,
1853 'NAME' => ($useProjects ?
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_OPEN') :
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_OPEN')),
1854 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_OPEN_DESC'),
1855 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_OPEN_DESC2'),
1858 'PROJECT' => ($useProjects ?
'Y' :
'N' ),
1860 'TILE_CLASS' =>
'social-group-tile-item-cover-open ' . ($useProjects ?
'social-group-tile-item-icon-project-open' :
'social-group-tile-item-icon-group-open')
1864 if (self::checkEntityOption([
'!open',
'!extranet',
'!landing' ], $entityOptions))
1866 $result[
'project-closed'] = [
1867 'SORT' => $sort += 10,
1868 'NAME' => ($useProjects ?
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED') :
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED')),
1869 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_DESC'),
1870 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_DESC'),
1873 'PROJECT' => ($useProjects ?
'Y' :
'N' ),
1875 'TILE_CLASS' =>
'social-group-tile-item-cover-close ' . ($useProjects ?
'social-group-tile-item-icon-project-close' :
'social-group-tile-item-icon-group-close')
1881 && self::checkEntityOption([
'project',
'scrum',
'!extranet',
'!landing' ], $entityOptions)
1884 $result[
'project-scrum'] = [
1885 'SORT' => $sort += 10,
1886 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM'),
1887 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_DESC'),
1888 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_DESC'),
1892 'SCRUM_PROJECT' =>
'Y',
1894 'TILE_CLASS' =>
'social-group-tile-item-cover-scrum social-group-tile-item-icon-project-scrum'
1900 && self::checkEntityOption([
'!open',
'!extranet',
'!landing' ], $entityOptions)
1903 $result[
'project-closed-visible'] = [
1904 'SORT' => $sort += 10,
1905 'NAME' => ($useProjects ?
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_VISIBLE') :
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_VISIBLE')),
1906 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_VISIBLE_DESC'),
1907 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_VISIBLE_DESC'),
1910 'PROJECT' => ($useProjects ?
'Y' :
'N' ),
1919 && self::checkEntityOption([
'extranet',
'!landing' ], $entityOptions)
1922 $result[
'project-external'] = [
1923 'SORT' => $sort += 10,
1924 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_EXTERNAL'),
1925 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_EXTERNAL_DESC'),
1926 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_EXTERNAL_DESC'),
1929 'PROJECT' => ($useProjects ?
'Y' :
'N' ),
1931 'TILE_CLASS' =>
'social-group-tile-item-cover-outer social-group-tile-item-icon-project-outer'
1937 && self::checkEntityOption([
'!project',
'landing',
'!extranet' ], $entityOptions)
1940 $result[
'group-landing'] = [
1941 'SORT' => $sort += 10,
1942 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING2'),
1943 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING_DESC2_MSGVER_1'),
1944 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING_DESC2_MSGVER_1'),
1950 'TILE_CLASS' =>
'social-group-tile-item-cover-public social-group-tile-item-icon-group-public'
1959 static $intranetInstalled =
null;
1960 static $extranetInstalled =
null;
1961 static $landingInstalled =
null;
1963 if ($intranetInstalled ===
null)
1965 $intranetInstalled = ModuleManager::isModuleInstalled(
'intranet');
1968 if ($extranetInstalled ===
null)
1970 $extranetInstalled = static::isExtranetInstalled();
1973 if ($landingInstalled ===
null)
1975 $landingInstalled = ModuleManager::isModuleInstalled(
'landing');
1978 $currentExtranetSite = (
1980 && isset($params[
'currentExtranetSite'])
1981 && $params[
'currentExtranetSite']
1985 if (!empty($params[
'category']) && is_array($params[
'category']))
1987 $categoryList = $params[
'category'];
1990 $entityOptions = [];
1991 if (!empty($params[
'entityOptions']) && is_array($params[
'entityOptions']))
1993 $entityOptions = $params[
'entityOptions'];
1998 && isset($params[
'fullMode'])
1999 && $params[
'fullMode']
2008 empty($categoryList)
2009 || in_array(
'projects', $categoryList,
true)
2013 if (!$currentExtranetSite)
2015 if (self::checkEntityOption([
'project',
'open',
'!extranet',
'!landing' ], $entityOptions))
2017 $result[
'project-open'] = array(
2018 'SORT' => $sort += 10,
2019 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_OPEN'),
2020 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_OPEN_DESC'),
2021 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_OPEN_DESC2'),
2025 'SCRUM_PROJECT' =>
'N',
2027 'TILE_CLASS' =>
'social-group-tile-item-cover-open social-group-tile-item-icon-project-open'
2031 if (self::checkEntityOption([
'project',
'!open',
'!extranet',
'!landing' ], $entityOptions))
2033 $result[
'project-closed'] = array(
2034 'SORT' => $sort += 10,
2035 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED'),
2036 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED_DESC'),
2037 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED_DESC'),
2041 'SCRUM_PROJECT' =>
'N',
2043 'TILE_CLASS' =>
'social-group-tile-item-cover-close social-group-tile-item-icon-project-close'
2047 if (self::checkEntityOption([
'project',
'scrum',
'!extranet',
'!landing' ], $entityOptions))
2049 $result[
'project-scrum'] = [
2050 'SORT' => $sort += 10,
2051 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM2'),
2052 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_DESC2'),
2053 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_DESC2'),
2057 'SCRUM_PROJECT' =>
'Y',
2059 'TILE_CLASS' =>
'social-group-tile-item-cover-scrum social-group-tile-item-icon-project-scrum'
2065 && self::checkEntityOption([
'project',
'!open',
'!extranet',
'!landing' ], $entityOptions)
2068 $result[
'project-closed-visible'] = array(
2069 'SORT' => $sort += 10,
2070 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED_VISIBLE'),
2071 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED_VISIBLE_DESC'),
2072 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED_VISIBLE_DESC'),
2076 'SCRUM_PROJECT' =>
'N',
2085 && self::checkEntityOption([
'project',
'scrum',
'extranet',
'!landing' ], $entityOptions)
2088 $result[
'project-scrum-extranet'] = [
2089 'SORT' => $sort += 10,
2090 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_EXTERNAL'),
2091 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_EXTERNAL_DESC'),
2092 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_EXTERNAL_DESC'),
2096 'SCRUM_PROJECT' =>
'Y',
2098 'TILE_CLASS' =>
'social-group-tile-item-cover-scrum social-group-tile-item-icon-project-scrum'
2104 && self::checkEntityOption([
'project',
'extranet',
'!landing' ], $entityOptions)
2107 $result[
'project-external'] = array(
2108 'SORT' => $sort += 10,
2109 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_EXTERNAL'),
2110 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_EXTERNAL_DESC'),
2111 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_EXTERNAL_DESC'),
2115 'SCRUM_PROJECT' =>
'N',
2117 'TILE_CLASS' =>
'social-group-tile-item-cover-outer social-group-tile-item-icon-project-outer'
2123 !$currentExtranetSite
2125 empty($categoryList)
2126 || in_array(
'groups', $categoryList)
2130 if (self::checkEntityOption([
'!project',
'open',
'!extranet',
'!landing' ], $entityOptions))
2132 $result[
'group-open'] = array(
2133 'SORT' => $sort += 10,
2134 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_OPEN'),
2135 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_OPEN_DESC'),
2136 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_OPEN_DESC2'),
2140 'SCRUM_PROJECT' =>
'N',
2142 'TILE_CLASS' =>
'social-group-tile-item-cover-open social-group-tile-item-icon-group-open'
2146 if (self::checkEntityOption([
'!project',
'!open',
'!extranet',
'!landing' ], $entityOptions))
2148 $result[
'group-closed'] = array(
2149 'SORT' => $sort += 10,
2150 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED'),
2151 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_DESC'),
2152 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_DESC'),
2156 'SCRUM_PROJECT' =>
'N',
2158 'TILE_CLASS' =>
'social-group-tile-item-cover-close social-group-tile-item-icon-group-close'
2162 $result[
'group-closed-visible'] = array(
2163 'SORT' => $sort = $sort + 10,
2164 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_VISIBLE'),
2165 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_VISIBLE_DESC'),
2166 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_VISIBLE_DESC'),
2170 'SCRUM_PROJECT' =>
'N',
2180 && self::checkEntityOption([
'!project',
'extranet',
'!landing' ], $entityOptions)
2183 $result[
'group-external'] = array(
2184 'SORT' => $sort += 10,
2185 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_EXTERNAL'),
2186 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_EXTERNAL_DESC'),
2187 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_EXTERNAL_DESC'),
2191 'SCRUM_PROJECT' =>
'N',
2193 'TILE_CLASS' =>
'social-group-tile-item-cover-outer social-group-tile-item-icon-group-outer'
2199 && self::checkEntityOption([
'!project',
'landing',
'!extranet' ], $entityOptions)
2202 $result[
'group-landing'] = array(
2203 'SORT' => $sort += 10,
2204 'NAME' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING_MSGVER_1'),
2205 'DESCRIPTION' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING_DESC_MSGVER_1'),
2206 'DESCRIPTION2' =>
Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING_DESC_MSGVER_1'),
2210 'SCRUM_PROJECT' =>
'N',
2213 'TILE_CLASS' =>
'social-group-tile-item-cover-public social-group-tile-item-icon-group-public'
2223 ModuleManager::isModuleInstalled(
'extranet')
2224 && Option::get(
'extranet',
'extranet_site') !==
''
2230 return array_merge(self::getDefaultAvatarTypes(), self::getColoredAvatarTypes());
2238 'mobileUrl' =>
'/bitrix/images/socialnetwork/workgroup/folder.png',
2239 'webCssClass' =>
'folder',
2240 'entitySelectorUrl' =>
'/bitrix/images/socialnetwork/workgroup/folder.png',
2244 'mobileUrl' =>
'/bitrix/images/socialnetwork/workgroup/checks.png',
2245 'webCssClass' =>
'tasks',
2246 'entitySelectorUrl' =>
'/bitrix/images/socialnetwork/workgroup/checks.png',
2250 'mobileUrl' =>
'/bitrix/images/socialnetwork/workgroup/pie.png',
2251 'webCssClass' =>
'chart',
2252 'entitySelectorUrl' =>
'/bitrix/images/socialnetwork/workgroup/pie.png',
2256 'mobileUrl' =>
'/bitrix/images/socialnetwork/workgroup/bag.png',
2257 'webCssClass' =>
'briefcase',
2258 'entitySelectorUrl' =>
'/bitrix/images/socialnetwork/workgroup/bag.png',
2262 'mobileUrl' =>
'/bitrix/images/socialnetwork/workgroup/members.png',
2263 'webCssClass' =>
'group',
2264 'entitySelectorUrl' =>
'/bitrix/images/socialnetwork/workgroup/members.png',
2271 $colors = self::getAvatarColors();
2274 foreach ($colors as $color)
2276 $avatarTypes[
"space_$color"] = [
2278 'mobileUrl' =>
"/bitrix/images/socialnetwork/workgroup/space_$color.png",
2279 'webCssClass' =>
"space_$color",
2280 'entitySelectorUrl' =>
"/bitrix/images/socialnetwork/workgroup/space_$color.png",
2284 return $avatarTypes;
2305 $types = static::getAvatarTypes();
2306 if (empty($types[$type]))
2311 return $types[$type][
'webCssClass'];
2317 $types = static::getAvatarTypes();
2318 if (empty($types[$type]))
2323 return $types[$type][
'entitySelectorUrl'];
2331 is_array($params[
'ids'])
2334 static function($val) {
return (
int)$val; },
2337 static function ($val) {
return $val > 0; }
2342 is_array($params[
'features'])
2345 static function($val) {
return trim((
string)$val); },
2348 static function ($val) {
return !empty($val); }
2352 $mandatoryFeatures = (
2353 is_array($params[
'mandatoryFeatures'])
2356 static function($val) {
return trim((
string)$val); },
2357 $params[
'mandatoryFeatures']
2359 static function ($val) {
return !empty($val); }
2363 $currentUserId = (int)($params[
'currentUserId'] ?? $USER->getId());
2369 $featuresSettings = \CSocNetAllowed::getAllowedFeatures();
2374 $res = UserToGroupTable::getList([
2377 'USER_ID' => $currentUserId,
2379 'select' => [
'GROUP_ID',
'ROLE',
'INITIATED_BY_TYPE' ]
2382 while ($relationFields = $res->fetch())
2384 $userRoles[(int)$relationFields[
'GROUP_ID']] = [
2385 'ROLE' => $relationFields[
'ROLE'],
2386 'INITIATED_BY_TYPE' => $relationFields[
'INITIATED_BY_TYPE'],
2390 foreach ($features as $feature)
2392 $activeFeaturesList = \CSocNetFeatures::isActiveFeature(SONET_ENTITY_GROUP, $ids, $feature);
2393 $filteredIds = array_keys(array_filter($activeFeaturesList,
static function($val) {
return $val; }));
2397 || !isset($featuresSettings[$feature])
2404 $minOperationList = $featuresSettings[$feature][
'minoperation'];
2405 if (!is_array($minOperationList))
2407 $minOperationList = [ $minOperationList ];
2411 foreach ($minOperationList as $minOperation)
2413 $operationPermissions = \CSocNetFeaturesPerms::getOperationPerm(SONET_ENTITY_GROUP, $filteredIds, $feature, $minOperation);
2414 foreach ($operationPermissions as $groupId => $role)
2417 !isset($permissions[$groupId])
2418 || $role > $permissions[$groupId]
2421 $permissions[$groupId] = $role;
2427 foreach ($ids as $id)
2429 if (!isset($result[$id]))
2434 if (!isset($result[$id][
'FEATURES']))
2436 $result[$id][
'FEATURES'] = [];
2440 in_array($feature, $mandatoryFeatures,
true)
2442 isset($permissions[$id])
2446 isset($userRoles[$id])
2447 && $userRoles[$id][
'ROLE'] <= $permissions[$id]
2453 $result[$id][
'FEATURES'][] = $feature;
2458 foreach ($ids as $id)
2460 $result[$id][
'ROLE'] = ($userRoles[$id][
'ROLE'] ??
'');
2461 $result[$id][
'INITIATED_BY_TYPE'] = ($userRoles[$id][
'INITIATED_BY_TYPE'] ??
'');
2469 if (empty($fields[
'SCRUM_MASTER_ID']))
2474 $fields[
'PROJECT'] =
'Y';
2476 if (empty($fields[
'SUBJECT_ID']))
2478 $siteId = (!empty($fields[
'SITE_ID']) ? $fields[
'SITE_ID'] : SITE_ID);
2480 $subjectQueryObject = \CSocNetGroupSubject::getList(
2486 'SITE_ID' => $siteId,
2492 if ($subject = $subjectQueryObject->fetch())
2494 $fields[
'SUBJECT_ID'] = (int)$subject[
'ID'];
2499 public static function pin(
int $groupId,
string $mode =
''): ?bool
2504 || static::getIsPinned($groupId, $mode)
2514 WorkgroupPinTable::add([
2515 'GROUP_ID' => $groupId,
2516 'USER_ID' => $userId,
2520 catch (\Exception $e)
2525 static::sendPinChangedPushEvent($groupId, $userId,
'pin');
2530 public static function unpin(
int $groupId,
string $mode =
''): ?bool
2535 || !($isPinned = static::getIsPinned($groupId, $mode))
2541 $tableDeleteResult = WorkgroupPinTable::delete($isPinned->get(
'ID'));
2542 if (!$tableDeleteResult->isSuccess())
2552 private static function getIsPinned(
int $groupId,
string $mode): ?EO_WorkgroupPin
2554 $query = WorkgroupPinTable::query();
2556 ->setSelect([
'ID',
'GROUP_ID',
'USER_ID'])
2557 ->where(
'GROUP_ID', $groupId)
2567 ->whereNull(
'CONTEXT')
2568 ->where(
'CONTEXT',
'')
2573 $query->where(
'CONTEXT', $mode);
2576 return $query->exec()->fetchObject();
2579 private static function sendPinChangedPushEvent(
int $groupId,
int $userId,
string $action): void
2581 PushService::addEvent(
2584 'module_id' =>
'socialnetwork',
2585 'command' =>
'workgroup_pin_changed',
2587 'GROUP_ID' => $groupId,
2588 'USER_ID' => $userId,
2589 'ACTION' => $action,
static getConnection($name="")
static getMessage($code, $replace=null, $language=null)
const FEATURE_ENTITY_TYPE_GROUP
static get(string $key='', $siteId=SITE_ID)
static getCurrentUserId()
static canSetModerator(array $params=[])
static canView(array $params=[])
static canJoin(array $params=[])
static canRemoveModerator(array $params=[])
static canDeleteIncomingRequest(array $params=[])
static canSetScrumMaster(array $params=[])
static canModify(array $params=[])
static canExclude(array $params=[])
static canDeleteOutgoingRequest(array $params=[])
static canLeave(array $params=[])
static canProcessIncomingRequest(array $params=[])
static getRelation(array $filter=[])
static checkEntityOption(array $keysList=[], array $entityOptions=[])
static isGroupCopyFeatureEnabled()
static getDefaultAvatarTypes()
static join(array $fields=[])
static canCreate(array $params=[])
static getTypes($params=[])
static setOwner(array $fields=[])
static acceptOutgoingRequest(array $fields=[])
static unpin(int $groupId, string $mode='')
static getProjectPresets($params=[])
static setArchive(array $fields=[])
static setModerator(array $fields=[])
static setModerators(array $fields=[])
static getEmptyPermissions()
static rejectIncomingRequest(array $fields=[])
static pin(int $groupId, string $mode='')
static disconnectDepartment(array $fields=[])
static getSprintDurationDefaultKey()
static getPermissions(array $params=[])
static getColoredAvatarTypes()
static rejectOutgoingRequest(array $fields=[])
static setScrumMaster(array $fields=[])
static getCurrentUserId()
static leave(array $fields=[])
static checkAnyOpened(array $idList=[])
static exclude(array $fields=[])
static getPresets($params=[])
static getTypeCodeByParams($params)
static getSprintDurationValues()
static getByFeatureOperation(array $params=[])
static isCurrentUserModuleAdmin(bool $checkSession=false)
static getProjectTypeCodeByParams($params)
static deleteIncomingRequest(array $fields=[])
static getSprintDurationList()
static acceptIncomingRequest(array $fields=[])
static deleteOutgoingRequest(array $fields=[])
static mutateScrumFormFields(array &$fields=[])
static removeModerator(array $fields=[])
static getTypeByCode($params=[])
static getEditFeaturesAvailability()
static getConfidentialityPresets(array $params=[])
static deleteRelation(array $fields=[])
static getConfidentialityTypeCodeByParams($params)
static getScrumTaskResponsibleList()
static getAvatarTypeWebCssClass($type='')
static getAvatarEntitySelectorUrl($type='')
static getAdditionalData(array $params=[])
static isExtranetInstalled()