• Модуль: socialservices
  • Путь к файлу: ~/bitrix/modules/socialservices/lib/contact.php
  • Класс: BitrixSocialservicesContactTable
  • Вызов: ContactTable::notifyJoinFinish
static function notifyJoinFinish($userId)
{
	$network = new Network();
	if(
		$network->isOptionEnabled()
		&& count(static::$notifyStack) > 0
		&& MainLoader::includeModule('im')
	)
	{
		$attach = new CIMMessageParamAttach(null, CIMMessageParamAttach::NORMAL);

		$count = 0;
		foreach(static::$notifyStack as $contactInfo)
		{
			if(++$count > static::NOTIFY_CONTACT_COUNT)
			{
				$attach->AddHtml(''.Loc::getMessage("SS_JOIN_NOTIFY_MORE", array("#NUM#" => count(static::$notifyStack)-$count+1)).'');
				break;
			}
			else
			{
				$attachParams = array(
					"NAME" => CUser::FormatName(CSite::GetNameFormat(), array(
						"NAME" => $contactInfo["CONTACT_NAME"],
						"LAST_NAME" => $contactInfo["CONTACT_LAST_NAME"]
					), false, false),
				);
				if($contactInfo["CONTACT_PHOTO"])
				{
					$attachParams["AVATAR"] = $contactInfo["CONTACT_PHOTO"];
				}
				$attachParams["NETWORK_ID"] = static::getConnectId($contactInfo["CONNECT"][0]);

				$attach->AddUser($attachParams);
			}
		}

		$messageFields = array(
			"TO_USER_ID" => $userId,
			"FROM_USER_ID" => 0,
			"NOTIFY_TYPE" => IM_NOTIFY_SYSTEM,
			"NOTIFY_MODULE" => "socialservices",
			"NOTIFY_EVENT" => "multiple_contacts",
			"NOTIFY_MESSAGE" => Loc::getMessage("SS_JOIN_NOTIFY_MULTIPLE"),
			"NOTIFY_MESSAGE_OUT" => IM_MAIL_SKIP,
			"ATTACH" => array($attach),
		);

		CIMNotify::Add($messageFields);

		static::$notifyStack = array();
	}
}