9namespace Bitrix\Socialnetwork\Helper;
11use Bitrix\Main\AccessDeniedException;
12use Bitrix\Main\Application;
13use Bitrix\Main\ArgumentException;
14use Bitrix\Main\Entity\Query;
15use Bitrix\Main\Entity\ReferenceField;
16use Bitrix\Main\NotImplementedException;
17use Bitrix\Main\ObjectNotFoundException;
18use Bitrix\Main\Config\Option;
19use Bitrix\Main\DB\SqlExpression;
20use Bitrix\Main\Loader;
21use Bitrix\Main\Localization\Loc;
22use Bitrix\Main\ModuleManager;
23use Bitrix\Main\ORM\Query\Join;
24use Bitrix\Main\SystemException;
25use Bitrix\Socialnetwork\Collab\CollabFeature;
26use Bitrix\Socialnetwork\EO_WorkgroupPin;
27use Bitrix\Socialnetwork\FeatureTable;
28use Bitrix\Socialnetwork\FeaturePermTable;
29use Bitrix\Socialnetwork\Integration\Intranet\Settings;
30use Bitrix\Socialnetwork\Integration\Pull\PushService;
31use Bitrix\Socialnetwork\Integration\Pull;
32use Bitrix\Socialnetwork\WorkgroupPinTable;
33use Bitrix\Socialnetwork\WorkgroupTable;
34use Bitrix\Socialnetwork\UserToGroupTable;
35use Bitrix\Socialnetwork\Item;
36use Bitrix\Socialnetwork\Helper;
48 $selfJoin = (
new ReferenceField(
50 UserToGroupTable::getEntity(),
51 Join::on(
'this.GROUP_ID',
'ref.GROUP_ID')
52 ->where(
'ref.USER_ID', $targetUserId)
53 ->whereIn(
'ref.ROLE', $roles)
54 ))->configureJoinType(Join::TYPE_INNER);
56 $query = UserToGroupTable::query()
57 ->setSelect([Query::expr(
'CNT')->
count(
'ID')])
58 ->registerRuntimeField($selfJoin)
60 ->whereIn(
'ROLE', $roles);
74 $oneWeek = \DateInterval::createFromDateString(
'1 week')->format(
'%d') * 86400;
75 $twoWeek = \DateInterval::createFromDateString(
'2 weeks')->format(
'%d') * 86400;
76 $threeWeek = \DateInterval::createFromDateString(
'3 weeks')->format(
'%d') * 86400;
77 $fourWeek = \DateInterval::createFromDateString(
'4 weeks')->format(
'%d') * 86400;
81 'TITLE' => Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_SPRINT_DURATION_ONE_WEEK'),
84 'TITLE' => Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_SPRINT_DURATION_TWO_WEEK'),
88 'TITLE' => Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_SPRINT_DURATION_THREE_WEEK'),
91 'TITLE' => Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_SPRINT_DURATION_FOUR_WEEK'),
101 $list = static::getSprintDurationList();
104 foreach ($list as
$key => $item)
114 $list = static::getSprintDurationList();
115 $result = array_key_first($list);
116 foreach ($list as
$key => $item)
119 isset($item[
'DEFAULT'])
120 && $item[
'DEFAULT'] ===
true
134 'A' => Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_TASK_RESPONSIBLE_AUTHOR'),
135 'M' => Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_TYPE_PROJECT_SCRUM_TASK_RESPONSIBLE_MASTER'),
158 !isset(
$params[
'fields'][
'OPENED'])
162 !isset(
$params[
'fields'][
'VISIBLE'])
168 !isset(
$params[
'fields'][
'SCRUM_PROJECT'])
170 isset(
$type[
'SCRUM_PROJECT'])
171 &&
$params[
'fields'][
'SCRUM_PROJECT'] ===
$type[
'SCRUM_PROJECT']
196 : static::getProjectPresets(
$params)
202 (
$params[
'fields'][
'PROJECT'] ??
'') === (
$type[
'PROJECT'] ??
'')
203 &&
$params[
'fields'][
'SCRUM_PROJECT'] ===
$type[
'SCRUM_PROJECT']
226 : self::getConfidentialityPresets(
$params)
232 (
$params[
'fields'][
'OPENED'] ??
'') === (
$type[
'OPENED'] ??
'')
234 isset(
$params[
'fields'][
'VISIBLE'])
237 && (
$params[
'fields'][
'PROJECT'] ??
'') === (
$type[
'PROJECT'] ??
'')
269 && is_array($typesList)
270 && !empty($typesList[
$code])
290 if (!ModuleManager::isModuleInstalled(
'bitrix24'))
295 if (\CBitrix24::isNfrLicense())
300 if (\CBitrix24::isDemoLicense())
306 \CBitrix24::getLicenseType() !==
'project'
307 || !Option::get(
'socialnetwork',
'demo_edit_features',
false)
329 $feature = (string)(
$params[
'feature'] ??
'');
330 $operation = (string)(
$params[
'operation'] ??
'');
348 $featuresSettings = \CSocNetAllowed::getAllowedFeatures();
350 empty($featuresSettings)
351 || empty($featuresSettings[$feature])
352 || empty($featuresSettings[$feature][
'allowed'])
353 || empty($featuresSettings[$feature][
'operations'])
354 || empty($featuresSettings[$feature][
'operations'][$operation])
362 $cacheTTL = 3600 * 24 * 30;
364 $cacheId = implode(
' ', [
'entities_list', $feature, $operation,
$userId ]);
366 $cache = new \CPHPCache();
367 if ($cache->initCache($cacheTTL, $cacheId, $cacheDir))
369 $cacheValue = $cache->getVars();
370 if (is_array($cacheValue))
377 $cache->startDataCache();
387 $query = new \Bitrix\Main\Entity\Query(WorkgroupTable::getEntity());
388 $query->addFilter(
'=ACTIVE',
'Y');
392 !is_array($featuresSettings[$feature][
'minoperation'])
393 || !in_array($operation, $featuresSettings[$feature][
'minoperation'],
true)
395 && Option::get(
'socialnetwork',
'work_with_closed_groups',
'N') !==
'Y'
398 $query->addFilter(
'!=CLOSED',
'Y');
408 $query->registerRuntimeField(
411 FeatureTable::getEntity(),
414 '=ref.ENTITY_ID' =>
'this.ID',
417 [
'join_type' =>
'LEFT' ]
420 $query->addSelect(
'F.ID',
'FEATURE_ID');
422 $query->registerRuntimeField(
425 FeaturePermTable::getEntity(),
427 '=ref.FEATURE_ID' =>
'this.FEATURE_ID',
430 [
'join_type' =>
'LEFT' ]
435 'PERM_ROLE_CALCULATED',
436 'COALESCE(%s, \''.$defaultRole.
'\')
',
437 [ 'FP.ROLE
', 'FP.ROLE
' ]
440 $query->registerRuntimeField(
442 new \Bitrix\Main\Entity\ReferenceField('UG
',
443 UserToGroupTable::getEntity(),
445 '=ref.GROUP_ID
' => 'this.ID
',
446 '=ref.USER_ID
' => new SqlExpression($userId),
448 [ 'join_type
' => 'LEFT
' ]
452 $query->registerRuntimeField(new \Bitrix\Main\Entity\ExpressionField(
471 AND \
''. $isIntranet .
'\' = \
'Y\'
478 'PERM_ROLE_CALCULATED',
479 'PERM_ROLE_CALCULATED',
'UG.ROLE',
485 $query->addFilter(
'=HAS_ACCESS',
'Y');
489 while ($row =
$res->fetch())
492 'ID' => (int) $row[
'ID'],
510 $res = WorkgroupTable::getList([
516 'select' => [
'ID' ],
534 $groupId = (int)(
$params[
'groupId'] ?? 0);
537 $APPLICATION->throwException(
'Empty workgroup Id',
'SONET_HELPER_WORKGROUP_EMPTY_GROUP');
545 $group = Item\Workgroup::getById($groupId);
548 return self::getEmptyPermissions();
550 $groupFields = $group->getFields();
551 if (empty($groupFields))
553 return self::getEmptyPermissions();
559 \CSocNetUser::isCurrentUserModuleAdmin(),
568 return self::getEmptyPermissions();
574 'Operations' =>
false,
576 'UserIsMember' =>
false,
577 'UserIsAutoMember' =>
false,
578 'InitiatedByType' =>
false,
579 'InitiatedByUserId' =>
false,
580 'UserIsOwner' =>
false,
581 'UserIsScrumMaster' =>
false,
582 'UserCanInitiate' =>
false,
583 'UserCanProcessRequestsIn' =>
false,
584 'UserCanViewGroup' =>
false,
585 'UserCanAutoJoinGroup' =>
false,
586 'UserCanModifyGroup' =>
false,
587 'UserCanModerateGroup' =>
false,
588 'UserCanSpamGroup' =>
false,
594 $isB24Installed = ModuleManager::isModuleInstalled(
'bitrix24') && Loader::includeModule(
'bitrix24');
596 if (!$isB24Installed)
606 $isB24Installed = ModuleManager::isModuleInstalled(
'bitrix24') && Loader::includeModule(
'bitrix24');
608 if (!$isB24Installed)
620 if (!isset(
$fields[
'archive']))
622 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
625 $groupId = (int)(
$fields[
'groupId'] ?? 0);
626 $archive = (bool)
$fields[
'archive'];
631 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
638 $isCurrentUserAdmin = static::isCurrentUserModuleAdmin();
640 if (!$isCurrentUserAdmin)
642 $filter[
'CHECK_PERMISSIONS'] = $currentUserId;
646 if (!($groupFields =
$res->fetch()))
652 'groupId' => $groupId,
655 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
658 if (!\CSocNetGroup::update($groupId, [
'CLOSED' => ($archive ?
'Y' :
'N') ],
false,
true,
false))
663 $errorCode = $ex->getId();
667 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
681 $groupId = (int) (
$fields[
'groupId'] ?? 0);
682 $newOwnerId = (int) (
$fields[
'userId'] ?? 0);
687 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
690 if ($newOwnerId <= 0)
692 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
699 $isCurrentUserAdmin = static::isCurrentUserModuleAdmin();
701 if (!$isCurrentUserAdmin)
703 $filter[
'CHECK_PERMISSIONS'] = $currentUserId;
707 if (!($groupFields =
$res->fetch()))
712 $groupPerms = static::getPermissions([
713 'groupId' => $groupId,
716 if (!$groupPerms[
'UserCanModifyGroup'])
718 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
721 if (!\CSocNetUserToGroup::setOwner($newOwnerId, $groupFields[
'ID'], $groupFields))
729 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
740 $groupId = (int)(
$fields[
'groupId'] ?? 0);
741 $newScrumMasterId = (int)(
$fields[
'userId'] ?? 0);
746 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
749 if ($newScrumMasterId <= 0)
751 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
755 'userId' => $newScrumMasterId,
756 'groupId' => $groupId,
759 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
762 if (!\CSocNetGroup::Update($groupId, [
763 'SCRUM_MASTER_ID' => $newScrumMasterId,
766 throw new \Exception(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'), 100);
769 $relation = UserToGroupTable::getList([
771 'USER_ID' => $newScrumMasterId,
772 'GROUP_ID' => $groupId,
774 'select' => [
'ID',
'ROLE' ],
781 && !\CSocNetUserToGroup::Update($relation->getId(), [
786 throw new \Exception(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'), 100);
791 static $helper =
null;
798 if (!\CSocNetUserToGroup::Add([
799 'AUTO_MEMBER' =>
'N',
800 'USER_ID' => $newScrumMasterId,
801 'GROUP_ID' => $groupId,
804 'INITIATED_BY_USER_ID' => $currentUserId,
805 '=DATE_CREATE' => $helper->getCurrentDateTimeFunction(),
806 '=DATE_UPDATE' => $helper->getCurrentDateTimeFunction(),
809 throw new \RuntimeException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'), 100);
820 $groupId = (int)(
$fields[
'groupId'] ?? 0);
826 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
831 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
836 $relation = static::getRelation([
837 '=GROUP_ID' => $groupId,
843 throw new \Exception($e->getMessage(), $e->getCode());
848 'groupId' => $groupId,
851 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
854 if (!\CSocNetUserToGroup::transferMember2Moderator(
857 [ $relation->getId() ]
866 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
879 $groupId = (int)(
$fields[
'groupId'] ?? 0);
885 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
890 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
895 $relation = static::getRelation([
896 '=GROUP_ID' => $groupId,
902 throw new \Exception($e->getMessage(), $e->getCode());
907 'groupId' => $groupId,
910 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
913 if (!\CSocNetUserToGroup::TransferModerator2Member(
916 [ $relation->getId() ]
925 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
936 $groupId = (int)(
$fields[
'groupId'] ?? 0);
937 $userIds = array_map(
'intval', array_filter(
$fields[
'userIds'] ?? []));
941 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
945 $isCurrentUserModuleAdmin = static::isCurrentUserModuleAdmin();
947 $groupPerms = static::getPermissions([
'groupId' => $groupId]);
948 if (!$groupPerms || (!$groupPerms[
'UserCanModifyGroup'] && !$isCurrentUserModuleAdmin))
950 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
953 $currentModeratorRelations = static::getCurrentModeratorRelations($groupId);
954 $moderatorsToAdd = array_diff($userIds, array_keys($currentModeratorRelations));
955 $moderatorsToRemove = array_diff_key($currentModeratorRelations, array_fill_keys($userIds,
true));
957 if (!empty($moderatorsToRemove))
959 \CSocNetUserToGroup::TransferModerator2Member(
966 if (!empty($moderatorsToAdd))
968 [$ownerRelations, $memberRelations, $otherRelations] = static::getUserRelations($groupId, $moderatorsToAdd);
970 if (!empty($memberRelations))
972 \CSocNetUserToGroup::transferMember2Moderator(
979 $moderatorsToAdd = array_diff($moderatorsToAdd, array_keys($memberRelations), array_keys($ownerRelations));
980 foreach ($moderatorsToAdd as
$userId)
982 if (array_key_exists(
$userId, $otherRelations))
984 $relationId = static::transferToModerators($otherRelations[
$userId]);
988 $relationId = static::addToModerators(
$userId, $groupId);
993 static::sendNotifications(
$userId, $groupId, $relationId);
1001 private static function getCurrentModeratorRelations(
int $groupId):
array
1003 $currentModeratorRelations = [];
1005 $relationResult = UserToGroupTable::getList([
1006 'select' => [
'ID',
'USER_ID'],
1008 'GROUP_ID' => $groupId,
1012 while ($relation = $relationResult->fetch())
1014 $currentModeratorRelations[$relation[
'USER_ID']] = $relation[
'ID'];
1017 return $currentModeratorRelations;
1020 private static function getUserRelations(
int $groupId,
array $userIds):
array
1022 $ownerRelations = [];
1023 $memberRelations = [];
1024 $otherRelations = [];
1026 $relationResult = UserToGroupTable::getList([
1027 'select' => [
'ID',
'USER_ID',
'ROLE'],
1029 'GROUP_ID' => $groupId,
1030 '@USER_ID' => $userIds,
1033 while ($relation = $relationResult->fetch())
1035 $id = $relation[
'ID'];
1036 $userId = $relation[
'USER_ID'];
1038 switch ($relation[
'ROLE'])
1041 $ownerRelations[
$userId] = $id;
1045 $memberRelations[
$userId] = $id;
1049 $otherRelations[
$userId] = $id;
1054 return [$ownerRelations, $memberRelations, $otherRelations];
1057 private static function transferToModerators(
int $relationId)
1059 return \CSocNetUserToGroup::update(
1063 '=DATE_UPDATE' => \CDatabase::CurrentTimeFunction(),
1068 private static function addToModerators(
int $userId,
int $groupId)
1070 return \CSocNetUserToGroup::add([
1072 'GROUP_ID' => $groupId,
1074 '=DATE_CREATE' => \CDatabase::CurrentTimeFunction(),
1075 '=DATE_UPDATE' => \CDatabase::CurrentTimeFunction(),
1083 private static function sendNotifications(
int $userId,
int $groupId,
int $relationId): void
1085 \CSocNetUserToGroup::notifyModeratorAdded([
1087 'groupId' => $groupId,
1088 'relationId' => $relationId,
1091 'group_id' => $groupId,
1094 'sendMessage' =>
false,
1101 $groupId = (int)(
$fields[
'groupId'] ?? 0);
1106 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
1111 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
1116 'groupId' => $groupId,
1119 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
1122 $relation = UserToGroupTable::getList([
1125 'GROUP_ID' => $groupId,
1127 'select' => [
'ID',
'ROLE',
'INITIATED_BY_TYPE' ],
1136 if (!\CSocNetUserToGroup::userConfirmRequestToBeMember(
$userId, $relation->getId(),
false))
1138 throw new \RuntimeException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
1141 $confirmationNeeded =
false;
1145 $requestConfirmUrl = \CComponentEngine::MakePathFromTemplate(
Path::get(
'group_requests_path_template'), [
'group_id' => $groupId ]);
1146 if (!\CSocNetUserToGroup::sendRequestToBeMember(
$userId, $groupId,
'', $requestConfirmUrl,
false))
1148 throw new \RuntimeException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
1151 $confirmationNeeded = !(WorkgroupTable::getList([
1155 'select' => [
'OPENED' ],
1156 ])->fetchObject()->getOpened());
1159 return $confirmationNeeded;
1164 $groupId = (int)(
$fields[
'groupId'] ?? 0);
1169 'groupId' => $groupId,
1172 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
1175 if (!\CSocNetUserToGroup::deleteRelation(
$userId, $groupId))
1177 throw new \RuntimeException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
1185 $groupId = (int)(
$fields[
'groupId'] ?? 0);
1190 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
1195 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
1200 $relation = static::getRelation([
1201 '=GROUP_ID' => $groupId,
1207 throw new \Exception($e->getMessage(), $e->getCode());
1212 'groupId' => $groupId,
1215 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
1220 self::deleteRelation([
1221 'relationId' => $relation->getId(),
1226 throw new \Exception($e->getMessage(), $e->getCode());
1234 $groupId = (int)(
$fields[
'groupId'] ?? 0);
1239 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
1244 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
1249 $relation = static::getRelation([
1250 '=GROUP_ID' => $groupId,
1256 throw new \Exception($e->getMessage(), $e->getCode());
1261 'groupId' => $groupId,
1264 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
1269 self::deleteRelation([
1270 'relationId' => $relation->getId(),
1275 throw new \Exception($e->getMessage(), $e->getCode());
1285 $groupId = (int)(
$fields[
'groupId'] ?? 0);
1290 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
1295 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
1300 $relation = static::getRelation([
1301 '=GROUP_ID' => $groupId,
1307 throw new \Exception($e->getMessage(), $e->getCode());
1312 'groupId' => $groupId,
1315 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
1318 if (!\CSocNetUserToGroup::delete($relation->getId(),
true))
1326 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1333 (
new Pull\
Tag())->getTasksProjects($groupId),
1344 $relationId = (int)(
$fields[
'relationId'] ?? 0);
1346 if ($relationId <= 0)
1348 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_RELATION_ID'));
1353 $relation = static::getRelation([
1354 '=ID' => $relationId,
1359 throw new \Exception($e->getMessage(), $e->getCode());
1362 if (!\CSocNetUserToGroup::delete($relation->getId()))
1370 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1383 $groupId = (int)(
$fields[
'groupId'] ?? 0);
1388 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
1393 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
1398 $relation = static::getRelation([
1399 '=GROUP_ID' => $groupId,
1405 throw new \Exception($e->getMessage(), $e->getCode());
1410 'groupId' => $groupId,
1413 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
1416 if (!\CSocNetUserToGroup::confirmRequestToBeMember(
1419 [ $relation->getId() ]
1428 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1441 $groupId = (int) (
$fields[
'groupId'] ?? 0);
1446 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
1451 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
1456 $relation = static::getRelation([
1457 '=GROUP_ID' => $groupId,
1463 throw new \Exception($e->getMessage(), $e->getCode());
1466 if (!\CSocNetUserToGroup::UserConfirmRequestToBeMember(
$userId, $relation->getId()))
1474 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1487 $groupId = (int) (
$fields[
'groupId'] ?? 0);
1492 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
1497 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
1502 $relation = static::getRelation([
1503 '=GROUP_ID' => $groupId,
1509 throw new \Exception($e->getMessage(), $e->getCode());
1512 if (!\CSocNetUserToGroup::userRejectRequestToBeMember(
$userId, $relation->getId()))
1520 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1533 $groupId = (int)(
$fields[
'groupId'] ?? 0);
1538 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
1543 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_USER_ID'));
1548 $relation = static::getRelation([
1549 '=GROUP_ID' => $groupId,
1555 throw new \Exception($e->getMessage(), $e->getCode());
1560 'groupId' => $groupId,
1563 throw new AccessDeniedException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_NO_PERMS'));
1566 if (!\CSocNetUserToGroup::rejectRequestToBeMember(
1569 [ $relation->getId() ]
1578 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1591 $departmentId = (int)(
$fields[
'departmentId'] ?? 0);
1592 $groupId = (int)(
$fields[
'groupId'] ?? 0);
1596 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_GROUP_ID'));
1599 if ($departmentId <= 0)
1601 throw new ArgumentException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_WRONG_DEPARTMENT_ID'));
1604 if (!ModuleManager::isModuleInstalled(
'intranet'))
1609 $workgroup = Item\Workgroup::getById($groupId);
1615 if (!isset($workgroup->getFields()[
'UF_SG_DEPT']))
1617 throw new \Exception(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
1620 $workgroupFields = $workgroup->getFields();
1621 $currentDepartmentsList = $workgroupFields[
'UF_SG_DEPT'][
'VALUE'];
1624 !is_array($currentDepartmentsList)
1625 || empty($currentDepartmentsList)
1628 throw new \Exception(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED'));
1631 $currentDepartmentsList = array_map(
'intval', array_unique($currentDepartmentsList));
1633 if (!\CSocNetGroup::update(
1636 'NAME' => $workgroupFields[
'NAME'],
1637 'UF_SG_DEPT' => array_diff($currentDepartmentsList, [ $departmentId ]),
1647 $errorMessage = Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_OPERATION_FAILED');
1658 $res = UserToGroupTable::getList([
1660 'select' => [
'ID',
'USER_ID',
'GROUP_ID',
'ROLE',
'INITIATED_BY_TYPE',
'INITIATED_BY_USER_ID',
'AUTO_MEMBER' ],
1665 throw new ObjectNotFoundException(Loc::getMessage(
'SOCIALNETWORK_HELPER_WORKGROUP_ERROR_RELATION_NOT_FOUND'));
1676 return Helper\Workgroup\Access::canCreate(
$params);
1684 $result = \CSocNetUser::isCurrentUserModuleAdmin(
SITE_ID, $checkSession);
1700 static $useProjects =
null;
1701 static $extranetInstalled =
null;
1703 if ($extranetInstalled ===
null)
1705 $extranetInstalled = self::isExtranetInstalled();
1708 $entityOptions = [];
1709 if (!empty(
$params[
'entityOptions']) && is_array(
$params[
'entityOptions']))
1711 $entityOptions =
$params[
'entityOptions'];
1717 if ($useProjects ===
null)
1720 ModuleManager::isModuleInstalled(
'intranet')
1721 && self::checkEntityOption([
'project' ], $entityOptions)
1727 if (self::checkEntityOption([
'!landing',
'!scrum' ], $entityOptions))
1730 'SORT' => $sort += 10,
1731 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_PROJECT'),
1732 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_PROJECT_DESC'),
1736 'SCRUM_PROJECT' =>
'N',
1741 if (self::checkEntityOption([
'scrum',
'!extranet',
'!landing' ], $entityOptions))
1744 'SORT' => $sort += 10,
1745 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_SCRUM'),
1746 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_SCRUM_DESC'),
1750 'SCRUM_PROJECT' =>
'Y',
1756 if (self::checkEntityOption([
'!scrum' ], $entityOptions))
1758 if (self::checkEntityOption([
'!landing',
'!flow'], $entityOptions))
1761 'SORT' => $sort += 10,
1762 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_COLLAB'),
1763 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_COLLAB_DESC'),
1767 'SCRUM_PROJECT' =>
'N',
1771 if (!CollabFeature::isFeatureEnabledInPortalSettings())
1773 $result[
'collab'][
'LIMIT_FEATURE'] = Settings::LIMIT_FEATURES[
'collab'];
1778 'SORT' => $sort += 10,
1779 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_GROUP'),
1780 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_PROJECT_PRESET_GROUP_DESC'),
1784 'SCRUM_PROJECT' =>
'N',
1794 static $useProjects =
null;
1796 $currentExtranetSite = (
1798 && isset(
$params[
'currentExtranetSite'])
1799 &&
$params[
'currentExtranetSite']
1803 !empty(
$params[
'entityOptions'])
1804 && is_array(
$params[
'entityOptions'])
1812 if ($useProjects ===
null)
1815 ModuleManager::isModuleInstalled(
'intranet')
1816 && self::checkEntityOption([
'project' ], $entityOptions)
1820 if (!$currentExtranetSite)
1822 if (self::checkEntityOption([
'open',
'!extranet',
'!landing' ], $entityOptions))
1825 'SORT' => $sort += 10,
1826 'NAME' => ($useProjects ? Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_OPEN') : Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_OPEN')),
1827 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_OPEN_DESC3'),
1834 if (self::checkEntityOption([
'!open',
'!extranet',
'!landing' ], $entityOptions))
1837 'SORT' => $sort += 10,
1838 'NAME' => ($useProjects ? Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED') : Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED')),
1839 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_DESC3'),
1846 if (self::checkEntityOption([
'!open',
'!extranet',
'!landing' ], $entityOptions))
1849 'SORT' => $sort += 10,
1850 'NAME' => ($useProjects ?
1851 Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_SECRET_1')
1852 : Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_SECRET_1')
1854 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_SECRET_DESC3_1'),
1869 foreach ($keysList as
$key)
1872 !empty($entityOptions)
1875 isset($entityOptions[
$key])
1876 && !$entityOptions[
$key]
1880 && isset($entityOptions[
$matches[1]])
1896 static $useProjects =
null;
1897 static $extranetInstalled =
null;
1898 static $landingInstalled =
null;
1900 if ($extranetInstalled ===
null)
1902 $extranetInstalled = self::isExtranetInstalled();
1905 if ($landingInstalled ===
null)
1907 $landingInstalled = ModuleManager::isModuleInstalled(
'landing');
1910 $currentExtranetSite = (
1912 && isset(
$params[
'currentExtranetSite'])
1913 &&
$params[
'currentExtranetSite']
1918 && is_array(
$params[
'entityOptions'])
1919 && !empty(
$params[
'entityOptions'])
1933 if ($useProjects ===
null)
1936 ModuleManager::isModuleInstalled(
'intranet')
1937 && self::checkEntityOption([
'project' ], $entityOptions)
1941 if (!$currentExtranetSite)
1943 if (self::checkEntityOption([
'open',
'!extranet',
'!landing' ], $entityOptions))
1946 'SORT' => $sort += 10,
1947 'NAME' => ($useProjects ? Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_OPEN') : Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_OPEN')),
1948 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_OPEN_DESC'),
1949 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_OPEN_DESC2'),
1952 'PROJECT' => ($useProjects ?
'Y' :
'N' ),
1954 'TILE_CLASS' =>
'social-group-tile-item-cover-open ' . ($useProjects ?
'social-group-tile-item-icon-project-open' :
'social-group-tile-item-icon-group-open'),
1958 if (self::checkEntityOption([
'!open',
'!extranet',
'!landing' ], $entityOptions))
1961 'SORT' => $sort += 10,
1962 'NAME' => ($useProjects ? Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED') : Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED')),
1963 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_DESC'),
1964 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_DESC'),
1967 'PROJECT' => ($useProjects ?
'Y' :
'N' ),
1969 'TILE_CLASS' =>
'social-group-tile-item-cover-close ' . ($useProjects ?
'social-group-tile-item-icon-project-close' :
'social-group-tile-item-icon-group-close'),
1975 && self::checkEntityOption([
'project',
'scrum',
'!extranet',
'!landing' ], $entityOptions)
1979 'SORT' => $sort += 10,
1980 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM'),
1981 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_DESC'),
1982 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_DESC'),
1986 'SCRUM_PROJECT' =>
'Y',
1988 'TILE_CLASS' =>
'social-group-tile-item-cover-scrum social-group-tile-item-icon-project-scrum',
1994 && self::checkEntityOption([
'!open',
'!extranet',
'!landing' ], $entityOptions)
1997 $result[
'project-closed-visible'] = [
1998 'SORT' => $sort += 10,
1999 'NAME' => ($useProjects ? Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_VISIBLE') : Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_VISIBLE')),
2000 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_VISIBLE_DESC'),
2001 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_CLOSED_VISIBLE_DESC'),
2004 'PROJECT' => ($useProjects ?
'Y' :
'N' ),
2013 && self::checkEntityOption([
'extranet',
'!landing' ], $entityOptions)
2016 $result[
'project-external'] = [
2017 'SORT' => $sort += 10,
2018 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_EXTERNAL'),
2019 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_EXTERNAL_DESC'),
2020 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GP_EXTERNAL_DESC'),
2023 'PROJECT' => ($useProjects ?
'Y' :
'N' ),
2025 'TILE_CLASS' =>
'social-group-tile-item-cover-outer social-group-tile-item-icon-project-outer',
2031 && self::checkEntityOption([
'!project',
'landing',
'!extranet' ], $entityOptions)
2035 'SORT' => $sort += 10,
2036 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING2_MSGVER_1'),
2037 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING_DESC2_MSGVER_2'),
2038 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING_DESC2_MSGVER_2'),
2044 'TILE_CLASS' =>
'social-group-tile-item-cover-public social-group-tile-item-icon-group-public',
2053 static $intranetInstalled =
null;
2054 static $extranetInstalled =
null;
2055 static $landingInstalled =
null;
2057 if ($intranetInstalled ===
null)
2059 $intranetInstalled = ModuleManager::isModuleInstalled(
'intranet');
2062 if ($extranetInstalled ===
null)
2064 $extranetInstalled = static::isExtranetInstalled();
2067 if ($landingInstalled ===
null)
2069 $landingInstalled = ModuleManager::isModuleInstalled(
'landing');
2072 $currentExtranetSite = (
2074 && isset(
$params[
'currentExtranetSite'])
2075 &&
$params[
'currentExtranetSite']
2079 if (!empty(
$params[
'category']) && is_array(
$params[
'category']))
2081 $categoryList =
$params[
'category'];
2084 $entityOptions = [];
2085 if (!empty(
$params[
'entityOptions']) && is_array(
$params[
'entityOptions']))
2087 $entityOptions =
$params[
'entityOptions'];
2102 empty($categoryList)
2103 || in_array(
'projects', $categoryList,
true)
2107 if (!$currentExtranetSite)
2109 if (self::checkEntityOption([
'project',
'open',
'!extranet',
'!landing' ], $entityOptions))
2112 'SORT' => $sort += 10,
2113 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_OPEN'),
2114 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_OPEN_DESC'),
2115 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_OPEN_DESC2'),
2119 'SCRUM_PROJECT' =>
'N',
2121 'TILE_CLASS' =>
'social-group-tile-item-cover-open social-group-tile-item-icon-project-open',
2125 if (self::checkEntityOption([
'project',
'!open',
'!extranet',
'!landing' ], $entityOptions))
2128 'SORT' => $sort += 10,
2129 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED'),
2130 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED_DESC'),
2131 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED_DESC'),
2135 'SCRUM_PROJECT' =>
'N',
2137 'TILE_CLASS' =>
'social-group-tile-item-cover-close social-group-tile-item-icon-project-close',
2141 if (self::checkEntityOption([
'project',
'scrum',
'!extranet',
'!landing' ], $entityOptions))
2144 'SORT' => $sort += 10,
2145 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM2'),
2146 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_DESC2'),
2147 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_DESC2'),
2151 'SCRUM_PROJECT' =>
'Y',
2153 'TILE_CLASS' =>
'social-group-tile-item-cover-scrum social-group-tile-item-icon-project-scrum',
2159 && self::checkEntityOption([
'project',
'!open',
'!extranet',
'!landing' ], $entityOptions)
2163 'SORT' => $sort += 10,
2164 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED_VISIBLE'),
2165 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED_VISIBLE_DESC'),
2166 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_CLOSED_VISIBLE_DESC'),
2170 'SCRUM_PROJECT' =>
'N',
2179 && self::checkEntityOption([
'project',
'scrum',
'extranet',
'!landing' ], $entityOptions)
2182 $result[
'project-scrum-extranet'] = [
2183 'SORT' => $sort += 10,
2184 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_EXTERNAL'),
2185 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_EXTERNAL_DESC'),
2186 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_SCRUM_EXTERNAL_DESC'),
2190 'SCRUM_PROJECT' =>
'Y',
2192 'TILE_CLASS' =>
'social-group-tile-item-cover-scrum social-group-tile-item-icon-project-scrum',
2198 && self::checkEntityOption([
'project',
'extranet',
'!landing' ], $entityOptions)
2202 'SORT' => $sort += 10,
2203 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_EXTERNAL'),
2204 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_EXTERNAL_DESC'),
2205 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_PROJECT_EXTERNAL_DESC'),
2209 'SCRUM_PROJECT' =>
'N',
2211 'TILE_CLASS' =>
'social-group-tile-item-cover-outer social-group-tile-item-icon-project-outer',
2217 !$currentExtranetSite
2219 empty($categoryList)
2220 || in_array(
'groups', $categoryList)
2224 if (self::checkEntityOption([
'!project',
'open',
'!extranet',
'!landing' ], $entityOptions))
2227 'SORT' => $sort += 10,
2228 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_OPEN'),
2229 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_OPEN_DESC'),
2230 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_OPEN_DESC2'),
2234 'SCRUM_PROJECT' =>
'N',
2236 'TILE_CLASS' =>
'social-group-tile-item-cover-open social-group-tile-item-icon-group-open',
2240 if (self::checkEntityOption([
'!project',
'!open',
'!extranet',
'!landing' ], $entityOptions))
2243 'SORT' => $sort += 10,
2244 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED'),
2245 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_DESC'),
2246 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_DESC'),
2250 'SCRUM_PROJECT' =>
'N',
2252 'TILE_CLASS' =>
'social-group-tile-item-cover-close social-group-tile-item-icon-group-close',
2257 'SORT' => $sort = $sort + 10,
2258 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_VISIBLE'),
2259 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_VISIBLE_DESC'),
2260 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_CLOSED_VISIBLE_DESC'),
2264 'SCRUM_PROJECT' =>
'N',
2274 && self::checkEntityOption([
'!project',
'extranet',
'!landing' ], $entityOptions)
2278 'SORT' => $sort += 10,
2279 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_EXTERNAL'),
2280 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_EXTERNAL_DESC'),
2281 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_EXTERNAL_DESC'),
2285 'SCRUM_PROJECT' =>
'N',
2287 'TILE_CLASS' =>
'social-group-tile-item-cover-outer social-group-tile-item-icon-group-outer',
2293 && self::checkEntityOption([
'!project',
'landing',
'!extranet' ], $entityOptions)
2297 'SORT' => $sort += 10,
2298 'NAME' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING_MSGVER_2'),
2299 'DESCRIPTION' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING_DESC_MSGVER_2'),
2300 'DESCRIPTION2' => Loc::getMessage(
'SOCIALNETWORK_ITEM_WORKGROUP_TYPE_GROUP_LANDING_DESC_MSGVER_2'),
2304 'SCRUM_PROJECT' =>
'N',
2307 'TILE_CLASS' =>
'social-group-tile-item-cover-public social-group-tile-item-icon-group-public',
2317 ModuleManager::isModuleInstalled(
'extranet')
2318 && Option::get(
'extranet',
'extranet_site') !==
''
2324 return self::getDefaultAvatarTypes();
2330 Item\Workgroup\AvatarType::Folder->value => [
2332 'mobileUrl' =>
'/bitrix/images/socialnetwork/workgroup/folder.png',
2333 'webCssClass' =>
'folder',
2334 'entitySelectorUrl' =>
'/bitrix/images/socialnetwork/workgroup/folder.png',
2336 Item\Workgroup\AvatarType::Checks->value => [
2338 'mobileUrl' =>
'/bitrix/images/socialnetwork/workgroup/checks.png',
2339 'webCssClass' =>
'tasks',
2340 'entitySelectorUrl' =>
'/bitrix/images/socialnetwork/workgroup/checks.png',
2342 Item\Workgroup\AvatarType::Pie->value => [
2344 'mobileUrl' =>
'/bitrix/images/socialnetwork/workgroup/pie.png',
2345 'webCssClass' =>
'chart',
2346 'entitySelectorUrl' =>
'/bitrix/images/socialnetwork/workgroup/pie.png',
2348 Item\Workgroup\AvatarType::Bag->value => [
2350 'mobileUrl' =>
'/bitrix/images/socialnetwork/workgroup/bag.png',
2351 'webCssClass' =>
'briefcase',
2352 'entitySelectorUrl' =>
'/bitrix/images/socialnetwork/workgroup/bag.png',
2354 Item\Workgroup\AvatarType::Members->value => [
2356 'mobileUrl' =>
'/bitrix/images/socialnetwork/workgroup/members.png',
2357 'webCssClass' =>
'group',
2358 'entitySelectorUrl' =>
'/bitrix/images/socialnetwork/workgroup/members.png',
2365 $colors = self::getAvatarColors();
2368 foreach ($colors as $color)
2370 $avatarTypes[
"space_$color"] = [
2372 'mobileUrl' =>
"/bitrix/images/socialnetwork/workgroup/space_$color.png",
2373 'webCssClass' =>
"space_$color",
2374 'entitySelectorUrl' =>
"/bitrix/images/socialnetwork/workgroup/space_$color.png",
2378 return $avatarTypes;
2399 $types = static::getAvatarTypes();
2400 if (empty($types[
$type]))
2405 return $types[
$type][
'webCssClass'];
2411 $types = static::getAvatarTypes();
2412 if (empty($types[
$type]))
2417 return $types[
$type][
'entitySelectorUrl'];
2428 static function(
$val) {
return (
int)
$val; },
2431 static function (
$val) {
return $val > 0; }
2439 static function(
$val) {
return trim((
string)
$val); },
2442 static function (
$val) {
return !empty(
$val); }
2446 $mandatoryFeatures = (
2447 is_array(
$params[
'mandatoryFeatures'])
2450 static function(
$val) {
return trim((
string)
$val); },
2453 static function (
$val) {
return !empty(
$val); }
2457 $currentUserId = (int)(
$params[
'currentUserId'] ??
$USER->getId());
2463 $featuresSettings = \CSocNetAllowed::getAllowedFeatures();
2468 $res = UserToGroupTable::getList([
2471 'USER_ID' => $currentUserId,
2473 'select' => [
'GROUP_ID',
'ROLE',
'INITIATED_BY_TYPE' ],
2476 while ($relationFields =
$res->fetch())
2478 $userRoles[(int)$relationFields[
'GROUP_ID']] = [
2479 'ROLE' => $relationFields[
'ROLE'],
2480 'INITIATED_BY_TYPE' => $relationFields[
'INITIATED_BY_TYPE'],
2484 foreach ($features as $feature)
2487 $filteredIds = array_keys(array_filter($activeFeaturesList,
static function(
$val) {
return $val; }));
2491 || !isset($featuresSettings[$feature])
2498 $minOperationList = $featuresSettings[$feature][
'minoperation'];
2499 if (!is_array($minOperationList))
2501 $minOperationList = [ $minOperationList ];
2505 foreach ($minOperationList as $minOperation)
2507 $operationPermissions = \CSocNetFeaturesPerms::getOperationPerm(
SONET_ENTITY_GROUP, $filteredIds, $feature, $minOperation);
2508 foreach ($operationPermissions as $groupId => $role)
2511 !isset($permissions[$groupId])
2512 || $role > $permissions[$groupId]
2515 $permissions[$groupId] = $role;
2521 foreach ($ids as $id)
2528 if (!isset(
$result[$id][
'FEATURES']))
2530 $result[$id][
'FEATURES'] = [];
2534 in_array($feature, $mandatoryFeatures,
true)
2536 isset($permissions[$id])
2540 isset($userRoles[$id])
2541 && $userRoles[$id][
'ROLE'] <= $permissions[$id]
2547 $result[$id][
'FEATURES'][] = $feature;
2552 foreach ($ids as $id)
2554 $result[$id][
'ROLE'] = ($userRoles[$id][
'ROLE'] ??
'');
2555 $result[$id][
'INITIATED_BY_TYPE'] = ($userRoles[$id][
'INITIATED_BY_TYPE'] ??
'');
2563 if (empty(
$fields[
'SCRUM_MASTER_ID']))
2570 if (empty(
$fields[
'SUBJECT_ID']))
2574 $subjectQueryObject = \CSocNetGroupSubject::getList(
2586 if ($subject = $subjectQueryObject->fetch())
2588 $fields[
'SUBJECT_ID'] = (int)$subject[
'ID'];
2593 public static function pin(
int $groupId,
string $mode =
''): ?bool
2598 || static::getIsPinned($groupId, $mode)
2608 WorkgroupPinTable::add([
2609 'GROUP_ID' => $groupId,
2619 static::sendPinChangedPushEvent($groupId,
$userId,
'pin');
2624 public static function unpin(
int $groupId,
string $mode =
''): ?bool
2629 || !($isPinned = static::getIsPinned($groupId, $mode))
2635 $tableDeleteResult = WorkgroupPinTable::delete($isPinned->get(
'ID'));
2636 if (!$tableDeleteResult->isSuccess())
2646 private static function getIsPinned(
int $groupId,
string $mode): ?
EO_WorkgroupPin
2648 $query = WorkgroupPinTable::query();
2650 ->setSelect([
'ID',
'GROUP_ID',
'USER_ID'])
2651 ->where(
'GROUP_ID', $groupId)
2661 ->whereNull(
'CONTEXT')
2662 ->where(
'CONTEXT',
'')
2667 $query->where(
'CONTEXT', $mode);
2670 return $query->exec()->fetchObject();
2673 private static function sendPinChangedPushEvent(
int $groupId,
int $userId,
string $action): void
2675 PushService::addEvent(
2678 'module_id' =>
'socialnetwork',
2679 'command' =>
'workgroup_pin_changed',
2681 'GROUP_ID' => $groupId,
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
const FEATURE_ENTITY_TYPE_GROUP
const PROJECTS_ACCESS_PERMISSIONS
static isFeatureEnabled(string $featureName, int $groupId=0)
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 isUsersHaveCommonGroups(int $userId, int $targetUserId, bool $includeInvited=false)
static exclude(array $fields=[])
static getPresets($params=[])
static getTypeCodeByParams($params)
static isProjectAccessFeatureEnabled()
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()
static isIntranet(int $userId)
static addInfoToChat($params=[])
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
if(!is_null($config))($config as $configItem)(! $configItem->isVisible()) $code
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']