• Модуль: socialservices
  • Путь к файлу: ~/bitrix/modules/socialservices/lib/contact.php
  • Класс: BitrixSocialservicesContactTable
  • Вызов: ContactTable::notifyJoin
static function notifyJoin($contactId, array $contactInfo = null)
{
	$network = new Network();
	if($network->isOptionEnabled() && MainLoader::includeModule('im'))
	{
		if($contactInfo === null)
		{
			$dbRes = static::getByPrimary($contactId);
			$contactInfo = $dbRes->fetch();
		}

		if(!$contactInfo)
		{
			return false;
		}

		if(!isset($contactInfo["CONNECT"]))
		{
			$contactInfo["CONNECT"] = array();
			$dbRes = ContactConnectTable::getList(array(
				"order" => array("LAST_AUTHORIZE" => "ASC"),
				"filter" => array(
					"=CONTACT_ID" => $contactInfo["ID"],
				),
				"limit" => 1,
				"select" => array(
					"CONTACT_PROFILE_ID", "CONNECT_TYPE"
				)
			));
			while($connect = $dbRes->fetch())
			{
				$contactInfo["CONNECT"][] = $connect;
			}
		}

		if(count($contactInfo["CONNECT"]) > 0)
		{
			if(isset($contactInfo["CONTACT_PHOTO_RESIZED"]))
			{
				$contactInfo["CONTACT_PHOTO"] = $contactInfo["CONTACT_PHOTO_RESIZED"];
			}

			if($contactInfo["NOTIFY"] == ContactTable::NOTIFY)
			{
				$attach = new CIMMessageParamAttach(null, CIMMessageParamAttach::NORMAL);

				$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" => $contactInfo["USER_ID"],
					"FROM_USER_ID" => 0,
					"NOTIFY_TYPE" => IM_NOTIFY_SYSTEM,
					"NOTIFY_MODULE" => "socialservices",
					"NOTIFY_EVENT" => "contacts",
					"NOTIFY_MESSAGE" => Loc::getMessage("SS_JOIN_NOTIFY"),
					"NOTIFY_MESSAGE_OUT" => IM_MAIL_SKIP,
					"ATTACH" => array($attach),
				);

				return CIMNotify::Add($messageFields);
			}
			else
			{
				static::$notifyStack[] = $contactInfo;
			}
		}
	}

	return false;
}