• Модуль: blog
  • Путь к файлу: ~/bitrix/modules/blog/lib/copy/integration/groupstepper.php
  • Класс: BitrixBlogCopyIntegrationGroupStepper
  • Вызов: GroupStepper::execute
public function execute(array &$option)
{
	if (!Loader::includeModule(self::$moduleId))
	{
		return false;
	}

	try
	{
		$queue = $this->getQueue();
		$this->setQueue($queue);

		$queueOption = $this->getQueueOption();
		if (empty($queueOption))
		{
			$this->deleteQueueOption();
			return !$this->isQueueEmpty();
		}

		$executiveUserId = ($queueOption["executiveUserId"] ?: 0);
		$groupId = ($queueOption["groupId"] ?: 0);
		$copiedGroupId = ($queueOption["copiedGroupId"] ?: 0);
		$errorOffset = ($queueOption["errorOffset"] ?: 0);

		$limit = 10;
		$offset = $this->getOffset($copiedGroupId) + $errorOffset;

		$blogPostIds = $this->getBlogPostIdsByGroupId($groupId);
		$count = count($blogPostIds);
		$blogPostIds = array_slice($blogPostIds, $offset, $limit);
		$features = ($queueOption["features"] ?: []);

		if ($blogPostIds)
		{
			$option["count"] = $count;

			$copyManager = new BlogPostManager($executiveUserId, $blogPostIds);
			$copyManager->setChangedRights([
				"SG" => [$groupId => $copiedGroupId]
			]);

			$featuresToBlogPost = [];
			if (in_array("comments", $features))
			{
				$featuresToBlogPost[] = "comments";
			}
			if (in_array("voteResult", $features))
			{
				$featuresToBlogPost[] = "voteResult";
			}

			$copyManager->setFeatures($featuresToBlogPost);

			$result = $copyManager->startCopy();
			if (!$result->isSuccess())
			{
				$queueOption["errorOffset"] += $this->getErrorOffset($copyManager);
				$this->saveQueueOption($queueOption);
			}

			$option["steps"] = $offset;

			return true;
		}
		else
		{
			$this->deleteQueueOption();
			return !$this->isQueueEmpty();
		}
	}
	catch (Exception $exception)
	{
		$this->writeToLog($exception);
		$this->deleteQueueOption();
		return false;
	}
}