19declare(strict_types=1);
31 return "PollImagesMigration";
52 $this->db = $environment->getResource(
Environment::RESOURCE_DATABASE);
58 $res = $this->db->query(
"SELECT id, image FROM il_poll WHERE migrated = 0 LIMIT 1");
59 $row =
$res->fetchAssoc();
60 $image = $row[
"image"] ??
"";
68 $file_path = $this->getImageFullPath($image,
$id);
69 $thumbnail_path = $this->getThumbnailImagePath($image,
$id);
70 $org_path = $this->getOrgImagePath($image,
$id);
71 $stakeholder = (
new ilPollImageRepositoryStakeholder())->withUserId(6);
73 $rid = $irss_helper->movePathToStorage($file_path, 6,
null,
null,
false);
74 $rid_thumbnail = $irss_helper->movePathToStorage($thumbnail_path, 6,
null,
null,
false);
75 $org_thumbnail = $irss_helper->movePathToStorage($org_path, 6,
null,
null,
false);
77 $res_existing = $this->db->query(
"SELECT * FROM il_poll_image WHERE object_id = " . $this->db->quote(
$id,
ilDBConstants::T_INTEGER));
78 $row_existing = $res_existing->fetchAssoc();
79 if (is_null($row_existing)) {
80 $this->db->manipulate(
81 "INSERT INTO il_poll_image (object_id, rid) VALUES "
87 if (!is_null($row_existing)) {
88 $irss_helper->getResourceBuilder()->remove($irss_helper->getResourceBuilder()->get($rid), $stakeholder);
90 $irss_helper->getResourceBuilder()->remove($irss_helper->getResourceBuilder()->get($rid_thumbnail), $stakeholder);
91 $irss_helper->getResourceBuilder()->remove($irss_helper->getResourceBuilder()->get($org_thumbnail), $stakeholder);
98 $res = $this->db->query(
99 'SELECT COUNT(*) AS count FROM il_poll WHERE migrated = 0'
101 $row = $this->db->fetchAssoc(
$res);
102 return (
int) $row[
'count'];
107 return $this->getLegacyPath(
$id) .
'/' . $img;
112 return $this->getLegacyPath(
$id) .
"/thb_" . $img;
117 return $this->getLegacyPath(
$id) .
"/org_" . $img;
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
static createPathFromId(int $a_container_id, string $a_name)
getImageFullPath(string $img, int $id)
getRemainingAmountOfSteps()
Count up how many "things" need to be migrated.
step(Environment $environment)
Run one step of the migration.
getPreconditions(Environment $environment)
Objectives the migration depend on.
getDefaultAmountOfStepsPerRun()
Tell the default amount of steps to be executed for one run of the migration.
getThumbnailImagePath(string $img, int $id)
getOrgImagePath(string $img, int $id)
prepare(Environment $environment)
Prepare the migration by means of some environment.
Class ilResourceStorageMigrationHelper.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
An environment holds resources to be used in the setup process.
A migration is a potentially long lasting operation that can be broken into discrete steps.