Exemplo n.º 1
0
 public static function OnSocNetUserToGroupUpdate($ID, $arFields)
 {
     if (intval($ID) <= 0) {
         return false;
     }
     if (!CModule::IncludeModule('socialnetwork')) {
         return false;
     }
     if (!CModule::IncludeModule('webdav')) {
         return false;
     }
     if (isset($arFields['ROLE']) && ($arFields['ROLE'] == SONET_ROLES_USER || $arFields['ROLE'] == SONET_ROLES_MODERATOR || $arFields['ROLE'] == SONET_ROLES_OWNER)) {
         if (!isset($arFields['USER_ID'])) {
             $query = CSocNetUserToGroup::GetList(array(), array('ID' => $ID), false, false, array('USER_ID', 'GROUP_ID'));
             if ($query) {
                 $row = $query->fetch();
                 if ($row) {
                     $userId = $row['USER_ID'];
                     $groupId = $row['GROUP_ID'];
                 }
             }
         }
         if (!empty($userId) && !empty($groupId) && CSocNetFeatures::IsActiveFeature(SONET_ENTITY_GROUP, $groupId, 'files')) {
             $dispatcher = new \Bitrix\Webdav\InviteDispatcher();
             $attachObjectType = CWebDavSymlinkHelper::ENTITY_TYPE_GROUP;
             $attachObjectId = (int) $groupId;
             $inviteComponentParams = array('attachObject' => array('id' => $attachObjectId, 'type' => $attachObjectType), 'attachToUserId' => $userId, 'inviteFromUserId' => $userId, 'canEdit' => true);
             $response = CWebDavTools::allowAutoconnectShareGroupFolder() ? $dispatcher->processActionConnect($inviteComponentParams) : $dispatcher->processActionInvite($inviteComponentParams);
             if ($response['status'] == $dispatcher::STATUS_SUCCESS) {
             }
         }
     }
     CIBlockWebdavSocnet::ClearTagCache('wd_socnet');
 }
Exemplo n.º 2
0
 public static function sendNotify(array $folderInvite)
 {
     $serverName = (CMain::IsHTTPS() ? "https" : "http") . "://" . (defined("SITE_SERVER_NAME") && strlen(SITE_SERVER_NAME) > 0 ? SITE_SERVER_NAME : COption::GetOptionString("main", "server_name", ""));
     if (empty($folderInvite['IS_DELETED']) && !empty($folderInvite['IS_APPROVED']) && $folderInvite['USER_ID'] != $folderInvite['INVITE_USER_ID'] && \Bitrix\Main\Loader::includeModule('im')) {
         $sectionToShare = CIBlockSection::getList(array(), array('ID' => $folderInvite['SECTION_ID'], 'IBLOCK_ID' => $folderInvite['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'), false, array('NAME'))->fetch();
         if (empty($sectionToShare['NAME'])) {
             return;
         }
         $notifyFields = array();
         $notifyFields['NOTIFY_MODULE'] = 'webdav';
         $notifyFields['NOTIFY_EVENT'] = "invite";
         $notifyFields['NOTIFY_TYPE'] = IM_NOTIFY_FROM;
         $notifyFields['FROM_USER_ID'] = $folderInvite['USER_ID'];
         $notifyFields['TO_USER_ID'] = $folderInvite['INVITE_USER_ID'];
         $notifyFields['NOTIFY_TAG'] = \Bitrix\Webdav\FolderInviteTable::getNotifyTag($folderInvite);
         $notifyFields['NOTIFY_SUB_TAG'] = "WEBDAV|INVITE|{$folderInvite['ID']}";
         $uriShow = \CComponentEngine::makePathFromTemplate(CWebDavSymlinkHelper::getPathPattern('user', '/company/personal/user/#user_id#/'), array('user_id' => $folderInvite['INVITE_USER_ID'])) . 'files/lib/?result=sec' . $folderInvite['LINK_SECTION_ID'];
         $uriDisconnect = \CComponentEngine::makePathFromTemplate(CWebDavSymlinkHelper::getPathPattern('user', '/company/personal/user/#user_id#/'), array('user_id' => $folderInvite['INVITE_USER_ID'])) . 'files/lib/?result=sec' . $folderInvite['LINK_SECTION_ID'] . '#disconnect';
         $notifyFields['NOTIFY_MESSAGE'] = GetMessage('WD_SYMLINK_INVITE_TEXT_APPROVE_N1', array('#FOLDERNAME#' => '<a href="' . $uriShow . '">' . $sectionToShare['NAME'] . '</a>', '#DISCONNECT_LINK#' => '<a href="' . $uriDisconnect . '">' . GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_LINK') . '</a>', '#INVITETEXT#' => $folderInvite['DESCRIPTION'] ?: ''));
         $notifyFields['NOTIFY_MESSAGE_OUT'] = GetMessage('WD_SYMLINK_INVITE_TEXT_APPROVE_N1', array('#FOLDERNAME#' => $sectionToShare['NAME'] . " ({$uriShow})", '#DISCONNECT_LINK#' => "\n\n" . GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_LINK') . ': ' . $serverName . $uriDisconnect, '#INVITETEXT#' => $folderInvite['DESCRIPTION'] ?: ''));
         \CIMNotify::Add($notifyFields);
     } elseif (empty($folderInvite['IS_DELETED']) && $folderInvite['USER_ID'] == $folderInvite['INVITE_USER_ID'] && \Bitrix\Main\Loader::includeModule('im')) {
         $sectionToShare = CIBlockSection::getList(array(), array('ID' => $folderInvite['SECTION_ID'], 'IBLOCK_ID' => $folderInvite['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'), false, array('NAME', 'SOCNET_GROUP_ID'))->fetch();
         if (empty($sectionToShare['NAME']) || empty($sectionToShare['SOCNET_GROUP_ID'])) {
             return;
         }
         if (\Bitrix\Main\Loader::includeModule('socialnetwork')) {
             $group = CSocNetGroup::GetList(array(), array('ID' => $sectionToShare['SOCNET_GROUP_ID']), false, false, array('NAME'))->fetch();
         }
         $notifyFields = array();
         $notifyFields['NOTIFY_MODULE'] = 'webdav';
         $notifyFields['NOTIFY_EVENT'] = "invite";
         $notifyFields['NOTIFY_TYPE'] = IM_NOTIFY_FROM;
         $notifyFields['FROM_USER_ID'] = $folderInvite['USER_ID'];
         $notifyFields['TO_USER_ID'] = $folderInvite['INVITE_USER_ID'];
         $notifyFields['NOTIFY_TAG'] = \Bitrix\Webdav\FolderInviteTable::getNotifyTag($folderInvite);
         $notifyFields['NOTIFY_SUB_TAG'] = "WEBDAV|INVITE|{$folderInvite['ID']}";
         $uriShow = \CComponentEngine::makePathFromTemplate(CWebDavSymlinkHelper::getPathPattern('group', '/company/personal/user/#user_id#/'), array('user_id' => $folderInvite['INVITE_USER_ID'])) . 'files/lib/?result=sec' . $folderInvite['LINK_SECTION_ID'];
         $uriDisconnect = \CComponentEngine::makePathFromTemplate(CWebDavSymlinkHelper::getPathPattern('user', '/company/personal/user/#user_id#/'), array('user_id' => $folderInvite['INVITE_USER_ID'])) . 'files/lib/?result=sec' . $folderInvite['LINK_SECTION_ID'] . '#disconnect';
         if (\CWebDavTools::allowAutoconnectShareGroupFolder()) {
             $notifyFields['NOTIFY_MESSAGE'] = GetMessage('WD_SYMLINK_INVITE_GROUP_TEXT_APPROVE_N1', array('#FOLDERNAME#' => $sectionToShare['NAME'], '#INVITETEXT#' => $folderInvite['DESCRIPTION'] ?: '', '#GROUPNAME#' => '<a href="' . $uriShow . '">' . $group['NAME'] . '</a>', '#DISCONNECT_LINK#' => '<a href="' . $uriDisconnect . '">' . GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_LINK') . '</a>'));
             $notifyFields['NOTIFY_MESSAGE_OUT'] = GetMessage('WD_SYMLINK_INVITE_GROUP_TEXT_APPROVE_N1', array('#FOLDERNAME#' => $sectionToShare['NAME'], '#INVITETEXT#' => $folderInvite['DESCRIPTION'] ?: '', '#GROUPNAME#' => $group['NAME'], '#DISCONNECT_LINK#' => "\n\n" . GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_LINK') . ': ' . $serverName . $uriDisconnect));
         } elseif (empty($folderInvite['IS_APPROVED'])) {
             $notifyFields['NOTIFY_TYPE'] = IM_NOTIFY_CONFIRM;
             $notifyFields['NOTIFY_BUTTONS'] = array(array('TITLE' => GetMessage('WD_SYMLINK_INVITE_APPROVE_Y'), 'VALUE' => 'Y', 'TYPE' => 'accept'), array('TITLE' => GetMessage('WD_SYMLINK_INVITE_APPROVE_N'), 'VALUE' => 'N', 'TYPE' => 'cancel'));
             $notifyFields['MESSAGE'] = GetMessage('WD_SYMLINK_INVITE_GROUP_TEXT_APPROVE_CONFIRM_N1', array('#FOLDERNAME#' => $sectionToShare['NAME'], '#GROUPNAME#' => $group['NAME']));
         }
         \CIMNotify::Add($notifyFields);
     } elseif (!empty($folderInvite['IS_DELETED']) && \Bitrix\Main\Loader::includeModule('im')) {
         $sectionToShare = CIBlockSection::getList(array(), array('ID' => $folderInvite['SECTION_ID'], 'IBLOCK_ID' => $folderInvite['IBLOCK_ID'], 'CHECK_PERMISSIONS' => 'N'), false, array('NAME'))->fetch();
         if (empty($sectionToShare['NAME'])) {
             return;
         }
         $inviteUser = \CUser::getById($folderInvite['INVITE_USER_ID']);
         if ($inviteUser) {
             $inviteUser = $inviteUser->fetch();
         }
         $notifyFields = array();
         $notifyFields['NOTIFY_MODULE'] = 'webdav';
         $notifyFields['NOTIFY_EVENT'] = "invite";
         $notifyFields['NOTIFY_TYPE'] = IM_NOTIFY_FROM;
         $notifyFields['FROM_USER_ID'] = $folderInvite['INVITE_USER_ID'];
         $notifyFields['TO_USER_ID'] = $folderInvite['USER_ID'];
         $notifyFields['NOTIFY_TAG'] = \Bitrix\Webdav\FolderInviteTable::getNotifyTag($folderInvite);
         $notifyFields['NOTIFY_SUB_TAG'] = "WEBDAV|INVITE|{$folderInvite['ID']}";
         if (CWebDavTools::getUserGender($inviteUser['PERSONAL_GENDER']) == 'F') {
             $notifyFields['MESSAGE'] = GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_F', array('#FOLDERNAME#' => $sectionToShare['NAME'], '#USERNAME#' => CWebDavTools::getUserName($inviteUser)));
         } else {
             $notifyFields['MESSAGE'] = GetMessage('WD_SYMLINK_INVITE_TEXT_DISCONNECT_M', array('#FOLDERNAME#' => $sectionToShare['NAME'], '#USERNAME#' => CWebDavTools::getUserName($inviteUser)));
         }
         \CIMNotify::Add($notifyFields);
     }
 }