diff --git a/assets/css/app.scss b/assets/css/app.scss
index 97dbd0904f..b432b2687b 100644
--- a/assets/css/app.scss
+++ b/assets/css/app.scss
@@ -132,7 +132,17 @@
.progress {
@apply rounded-sm ring-1 text-center min-h-full ml-12 mr-4;
}
- .progress .progress-bar {
+
+ .log-container {
+ height: 300px;
+ overflow-y: scroll;
+ background-color: #000;
+ padding: 10px;
+ }
+
+ .terminal {
+ color: #00ff00; /* Green */
+ font-family: monospace;
}
// Pager
diff --git a/assets/vue/components/installer/Step1.vue b/assets/vue/components/installer/Step1.vue
index 571bede5ad..0fe8e8d32a 100644
--- a/assets/vue/components/installer/Step1.vue
+++ b/assets/vue/components/installer/Step1.vue
@@ -42,20 +42,39 @@
-
diff --git a/assets/vue/components/installer/Step6.vue b/assets/vue/components/installer/Step6.vue
index 6e7defc3ed..11b7da674c 100644
--- a/assets/vue/components/installer/Step6.vue
+++ b/assets/vue/components/installer/Step6.vue
@@ -238,29 +238,21 @@
diff --git a/public/main/inc/lib/course.lib.php b/public/main/inc/lib/course.lib.php
index 10029a6021..b7baf480b2 100644
--- a/public/main/inc/lib/course.lib.php
+++ b/public/main/inc/lib/course.lib.php
@@ -3445,7 +3445,7 @@ class CourseManager
);
if (!empty($result)) {
- if (1 == $result['value']) {
+ if (1 == $result['field_value']) {
return true;
}
}
diff --git a/public/main/install/get_migration_status.php b/public/main/install/get_migration_status.php
new file mode 100644
index 0000000000..c1f71333ab
--- /dev/null
+++ b/public/main/install/get_migration_status.php
@@ -0,0 +1,37 @@
+ '' . $logContent . '
',
+ 'progress_percentage' => $result['progress_percentage'],
+];
+
+// Send the response as JSON
+header('Content-Type: application/json');
+echo json_encode($response);
diff --git a/public/main/install/index.php b/public/main/install/index.php
index 6b4737ac3f..f5b60d7350 100644
--- a/public/main/install/index.php
+++ b/public/main/install/index.php
@@ -134,6 +134,7 @@ $upgradeFromVersion = [
'1.11.11',
'1.11.12',
'1.11.14',
+ '1.11.16',
];
$my_old_version = '';
@@ -165,6 +166,8 @@ if (!empty($_POST['updatePath'])) {
$proposedUpdatePath = $_POST['updatePath'];
}
+$checkMigrationStatus = checkMigrationStatus();
+$isUpdateAvailable = isUpdateAvailable(api_get_path(SYS_PATH));
if (isset($_POST['step2_install']) || isset($_POST['step2_update_8']) || isset($_POST['step2_update_6'])) {
if (isset($_POST['step2_install'])) {
$installType = 'new';
@@ -188,7 +191,7 @@ if (isset($_POST['step2_install']) || isset($_POST['step2_update_8']) || isset($
}
} elseif (isset($_POST['step1'])) {
$_POST['updatePath'] = '';
- $installType = '';
+ $installType = $_GET['installType'] ?? '';
$updateFromConfigFile = '';
unset($_GET['running']);
} else {
@@ -428,11 +431,24 @@ if (isset($_POST['step2'])) {
$stepData['institutionUrlForm'] = $institutionUrlForm;
$stepData['encryptPassForm'] = $encryptPassForm;
- $stepData['dbHostForm'] = $dbHostForm;
- $stepData['dbPortForm'] = $dbPortForm;
- $stepData['dbUsernameForm'] = $dbUsernameForm;
- $stepData['dbPassForm'] = str_repeat('*', api_strlen($dbPassForm));
- $stepData['dbNameForm'] = $dbNameForm;
+ $isPendingMigration = ($isUpdateAvailable && false === $checkMigrationStatus['status']);
+ if ($isPendingMigration) {
+ $envFile = api_get_path(SYMFONY_SYS_PATH) . '.env.local';
+ $dotenv = new Dotenv();
+ $envFile = api_get_path(SYMFONY_SYS_PATH) . '.env.local';
+ $dotenv->loadEnv($envFile);
+ $stepData['dbHostForm'] = $_ENV['DATABASE_HOST'];
+ $stepData['dbPortForm'] = $_ENV['DATABASE_PORT'];
+ $stepData['dbUsernameForm'] = $_ENV['DATABASE_USER'];
+ $stepData['dbPassForm'] = str_repeat('*', api_strlen($_ENV['DATABASE_PASSWORD']));
+ $stepData['dbNameForm'] = $_ENV['DATABASE_NAME'];
+ } else {
+ $stepData['dbHostForm'] = $dbHostForm;
+ $stepData['dbPortForm'] = $dbPortForm;
+ $stepData['dbUsernameForm'] = $dbUsernameForm;
+ $stepData['dbPassForm'] = str_repeat('*', api_strlen($dbPassForm));
+ $stepData['dbNameForm'] = $dbNameForm;
+ }
} elseif (isset($_POST['step6'])) {
//STEP 6 : INSTALLATION PROCESS
$current_step = 7;
@@ -452,24 +468,30 @@ if (isset($_POST['step2'])) {
$perm = octdec('0777');
$perm_file = octdec('0777');
- // Create .env.local file
- $envFile = api_get_path(SYMFONY_SYS_PATH).'.env.local';
- $distFile = api_get_path(SYMFONY_SYS_PATH).'.env';
-
- $params = [
- '{{DATABASE_HOST}}' => $dbHostForm,
- '{{DATABASE_PORT}}' => $dbPortForm,
- '{{DATABASE_NAME}}' => $dbNameForm,
- '{{DATABASE_USER}}' => $dbUsernameForm,
- '{{DATABASE_PASSWORD}}' => $dbPassForm,
- '{{APP_INSTALLED}}' => 1,
- '{{APP_ENCRYPT_METHOD}}' => $encryptPassForm,
- '{{APP_SECRET}}' => generateRandomToken(),
- ];
+ if (!$isUpdateAvailable) {
+ $installType = 'update';
+ // Create .env.local file
+ $envFile = api_get_path(SYMFONY_SYS_PATH) . '.env.local';
+ $distFile = api_get_path(SYMFONY_SYS_PATH) . '.env';
+ $params = [
+ '{{DATABASE_HOST}}' => $dbHostForm,
+ '{{DATABASE_PORT}}' => $dbPortForm,
+ '{{DATABASE_NAME}}' => $dbNameForm,
+ '{{DATABASE_USER}}' => $dbUsernameForm,
+ '{{DATABASE_PASSWORD}}' => $dbPassForm,
+ '{{APP_INSTALLED}}' => 1,
+ '{{APP_ENCRYPT_METHOD}}' => $encryptPassForm,
+ '{{APP_SECRET}}' => generateRandomToken(),
+ ];
+ error_log('Update env file');
+ updateEnvFile($distFile, $envFile, $params);
+ (new Dotenv())->load($envFile);
- error_log('Update env file');
- updateEnvFile($distFile, $envFile, $params);
- (new Dotenv())->load($envFile);
+ } else {
+ $dotenv = new Dotenv();
+ $envFile = api_get_path(SYMFONY_SYS_PATH) . '.env.local';
+ $dotenv->loadEnv($envFile);
+ }
// Load Symfony Kernel
$kernel = new Kernel('dev', true);
@@ -629,6 +651,9 @@ if (isset($_POST['step2'])) {
$stepData['installationProfile'] = $installationProfile;
}
+if ($isUpdateAvailable) {
+ $installType = 'update';
+}
$installerData = [
'poweredBy' => 'Powered by Chamilo © '.date('Y'),
@@ -678,9 +703,10 @@ $installerData = [
'old_version' => api_htmlentities($my_old_version, ENT_QUOTES),
'new_version' => api_htmlentities($new_version, ENT_QUOTES),
'installationProfile' => api_htmlentities($installationProfile, ENT_QUOTES),
-
'currentStep' => $current_step,
-
+ 'isUpdateAvailable' => $isUpdateAvailable,
+ 'checkMigrationStatus' => $checkMigrationStatus,
+ 'logUrl' => '/main/install/get_migration_status.php',
'stepData' => $stepData,
];
?>
diff --git a/public/main/install/install.lib.php b/public/main/install/install.lib.php
index 5ed12b1cd0..5ecde02cce 100644
--- a/public/main/install/install.lib.php
+++ b/public/main/install/install.lib.php
@@ -15,6 +15,7 @@ use Doctrine\Migrations\DependencyFactory;
use Doctrine\Migrations\Query\Query;
use Doctrine\ORM\EntityManager;
use Symfony\Component\DependencyInjection\Container as SymfonyContainer;
+use Symfony\Component\Dotenv\Dotenv;
/*
* Chamilo LMS
@@ -1347,21 +1348,21 @@ function migrate(EntityManager $manager)
$versionCounter = 1;
foreach ($versions as $version => $queries) {
$total = count($queries);
- echo '----------------------------------------------
';
+ //echo '----------------------------------------------
';
$message = "VERSION: $version";
- echo "$message
";
+ //echo "$message
";
error_log('-------------------------------------');
error_log($message);
$counter = 1;
foreach ($queries as $query) {
$sql = $query->getStatement();
- echo "$sql
";
+ //echo "$sql
";
error_log("$counter/$total : $sql");
$counter++;
}
$versionCounter++;
}
- echo '
DONE!
';
+ //echo '
DONE!
';
error_log('DONE!');
}
@@ -1661,6 +1662,7 @@ function migrateSwitch($fromVersion, $manager, $processFiles = true)
case '1.11.10':
case '1.11.12':
case '1.11.14':
+ case '1.11.16':
$start = time();
// Migrate using the migration files located in:
// /srv/http/chamilo2/src/CoreBundle/Migrations/Schema/V200
@@ -1724,3 +1726,110 @@ function checkCanCreateFile(string $file): bool
return false;
}
+
+/**
+ * Checks if the update option is available.
+ *
+ * Checks the existence of the "app" folder and the "configuration.php" file
+ * to determine if an update is available from version 1.11.x.
+ *
+ * @param string $baseDir The base directory.
+ * @return bool True if the update is available, false otherwise.
+ */
+function isUpdateAvailable(string $baseDir): bool
+{
+ // Path to the "app" folder
+ $appFolder = $baseDir.'/../app';
+
+ // Path to the "configuration.php" file
+ $configFile = $baseDir.'/../app/config/configuration.php';
+
+ // Check the existence of the "app" folder and the "configuration.php" file
+ return is_dir($appFolder) && file_exists($configFile);
+}
+
+function checkMigrationStatus(): array
+{
+ $envFile = api_get_path(SYMFONY_SYS_PATH) . '.env.local';
+ $dotenv = new Dotenv();
+ $envFile = api_get_path(SYMFONY_SYS_PATH) . '.env.local';
+ $dotenv->loadEnv($envFile);
+
+ $database = connectToDatabase(
+ $_ENV['DATABASE_HOST'],
+ $_ENV['DATABASE_USER'],
+ $_ENV['DATABASE_PASSWORD'],
+ $_ENV['DATABASE_NAME'],
+ $_ENV['DATABASE_PORT']
+ );
+ $manager = $database->getManager();
+
+ $connection = $manager->getConnection();
+
+ // Loading migration configuration.
+ $config = new PhpFile('./migrations.php');
+ $dependency = DependencyFactory::fromConnection($config, new ExistingConnection($connection));
+
+ // Check if old "version" table exists from 1.11.x, use new version.
+ $schema = $manager->getConnection()->getSchemaManager();
+ $hasOldVersionTable = false;
+ $anyVersionYet = !$schema->tablesExist('version');
+ $isVersionEmpty = false;
+ $executedMigrations = 0;
+ $currentMigration = '';
+ if ($schema->tablesExist('version')) {
+ $columns = $schema->listTableColumns('version');
+ if (in_array('id', array_keys($columns), true)) {
+ $hasOldVersionTable = true;
+ }
+ $query = $connection->createQueryBuilder()
+ ->select('*')
+ ->from('version');
+ $result = $query->execute();
+ $executedMigrations = $result->rowCount();
+ $isVersionEmpty = ($executedMigrations == 0);
+ if (!$isVersionEmpty) {
+ $query = $connection->createQueryBuilder()
+ ->select('*')
+ ->from('version')
+ ->orderBy('executed_at', 'DESC')
+ ->setMaxResults(1);
+ $result = $query->execute()->fetch();
+ $currentMigration = $result['version'];
+ }
+ }
+
+ if (!$hasOldVersionTable) {
+ // Loading migrations.
+ $migratorConfigurationFactory = $dependency->getConsoleInputMigratorConfigurationFactory();
+ $result = '';
+ $input = new Symfony\Component\Console\Input\StringInput($result);
+ $planCalculator = $dependency->getMigrationPlanCalculator();
+ $migrations = $planCalculator->getMigrations();
+ $totalMigrations = $migrations->count();
+ $lastVersion = $migrations->getLast();
+
+ if ($anyVersionYet || $isVersionEmpty) {
+ $currentMigration = '';
+ $executedMigrations = 0;
+ }
+
+ // Calculate progress percentage
+ $progressPercentage = ceil(($executedMigrations / $totalMigrations) * 100);
+ $resultStatus = [
+ 'status' => ($progressPercentage >= 100),
+ 'message' => ($progressPercentage >= 100) ? 'All migrations have been executed.' : 'Migrations are pending.',
+ 'current_migration' => ($progressPercentage >= 100) ? null : $currentMigration,
+ 'progress_percentage' => $progressPercentage
+ ];
+ } else {
+ $resultStatus = [
+ 'status' => false,
+ 'message' => 'Error executing migrations status command.',
+ 'current_migration' => null,
+ 'progress_percentage' => 0
+ ];
+ }
+
+ return $resultStatus;
+}
diff --git a/src/CoreBundle/Entity/Listener/ResourceListener.php b/src/CoreBundle/Entity/Listener/ResourceListener.php
index e2cec5f718..dd0bca26d0 100644
--- a/src/CoreBundle/Entity/Listener/ResourceListener.php
+++ b/src/CoreBundle/Entity/Listener/ResourceListener.php
@@ -183,6 +183,9 @@ class ResourceListener
}
if ($resource instanceof PersonalFile) {
+ if (null === $currentUser) {
+ $currentUser = $parentNode->getCreator();
+ }
$valid = $parentNode->getCreator()->getUsername() === $currentUser->getUsername() ||
$parentNode->getId() === $currentUser->getResourceNode()->getId();
diff --git a/src/CoreBundle/Entity/ResourceNode.php b/src/CoreBundle/Entity/ResourceNode.php
index 7fe3d0a136..4fbe54095e 100644
--- a/src/CoreBundle/Entity/ResourceNode.php
+++ b/src/CoreBundle/Entity/ResourceNode.php
@@ -121,7 +121,7 @@ class ResourceNode implements Stringable
#[Assert\NotNull]
#[Groups(['resource_node:read', 'resource_node:write', 'document:write'])]
- #[ORM\ManyToOne(targetEntity: User::class, inversedBy: 'resourceNodes')]
+ #[ORM\ManyToOne(targetEntity: \Chamilo\CoreBundle\Entity\User::class, cascade: ["persist"], inversedBy: 'resourceNodes')]
#[ORM\JoinColumn(name: 'creator_id', referencedColumnName: 'id', nullable: true, onDelete: 'CASCADE')]
protected User $creator;
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20.php b/src/CoreBundle/Migrations/Schema/V200/Version20.php
index c11d117224..a691cbf851 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20.php
@@ -378,10 +378,18 @@ class Version20 extends AbstractMigrationChamilo
$this->addSql('CREATE TABLE IF NOT EXISTS ext_translations (id INT AUTO_INCREMENT NOT NULL, locale VARCHAR(8) NOT NULL, object_class VARCHAR(191) NOT NULL, field VARCHAR(32) NOT NULL, foreign_key VARCHAR(64) NOT NULL, content LONGTEXT DEFAULT NULL, INDEX translations_lookup_idx (locale, object_class, foreign_key), UNIQUE INDEX lookup_unique_idx (locale, object_class, field, foreign_key), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
// Rename extra_field field_type and extra_field_type to item_type and value_type, also, the term "value" in exta_field_values.value renamed to field_value
- $this->addSql('ALTER TABLE extra_field CHANGE extra_field_type item_type INT NOT NULL');
- $this->addSql('ALTER TABLE extra_field CHANGE field_type value_type INT NOT NULL');
- $this->addSql('ALTER TABLE extra_field_values CHANGE `value` field_value LONGTEXT DEFAULT NULL');
-
+ $table = $schema->getTable('extra_field');
+ if (false === $table->hasColumn('extra_field_type')) {
+ $this->addSql('ALTER TABLE extra_field CHANGE extra_field_type item_type INT NOT NULL');
+ }
+ if (false === $table->hasColumn('field_type')) {
+ $this->addSql('ALTER TABLE extra_field CHANGE field_type value_type INT NOT NULL');
+ }
+ $table = $schema->getTable('extra_field_values');
+ if (false === $table->hasColumn('value')) {
+ $this->addSql('ALTER TABLE extra_field_values CHANGE `value` field_value LONGTEXT DEFAULT NULL');
+ }
+
// Drop unused columns
$dropColumnsAndIndex = [
'track_e_uploads' => [
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20180319145700.php b/src/CoreBundle/Migrations/Schema/V200/Version20180319145700.php
index 07658e0174..db328a2ffc 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20180319145700.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20180319145700.php
@@ -107,7 +107,7 @@ class Version20180319145700 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE c_survey_invitation CHANGE reminder_date reminder_date DATETIME DEFAULT NULL');
$this->addSql(
- 'UPDATE c_survey_invitation SET reminder_date = NULL WHERE CAST(reminder_date AS CHAR(20)) = "0000-00-00 00:00:00"'
+ 'UPDATE c_survey_invitation SET reminder_date = NULL WHERE reminder_date = "0000-00-00 00:00:00"'
);
// c_survey_invitation.user_id
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20180904175500.php b/src/CoreBundle/Migrations/Schema/V200/Version20180904175500.php
index acf50e4a8b..4a7e3a147b 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20180904175500.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20180904175500.php
@@ -24,10 +24,11 @@ class Version20180904175500 extends AbstractMigrationChamilo
$this->addSql('DELETE FROM track_e_exercises WHERE exe_user_id = 0 OR exe_user_id IS NULL');
$this->addSql('ALTER TABLE track_e_exercises CHANGE exe_user_id exe_user_id INT NOT NULL');
+ $this->addSql('ALTER TABLE track_e_exercises CHANGE session_id session_id INT DEFAULT NULL');
$this->addSql('UPDATE track_e_exercises SET session_id = NULL WHERE session_id = 0');
$this->addSql('DELETE FROM track_e_exercises WHERE session_id IS NOT NULL AND session_id NOT IN (SELECT id FROM session)');
- $this->addSql('ALTER TABLE track_e_exercises CHANGE session_id session_id INT NOT NULL');
+
if (!$schema->hasTable('attempt_file')) {
$this->addSql("CREATE TABLE attempt_file (id BINARY(16) NOT NULL COMMENT '(DC2Type:uuid)', attempt_id INT DEFAULT NULL, asset_id BINARY(16) DEFAULT NULL COMMENT '(DC2Type:uuid)', comment LONGTEXT NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', INDEX IDX_4F22BDF0B191BE6B (attempt_id), INDEX IDX_4F22BDF05DA1941 (asset_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;");
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php b/src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php
index 44c1ed02a2..b1f37b172c 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php
@@ -291,7 +291,7 @@ class Version20181025064351 extends AbstractMigrationChamilo
$this->addSql('ALTER TABLE gradebook_certificate ADD downloaded_at DATETIME DEFAULT NULL;');
$this->addSql(
'UPDATE gradebook_certificate gc SET downloaded_at = (
- SELECT value from extra_field e
+ SELECT field_value from extra_field e
INNER JOIN extra_field_values v on v.field_id = e.id
WHERE variable = "downloaded_at" and item_type = 11 and item_id = gc.id
)'
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php b/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php
index 4e97127003..086f991b54 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php
@@ -152,6 +152,7 @@ class Version20191101132000 extends AbstractMigrationChamilo
}
$filePath = $rootPath.'/app/upload/course_category/'.$category['image'];
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
if ($this->fileExists($filePath)) {
$fileName = basename($filePath);
$mimeType = mime_content_type($filePath);
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20191206150000.php b/src/CoreBundle/Migrations/Schema/V200/Version20191206150000.php
index 9b04f6cd31..23e1daecd4 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20191206150000.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20191206150000.php
@@ -22,7 +22,7 @@ class Version20191206150000 extends AbstractMigrationChamilo
if (false === $table->hasColumn('helper_text')) {
$this->addSql('ALTER TABLE extra_field ADD helper_text text DEFAULT NULL AFTER display_text');
}
- $this->addSql('ALTER TABLE extra_field_values CHANGE value value LONGTEXT DEFAULT NULL;');
+ $this->addSql('ALTER TABLE extra_field_values CHANGE field_value field_value LONGTEXT DEFAULT NULL;');
if (false === $table->hasColumn('description')) {
$this->addSql('ALTER TABLE extra_field ADD description LONGTEXT DEFAULT NULL');
}
@@ -31,7 +31,7 @@ class Version20191206150000 extends AbstractMigrationChamilo
$this->addSql("UPDATE extra_field_values SET created_at = NOW() WHERE CAST(created_at AS CHAR(20)) = '0000-00-00 00:00:00'");
$this->addSql("UPDATE extra_field_values SET updated_at = NOW() WHERE CAST(updated_at AS CHAR(20)) = '0000-00-00 00:00:00'");
- $this->addSql('ALTER TABLE extra_field_values MODIFY COLUMN value LONGTEXT NULL');
+ $this->addSql('ALTER TABLE extra_field_values MODIFY COLUMN field_value LONGTEXT NULL');
if (!$table->hasIndex('idx_efv_item')) {
$this->addSql('CREATE INDEX idx_efv_item ON extra_field_values (item_id)');
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20191206150030.php b/src/CoreBundle/Migrations/Schema/V200/Version20191206150030.php
index 46c6df7b34..1e28f1aede 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20191206150030.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20191206150030.php
@@ -43,6 +43,7 @@ class Version20191206150030 extends AbstractMigrationChamilo
continue;
}
$filePath = $rootPath.'/app/upload/'.$path;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
if ($this->fileExists($filePath)) {
$fileName = basename($path);
$mimeType = mime_content_type($filePath);
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201211114900.php b/src/CoreBundle/Migrations/Schema/V200/Version20201211114900.php
new file mode 100644
index 0000000000..5c14168bea
--- /dev/null
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201211114900.php
@@ -0,0 +1,220 @@
+hasTable('gradebook_category')) {
+ $table = $schema->getTable('gradebook_category');
+ if (!$table->hasColumn('allow_skills_by_subcategory')) {
+ $this->addSql(
+ 'ALTER TABLE gradebook_category ADD allow_skills_by_subcategory INT DEFAULT 1'
+ );
+ }
+ }
+
+ if ($schema->hasTable('c_survey_answer')) {
+ $table = $schema->getTable('c_survey_answer');
+ if (!$table->hasColumn('session_id')) {
+ $this->addSql(
+ 'ALTER TABLE c_survey_answer ADD session_id INT NOT NULL'
+ );
+ }
+ if (!$table->hasColumn('c_lp_item_id')) {
+ $this->addSql(
+ 'ALTER TABLE c_survey_answer ADD c_lp_item_id INT NOT NULL'
+ );
+ }
+
+ }
+
+ if ($schema->hasTable('c_survey_invitation')) {
+ $table = $schema->getTable('c_survey_invitation');
+ if (!$table->hasColumn('c_lp_item_id')) {
+ $this->addSql(
+ 'ALTER TABLE c_survey_invitation ADD c_lp_item_id INT NOT NULL'
+ );
+ }
+ }
+
+ if ($schema->hasTable('c_quiz')) {
+ $table = $schema->getTable('c_quiz');
+ if (!$table->hasColumn('hide_attempts_table')) {
+ $this->addSql(
+ 'ALTER TABLE c_quiz ADD hide_attempts_table TINYINT(1) NOT NULL'
+ );
+ }
+ }
+
+ if ($schema->hasTable('c_attendance_calendar')) {
+ $table = $schema->getTable('c_attendance_calendar');
+ if (!$table->hasColumn('blocked')) {
+ $this->addSql(
+ 'ALTER TABLE c_attendance_calendar ADD blocked TINYINT(1) DEFAULT NULL'
+ );
+ }
+ }
+
+ if ($schema->hasTable('c_attendance_sheet')) {
+ $table = $schema->getTable('c_attendance_sheet');
+ if (!$table->hasColumn('signature')) {
+ $this->addSql(
+ 'ALTER TABLE c_attendance_sheet ADD signature VARCHAR(255) DEFAULT NULL'
+ );
+ }
+ }
+
+ if ($schema->hasTable('c_lp')) {
+ $table = $schema->getTable('c_lp');
+ if (!$table->hasColumn('published_on')) {
+ $this->addSql(
+ 'ALTER TABLE c_lp CHANGE publicated_on published_on datetime NULL;'
+ );
+ }
+ }
+
+ if ($schema->hasTable('c_lp')) {
+ $table = $schema->getTable('c_lp');
+ if (!$table->hasColumn('next_lp_id')) {
+ $this->addSql(
+ 'ALTER TABLE c_lp ADD next_lp_id INT DEFAULT 0 NOT NULL'
+ );
+ }
+ }
+
+ if ($schema->hasTable('c_lp_item')) {
+ $table = $schema->getTable('c_lp_item');
+ if (!$table->hasColumn('item_root')) {
+ $this->addSql(
+ 'ALTER TABLE c_lp_item CHANGE c_id item_root INT DEFAULT NULL'
+ );
+ $this->addSql(
+ 'ALTER TABLE c_lp_item ADD CONSTRAINT FK_CCC9C1EDDEC4BDA0 FOREIGN KEY (item_root) REFERENCES c_lp_item (iid) ON DELETE CASCADE'
+ );
+ $this->addSql(
+ 'CREATE INDEX IDX_CCC9C1EDDEC4BDA0 ON c_lp_item (item_root)'
+ );
+ }
+ }
+
+ if (!$schema->hasTable('c_wiki_category')) {
+ $this->addSql(
+ 'CREATE TABLE c_wiki_category (id INT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, session_id INT DEFAULT NULL, tree_root INT DEFAULT NULL, parent_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, lft INT NOT NULL, lvl INT NOT NULL, rgt INT NOT NULL, INDEX IDX_17F1099A91D79BD3 (c_id), INDEX IDX_17F1099A613FECDF (session_id), INDEX IDX_17F1099AA977936C (tree_root), INDEX IDX_17F1099A727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'
+ );
+ $this->addSql(
+ 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE'
+ );
+ $this->addSql(
+ 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE CASCADE'
+ );
+ $this->addSql(
+ 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099AA977936C FOREIGN KEY (tree_root) REFERENCES c_wiki_category (id) ON DELETE CASCADE'
+ );
+ $this->addSql(
+ 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A727ACA70 FOREIGN KEY (parent_id) REFERENCES c_wiki_category (id) ON DELETE CASCADE'
+ );
+ }
+
+ if (!$schema->hasTable('c_wiki_rel_category')) {
+ $this->addSql(
+ 'CREATE TABLE c_wiki_rel_category (wiki_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_AC88945BAA948DBE (wiki_id), INDEX IDX_AC88945B12469DE2 (category_id), PRIMARY KEY(wiki_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'
+ );
+ $this->addSql(
+ 'ALTER TABLE c_wiki_rel_category ADD CONSTRAINT FK_AC88945BAA948DBE FOREIGN KEY (wiki_id) REFERENCES c_wiki (iid) ON DELETE CASCADE'
+ );
+ $this->addSql(
+ 'ALTER TABLE c_wiki_rel_category ADD CONSTRAINT FK_AC88945B12469DE2 FOREIGN KEY (category_id) REFERENCES c_wiki_category (id) ON DELETE CASCADE'
+ );
+ }
+
+
+ }
+
+ public function down(Schema $schema): void
+ {
+ if ($schema->hasTable('c_wiki_category')) {
+ $this->addSql(
+ 'DROP TABLE c_wiki_category'
+ );
+ }
+
+ if ($schema->hasTable('c_wiki_rel_category')) {
+ $this->addSql(
+ 'DROP TABLE c_wiki_rel_category'
+ );
+ }
+
+ if ($schema->hasTable('c_lp_item')) {
+ $table = $schema->getTable('c_lp_item');
+ if ($table->hasColumn('item_root')) {
+ $this->addSql(
+ 'ALTER TABLE c_lp_item CHANGE item_root c_id INT DEFAULT NULL'
+ );
+ }
+ }
+
+ $table = $schema->getTable('c_lp');
+ if ($table->hasColumn('next_lp_id')) {
+ $this->addSql('ALTER TABLE c_lp DROP next_lp_id');
+ }
+
+ if ($schema->hasTable('c_lp')) {
+ $table = $schema->getTable('c_lp');
+ if ($table->hasColumn('published_on')) {
+ $this->addSql(
+ 'ALTER TABLE c_lp CHANGE published_on publicated_on datetime NULL;'
+ );
+ }
+ }
+ $table = $schema->getTable('c_attendance_sheet');
+ if ($table->hasColumn('signature')) {
+ $this->addSql('ALTER TABLE c_attendance_sheet DROP signature');
+ }
+
+ $table = $schema->getTable('c_attendance_calendar');
+ if ($table->hasColumn('blocked')) {
+ $this->addSql('ALTER TABLE c_attendance_calendar DROP blocked');
+ }
+
+ $table = $schema->getTable('c_quiz');
+ if ($table->hasColumn('hide_attempts_table')) {
+ $this->addSql('ALTER TABLE c_quiz DROP hide_attempts_table');
+ }
+
+ $table = $schema->getTable('c_survey_answer');
+ if ($table->hasColumn('session_id')) {
+ $this->addSql('ALTER TABLE c_survey_answer DROP session_id');
+ }
+
+ if ($table->hasColumn('c_lp_item_id')) {
+ $this->addSql('ALTER TABLE c_survey_answer DROP c_lp_item_id');
+ }
+
+ $table = $schema->getTable('c_survey_invitation');
+ if ($table->hasColumn('c_lp_item_id')) {
+ $this->addSql('ALTER TABLE c_survey_invitation DROP c_lp_item_id');
+ }
+
+ $table = $schema->getTable('gradebook_category');
+ if ($table->hasColumn('allow_skills_by_subcategory')) {
+ $this->addSql('ALTER TABLE gradebook_category DROP allow_skills_by_subcategory');
+ }
+ }
+}
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201211114910.php b/src/CoreBundle/Migrations/Schema/V200/Version20201211114910.php
new file mode 100644
index 0000000000..9652a337b7
--- /dev/null
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201211114910.php
@@ -0,0 +1,52 @@
+hasTable('resource_format')) {
+ $this->addSql(
+ "CREATE TABLE resource_format (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', updated_at DATETIME NOT NULL COMMENT '(DC2Type:datetime)', PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC;"
+ );
+ $this->addSql(
+ 'ALTER TABLE resource_node ADD resource_format_id INT DEFAULT NULL;'
+ );
+ $this->addSql(
+ 'ALTER TABLE resource_node ADD CONSTRAINT FK_8A5F48FF7EE0A59A FOREIGN KEY (resource_format_id) REFERENCES resource_format (id) ON DELETE SET NULL;'
+ );
+ $this->addSql(
+ 'CREATE INDEX IDX_8A5F48FF7EE0A59A ON resource_node (resource_format_id);'
+ );
+ }
+ }
+
+ public function down(Schema $schema): void
+ {
+ if ($schema->hasTable('resource_format')) {
+ $this->addSql(
+ 'ALTER TABLE resource_node DROP FOREIGN KEY FK_8A5F48FF7EE0A59A;'
+ );
+ $this->addSql(
+ 'ALTER TABLE resource_node DROP INDEX IDX_8A5F48FF7EE0A59A;'
+ );
+ $this->addSql(
+ 'ALTER TABLE resource_node DROP resource_format_id;'
+ );
+ $this->addSql(
+ 'DROP TABLE resource_format;'
+ );
+ }
+ }
+}
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201211124910.php b/src/CoreBundle/Migrations/Schema/V200/Version20201211124910.php
new file mode 100644
index 0000000000..3ecba221f9
--- /dev/null
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201211124910.php
@@ -0,0 +1,50 @@
+getEntityManager()->getConnection();
+ if ($schema->hasTable('resource_format')) {
+ $result = $connection->executeQuery(" SELECT * FROM resource_format WHERE name = 'html'");
+ $exists = $result->fetchAllAssociative();
+ if (empty($exists)) {
+ $this->addSql("INSERT INTO resource_format SET name = 'html', created_at = NOW(), updated_at = NOW();");
+ }
+ $result = $connection->executeQuery(" SELECT * FROM resource_format WHERE name = 'txt'");
+ $exists = $result->fetchAllAssociative();
+ if (empty($exists)) {
+ $this->addSql("INSERT INTO resource_format SET name = 'txt', created_at = NOW(), updated_at = NOW();");
+ }
+ }
+ }
+
+ public function down(Schema $schema): void
+ {
+ $connection = $this->getEntityManager()->getConnection();
+ if ($schema->hasTable('resource_format')) {
+ $result = $connection->executeQuery(" SELECT * FROM resource_format WHERE name = 'txt'");
+ $exists = $result->fetchAllAssociative();
+ if (!empty($exists)) {
+ $this->addSql("DELETE FROM resource_format WHERE name = 'txt';");
+ }
+ $result = $connection->executeQuery(" SELECT * FROM resource_format WHERE name = 'html'");
+ $exists = $result->fetchAllAssociative();
+ if (!empty($exists)) {
+ $this->addSql("DELETE FROM resource_format WHERE name = 'html';");
+ }
+ }
+ }
+}
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201212195011.php b/src/CoreBundle/Migrations/Schema/V200/Version20201212195011.php
index 902f87f057..897a0302f7 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20201212195011.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201212195011.php
@@ -88,7 +88,7 @@ final class Version20201212195011 extends AbstractMigrationChamilo
$extraFieldId = (int) $extraFieldId;
$sql = "SELECT DISTINCT(item_id)
FROM extra_field_values
- WHERE field_id = $extraFieldId AND value = 1 ";
+ WHERE field_id = $extraFieldId AND field_value= 1 ";
$result = $connection->executeQuery($sql);
$specialCourses = $result->fetchAllAssociative();
if (!empty($specialCourses)) {
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201212195110.php b/src/CoreBundle/Migrations/Schema/V200/Version20201212195110.php
new file mode 100644
index 0000000000..9944d34103
--- /dev/null
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201212195110.php
@@ -0,0 +1,31 @@
+getTable('session');
+ if (false === $table->hasColumn('image_id')) {
+ $this->addSql("ALTER TABLE session ADD image_id BINARY(16) DEFAULT NULL COMMENT '(DC2Type:uuid)'");
+ $this->addSql("ALTER TABLE session ADD CONSTRAINT FK_D044D5D43DA5256D FOREIGN KEY (image_id) REFERENCES asset (id) ON DELETE SET NULL");
+ $this->addSql("CREATE INDEX IDX_D044D5D43DA5256D ON session (image_id)");
+ }
+ }
+
+ public function down(Schema $schema): void
+ {
+ }
+}
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201212203625.php b/src/CoreBundle/Migrations/Schema/V200/Version20201212203625.php
index 89fc5237f4..4d6af4bb8e 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20201212203625.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201212203625.php
@@ -18,6 +18,7 @@ use Chamilo\CourseBundle\Repository\CDocumentRepository;
use Chamilo\Kernel;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;
+use Doctrine\ORM\EntityManager;
use DocumentManager;
use Symfony\Component\HttpFoundation\File\UploadedFile;
@@ -32,10 +33,12 @@ final class Version20201212203625 extends AbstractMigrationChamilo
{
$container = $this->getContainer();
$doctrine = $container->get('doctrine');
+ /** @var EntityManager $em */
$em = $doctrine->getManager();
/** @var Connection $connection */
$connection = $em->getConnection();
+ /* @var CDocumentRepository $documentRepo */
$documentRepo = $container->get(CDocumentRepository::class);
$courseRepo = $container->get(CourseRepository::class);
$attemptRepo = $em->getRepository(TrackEAttempt::class);
@@ -68,7 +71,7 @@ final class Version20201212203625 extends AbstractMigrationChamilo
$path = str_replace('/../exercises/teacher_audio/', '', $path);
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/exercises/teacher_audio/'.$path;
-
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
if ($this->fileExists($filePath)) {
preg_match('#/(.*)/#', '/'.$path, $matches);
if (isset($matches[1]) && !empty($matches[1])) {
@@ -138,6 +141,7 @@ final class Version20201212203625 extends AbstractMigrationChamilo
$path = str_replace('/../exercises/', '', $path);
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/exercises/'.$path;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
if ($this->fileExists($filePath)) {
$fileName = basename($filePath);
preg_match('#/(.*)/(.*)/(.*)/(.*)/#', '/'.$path, $matches);
@@ -217,12 +221,14 @@ final class Version20201212203625 extends AbstractMigrationChamilo
$parent = null;
if ('.' !== \dirname($documentPath)) {
- $parentId = (int) DocumentManager::get_document_id(
- [
- 'real_id' => $courseId,
- ],
- \dirname($documentPath)
- );
+ $currentPath = \dirname($documentPath);
+ $sql = "SELECT iid FROM c_document
+ WHERE
+ c_id = {$courseId} AND
+ path LIKE '$currentPath'";
+ $result = $connection->executeQuery($sql);
+ $parentId = $result->fetchOne();
+
if (!empty($parentId)) {
$parent = $documentRepo->find($parentId);
}
@@ -237,8 +243,9 @@ final class Version20201212203625 extends AbstractMigrationChamilo
if (false === $result) {
continue;
}
-
+ $documentPath = ltrim($documentPath, '/');
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/document/'.$documentPath;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
$this->addLegacyFileToResource($filePath, $documentRepo, $document, $documentId);
$em->persist($document);
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201215072918.php b/src/CoreBundle/Migrations/Schema/V200/Version20201215072918.php
index fa551e3879..65bba24b24 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20201215072918.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201215072918.php
@@ -127,6 +127,7 @@ final class Version20201215072918 extends AbstractMigrationChamilo
}
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/upload/calendar/'.$attachmentPath;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
$this->addLegacyFileToResource($filePath, $eventAttachmentRepo, $attachment, $id, $fileName);
$em->persist($attachment);
$em->flush();
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201215141131.php b/src/CoreBundle/Migrations/Schema/V200/Version20201215141131.php
index 8e8de36e64..b69ba5c8ca 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20201215141131.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201215141131.php
@@ -37,9 +37,6 @@ final class Version20201215141131 extends AbstractMigrationChamilo
$linkRepo = $container->get(CLinkRepository::class);
$linkCategoryRepo = $container->get(CLinkCategoryRepository::class);
$courseRepo = $container->get(CourseRepository::class);
- $sessionRepo = $container->get(SessionRepository::class);
- $groupRepo = $container->get(CGroupRepository::class);
- $userRepo = $container->get(UserRepository::class);
$admin = $this->getAdmin();
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201215153517.php b/src/CoreBundle/Migrations/Schema/V200/Version20201215153517.php
index 93934eed3a..aea593be9d 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20201215153517.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201215153517.php
@@ -112,13 +112,11 @@ final class Version20201215153517 extends AbstractMigrationChamilo
$em->flush();
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/upload/announcements/'.$path;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
$this->addLegacyFileToResource($filePath, $announcementAttachmentRepo, $resource, $id, $fileName);
$em->persist($resource);
$em->flush();
}
-
- $em->flush();
- $em->clear();
}
}
}
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201215160445.php b/src/CoreBundle/Migrations/Schema/V200/Version20201215160445.php
index f917ccd92a..680b6d4b69 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20201215160445.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201215160445.php
@@ -139,6 +139,7 @@ final class Version20201215160445 extends AbstractMigrationChamilo
$forumImage = $itemData['forum_image'];
if (!empty($forumImage)) {
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/upload/forum/images/'.$forumImage;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
if ($this->fileExists($filePath)) {
$this->addLegacyFileToResource($filePath, $forumRepo, $resource, $id, $forumImage);
}
@@ -284,6 +285,7 @@ final class Version20201215160445 extends AbstractMigrationChamilo
if (!empty($fileName) && !empty($path)) {
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/upload/forum/'.$path;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
if ($this->fileExists($filePath)) {
$this->addLegacyFileToResource($filePath, $forumPostRepo, $post, $id, $fileName);
$em->persist($post);
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20201217124011.php b/src/CoreBundle/Migrations/Schema/V200/Version20201217124011.php
index e291f642fe..69baf80f90 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20201217124011.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20201217124011.php
@@ -127,6 +127,7 @@ final class Version20201217124011 extends AbstractMigrationChamilo
}
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/'.$path;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
$this->addLegacyFileToResource($filePath, $studentPublicationRepo, $resource, $id, $title);
$em->persist($resource);
$em->flush();
@@ -165,6 +166,7 @@ final class Version20201217124011 extends AbstractMigrationChamilo
$em->persist($correction);
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/'.$path;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
$this->addLegacyFileToResource($filePath, $studentPublicationCorrectionRepo, $correction, null, $title);
$em->persist($correction);
$em->flush();
@@ -202,6 +204,7 @@ final class Version20201217124011 extends AbstractMigrationChamilo
$resource->addCourseLink($course, $session, $group, ResourceLink::VISIBILITY_PUBLISHED);
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/'.$file;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
$this->addLegacyFileToResource($filePath, $studentPublicationRepo, $resource, $id, $title);
$em->persist($resource);
$em->flush();
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20210205082253.php b/src/CoreBundle/Migrations/Schema/V200/Version20210205082253.php
index 453ed1e9a2..4f2762f8cd 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20210205082253.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20210205082253.php
@@ -59,6 +59,7 @@ final class Version20210205082253 extends AbstractMigrationChamilo
$path = 'users/'.substr((string) $id, 0, 1).'/'.$id.'/';
}
$picturePath = $rootPath.'/app/upload/'.$path.'/'.$picture;
+ error_log('MIGRATIONS :: $filePath -- '.$picturePath.' ...');
if ($this->fileExists($picturePath)) {
$mimeType = mime_content_type($picturePath);
$file = new UploadedFile($picturePath, $picture, $mimeType, null, true);
@@ -125,6 +126,7 @@ final class Version20210205082253 extends AbstractMigrationChamilo
$path = 'groups/'.substr((string) $id, 0, 1).'/'.$id.'/';
}
$picturePath = $rootPath.'/app/upload/'.$path.'/'.$picture;
+ error_log('MIGRATIONS :: $filePath -- '.$picturePath.' ...');
if ($this->fileExists($picturePath)) {
$mimeType = mime_content_type($picturePath);
$file = new UploadedFile($picturePath, $picture, $mimeType, null, true);
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20210221082033.php b/src/CoreBundle/Migrations/Schema/V200/Version20210221082033.php
index 184a5f85f5..04c3682959 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20210221082033.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20210221082033.php
@@ -47,6 +47,7 @@ class Version20210221082033 extends AbstractMigrationChamilo
$lp = $lpRepo->find($id);
if ($lp && !empty($path)) {
$filePath = $rootPath.'/app/courses/'.$course->getDirectory().'/upload/learning_path/images/'.$path;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
if ($this->fileExists($filePath)) {
$this->addLegacyFileToResource($filePath, $lpRepo, $lp, $lp->getIid(), $path);
$em->persist($lp);
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20210813150011.php b/src/CoreBundle/Migrations/Schema/V200/Version20210813150011.php
index 9e04427d40..cd45447fc1 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20210813150011.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20210813150011.php
@@ -47,6 +47,7 @@ class Version20210813150011 extends AbstractMigrationChamilo
}
$filePath = $rootPath.'/app/upload/badges/'.$icon;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
if ($this->fileExists($filePath)) {
$mimeType = mime_content_type($filePath);
$fileName = basename($filePath);
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20210923090920.php b/src/CoreBundle/Migrations/Schema/V200/Version20210923090920.php
index bfab731533..17bf99bd34 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20210923090920.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20210923090920.php
@@ -43,7 +43,7 @@ final class Version20210923090920 extends AbstractMigrationChamilo
}
$picturePath = $rootPath.'/app/courses/'.$directory.'/course-pic.png';
-
+ error_log('MIGRATIONS :: $filePath -- '.$picturePath.' ...');
if ($this->fileExists($picturePath)) {
$admin = $this->getAdmin();
$mimeType = mime_content_type($picturePath);
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20211005154000.php b/src/CoreBundle/Migrations/Schema/V200/Version20211005154000.php
index f3e03af32f..8f108d2ffe 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20211005154000.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20211005154000.php
@@ -63,6 +63,7 @@ class Version20211005154000 extends AbstractMigrationChamilo
$attachmentRepo->create($messageAttachment);
$filePath = $rootPath.'/app/upload/ticket_attachment/'.$item['path'];
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
$this->addLegacyFileToResource($filePath, $attachmentRepo, $messageAttachment, $item['id']);
$em->persist($messageAttachment);
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20230124123419.php b/src/CoreBundle/Migrations/Schema/V200/Version20230124123419.php
deleted file mode 100644
index 4bbfebbf98..0000000000
--- a/src/CoreBundle/Migrations/Schema/V200/Version20230124123419.php
+++ /dev/null
@@ -1,34 +0,0 @@
-hasTable('c_lp')) {
- $this->addSql(
- 'ALTER TABLE c_lp CHANGE publicated_on published_on datetime NULL;'
- );
- }
- }
-
- public function down(Schema $schema): void
- {
- if ($schema->hasTable('c_lp')) {
- $this->addSql(
- 'ALTER TABLE c_lp CHANGE published_on publicated_on datetime NULL;'
- );
- }
- }
-}
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20230204150030.php b/src/CoreBundle/Migrations/Schema/V200/Version20230204150030.php
index d4d8fab337..5c2db2a76b 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20230204150030.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20230204150030.php
@@ -7,10 +7,12 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Entity\Asset;
use Chamilo\CoreBundle\Entity\ExtraFieldValues;
+use Chamilo\CoreBundle\Entity\ExtraField;
+use Chamilo\CoreBundle\Repository\SessionRepository;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
-use ExtraField;
+use Doctrine\ORM\EntityManager;
use Symfony\Component\HttpFoundation\File\UploadedFile;
class Version20230204150030 extends AbstractMigrationChamilo
@@ -24,6 +26,7 @@ class Version20230204150030 extends AbstractMigrationChamilo
{
$container = $this->getContainer();
$doctrine = $container->get('doctrine');
+ /* @var EntityManager $em */
$em = $doctrine->getManager();
$kernel = $container->get('kernel');
@@ -40,7 +43,7 @@ class Version20230204150030 extends AbstractMigrationChamilo
'itemType' => ExtraField::SESSION_FIELD_TYPE,
]);
- $sessionRepo = $container->get(Session::class);
+ $sessionRepo = $container->get(SessionRepository::class);
/** @var ExtraFieldValues $item */
foreach ($q->toIterable() as $item) {
$path = $item->getFieldValue();
@@ -48,6 +51,7 @@ class Version20230204150030 extends AbstractMigrationChamilo
continue;
}
$filePath = $rootPath.'/app/upload/'.$path;
+ error_log('MIGRATIONS :: $filePath -- '.$filePath.' ...');
if ($this->fileExists($filePath)) {
$fileName = basename($path);
$mimeType = mime_content_type($filePath);
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20230215072918.php b/src/CoreBundle/Migrations/Schema/V200/Version20230215072918.php
index a8a1037b02..ea90e39849 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20230215072918.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20230215072918.php
@@ -11,9 +11,12 @@ use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\Entity\User;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Chamilo\CoreBundle\Repository\Node\CourseRepository;
+use Chamilo\CoreBundle\Repository\Node\UserRepository;
+use Chamilo\CoreBundle\Repository\SessionRepository;
use Chamilo\CourseBundle\Entity\CLp;
use Chamilo\CourseBundle\Entity\CLpRelUser;
use Chamilo\CourseBundle\Repository\CLpRelUserRepository;
+use Chamilo\CourseBundle\Repository\CLpRepository;
use Chamilo\Kernel;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\Schema;
@@ -33,14 +36,14 @@ final class Version20230215072918 extends AbstractMigrationChamilo
/** @var Connection $connection */
$connection = $em->getConnection();
- $lpRepo = $container->get(CLp::class);
+ $lpRepo = $container->get(CLpRepository::class);
/** @var CLpRelUserRepository $cLpRelUserRepo */
- $cLpRelUserRepo = $container->get(CLpRelUser::class);
+ $cLpRelUserRepo = $container->get(CLpRelUserRepository::class);
$courseRepo = $container->get(CourseRepository::class);
- $sessionRepo = $container->get(Session::class);
- $userRepo = $container->get(User::class);
+ $sessionRepo = $container->get(SessionRepository::class);
+ $userRepo = $container->get(UserRepository::class);
/** @var Kernel $kernel */
$kernel = $container->get('kernel');
diff --git a/src/CoreBundle/Migrations/Schema/V200/Version20230216122950.php b/src/CoreBundle/Migrations/Schema/V200/Version20230216122950.php
index c39bd1f4cb..c501ab38a0 100644
--- a/src/CoreBundle/Migrations/Schema/V200/Version20230216122950.php
+++ b/src/CoreBundle/Migrations/Schema/V200/Version20230216122950.php
@@ -17,15 +17,26 @@ final class Version20230216122950 extends AbstractMigrationChamilo
public function up(Schema $schema): void
{
if ($schema->hasTable('ticket_ticket')) {
- $this->addSql(
- 'ALTER TABLE ticket_ticket ADD exercise_id INT DEFAULT NULL, ADD lp_id INT DEFAULT NULL'
- );
+ $table = $schema->getTable('ticket_ticket');
+ if (!$table->hasColumn('exercise_id')) {
+ $this->addSql(
+ 'ALTER TABLE ticket_ticket ADD exercise_id INT DEFAULT NULL'
+ );
+ }
+ if (!$table->hasColumn('lp_id')) {
+ $this->addSql(
+ 'ALTER TABLE ticket_ticket ADD lp_id INT DEFAULT NULL'
+ );
+ }
}
if ($schema->hasTable('c_quiz_question_rel_category')) {
- $this->addSql(
- 'ALTER TABLE c_quiz_question_rel_category ADD COLUMN mandatory INT DEFAULT 0'
- );
+ $table = $schema->getTable('c_quiz_question_rel_category');
+ if (!$table->hasColumn('mandatory')) {
+ $this->addSql(
+ 'ALTER TABLE c_quiz_question_rel_category ADD COLUMN mandatory INT DEFAULT 0'
+ );
+ }
}
if (!$schema->hasTable('c_plagiarism_compilatio_docs')) {
@@ -41,9 +52,12 @@ final class Version20230216122950 extends AbstractMigrationChamilo
}
if ($schema->hasTable('system_template')) {
- $this->addSql(
- 'ALTER TABLE system_template ADD language VARCHAR(40) NOT NULL DEFAULT "english"'
- );
+ $table = $schema->getTable('system_template');
+ if (!$table->hasColumn('language')) {
+ $this->addSql(
+ 'ALTER TABLE system_template ADD language VARCHAR(40) NOT NULL DEFAULT "english"'
+ );
+ }
}
if (!$schema->hasTable('agenda_event_invitee')) {
@@ -73,58 +87,13 @@ final class Version20230216122950 extends AbstractMigrationChamilo
);
}
- if (!$schema->hasTable('c_wiki_category')) {
- $this->addSql(
- 'CREATE TABLE c_wiki_category (id INT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, session_id INT DEFAULT NULL, tree_root INT DEFAULT NULL, parent_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, lft INT NOT NULL, lvl INT NOT NULL, rgt INT NOT NULL, INDEX IDX_17F1099A91D79BD3 (c_id), INDEX IDX_17F1099A613FECDF (session_id), INDEX IDX_17F1099AA977936C (tree_root), INDEX IDX_17F1099A727ACA70 (parent_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'
- );
- $this->addSql(
- 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE'
- );
- $this->addSql(
- 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A613FECDF FOREIGN KEY (session_id) REFERENCES session (id) ON DELETE CASCADE'
- );
- $this->addSql(
- 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099AA977936C FOREIGN KEY (tree_root) REFERENCES c_wiki_category (id) ON DELETE CASCADE'
- );
- $this->addSql(
- 'ALTER TABLE c_wiki_category ADD CONSTRAINT FK_17F1099A727ACA70 FOREIGN KEY (parent_id) REFERENCES c_wiki_category (id) ON DELETE CASCADE'
- );
- }
-
- if (!$schema->hasTable('c_wiki_rel_category')) {
- $this->addSql(
- 'CREATE TABLE c_wiki_rel_category (wiki_id INT NOT NULL, category_id INT NOT NULL, INDEX IDX_AC88945BAA948DBE (wiki_id), INDEX IDX_AC88945B12469DE2 (category_id), PRIMARY KEY(wiki_id, category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'
- );
- $this->addSql(
- 'ALTER TABLE c_wiki_rel_category ADD CONSTRAINT FK_AC88945BAA948DBE FOREIGN KEY (wiki_id) REFERENCES c_wiki (iid) ON DELETE CASCADE'
- );
- $this->addSql(
- 'ALTER TABLE c_wiki_rel_category ADD CONSTRAINT FK_AC88945B12469DE2 FOREIGN KEY (category_id) REFERENCES c_wiki_category (id) ON DELETE CASCADE'
- );
- }
-
if (!$schema->hasTable('notification_event_rel_user')) {
- $this->addSql(
- 'CREATE TABLE notification_event_rel_user (id INT UNSIGNED AUTO_INCREMENT NOT NULL, event_id INT unsigned, user_id INT, INDEX FK_EVENT (event_id), INDEX FK_USER (user_id), PRIMARY KEY (id))'
- );
- $this->addSql(
- 'ALTER TABLE notification_event_rel_user ADD CONSTRAINT FK_EVENT FOREIGN KEY (event_id) REFERENCES notification_event (id) ON DELETE CASCADE'
- );
- $this->addSql(
- 'ALTER TABLE notification_event_rel_user ADD CONSTRAINT FK_USER FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE'
- );
- }
-
- if ($schema->hasTable('c_survey_answer')) {
- $this->addSql(
- 'ALTER TABLE c_survey_answer ADD session_id INT NOT NULL, ADD c_lp_item_id INT NOT NULL'
- );
- }
-
- if ($schema->hasTable('c_survey_invitation')) {
- $this->addSql(
- 'ALTER TABLE c_survey_invitation ADD c_lp_item_id INT NOT NULL'
- );
+ $this->addSql('CREATE TABLE notification_event_rel_user (
+ id INT UNSIGNED AUTO_INCREMENT NOT NULL,
+ event_id INT UNSIGNED,
+ user_id INT,
+ PRIMARY KEY (id)
+ )');
}
if (!$schema->hasTable('message_feedback')) {
@@ -175,64 +144,15 @@ final class Version20230216122950 extends AbstractMigrationChamilo
);
}
- if ($schema->hasTable('c_attendance_calendar')) {
- $this->addSql(
- 'ALTER TABLE c_attendance_calendar ADD blocked TINYINT(1) DEFAULT NULL'
- );
- }
-
- if ($schema->hasTable('c_attendance_sheet')) {
- $this->addSql(
- 'ALTER TABLE c_attendance_sheet ADD signature VARCHAR(255) DEFAULT NULL'
- );
- }
-
- if ($schema->hasTable('gradebook_category')) {
- $this->addSql(
- 'ALTER TABLE gradebook_category ADD allow_skills_by_subcategory INT DEFAULT 1'
- );
- }
-
- if ($schema->hasTable('c_quiz')) {
- $this->addSql(
- 'ALTER TABLE c_quiz ADD hide_attempts_table TINYINT(1) NOT NULL'
- );
- }
-
- if ($schema->hasTable('c_lp')) {
- $this->addSql(
- 'ALTER TABLE c_lp ADD next_lp_id INT DEFAULT 0 NOT NULL'
- );
- }
}
public function down(Schema $schema): void
{
- $table = $schema->getTable('c_lp');
- if ($table->hasColumn('next_lp_id')) {
- $this->addSql('ALTER TABLE c_lp DROP next_lp_id');
- }
-
- $table = $schema->getTable('c_quiz');
- if ($table->hasColumn('hide_attempts_table')) {
- $this->addSql('ALTER TABLE c_quiz DROP hide_attempts_table');
- }
-
$table = $schema->getTable('gradebook_category');
if ($table->hasColumn('allow_skills_by_subcategory')) {
$this->addSql('ALTER TABLE c_attendance_sheet DROP allow_skills_by_subcategory');
}
- $table = $schema->getTable('c_attendance_sheet');
- if ($table->hasColumn('signature')) {
- $this->addSql('ALTER TABLE c_attendance_sheet DROP signature');
- }
-
- $table = $schema->getTable('c_attendance_calendar');
- if ($table->hasColumn('blocked')) {
- $this->addSql('ALTER TABLE c_attendance_calendar DROP blocked');
- }
-
if ($schema->hasTable('c_attendance_result_comment')) {
$this->addSql(
'DROP TABLE c_attendance_result_comment'
@@ -274,37 +194,12 @@ final class Version20230216122950 extends AbstractMigrationChamilo
);
}
- $table = $schema->getTable('c_survey_answer');
- if ($table->hasColumn('session_id')) {
- $this->addSql('ALTER TABLE c_survey_answer DROP session_id');
- }
- if ($table->hasColumn('c_lp_item_id')) {
- $this->addSql('ALTER TABLE c_survey_answer DROP c_lp_item_id');
- }
-
- $table = $schema->getTable('c_survey_invitation');
- if ($table->hasColumn('c_lp_item_id')) {
- $this->addSql('ALTER TABLE c_survey_invitation DROP c_lp_item_id');
- }
-
if ($schema->hasTable('notification_event_rel_user')) {
$this->addSql(
'DROP TABLE notification_event_rel_user'
);
}
- if ($schema->hasTable('c_wiki_category')) {
- $this->addSql(
- 'DROP TABLE c_wiki_category'
- );
- }
-
- if ($schema->hasTable('c_wiki_rel_category')) {
- $this->addSql(
- 'DROP TABLE c_wiki_rel_category'
- );
- }
-
$table = $schema->getTable('system_template');
if ($table->hasColumn('language')) {
$this->addSql('ALTER TABLE system_template DROP language');
diff --git a/var/upload/.gitkeep b/var/upload/.gitkeep
old mode 100644
new mode 100755