LivefeedIndexComment::execute

  1. Bitrix24 API (v. 23.675.0)
  2. blog
  3. LivefeedIndexComment
  4. execute
  • Модуль: blog
  • Путь к файлу: ~/bitrix/modules/blog/lib/update/livefeedindexcomment.php
  • Класс: BitrixBlogUpdateLivefeedIndexComment
  • Вызов: LivefeedIndexComment::execute
public function execute(array &$result)
{
	if (!(
		Loader::includeModule("blog")
		&& Loader::includeModule("socialnetwork")
		&& Option::get('blog', 'needLivefeedIndexComment', 'Y') == 'Y'
	))
	{
		return false;
	}

	$return = false;

	$params = Option::get("blog", "livefeedindexcomment", "");
	$params = ($params !== "" ? @unserialize($params, ['allowed_classes' => false]) : array());
	$params = (is_array($params) ? $params : array());
	if (empty($params))
	{
		$params = array(
			"lastId" => 0,
			"number" => 0,
			"count" => LogCommentTable::getCount(
				array(
					'@EVENT_ID' => IntegrationSocialnetworkLogComment::getEventIdList(),
					'!SOURCE_ID' => false
				)
			)
		);
	}

	if ($params["count"] > 0)
	{
		$result["title"] = Loc::getMessage("FUPD_LF_BLOG_COMMENT_INDEX_TITLE");
		$result["progress"] = 1;
		$result["steps"] = "";
		$result["count"] = $params["count"];

		$res = LogCommentTable::getList(array(
			'order' => array('ID' => 'ASC'),
			'filter' => array(
				'>ID' => $params["lastId"],
				'@EVENT_ID' => IntegrationSocialnetworkLogComment::getEventIdList(),
				'!SOURCE_ID' => false
			),
			'select' => array('ID', 'EVENT_ID', 'SOURCE_ID'),
			'offset' => 0,
			'limit' => 100
		));

		$found = false;
		while ($record = $res->fetch())
		{
			LogIndex::setIndex(array(
				'itemType' => LogIndexTable::ITEM_TYPE_COMMENT,
				'itemId' => $record['ID'],
				'fields' => $record
			));

			$params["lastId"] = $record['ID'];
			$params["number"]++;
			$found = true;
		}

		if ($found)
		{
			Option::set("blog", "livefeedindexcomment", serialize($params));
			$return = true;
		}

		$result["progress"] = intval($params["number"] * 100/ $params["count"]);
		$result["steps"] = $params["number"];

		if ($found === false)
		{
			Option::delete("blog", array("name" => "livefeedindexcomment"));
			Option::set('blog', 'needLivefeedIndexComment', 'N');
		}
	}
	return $return;
}

Добавить комментарий