• Модуль: socialnetwork
  • Путь к файлу: ~/bitrix/modules/socialnetwork/classes/general/group_subject.php
  • Класс: CAllSocNetGroupSubject
  • Вызов: CAllSocNetGroupSubject::Delete
static function Delete($ID)
{
	global $DB, $CACHE_MANAGER, $APPLICATION;

	if (!CSocNetGroup::__ValidateID($ID))
		return false;

	$ID = intval($ID);

	$bCanDelete = true;
	$dbResult = CSocNetGroup::GetList(
		array(),
		array("SUBJECT_ID" => $ID)
	);
	if ($arResult = $dbResult->Fetch())
		$bCanDelete = false;

	if (!$bCanDelete)
	{
		$APPLICATION->ThrowException(GetMessage("SONET_GS_NOT_EMPTY_SUBJECT"), "NOT_EMPTY_SUBJECT");
		return false;
	}

	$events = GetModuleEvents("socialnetwork", "OnSocNetGroupSubjectDelete");
	while ($arEvent = $events->Fetch())
	{
		ExecuteModuleEventEx($arEvent, array($ID));
	}

	$bSuccess = $DB->Query("DELETE FROM b_sonet_group_subject_site WHERE SUBJECT_ID = ".$ID."", true);

	if ($bSuccess)
		$bSuccess = $DB->Query("DELETE FROM b_sonet_group_subject WHERE ID = ".$ID."", true);

	if (CACHED_b_sonet_group_subjects != false)
		$CACHE_MANAGER->CleanDir("b_sonet_group_subjects");

	return $bSuccess;
}