Skip to content

Commit

Permalink
Upgrade: reorganized interactive upgrade screen
Browse files Browse the repository at this point in the history
--HG--
branch : 3.13
  • Loading branch information
adia committed Jun 29, 2022
1 parent 14c72cc commit 26f952d
Show file tree
Hide file tree
Showing 10 changed files with 793 additions and 990 deletions.
44 changes: 16 additions & 28 deletions include/main_lib.php
Expand Up @@ -2872,7 +2872,6 @@ function active_subdirs($base, $filename) {
/*
* Delete a directory and its whole content
*
* @author - Hugues Peeters
* @param - $dirPath (String) - the path of the directory to delete
* @return - boolean - true if the delete succeed, false otherwise.
*/
Expand All @@ -2886,38 +2885,27 @@ function removeDir($dirPath) {
return false;
}

/* Try to remove the directory. If it can not manage to remove it,
* it's probable the directory contains some files or other directories,
* and that we must first delete them to remove the original directory.
*/
if (@rmdir($dirPath)) {
// Try to remove the directory recursively if it exists
if (!file_exists($dirPath)) {
return true;
} else { // if directory couldn't be removed...
$ok = true;
$cwd = getcwd();
if (@chdir($dirPath)) {
$handle = opendir($dirPath);

while ($element = readdir($handle)) {
if ($element == '.' or $element == '..') {
continue; // skip current and parent directories
} elseif (is_file($element)) {
$ok = @unlink($element) && $ok;
} elseif (is_dir($element)) {
$dirToRemove[] = $dirPath . '/' . $element;
} else {
$files = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($dirPath,
RecursiveDirectoryIterator::SKIP_DOTS),
RecursiveIteratorIterator::CHILD_FIRST);
foreach ($files as $file) {
$filePath = $file->getRealPath();
if ($file->isDir()) {
if (!rmdir($filePath)) {
return false;
}
}

closedir($handle);
chdir($cwd);

if (isset($dirToRemove) and count($dirToRemove)) {
foreach ($dirToRemove as $j) {
$ok = removeDir($j) && $ok;
} else {
if (!unlink($filePath)) {
return false;
}
}
}
return @rmdir($dirPath) && $ok;
return rmdir($dirPath);
}
}

Expand Down
44 changes: 21 additions & 23 deletions install/install_db.php
Expand Up @@ -75,30 +75,30 @@
`module_id` int(11) NOT NULL,
PRIMARY KEY (`id`)) $tbl_options");

$db->query("CREATE TABLE IF NOT EXISTS`course_units_activities` (
`id` INT NOT NULL AUTO_INCREMENT ,
`course_code` VARCHAR(20) NOT NULL ,
`activity_id` VARCHAR(5) NOT NULL ,
`unit_id` INT NOT NULL ,
`tool_ids` TEXT NOT NULL ,
$db->query("CREATE TABLE IF NOT EXISTS`course_units_activities` (
`id` INT NOT NULL AUTO_INCREMENT ,
`course_code` VARCHAR(20) NOT NULL ,
`activity_id` VARCHAR(5) NOT NULL ,
`unit_id` INT NOT NULL ,
`tool_ids` TEXT NOT NULL ,
`activity_type` INT NOT NULL,
`visible` INT NOT NULL,
PRIMARY KEY (`id`)) $tbl_options");

$db->query("CREATE TABLE IF NOT EXISTS `course_class_info` (
`id` INT NOT NULL AUTO_INCREMENT ,
`student_number` VARCHAR(50) NOT NULL ,
`lessons_number` INT NOT NULL ,
`lesson_hours` INT NOT NULL ,
`home_hours` INT NOT NULL ,
`total_hours` INT NOT NULL ,
$db->query("CREATE TABLE IF NOT EXISTS `course_class_info` (
`id` INT NOT NULL AUTO_INCREMENT ,
`student_number` VARCHAR(50) NOT NULL ,
`lessons_number` INT NOT NULL ,
`lesson_hours` INT NOT NULL ,
`home_hours` INT NOT NULL ,
`total_hours` INT NOT NULL ,
`course_code` VARCHAR(20) NOT NULL,
PRIMARY KEY (`id`)) $tbl_options");

$db->query("CREATE TABLE `course_learning_objectives` (
`id` INT NOT NULL AUTO_INCREMENT ,
`course_code` VARCHAR(20) NOT NULL ,
`title` TEXT NOT NULL ,
$db->query("CREATE TABLE `course_learning_objectives` (
`id` INT NOT NULL AUTO_INCREMENT ,
`course_code` VARCHAR(20) NOT NULL ,
`title` TEXT NOT NULL ,
PRIMARY KEY (`id`)) $tbl_options");
// end of flipped classroom

Expand Down Expand Up @@ -1162,8 +1162,8 @@
`type` INT(11) DEFAULT 1,
`difficulty` INT(1) DEFAULT 0,
`category` INT(11) DEFAULT 0,
`copy_of_qid` INT(11) DEFAULT NULL,
CONSTRAINT FOREIGN KEY (copy_of_qid)
`copy_of_qid` INT(11) DEFAULT NULL,
CONSTRAINT FOREIGN KEY (copy_of_qid)
REFERENCES exercise_question(id) ON DELETE SET NULL) $tbl_options");

$db->query("CREATE TABLE IF NOT EXISTS `exercise_question_cats` (
Expand Down Expand Up @@ -1461,9 +1461,6 @@
$eclass_stud_reg = intval($eclass_stud_reg);
$eclass_prof_reg = intval($eclass_prof_reg);

$student_upload_whitelist = 'pdf, ps, eps, tex, latex, dvi, texinfo, texi, zip, rar, tar, bz2, gz, 7z, xz, lha, lzh, z, Z, doc, docx, odt, ods, ott, sxw, stw, fodt, txt, rtf, dot, mcw, wps, xls, xlsx, xlt, ods, ots, sxc, stc, fods, uos, csv, ppt, pps, pot, pptx, ppsx, odp, otp, sxi, sti, fodp, uop, potm, odg, otg, sxd, std, fodg, odb, mdb, ttf, otf, jpg, jpeg, png, gif, bmp, tif, tiff, psd, dia, svg, ppm, xbm, xpm, ico, avi, asf, asx, wm, wmv, wma, dv, mov, moov, movie, mp4, mpg, mpeg, 3gp, 3g2, m2v, aac, m4a, flv, f4v, m4v, mp3, swf, webm, ogv, ogg, mid, midi, aif, rm, rpm, ram, wav, mp2, m3u, qt, vsd, vss, vst, pptx, ppsx, zipx, gsp, xml, a3p, ypr, mw2, dtd, aia, hex, mscz, pages, heic, piv, stk';
$teacher_upload_whitelist = 'htm, html, js, css, xml, xsl, xsd, dtd, cpp, c, java, m, h, tcl, py, sgml, sgm, ini, ds_store, dtd, xsd, woff2, ppsm, aia, hex, jqz, jm, data, jar, glo, jqz, jm, data, jar, mscz, epub, djvu, heic, piv, stk';

$db->query("CREATE TABLE `config` (
`key` VARCHAR(32) NOT NULL,
`value` TEXT NOT NULL,
Expand Down Expand Up @@ -1540,6 +1537,7 @@
implode(', ', array_fill(0, count($default_config) / 2, '(?s, ?s)')), $default_config);

store_mail_config();
update_upload_whitelists();

// table for cron parameters
$db->query("CREATE TABLE `cron_params` (
Expand Down Expand Up @@ -1572,7 +1570,7 @@
`date` DATETIME NOT NULL,
`fc_type` INT(11) NOT NULL DEFAULT 3,
`activity_title` VARCHAR(50) NOT NULL DEFAULT '',
`activity_id` VARCHAR(5) NOT NULL DEFAULT 'FC000',
`activity_id` VARCHAR(5) NOT NULL DEFAULT 'FC000',
UNIQUE KEY `unit_resources_order` (`unit_id`,`order`)) $tbl_options");

$db->query("CREATE TABLE `actions_daily` (
Expand Down
6 changes: 5 additions & 1 deletion lang/el/messages.inc.php
Expand Up @@ -3825,7 +3825,8 @@
$langUpgAddress = "Διεύθυνση Ιδρύματος:";
$langUpgTel = "Τηλ. Επικοινωνίας:";
$langUpgReg = "Εγγραφή Χρηστών";
$langUpgForVersion = 'Αναβαθμίσεις έκδοσης: ';
$langUpgForVersion = 'Αναβαθμίσεις έκδοσης:';
$langAddDirectoryIndexes = 'Προσθήκη αρχείων index σε υποφακέλους για λόγους ασφαλείας';
$langTable = "Πίνακας";
$langToTable = "στον πίνακα";
$langAddField = "Προσθήκη πεδίου";
Expand Down Expand Up @@ -3872,6 +3873,9 @@
$langChangeDBEncoding = "Αλλαγή κωδικοποίησης της βάσης δεδομένων σε utf8mb4";
$langUpgradeDBInfoMessage = "Η αναβάθμιση της βάσης δεδομένων έχει ξεκινήσει.";
$langUpgradePopUpCloseWarning = "Προσοχή! Μην κλείσετε αυτό το παράθυρο γιατί θα διακοπεί η αναβάθμιση!";
$langUpgFinished = 'Ολοκληρώθηκε';
$langUpgUTF8MB4 = 'Μετατροπή πινάκων σε πλήρες εύρος Unicode';
$langPreviousVersion = 'Προηγούμενη έκδοση';

/* * *****************************************************************
* course_tools.php
Expand Down
3 changes: 3 additions & 0 deletions lang/en/messages.inc.php
Expand Up @@ -5524,3 +5524,6 @@
$langQuestionPreview = 'Preview of Question';
$langDumpPDF = 'Export in PDF format';
$langQuestionUsedInExercises = 'Used in this exercises';
$langAddDirectoryIndexes = 'Adding subdirectory index files to hinder directory traversal in misconfigured servers';
$langUpgFinished = 'Finished';
$langUpgUTF8MB4 = 'Converting database tables to support full Unicode range';
5 changes: 4 additions & 1 deletion modules/db/database.php
Expand Up @@ -365,8 +365,11 @@ private function queryImpl($statement, $isTransactional, $callback_fetch, $callb
}

/* Execute statement */
if (!$stm->execute())
try {
$stm->execute();
} catch (PDOException $e) {
return $this->errorFound($callback_error, $isTransactional, "Unable to execute statement", $stm->errorInfo(), $statement, $init_time, $backtrace_info);
}

/* fetch results */
$result = null;
Expand Down

0 comments on commit 26f952d

Please sign in to comment.