15 const OPTION_ID =
'~LearnInstall201203ConvertDB::_IsAlreadyConverted';
28 public static function run()
35 if ( !
$DB->TableExists(
'b_learn_lesson') )
40 if ( ! self::IsNewRightsModelInitialized($step, $msg) )
44 if ( ! self::IsNewRightsModelInitialized($step, $msg) )
46 $errorMessage .=
'FAILED on step ' . $step .
'; msg = ' . $msg .
'.';
63 .
"; with message: " . $e->getMessage();
77 $errorMessage .=
"Cautch general exception at line: " . $e->getLine()
78 .
"; with message: " . $e->getMessage();
89 $DB->StartTransaction();
116 $arTasksOperations =
array(
117 'learning_lesson_access_denied' =>
array(),
118 'learning_lesson_access_read' =>
array(
121 'learning_lesson_access_manage_basic' =>
array(
127 'learning_lesson_access_linkage_as_child' =>
array(
129 'lesson_link_to_parents',
130 'lesson_unlink_from_parents'
132 'learning_lesson_access_linkage_as_parent' =>
array(
134 'lesson_link_descendants',
135 'lesson_unlink_descendants'
137 'learning_lesson_access_linkage_any' =>
array(
139 'lesson_link_to_parents',
140 'lesson_unlink_from_parents',
141 'lesson_link_descendants',
142 'lesson_unlink_descendants'
144 'learning_lesson_access_manage_as_child' =>
array(
149 'lesson_link_to_parents',
150 'lesson_unlink_from_parents'
152 'learning_lesson_access_manage_as_parent' =>
array(
157 'lesson_link_descendants',
158 'lesson_unlink_descendants'
160 'learning_lesson_access_manage_dual' =>
array(
165 'lesson_link_to_parents',
166 'lesson_unlink_from_parents',
167 'lesson_link_descendants',
168 'lesson_unlink_descendants'
170 'learning_lesson_access_manage_full' =>
array(
175 'lesson_link_to_parents',
176 'lesson_unlink_from_parents',
177 'lesson_link_descendants',
178 'lesson_unlink_descendants',
179 'lesson_manage_rights'
183 return ($arTasksOperations);
189 $arAllOperations =
array(
194 'lesson_link_to_parents',
195 'lesson_unlink_from_parents',
196 'lesson_link_descendants',
197 'lesson_unlink_descendants',
198 'lesson_manage_rights'
201 return ($arAllOperations);
214 $rc =
$DB->Query (
"SELECT ID, NAME, BINDING FROM b_operation WHERE MODULE_ID = 'learning'",
true);
219 $arOperationsInDB =
array();
220 while ($arOperation = $rc->Fetch())
222 if (mb_substr($arOperation[
'NAME'], 0, 7) ===
'lesson_')
227 if ($arOperation[
'BINDING'] !== $binding)
228 throw new Exception();
230 $arOperationsInDB[$arOperation[
'NAME']] = $arOperation[
'ID'];
233 if (
count($arOperationsInDB) !==
count($arAllOperations))
234 throw new Exception();
236 foreach ($arAllOperations as $operationName)
238 if ( ! isset($arOperationsInDB[$operationName]) )
239 throw new Exception();
242 return ($arOperationsInDB);
250 $rc =
$DB->Query (
"SELECT ID, NAME, BINDING FROM b_task WHERE MODULE_ID = 'learning'",
true);
255 $arTasksInDB =
array();
256 while ($arTask = $rc->Fetch())
258 if (mb_substr($arTask[
'NAME'], 0, 16) ===
'learning_lesson_')
263 if ($arTask[
'BINDING'] !== $binding)
264 throw new Exception();
266 $arTasksInDB[$arTask[
'NAME']] = $arTask[
'ID'];
269 if (
count($arTasksInDB) !==
count($arTasksOperations))
271 throw new Exception(
'count($arTasksInDB) = '
272 .
count($arTasksInDB)
273 .
'; count($arTasksOperations) = '
274 .
count($arTasksOperations));
277 foreach (array_keys($arTasksOperations) as $taskName)
279 if ( ! isset($arTasksInDB[$taskName]) )
280 throw new Exception();
283 return ($arTasksInDB);
291 foreach ($arTasksInDB as $taskName => $taskId)
293 if ( ! isset($arTasksOperations[$taskName]) )
294 throw new Exception();
296 $arCurTaskOperations = $arTasksOperations[$taskName];
297 $arCurTaskOperationsIDs =
array();
298 foreach ($arCurTaskOperations as $operationName)
300 if ( ! isset($arOperationsInDB[$operationName]) )
301 throw new Exception();
303 $operationId = $arOperationsInDB[$operationName];
305 $arCurTaskOperationsIDs[$operationId] =
'operation';
309 $rc =
$DB->Query (
"SELECT OPERATION_ID FROM b_task_operation WHERE TASK_ID = " . ($taskId + 0),
true);
316 while ($arRelation = $rc->Fetch())
318 if ( ! isset($arCurTaskOperationsIDs[$arRelation[
'OPERATION_ID']]) )
319 throw new Exception();
321 unset ($arCurTaskOperationsIDs[$arRelation[
'OPERATION_ID']]);
324 if (
count($arCurTaskOperationsIDs) > 0)
325 throw new Exception();
348 $step = $e->getLine();
349 $msg = $e->getMessage();
361 $arOperationsInDB =
array();
363 foreach ($arAllOperations as $operationName)
365 if (mb_substr($operationName, 0, 7) ===
'lesson_')
371 'NAME' =>
"'" .
$DB->ForSql($operationName) .
"'",
372 'MODULE_ID' =>
"'learning'",
373 'DESCRIPTION' =>
'NULL',
374 'BINDING' =>
"'" . $binding .
"'"
387 throw new Exception();
389 $arOperationsInDB[$operationName] = $id;
392 return ($arOperationsInDB);
400 $arOld2NewRightsMatrix =
array(
401 'D' =>
'learning_lesson_access_read',
402 'W' =>
'learning_lesson_access_manage_full'
407 $arDefaultRights =
array (
408 'learning_lesson_access_read' =>
array(),
409 'learning_lesson_access_manage_dual' =>
array(
'CR'),
410 'learning_lesson_access_manage_full' =>
array(
'G1')
414 while(
$zr = $rc->Fetch())
416 $group_id =
$zr[
'ID'];
420 $use_default_level =
"N",
421 $max_right_for_super_admin =
"N",
424 if (isset($arOld2NewRightsMatrix[$oldSymbol]))
426 $newSymbol = $arOld2NewRightsMatrix[$oldSymbol];
427 if (isset($arDefaultRights[$newSymbol]))
428 $arDefaultRights[$newSymbol][] =
'G' . $group_id;
434 foreach ($arTasksOperations as $taskName => $arOperationsForTask)
436 if (mb_substr($taskName, 0, 16) ===
'learning_lesson_')
442 'NAME' =>
"'" .
$DB->ForSql($taskName) .
"'",
444 'MODULE_ID' =>
"'learning'",
446 'DESCRIPTION' =>
'NULL',
447 'BINDING' =>
"'" . $binding .
"'"
450 $taskId =
$DB->Insert(
459 if ($taskId ===
false)
460 throw new Exception();
463 foreach ($arOperationsForTask as $operationName)
465 if ( ! isset($arOperationsInDB[$operationName]) )
466 throw new Exception();
468 $operationId = (int) $arOperationsInDB[$operationName];
471 "INSERT INTO b_task_operation (TASK_ID, OPERATION_ID)
472 VALUES (" . (
int) $taskId .
", " . (
int) $operationId .
")",
true);
475 throw new Exception();
479 if ( array_key_exists($taskName, $arDefaultRights) )
481 $arDefaultRights[$taskName] = array_unique($arDefaultRights[$taskName]);
482 foreach ($arDefaultRights[$taskName] as $subject_id)
484 $DB->Query(
"DELETE FROM b_learn_rights_all
485 WHERE SUBJECT_ID = '" .
$DB->ForSQL($subject_id) .
"'");
488 "INSERT INTO b_learn_rights_all (SUBJECT_ID, TASK_ID)
489 VALUES ('" .
$DB->ForSQL($subject_id) .
"', " . (
int) $taskId .
")",
493 throw new Exception();
505 "DELETE FROM b_task_operation
506 WHERE TASK_ID IN (SELECT ID FROM b_task WHERE MODULE_ID = 'learning')
507 OR OPERATION_ID IN (SELECT ID FROM b_operation WHERE MODULE_ID = 'learning')",
509 "DELETE FROM b_operation
510 WHERE MODULE_ID = 'learning'",
513 WHERE MODULE_ID = 'learning'"
520 throw new Exception (
'EA_SQLERROR in query #' .
$key);
532 if ( !
$DB->TableExists(
'b_learn_rights_all') )
545 if ( !
$DB->TableExists(
'b_learn_rights_all') )
548 $sql_tbl_b_learn_rights_all =
"
549 CREATE TABLE b_learn_rights_all (
550 SUBJECT_ID VARCHAR( 100 ) NOT NULL ,
551 TASK_ID INT NOT NULL ,
552 PRIMARY KEY ( SUBJECT_ID )
555 $rc =
$DB->Query($sql_tbl_b_learn_rights_all);
569 self::$items_processed = 0;
572 if (self::_IsAlreadyConverted() ===
true)
576 $rc = COption::SetOptionString(self::MODULE_ID, self::OPTION_ID, self::STATUS_INSTALL_INCOMPLETE);
621 $rc = COption::SetOptionString(self::MODULE_ID, self::OPTION_ID, self::STATUS_INSTALL_COMPLETE);
631 $arTaskIdByOldSymbol =
array();
633 'R' =>
'learning_lesson_access_read',
634 'W' =>
'learning_lesson_access_manage_basic',
635 'X' =>
'learning_lesson_access_manage_full');
637 foreach (
$arTasks as $oldSymbol => $taskName)
642 WHERE NAME = '" . $taskName .
"'",
650 if ( ! isset($row[
'ID']) )
653 $arTaskIdByOldSymbol[$oldSymbol] = (int) $row[
'ID'];
659 "SELECT TLL.ID, TLCP.PERMISSION, TLCP.USER_GROUP_ID
660 FROM b_learn_lesson TLL
661 INNER JOIN b_learn_course_permission TLCP
662 ON TLL.COURSE_ID = TLCP.COURSE_ID
663 WHERE TLL.COURSE_ID > 0
664 AND TLCP.PERMISSION != 'D'
668 SELECT TLL.ID, TLCP.PERMISSION, TLCP.USER_GROUP_ID
669 FROM b_learn_lesson TLL
670 INNER JOIN b_learn_course_permission TLCP
671 ON TLL.WAS_COURSE_ID = TLCP.COURSE_ID
672 WHERE TLL.COURSE_ID = 0
673 AND TLL.WAS_COURSE_ID > 0
674 AND TLCP.PERMISSION != 'D'
682 while ($row =
$res->Fetch())
684 $lessonId = $row[
'ID'];
685 $permission = $row[
'PERMISSION'];
686 $user_group_id = $row[
'USER_GROUP_ID'];
688 $group =
'G' . $user_group_id;
691 if ( ! in_array($permission,
array(
'R',
'W',
'X'),
true) )
694 $task_id = $arTaskIdByOldSymbol[$permission];
697 "DELETE FROM b_learn_rights
698 WHERE LESSON_ID = " . (
int) $lessonId .
"
699 AND SUBJECT_ID = '" .
$DB->ForSql($group) .
"'",
706 "INSERT INTO b_learn_rights (LESSON_ID, SUBJECT_ID, TASK_ID)
707 VALUES (" . (
int) $lessonId .
", '" .
$DB->ForSql($group) .
"', '" . $task_id .
"')",
true);
721 "SELECT DISTINCT SITE_ID
722 FROM b_learn_site_path
728 $arSitesIds =
array();
729 while ($row =
$res->Fetch())
730 $arSitesIds[] = $row[
'SITE_ID'];
735 "DELETE FROM b_learn_site_path
736 WHERE SITE_ID = '" .
$DB->ForSql(
$siteId) .
"'
737 AND TYPE = 'U'",
true);
744 FROM b_learn_site_path TSP
745 WHERE TYPE = 'C' AND SITE_ID = '" .
$DB->ForSql(
$siteId) .
"'",
751 $row =
$res->Fetch();
752 if (isset($row[
'PATH']))
754 $path = str_replace(
'COURSE_ID=#COURSE_ID#',
'LESSON_PATH=#LESSON_PATH#', $row[
'PATH']);
758 $path =
'/services/learning/course.php?LESSON_PATH=#LESSON_PATH#';
763 'SITE_ID' =>
"'" .
$DB->ForSql(
$siteId) .
"'",
764 'PATH' =>
"'" .
$DB->ForSql(
$path) .
"'",
780 "SELECT ID, COURSE_ID, CHAPTER_ID, ACTIVE, SORT, WAS_CHAPTER_ID,
781 WAS_PARENT_CHAPTER_ID, WAS_PARENT_COURSE_ID
783 WHERE JOURNAL_STATUS != " . self::JOURNAL_STATUS_LESSON_EDGES_CREATED .
"
784 AND WAS_COURSE_ID IS NULL",
785 $ignore_errors =
true);
790 while ($arLesson =
$res->Fetch())
792 $sort = $arLesson[
'SORT'];
794 $childNodeId = $arLesson[
'ID'];
797 if ($arLesson[
'WAS_CHAPTER_ID'] === NULL)
799 if ($arLesson[
'CHAPTER_ID'] !== NULL)
804 elseif ($arLesson[
'COURSE_ID'] !== NULL)
813 $parentNodeId = NULL;
818 if ($arLesson[
'WAS_PARENT_CHAPTER_ID'] !== NULL)
823 elseif ($arLesson[
'WAS_PARENT_COURSE_ID'] !== NULL)
832 $parentNodeId = NULL;
836 if ($parentNodeId === NULL)
838 elseif ($parentNodeId === -1)
853 $errorMessage .=
"Problem occured with CHAPTER_ID = " . $arLesson[
'CHAPTER_ID']
854 .
"; COURSE_ID = " . $arLesson[
'COURSE_ID'] .
"<br>\n";
856 elseif ($parentNodeId <= 0)
870 ++self::$items_processed;
882 $rc =
$DB->Update(
'b_learn_lesson',
883 array (
'JOURNAL_STATUS' => self::JOURNAL_STATUS_LESSON_EDGES_CREATED),
884 "WHERE ID = '" . ($lessonId + 0) .
"'",
885 $error_position =
"",
887 $ignore_errors =
true
904 "DELETE FROM b_learn_lesson_edges
905 WHERE SOURCE_NODE = '" . $parentNodeId .
"'
906 AND TARGET_NODE = '" . $childNodeId .
"'",
907 $ignore_errors =
true);
914 "INSERT INTO b_learn_lesson_edges (SOURCE_NODE, TARGET_NODE, SORT)
915 VALUES ('" . $parentNodeId .
"', '" . $childNodeId .
"', '" . $sort .
"')",
916 $ignore_errors =
true);
931 "SELECT ID FROM b_learn_lesson
932 WHERE WAS_CHAPTER_ID = '" . ($b_learn_chapter_ID + 0) .
"'",
933 $ignore_errors =
true);
938 if ($arLesson =
$res->Fetch())
939 return ($arLesson[
'ID'] + 0);
953 "SELECT ID FROM b_learn_lesson
954 WHERE WAS_COURSE_ID = '" . ($b_learn_course_ID + 0) .
"'",
955 $ignore_errors =
true);
960 if ($arLesson =
$res->Fetch())
961 return ($arLesson[
'ID'] + 0);
973 $res =
$DB->Query (
"SELECT * FROM b_learn_course WHERE JOURNAL_STATUS != " . self::JOURNAL_STATUS_COURSE_LINKED,
974 $ignore_errors =
true);
979 while ($arCourses =
$res->Fetch())
982 'ACTIVE' => $arCourses[
'ACTIVE'],
983 'NAME' => ($arCourses[
'NAME'] === NULL) ?
false : $arCourses[
'NAME'],
984 'CODE' => ($arCourses[
'CODE'] === NULL) ?
false : $arCourses[
'CODE'],
985 'SORT' => $arCourses[
'SORT'],
986 'PREVIEW_PICTURE' => ($arCourses[
'PREVIEW_PICTURE'] === NULL) ?
false : $arCourses[
'PREVIEW_PICTURE'],
987 'DETAIL_PICTURE' => ($arCourses[
'PREVIEW_PICTURE'] === NULL) ?
false : $arCourses[
'PREVIEW_PICTURE'],
988 'PREVIEW_TEXT_TYPE' => $arCourses[
'PREVIEW_TEXT_TYPE'],
989 'DETAIL_TEXT_TYPE' => $arCourses[
'DESCRIPTION_TYPE'],
991 'JOURNAL_STATUS' => self::JOURNAL_STATUS_UNPROCESSED,
992 'WAS_CHAPTER_ID' =>
false,
993 'WAS_PARENT_CHAPTER_ID' =>
false,
994 'WAS_PARENT_COURSE_ID' =>
false,
995 'WAS_COURSE_ID' => $arCourses[
'ID'],
996 'PREVIEW_TEXT' => $arCourses[
'PREVIEW_TEXT'],
997 'DETAIL_TEXT' => $arCourses[
'DESCRIPTION']
1004 $rc =
$DB->Update (
'b_learn_course',
1005 array (
'LINKED_LESSON_ID' => $id_of_new_lesson),
1006 "WHERE ID = '" . ($arCourses[
'ID'] + 0) .
"'",
1007 $error_position =
"",
1009 $ignore_errors =
true
1016 $rc =
$DB->Update(
'b_learn_course',
1017 array (
'JOURNAL_STATUS' => self::JOURNAL_STATUS_COURSE_LINKED),
1018 "WHERE ID = '" . ($arCourses[
'ID'] + 0) .
"'",
1019 $error_position =
"",
1021 $ignore_errors =
true
1027 ++self::$items_processed;
1039 static $started_at =
false;
1040 static $time_limit =
false;
1042 if ($started_at ===
false)
1044 $started_at = microtime (
true);
1046 $rc = ini_get(
'max_execution_time');
1047 if (($rc ===
false) || ($rc ===
'') || ($rc < 0))
1050 set_time_limit (25);
1053 $rc = ini_get(
'max_execution_time');
1056 if (($rc ===
false) || ($rc ===
'') || ($rc < 0))
1076 $time_limit = min(25, ($rc + 0));
1080 $time_executed = microtime(
true) - $started_at;
1081 $time_left = $time_limit - $time_executed;
1092 $res =
$DB->Query (
"SELECT * FROM b_learn_chapter WHERE JOURNAL_STATUS != " . self::JOURNAL_STATUS_CHAPTER_COPIED,
1093 $ignore_errors =
true);
1098 while ($arChapter =
$res->Fetch())
1101 'ACTIVE' => $arChapter[
'ACTIVE'],
1102 'NAME' => ($arChapter[
'NAME'] === NULL) ?
false : $arChapter[
'NAME'],
1103 'CODE' => ($arChapter[
'CODE'] === NULL) ?
false : $arChapter[
'CODE'],
1104 'SORT' => (
string) (1000000 + (
int) $arChapter[
'SORT']),
1105 'PREVIEW_PICTURE' => ($arChapter[
'PREVIEW_PICTURE'] === NULL) ?
false : $arChapter[
'PREVIEW_PICTURE'],
1106 'PREVIEW_TEXT' => $arChapter[
'PREVIEW_TEXT'],
1107 'PREVIEW_TEXT_TYPE' => $arChapter[
'PREVIEW_TEXT_TYPE'],
1108 'DETAIL_PICTURE' => ($arChapter[
'DETAIL_PICTURE'] === NULL) ?
false : $arChapter[
'DETAIL_PICTURE'],
1109 'DETAIL_TEXT' => $arChapter[
'DETAIL_TEXT'],
1110 'DETAIL_TEXT_TYPE' => $arChapter[
'DETAIL_TEXT_TYPE'],
1112 'JOURNAL_STATUS' => self::JOURNAL_STATUS_UNPROCESSED,
1113 'WAS_CHAPTER_ID' => ($arChapter[
'ID']),
1114 'WAS_PARENT_CHAPTER_ID' => ($arChapter[
'CHAPTER_ID'] === NULL) ?
false : $arChapter[
'CHAPTER_ID'],
1115 'WAS_PARENT_COURSE_ID' => ($arChapter[
'COURSE_ID'] === NULL) ?
false : $arChapter[
'COURSE_ID'],
1116 'WAS_COURSE_ID' =>
false
1127 "UPDATE b_learn_test
1128 SET TIMESTAMP_X = " .
$DB->GetNowFunction()
1129 .
", QUESTIONS_FROM = 'R',
1130 QUESTIONS_FROM_ID = " . ($id_of_new_lesson + 0)
1131 .
" WHERE QUESTIONS_FROM = 'H'
1132 AND QUESTIONS_FROM_ID = '" . ($arChapter[
'ID'] + 0) .
"'",
1133 $ignore_errors =
true
1140 $rc =
$DB->Update(
'b_learn_chapter',
1141 array (
'JOURNAL_STATUS' => self::JOURNAL_STATUS_CHAPTER_COPIED),
1142 "WHERE ID = '" . ($arChapter[
'ID'] + 0) .
"'",
1143 $error_position =
"",
1145 $ignore_errors =
true
1151 ++self::$items_processed;
1174 if (array_key_exists(
'WAS_CHAPTER_ID',
$arFields)
1175 && (
$arFields[
'WAS_CHAPTER_ID'] !==
false)
1179 $sqlWhere =
"WAS_CHAPTER_ID = '" . (
$arFields[
'WAS_CHAPTER_ID'] + 0) .
"'";
1182 && (
$arFields[
'WAS_COURSE_ID'] !==
false)
1186 $sqlWhere =
"WAS_COURSE_ID = '" . (
$arFields[
'WAS_COURSE_ID'] + 0) .
"'";
1194 $rc =
$DB->Query (
"DELETE FROM b_learn_lesson WHERE " . $sqlWhere, $ignore_errors =
true);
1204 return ($newLessonId);
1220 $rc = (string) COption::GetOptionString(self::MODULE_ID, self::OPTION_ID, self::STATUS_INSTALL_NEVER_START,
$site =
'');
1222 if ($rc === self::STATUS_INSTALL_NEVER_START)
1226 if (
$DB->TableExists(
'b_learn_lesson_edges')
1227 &&
$DB->TableExists(
'b_learn_rights_all')
1228 && ( !
$DB->TableExists(
'b_learn_course_permission') )
1232 $rc = COption::SetOptionString(self::MODULE_ID, self::OPTION_ID, self::STATUS_INSTALL_COMPLETE);
1241 elseif ($rc === self::STATUS_INSTALL_COMPLETE)
1243 elseif ($rc === self::STATUS_INSTALL_INCOMPLETE)
1254 if ( !
$DB->TableExists(
'b_learn_course_permission') )
1257 $rc =
$DB->Query (
"DROP TABLE b_learn_course_permission",
true);
1266 if (
$DB->TableExists(
'b_learn_lesson_edges'))
1270 =
"CREATE TABLE b_learn_lesson_edges (
1271 SOURCE_NODE INT NOT NULL ,
1272 TARGET_NODE INT NOT NULL ,
1273 SORT INT NOT NULL DEFAULT '500',
1274 PRIMARY KEY ( SOURCE_NODE , TARGET_NODE )
1277 $rc =
$DB->Query ($sql, $ignore_errors =
true);
1286 $arTableFields =
array(
1287 'b_learn_lesson' =>
$DB->GetTableFieldsList (
'b_learn_lesson'),
1288 'b_learn_chapter' =>
$DB->GetTableFieldsList (
'b_learn_chapter'),
1289 'b_learn_course' =>
$DB->GetTableFieldsList (
'b_learn_course')
1293 $other_sql_skip_errors =
array();
1294 $other_sql =
array();
1297 $sql_add[
'b_learn_lesson'] =
array (
1298 'KEYWORDS' =>
"ALTER TABLE b_learn_lesson ADD KEYWORDS TEXT NOT NULL",
1299 'CODE' =>
"ALTER TABLE b_learn_lesson ADD CODE VARCHAR( 50 ) NULL DEFAULT NULL",
1300 'WAS_CHAPTER_ID' =>
"ALTER TABLE b_learn_lesson ADD WAS_CHAPTER_ID INT NULL DEFAULT NULL",
1301 'WAS_PARENT_CHAPTER_ID' =>
"ALTER TABLE b_learn_lesson ADD WAS_PARENT_CHAPTER_ID INT NULL DEFAULT NULL",
1302 'WAS_PARENT_COURSE_ID' =>
"ALTER TABLE b_learn_lesson ADD WAS_PARENT_COURSE_ID INT NULL DEFAULT NULL",
1303 'WAS_COURSE_ID' =>
"ALTER TABLE b_learn_lesson ADD WAS_COURSE_ID INT NULL DEFAULT NULL",
1304 'JOURNAL_STATUS' =>
"ALTER TABLE b_learn_lesson ADD JOURNAL_STATUS INT NOT NULL DEFAULT '0'"
1307 $sql_add[
'b_learn_chapter'] =
array (
1308 'JOURNAL_STATUS' =>
"ALTER TABLE b_learn_chapter ADD JOURNAL_STATUS INT NOT NULL DEFAULT '0'"
1311 $sql_add[
'b_learn_course'] =
array (
1312 'LINKED_LESSON_ID' =>
"ALTER TABLE b_learn_course ADD LINKED_LESSON_ID INT NULL DEFAULT NULL",
1313 'JOURNAL_STATUS' =>
"ALTER TABLE b_learn_course ADD JOURNAL_STATUS INT NOT NULL DEFAULT '0'"
1316 $sql_tbl_b_learn_rights =
"
1317 CREATE TABLE b_learn_rights (
1318 LESSON_ID INT UNSIGNED NOT NULL ,
1319 SUBJECT_ID VARCHAR( 100 ) NOT NULL ,
1320 TASK_ID INT NOT NULL ,
1321 PRIMARY KEY ( LESSON_ID , SUBJECT_ID )
1324 $other_sql_skip_errors[] =
'ALTER TABLE b_learn_lesson DROP FOREIGN KEY FK_B_LEARN_LESSON1';
1325 $other_sql_skip_errors[] =
'ALTER TABLE b_learn_lesson DROP FOREIGN KEY FK_B_LEARN_LESSON2';
1326 $other_sql_skip_errors[] =
'ALTER TABLE b_learn_chapter DROP FOREIGN KEY FK_B_LEARN_CHAPTER1';
1327 $other_sql_skip_errors[] =
'ALTER TABLE b_learn_chapter DROP FOREIGN KEY FK_B_LEARN_CHAPTER2';
1329 $other_sql_skip_errors[] =
"ALTER TABLE b_learn_course ALTER COLUMN NAME SET DEFAULT 'name'";
1330 $other_sql_skip_errors[] =
"ALTER TABLE b_learn_lesson ALTER COLUMN NAME SET DEFAULT 'name'";
1331 $other_sql_skip_errors[] =
"ALTER TABLE b_learn_lesson ALTER COLUMN COURSE_ID SET DEFAULT '0'";
1333 $other_sql_skip_errors[] =
"
1334 CREATE TABLE b_learn_publish_prohibition
1336 COURSE_LESSON_ID INT UNSIGNED NOT NULL ,
1337 PROHIBITED_LESSON_ID INT UNSIGNED NOT NULL ,
1338 PRIMARY KEY ( COURSE_LESSON_ID , PROHIBITED_LESSON_ID )
1341 $other_sql_skip_errors[] =
"
1342 CREATE TABLE b_learn_exceptions_log (
1343 DATE_REGISTERED datetime NOT NULL,
1344 CODE int(11) NOT NULL,
1345 MESSAGE text NOT NULL,
1346 FFILE text NOT NULL,
1347 LINE int(11) NOT NULL,
1348 BACKTRACE text NOT NULL
1351 if ( !
$DB->TableExists(
'b_learn_rights'))
1353 $rc =
$DB->Query($sql_tbl_b_learn_rights);
1358 foreach ($sql_add as $tableName => $sql_for_table)
1361 foreach ($sql_for_table as $fieldName => $sql)
1363 if ( ! in_array($fieldName, $arTableFields[$tableName],
true) )
1365 $rc =
$DB->Query($sql, $ignore_erros =
true);
1384 foreach ($other_sql_skip_errors as $sql)
1385 $rc =
$DB->Query($sql, $ignore_erros =
true);
1387 foreach ($other_sql as $sql)
1389 $rc =
$DB->Query($sql, $ignore_erros =
true);
1395 $rc =
$DB->DDL(
"SELECT * FROM b_learn_lesson WHERE 1=1",
true);
1442 throw new Exception (
'FATAL: ' . $msg);
1444 throw new Exception (
'Shit happens.');
static GetList($by='c_sort', $order='asc', $arFilter=[], $SHOW_USERS_AMOUNT="N")
const STATUS_INSTALL_COMPLETE
const STATUS_INSTALL_NEVER_START
static _GiveUp($msg=false)
static _MarkLessonAsProcessed($lessonId)
static InitializeNewRightsModel()
const JOURNAL_STATUS_UNPROCESSED
static _CreateEdgeForNodes($parentNodeId, $childNodeId, $sort)
static StartTransaction()
static _RemoveOrphanedTables()
static _processChapters()
static ConvertPermissions()
const JOURNAL_STATUS_CHAPTER_COPIED
const JOURNAL_STATUS_LESSON_EDGES_CREATED
static _RightsModelGetAllOperations()
const STATUS_INSTALL_INCOMPLETE
static _RightsModelCreateOperations()
static _CheckTasksInDB($arTasksOperations)
const JOURNAL_STATUS_COURSE_LINKED
static _GetChapterIdInNewDataModel($b_learn_chapter_ID)
static ReCreateTriggersForMSSQL()
static _UnrepeatableCreateLesson($arFields)
static _CheckOperationsInDB()
static _GetCourseIdInNewDataModel($b_learn_course_ID)
static _buildEdges(&$errorMessage)
static ConvertDB(&$errorMessage)
static _RightsModelCreateTasksAndRelation($arOperationsInDB)
static _CreateTblRightsAll()
static _RightsModelPurge()
static IsNewRightsModelInitialized(&$step, &$msg)
static _CreateFieldsInTbls()
static _RightsModelGetTasksWithOperations()
static _CheckTasksOperationsRelations($arOperationsInDB, $arTasksInDB, $arTasksOperations)
static _IsAlreadyConverted()
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
if(empty($signedUserToken)) $key
</p ></td >< td valign=top style='border-top:none;border-left:none;border-bottom:solid windowtext 1.0pt;border-right:solid windowtext 1.0pt;padding:0cm 2.0pt 0cm 2.0pt;height:9.0pt'>< p class=Normal align=center style='margin:0cm;margin-bottom:.0001pt;text-align:center;line-height:normal'>< a name=ТекстовоеПоле54 ></a ><?=($taxRate > count( $arTaxList) > 0) ? $taxRate."%"