74 if (!is_array($params))
79 $groupId = (isset($params[
'groupId']) ? intval($params[
'groupId']) : 0);
80 $newRole = (isset($params[
'role']) ? $params[
'role'] :
false);
82 $application = \Bitrix\Main\Application::getInstance();
83 $connection = $application->getConnection();
93 if (!Loader::includeModule(
'socialnetwork'))
100 $prevValue = \Bitrix\Blog\Item\PostSocnetRights::get($groupId);
101 if ($prevValue != $newRole)
103 $sql =
"DELETE FROM ".self::getTableName().
" WHERE ENTITY_TYPE = 'SG' AND ENTITY_ID = ".$groupId;
106 $connection->query($sql);
115 $rightsList = \CBlogPost::getFullGroupRoleSet($newRole,
"SG".$groupId.
"_");
116 $rightsList[] =
'SG'.$groupId;
117 $rightsList = array_unique($rightsList);
119 foreach($rightsList as $right)
126 $sql =
"INSERT INTO ".self::getTableName().
" (POST_ID, ENTITY_TYPE, ENTITY_ID, ENTITY) ".
127 "SELECT SL.SOURCE_ID, 'SG', ".$groupId.
", '".$right.
"' ".
128 "FROM ".LogTable::getTableName().
" SL ".
129 "INNER JOIN ".LogRightTable::getTableName().
" SLR ON SLR.LOG_ID = SL.ID AND SLR.GROUP_CODE = 'SG".$groupId.
"' ".
130 "WHERE SL.EVENT_ID IN ('".implode(
"', '", \
Bitrix\Blog\Integration\Socialnetwork\Log::getEventIdList()).
"')";
134 $connection->query($sql);
144 if ($connection->getType() ===
'pgsql')
146 $sql =
"DELETE FROM ".LogRightTable::getTableName().
" ".
148 " SELECT ".LogTable::getTableName().
".ID".
149 " FROM ".LogTable::getTableName().
150 " WHERE ".LogTable::getTableName().
".EVENT_ID IN ('".implode(
"', '", \
Bitrix\Blog\Integration\Socialnetwork\Log::getEventIdList()).
"')".
151 " AND ".LogRightTable::getTableName().
".GROUP_CODE LIKE 'SG".$groupId.
"%'".
156 $sql =
"DELETE ".LogRightTable::getTableName().
" ".
157 "FROM ".LogRightTable::getTableName().
" ".
158 "INNER JOIN ".LogTable::getTableName().
" ON ".LogTable::getTableName().
".ID = ".
LogRightTable::getTableName().
".LOG_ID AND ".LogTable::getTableName().
".EVENT_ID IN ('".implode(
"', '", \
Bitrix\Blog\Integration\Socialnetwork\Log::getEventIdList()).
"') ".
159 "WHERE GROUP_CODE LIKE 'SG".$groupId.
"%'";
164 $connection->query($sql);
174 if ($connection->getType() ===
'pgsql')
176 $sql =
"DELETE FROM ".LogRightTable::getTableName().
" ".
178 " SELECT ".LogTable::getTableName().
".ID".
179 " FROM ".LogTable::getTableName().
180 " WHERE ".LogTable::getTableName().
".EVENT_ID IN ('".implode(
"', '", \
Bitrix\Blog\Integration\Socialnetwork\Log::getEventIdList()).
"')".
181 " AND ".LogRightTable::getTableName().
".GROUP_CODE LIKE 'OSG".$groupId.
"%'".
186 $sql =
"DELETE ".LogRightTable::getTableName().
" ".
187 "FROM ".LogRightTable::getTableName().
" ".
188 "INNER JOIN ".LogTable::getTableName().
" ON ".LogTable::getTableName().
".ID = ".
LogRightTable::getTableName().
".LOG_ID AND ".LogTable::getTableName().
".EVENT_ID IN ('".implode(
"', '", \
Bitrix\Blog\Integration\Socialnetwork\Log::getEventIdList()).
"') ".
189 "WHERE GROUP_CODE LIKE 'OSG".$groupId.
"%'";
194 $connection->query($sql);
204 $sql =
"INSERT INTO ".LogRightTable::getTableName().
" (LOG_ID, GROUP_CODE, LOG_UPDATE) ".
205 "SELECT SL.ID, BSR.ENTITY, SL.LOG_UPDATE ".
206 "FROM ".LogTable::getTableName().
" SL ".
207 "INNER JOIN ".self::getTableName().
" BSR ON BSR.POST_ID = SL.SOURCE_ID AND (BSR.ENTITY LIKE 'SG".$groupId.
"%' OR BSR.ENTITY LIKE 'OSG".$groupId.
"%') ".
208 "WHERE SL.EVENT_ID IN ('".implode(
"', '", \
Bitrix\Blog\Integration\Socialnetwork\Log::getEventIdList()).
"')";
212 $connection->query($sql);
220 BXClearCache(
true,
"/blog/getsocnetperms");