1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
subscription.php
См. документацию.
1<?php
2
9namespace Bitrix\Socialnetwork\Item;
10
11use Bitrix\Main\Error;
12use Bitrix\Main\Loader;
13use Bitrix\Main\Localization\Loc;
14use Bitrix\Main\SystemException;
15use Exception;
16
17Loc::loadMessages(__FILE__);
18
20{
21 public const AVAILABLE_VALUES = [
22 'Y', 'N'
23 ];
24
25 public static function onContentViewed(array $params)
26 {
27 if (
28 !isset($params['userId'], $params['logId'])
29 || !is_array($params)
30 || (int)$params['userId'] <= 0
31 || (int)$params['logId'] <= 0
32 || !Loader::includeModule('im')
33 )
34 {
35 return;
36 }
37
38 $CIMNotify = new \CIMNotify();
39 $CIMNotify->markNotifyReadBySubTag(array("SONET|EVENT|".(int)$params['logId']."|".(int)$params['userId']));
40 }
41
48 public static function set(array $params = [])
49 {
50 global $USER;
51
52 $groupId = (int)($params['GROUP_ID'] ?? 0);
53 $userId = (int)($params['USER_ID'] ?? $USER->getId());
54 $value = (isset($params['VALUE']) && in_array($params['VALUE'], [ 'Y', 'N' ]) ? $params['VALUE'] : false);
55
56 if (
57 $groupId <= 0
58 || $userId <= 0
59 || !$value
60 )
61 {
62 throw new SystemException(Loc::getMessage('SOCIALNETWORK_ITEM_SUBSCRIPTION_ERROR_NO_DATA'));
63 }
64
65 if (!(\CSocNetGroup::getById($groupId, true)))
66 {
67 throw new SystemException(Loc::getMessage('SOCIALNETWORK_ITEM_SUBSCRIPTION_ERROR_NO_ACCESS'));
68 }
69
70 $userRole = \CSocNetUserToGroup::getUserRole($userId, $groupId);
71 if (!in_array($userRole, \Bitrix\Socialnetwork\UserToGroupTable::getRolesMember()))
72 {
73 throw new SystemException(Loc::getMessage('SOCIALNETWORK_ITEM_SUBSCRIPTION_ERROR_NO_ACCESS'));
74 }
75
76 if (!\CSocNetSubscription::set($userId, 'SG' . $groupId, $value))
77 {
78 throw new SystemException(Loc::getMessage('SOCIALNETWORK_ITEM_SUBSCRIPTION_ERROR_FAILED'));
79 }
80
81 $res = \CSocNetSubscription::getList(
82 [],
83 [
84 'USER_ID' => $userId,
85 'CODE' => 'SG' . $groupId,
86 ]
87 );
88
89 return $res->fetch();
90 }
91}
if(!is_object($USER)||! $USER->IsAuthorized()) $userId
Определения check_mail.php:18
static onContentViewed(array $params)
Определения subscription.php:25
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
global $USER
Определения csv_new_run.php:40
if($inWords) echo htmlspecialcharsbx(Number2Word_Rus(roundEx($totalVatSum $params['CURRENCY']
Определения template.php:799