1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
converter_to_11.5.0.php
См. документацию.
1<?php
2 class CLearnInstall201203ConvertDBTimeOut extends Exception
3 {
4 }
5
6
8 {
9 }
10
11
13 {
14 const MODULE_ID = 'learning';
15 const OPTION_ID = '~LearnInstall201203ConvertDB::_IsAlreadyConverted'; // don't change this constant, NEVER!
19
24
25 public static $items_processed = 0;
26
27
28 public static function run()
29 {
30 global $DB;
31 $msg = $step = false;
32 $errorMessage = '';
33
34 // If data tables are not installed - nothing to do
35 if ( ! $DB->TableExists('b_learn_lesson') )
36 return ($errorMessage);
37
38 try
39 {
40 if ( ! self::IsNewRightsModelInitialized($step, $msg) )
41 {
43 $step = false;
44 if ( ! self::IsNewRightsModelInitialized($step, $msg) )
45 {
46 $errorMessage .= 'FAILED on step ' . $step . '; msg = ' . $msg . '.';
47 return ($errorMessage); // FATAL
48 }
49 }
50
54
58 }
60 {
62 $errorMessage .= "Cautch exception at line: " . $e->getLine()
63 . "; with message: " . $e->getMessage();
64 }
66 {
68 /*
69 $errorMessage .= "Timeout occured at line: " . $e->getLine()
70 . ". Convertation is incomplete and should be executed another time.";
71 */
72 $errorMessage .= '';
73 }
74 catch (Exception $e)
75 {
77 $errorMessage .= "Cautch general exception at line: " . $e->getLine()
78 . "; with message: " . $e->getMessage();
79 }
80
81 return ($errorMessage);
82 }
83
84
85 protected static function StartTransaction()
86 {
87 global $DB;
88
89 $DB->StartTransaction();
90 }
91
92
93 protected static function Rollback()
94 {
95 global $DB;
96
97 $DB->Rollback();
98 }
99
100
101 protected static function Commit()
102 {
103 global $DB;
104
105 $DB->Commit();
106 }
107
108
109 protected static function ReCreateTriggersForMSSQL()
110 {
111 }
112
113
114 protected static function _RightsModelGetTasksWithOperations()
115 {
116 $arTasksOperations = array(
117 'learning_lesson_access_denied' => array(),
118 'learning_lesson_access_read' => array(
119 'lesson_read'
120 ),
121 'learning_lesson_access_manage_basic' => array(
122 'lesson_read',
123 'lesson_create',
124 'lesson_write',
125 'lesson_remove'
126 ),
127 'learning_lesson_access_linkage_as_child' => array(
128 'lesson_read',
129 'lesson_link_to_parents',
130 'lesson_unlink_from_parents'
131 ),
132 'learning_lesson_access_linkage_as_parent' => array(
133 'lesson_read',
134 'lesson_link_descendants',
135 'lesson_unlink_descendants'
136 ),
137 'learning_lesson_access_linkage_any' => array(
138 'lesson_read',
139 'lesson_link_to_parents',
140 'lesson_unlink_from_parents',
141 'lesson_link_descendants',
142 'lesson_unlink_descendants'
143 ),
144 'learning_lesson_access_manage_as_child' => array(
145 'lesson_read',
146 'lesson_create',
147 'lesson_write',
148 'lesson_remove',
149 'lesson_link_to_parents',
150 'lesson_unlink_from_parents'
151 ),
152 'learning_lesson_access_manage_as_parent' => array(
153 'lesson_read',
154 'lesson_create',
155 'lesson_write',
156 'lesson_remove',
157 'lesson_link_descendants',
158 'lesson_unlink_descendants'
159 ),
160 'learning_lesson_access_manage_dual' => array(
161 'lesson_read',
162 'lesson_create',
163 'lesson_write',
164 'lesson_remove',
165 'lesson_link_to_parents',
166 'lesson_unlink_from_parents',
167 'lesson_link_descendants',
168 'lesson_unlink_descendants'
169 ),
170 'learning_lesson_access_manage_full' => array(
171 'lesson_read',
172 'lesson_create',
173 'lesson_write',
174 'lesson_remove',
175 'lesson_link_to_parents',
176 'lesson_unlink_from_parents',
177 'lesson_link_descendants',
178 'lesson_unlink_descendants',
179 'lesson_manage_rights'
180 )
181 );
182
183 return ($arTasksOperations);
184 }
185
186
187 protected static function _RightsModelGetAllOperations()
188 {
189 $arAllOperations = array(
190 'lesson_read',
191 'lesson_create',
192 'lesson_write',
193 'lesson_remove',
194 'lesson_link_to_parents',
195 'lesson_unlink_from_parents',
196 'lesson_link_descendants',
197 'lesson_unlink_descendants',
198 'lesson_manage_rights'
199 );
200
201 return ($arAllOperations);
202 }
203
204
208 protected static function _CheckOperationsInDB()
209 {
210 global $DB;
211
212 $arAllOperations = self::_RightsModelGetAllOperations();
213
214 $rc = $DB->Query ("SELECT ID, NAME, BINDING FROM b_operation WHERE MODULE_ID = 'learning'", true);
215
216 if ($rc === false)
217 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
218
219 $arOperationsInDB = array();
220 while ($arOperation = $rc->Fetch())
221 {
222 if (mb_substr($arOperation['NAME'], 0, 7) === 'lesson_')
223 $binding = 'lesson';
224 else
225 $binding = 'module';
226
227 if ($arOperation['BINDING'] !== $binding)
228 throw new Exception();
229
230 $arOperationsInDB[$arOperation['NAME']] = $arOperation['ID'];
231 }
232
233 if (count($arOperationsInDB) !== count($arAllOperations))
234 throw new Exception(); // not all operations in DB
235
236 foreach ($arAllOperations as $operationName)
237 {
238 if ( ! isset($arOperationsInDB[$operationName]) )
239 throw new Exception(); // not all operations in DB
240 }
241
242 return ($arOperationsInDB);
243 }
244
245
246 protected static function _CheckTasksInDB($arTasksOperations)
247 {
248 global $DB;
249
250 $rc = $DB->Query ("SELECT ID, NAME, BINDING FROM b_task WHERE MODULE_ID = 'learning'", true);
251
252 if ($rc === false)
253 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
254
255 $arTasksInDB = array();
256 while ($arTask = $rc->Fetch())
257 {
258 if (mb_substr($arTask['NAME'], 0, 16) === 'learning_lesson_')
259 $binding = 'lesson';
260 else
261 $binding = 'module';
262
263 if ($arTask['BINDING'] !== $binding)
264 throw new Exception();
265
266 $arTasksInDB[$arTask['NAME']] = $arTask['ID'];
267 }
268
269 if (count($arTasksInDB) !== count($arTasksOperations))
270 {
271 throw new Exception('count($arTasksInDB) = '
272 . count($arTasksInDB)
273 . '; count($arTasksOperations) = '
274 . count($arTasksOperations)); // not all tasks in DB
275 }
276
277 foreach (array_keys($arTasksOperations) as $taskName)
278 {
279 if ( ! isset($arTasksInDB[$taskName]) )
280 throw new Exception(); // not all tasks in DB
281 }
282
283 return ($arTasksInDB);
284 }
285
286
287 protected static function _CheckTasksOperationsRelations($arOperationsInDB, $arTasksInDB, $arTasksOperations)
288 {
289 global $DB;
290
291 foreach ($arTasksInDB as $taskName => $taskId)
292 {
293 if ( ! isset($arTasksOperations[$taskName]) )
294 throw new Exception();
295
296 $arCurTaskOperations = $arTasksOperations[$taskName];
297 $arCurTaskOperationsIDs = array();
298 foreach ($arCurTaskOperations as $operationName)
299 {
300 if ( ! isset($arOperationsInDB[$operationName]) )
301 throw new Exception();
302
303 $operationId = $arOperationsInDB[$operationName];
304
305 $arCurTaskOperationsIDs[$operationId] = 'operation';
306 }
307
308 // Get list of task's operations reltaions
309 $rc = $DB->Query ("SELECT OPERATION_ID FROM b_task_operation WHERE TASK_ID = " . ($taskId + 0), true);
310
311 if ($rc === false)
312 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
313
314
315
316 while ($arRelation = $rc->Fetch())
317 {
318 if ( ! isset($arCurTaskOperationsIDs[$arRelation['OPERATION_ID']]) )
319 throw new Exception();
320
321 unset ($arCurTaskOperationsIDs[$arRelation['OPERATION_ID']]);
322 }
323
324 if (count($arCurTaskOperationsIDs) > 0)
325 throw new Exception();
326 }
327 }
328
329
330 protected static function IsNewRightsModelInitialized(&$step, &$msg)
331 {
332 try
333 {
334 $arTasksOperations = self::_RightsModelGetTasksWithOperations();
335 // Compare list of operations in DB
336 $arOperationsInDB = self::_CheckOperationsInDB();
337
338 // Compare list of tasks in DB
339 $arTasksInDB = self::_CheckTasksInDB($arTasksOperations);
340
341 // Compare relations between tasks and operations
342 self::_CheckTasksOperationsRelations($arOperationsInDB, $arTasksInDB, $arTasksOperations);
343
344 return (true); // new rights model correctly initialized
345 }
346 catch (Exception $e)
347 {
348 $step = $e->getLine();
349 $msg = $e->getMessage();
350 return (false); // new rights model not initialized
351 }
352 }
353
354
355 protected static function _RightsModelCreateOperations()
356 {
357 global $DB;
358
359 $arAllOperations = self::_RightsModelGetAllOperations();
360
361 $arOperationsInDB = array();
362
363 foreach ($arAllOperations as $operationName)
364 {
365 if (mb_substr($operationName, 0, 7) === 'lesson_')
366 $binding = 'lesson';
367 else
368 $binding = 'module';
369
371 'NAME' => "'" . $DB->ForSql($operationName) . "'",
372 'MODULE_ID' => "'learning'",
373 'DESCRIPTION' => 'NULL',
374 'BINDING' => "'" . $binding . "'"
375 );
376
377 $id = $DB->Insert(
378 'b_operation',
379 $arFields,
380 "", // $error_position
381 false, // $debug
382 "", // $exist_id
383 false // don't ignore errors, due to the bug in Database::Insert (it don't checks Query return status)
384 );
385
386 if ($id === false)
387 throw new Exception();
388
389 $arOperationsInDB[$operationName] = $id;
390 }
391
392 return ($arOperationsInDB);
393 }
394
395
396 protected static function _RightsModelCreateTasksAndRelation($arOperationsInDB)
397 {
398 global $DB, $APPLICATION;
399
400 $arOld2NewRightsMatrix = array(
401 'D' => 'learning_lesson_access_read',
402 'W' => 'learning_lesson_access_manage_full'
403 );
404
405 $module_id = 'learning';
406
407 $arDefaultRights = array (
408 'learning_lesson_access_read' => array(),
409 'learning_lesson_access_manage_dual' => array('CR'), // Author
410 'learning_lesson_access_manage_full' => array('G1') // Admins
411 );
412
413 $rc = CGroup::GetList('sort', 'asc', array('ACTIVE' => 'Y'));
414 while($zr = $rc->Fetch())
415 {
416 $group_id = $zr['ID'];
417 $oldSymbol = $APPLICATION->GetGroupRight(
418 $module_id,
419 array($group_id),
420 $use_default_level = "N",
421 $max_right_for_super_admin = "N",
422 $site_id = false);
423
424 if (isset($arOld2NewRightsMatrix[$oldSymbol]))
425 {
426 $newSymbol = $arOld2NewRightsMatrix[$oldSymbol];
427 if (isset($arDefaultRights[$newSymbol]))
428 $arDefaultRights[$newSymbol][] = 'G' . $group_id;
429 }
430 }
431
432 $arTasksOperations = self::_RightsModelGetTasksWithOperations();
433
434 foreach ($arTasksOperations as $taskName => $arOperationsForTask)
435 {
436 if (mb_substr($taskName, 0, 16) === 'learning_lesson_')
437 $binding = 'lesson';
438 else
439 $binding = 'module';
440
442 'NAME' => "'" . $DB->ForSql($taskName) . "'",
443 'LETTER' => 'NULL',
444 'MODULE_ID' => "'learning'",
445 'SYS' => "'Y'",
446 'DESCRIPTION' => 'NULL',
447 'BINDING' => "'" . $binding . "'"
448 );
449
450 $taskId = $DB->Insert(
451 'b_task',
452 $arFields,
453 "", // $error_position
454 false, // $debug
455 "", // $exist_id
456 false // don't ignore errors, due to the bug in Database::Insert (it don't checks Query return status)
457 );
458
459 if ($taskId === false)
460 throw new Exception();
461
462 // Create relation for every operation per task
463 foreach ($arOperationsForTask as $operationName)
464 {
465 if ( ! isset($arOperationsInDB[$operationName]) )
466 throw new Exception();
467
468 $operationId = (int) $arOperationsInDB[$operationName];
469
470 $rc = $DB->Query(
471 "INSERT INTO b_task_operation (TASK_ID, OPERATION_ID)
472 VALUES (" . (int) $taskId . ", " . (int) $operationId . ")", true);
473
474 if ($rc === false)
475 throw new Exception();
476 }
477
478 // Add default rights for this task, if it exists
479 if ( array_key_exists($taskName, $arDefaultRights) )
480 {
481 $arDefaultRights[$taskName] = array_unique($arDefaultRights[$taskName]);
482 foreach ($arDefaultRights[$taskName] as $subject_id)
483 {
484 $DB->Query("DELETE FROM b_learn_rights_all
485 WHERE SUBJECT_ID = '" . $DB->ForSQL($subject_id) . "'");
486
487 $rc = $DB->Query (
488 "INSERT INTO b_learn_rights_all (SUBJECT_ID, TASK_ID)
489 VALUES ('" . $DB->ForSQL($subject_id) . "', " . (int) $taskId . ")",
490 true);
491
492 if ($rc === false)
493 throw new Exception();
494 }
495 }
496 }
497 }
498
499
500 protected static function _RightsModelPurge()
501 {
502 global $DB;
503
504 $arQueries = array(
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')",
508
509 "DELETE FROM b_operation
510 WHERE MODULE_ID = 'learning'",
511
512 "DELETE FROM b_task
513 WHERE MODULE_ID = 'learning'"
514 );
515
516 foreach ($arQueries as $key => $query)
517 {
518 $rc = $DB->Query($query, true); // ignore_errors = true
519 if ($rc === false)
520 throw new Exception ('EA_SQLERROR in query #' . $key);
521 }
522 }
523
524
525 protected static function InitializeNewRightsModel()
526 {
527 global $DB;
528
529 // Clean up learning module operations and tasks (if exists)
531
532 if ( ! $DB->TableExists('b_learn_rights_all') )
534
535 $arOperationsInDB = self::_RightsModelCreateOperations();
536
538 }
539
540
541 protected static function _CreateTblRightsAll ()
542 {
543 global $DB;
544
545 if ( ! $DB->TableExists('b_learn_rights_all') )
546 {
547 // Prepare sql code for adding fields
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 )
553 )";
554
555 $rc = $DB->Query($sql_tbl_b_learn_rights_all);
556 if ($rc === false)
557 throw new CLearnInstall201203ConvertDBException(__LINE__ . '/tbl: sql_tbl_b_learn_rights_all');
558 }
559 }
560
561
565 public static function ConvertDB(&$errorMessage)
566 {
567 global $DB;
568
569 self::$items_processed = 0;
570
571 // Check, was DB already converted?
572 if (self::_IsAlreadyConverted() === true)
573 return (true);
574
575 // Mark that db convert process started
576 $rc = COption::SetOptionString(self::MODULE_ID, self::OPTION_ID, self::STATUS_INSTALL_INCOMPLETE);
577 if ($rc === false)
578 throw new CLearnInstall201203ConvertDBException('SetOptionString() failed!');
579
580 // Create fields `CODE`, `WAS_CHAPTER_ID` in `b_learn_lesson` (if they doesn't exists yet)
581 // and `JOURNAL_STATUS` in `b_learn_chapter`
582 // and `LINKED_LESSON_ID` in `b_learn_course`
584
597
598 // Process courses
600
601 // Process chapters
602 self::$items_processed += self::_processChapters();
603
604 // Creates table for edges, if it doesn't exists yet.
606
607 // Build edges for lessons and chapters (`WAS_COURSE_ID` === NULL)
609
610 // Convert old permissions to new
612
613 // Add new path: COURSE_ID=#COURSE_ID#
614 // ?LESSON_PATH=#LESSON_PATH#
616
617 // Remove b_learn_course_permission, if exists
619
620 // Mark that db convert process complete
621 $rc = COption::SetOptionString(self::MODULE_ID, self::OPTION_ID, self::STATUS_INSTALL_COMPLETE);
622 if ($rc === false)
623 throw new CLearnInstall201203ConvertDBException('SetOptionString() failed!');
624 }
625
626
627 protected static function ConvertPermissions()
628 {
629 global $DB;
630
631 $arTaskIdByOldSymbol = array();
632 $arTasks = array(
633 'R' => 'learning_lesson_access_read',
634 'W' => 'learning_lesson_access_manage_basic',
635 'X' => 'learning_lesson_access_manage_full');
636
637 foreach ($arTasks as $oldSymbol => $taskName)
638 {
639 $rc = $DB->Query (
640 "SELECT ID
641 FROM b_task
642 WHERE NAME = '" . $taskName . "'",
643 true);
644
645 if ($rc === false)
646 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
647
648 $row = $rc->Fetch();
649
650 if ( ! isset($row['ID']) )
651 throw new CLearnInstall201203ConvertDBException('EA_LOGIC');
652
653 $arTaskIdByOldSymbol[$oldSymbol] = (int) $row['ID'];
654 }
655
656
657
658 $sql =
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'
665
666 UNION
667
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'
675 ";
676
677 $res = $DB->Query($sql, true);
678
679 if ($res === false)
680 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
681
682 while ($row = $res->Fetch())
683 {
684 $lessonId = $row['ID'];
685 $permission = $row['PERMISSION'];
686 $user_group_id = $row['USER_GROUP_ID'];
687
688 $group = 'G' . $user_group_id;
689
690 // Determine task id
691 if ( ! in_array($permission, array('R', 'W', 'X'), true) )
692 continue; // skip elements with D
693
694 $task_id = $arTaskIdByOldSymbol[$permission];
695
696 $rc = $DB->Query (
697 "DELETE FROM b_learn_rights
698 WHERE LESSON_ID = " . (int) $lessonId . "
699 AND SUBJECT_ID = '" . $DB->ForSql($group) . "'",
700 true);
701 if ($rc === false)
702 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
703
704
705 $rc = $DB->Query (
706 "INSERT INTO b_learn_rights (LESSON_ID, SUBJECT_ID, TASK_ID)
707 VALUES (" . (int) $lessonId . ", '" . $DB->ForSql($group) . "', '" . $task_id . "')", true);
708
709 if ($rc === false)
710 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
711 }
712
713 }
714
715
716 protected static function AddPath()
717 {
718 global $DB;
719
720 $res = $DB->Query(
721 "SELECT DISTINCT SITE_ID
722 FROM b_learn_site_path
723 WHERE 1=1", true);
724
725 if ($res === false)
726 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
727
728 $arSitesIds = array();
729 while ($row = $res->Fetch())
730 $arSitesIds[] = $row['SITE_ID'];
731
732 foreach ($arSitesIds as $k => $siteId)
733 {
734 $res = $DB->Query (
735 "DELETE FROM b_learn_site_path
736 WHERE SITE_ID = '" . $DB->ForSql($siteId) . "'
737 AND TYPE = 'U'", true);
738
739 if ($res === false)
740 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
741
742 $res = $DB->Query (
743 "SELECT TSP.PATH
744 FROM b_learn_site_path TSP
745 WHERE TYPE = 'C' AND SITE_ID = '" . $DB->ForSql($siteId) . "'",
746 true);
747
748 if ($res === false)
749 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
750
751 $row = $res->Fetch();
752 if (isset($row['PATH']))
753 {
754 $path = str_replace('COURSE_ID=#COURSE_ID#', 'LESSON_PATH=#LESSON_PATH#', $row['PATH']);
755 $path = str_replace('&INDEX=Y', '', $path);
756 }
757 else
758 $path = '/services/learning/course.php?LESSON_PATH=#LESSON_PATH#';
759
760 $DB->Insert(
761 'b_learn_site_path',
762 array(
763 'SITE_ID' => "'" . $DB->ForSql($siteId) . "'",
764 'PATH' => "'" . $DB->ForSql($path) . "'",
765 'TYPE' => "'U'"
766 )
767 );
768 }
769 }
770
774 public static function _buildEdges(&$errorMessage)
775 {
776 global $DB;
777
778 // For lessons, on which b_learn_course.LINKED_LESSON_ID linked we don't need edges, because they are tops nodes now.
779 $res = $DB->Query (
780 "SELECT ID, COURSE_ID, CHAPTER_ID, ACTIVE, SORT, WAS_CHAPTER_ID,
781 WAS_PARENT_CHAPTER_ID, WAS_PARENT_COURSE_ID
782 FROM b_learn_lesson
783 WHERE JOURNAL_STATUS != " . self::JOURNAL_STATUS_LESSON_EDGES_CREATED . "
784 AND WAS_COURSE_ID IS NULL",
785 $ignore_errors = true);
786
787 if ($res === false)
788 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
789
790 while ($arLesson = $res->Fetch())
791 {
792 $sort = $arLesson['SORT'];
793
794 $childNodeId = $arLesson['ID'];
795
796 // Determine, who is immediate parent of lesson - chapter or course
797 if ($arLesson['WAS_CHAPTER_ID'] === NULL) // current node wasn't a chapter
798 {
799 if ($arLesson['CHAPTER_ID'] !== NULL)
800 {
801 // intermediate parent is chapter, get it id in new data model
802 $parentNodeId = self::_GetChapterIdInNewDataModel ($arLesson['CHAPTER_ID']);
803 }
804 elseif ($arLesson['COURSE_ID'] !== NULL)
805 {
806 // intermediate parent is course, get it id in new data model
807 $parentNodeId = self::_GetCourseIdInNewDataModel ($arLesson['COURSE_ID']);
808 }
809 else
810 {
811 // No parent? It's very strange for old data model, but it's OK for new data model.
812 // So, nothing to do here.
813 $parentNodeId = NULL;
814 }
815 }
816 else // current node was a chapter
817 {
818 if ($arLesson['WAS_PARENT_CHAPTER_ID'] !== NULL)
819 {
820 // intermediate parent is chapter, get it id in new data model
821 $parentNodeId = self::_GetChapterIdInNewDataModel ($arLesson['WAS_PARENT_CHAPTER_ID']);
822 }
823 elseif ($arLesson['WAS_PARENT_COURSE_ID'] !== NULL)
824 {
825 // intermediate parent is course, get it id in new data model
826 $parentNodeId = self::_GetCourseIdInNewDataModel ($arLesson['WAS_PARENT_COURSE_ID']);
827 }
828 else
829 {
830 // No parent? It's very strange for old data model, but it's OK for new data model.
831 // So, nothing to do here.
832 $parentNodeId = NULL;
833 }
834 }
835
836 if ($parentNodeId === NULL)
837 ; // nothing to do
838 elseif ($parentNodeId === -1)
839 {
853 $errorMessage .= "Problem occured with CHAPTER_ID = " . $arLesson['CHAPTER_ID']
854 . "; COURSE_ID = " . $arLesson['COURSE_ID'] . "<br>\n";
855 }
856 elseif ($parentNodeId <= 0)
857 {
858 // This is invalid value
859 throw new CLearnInstall201203ConvertDBException('EA_OTHER: invalid parentNodeId for lesson_id = ' . $arLesson['ID']);
860 }
861 else
862 {
863 // All is OK, so create edge for nodes
864 self::_CreateEdgeForNodes ($parentNodeId, $childNodeId, $sort);
865 }
866
867 // Mark lesson as processed
868 self::_MarkLessonAsProcessed ($arLesson['ID']);
869
870 ++self::$items_processed;
871
872 // This function throws exception CLearnInstall201203ConvertDBTimeOut, if it's low time left.
874 }
875 }
876
877 public static function _MarkLessonAsProcessed ($lessonId)
878 {
879 global $DB;
880
881 // Mark this course as 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 = "",
886 $debug = false,
887 $ignore_errors = true
888 );
889
890 if ($rc === false)
891 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
892
893 }
894
895 public static function _CreateEdgeForNodes ($parentNodeId, $childNodeId, $sort)
896 {
897 global $DB;
898
899 $parentNodeId += 0;
900 $childNodeId += 0;
901
902 // Firstly, remove such edge, if exists
903 $rc = $DB->Query (
904 "DELETE FROM b_learn_lesson_edges
905 WHERE SOURCE_NODE = '" . $parentNodeId . "'
906 AND TARGET_NODE = '" . $childNodeId . "'",
907 $ignore_errors = true);
908
909 if ($rc === false)
910 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
911
912 // Now, create edge
913 $rc = $DB->Query (
914 "INSERT INTO b_learn_lesson_edges (SOURCE_NODE, TARGET_NODE, SORT)
915 VALUES ('" . $parentNodeId . "', '" . $childNodeId . "', '" . $sort . "')",
916 $ignore_errors = true);
917
918 if ($rc === false)
919 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
920 }
921
926 public static function _GetChapterIdInNewDataModel ($b_learn_chapter_ID)
927 {
928 global $DB;
929
930 $res = $DB->Query (
931 "SELECT ID FROM b_learn_lesson
932 WHERE WAS_CHAPTER_ID = '" . ($b_learn_chapter_ID + 0) . "'",
933 $ignore_errors = true);
934
935 if ($res === false)
936 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
937
938 if ($arLesson = $res->Fetch())
939 return ($arLesson['ID'] + 0);
940 else
941 return (-1);
942 }
943
948 public static function _GetCourseIdInNewDataModel ($b_learn_course_ID)
949 {
950 global $DB;
951
952 $res = $DB->Query (
953 "SELECT ID FROM b_learn_lesson
954 WHERE WAS_COURSE_ID = '" . ($b_learn_course_ID + 0) . "'",
955 $ignore_errors = true);
956
957 if ($res === false)
958 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
959
960 if ($arLesson = $res->Fetch())
961 return ($arLesson['ID'] + 0);
962 else
963 return (-1);
964 }
965
969 public static function _processCourses()
970 {
971 global $DB;
972
973 $res = $DB->Query ("SELECT * FROM b_learn_course WHERE JOURNAL_STATUS != " . self::JOURNAL_STATUS_COURSE_LINKED,
974 $ignore_errors = true);
975
976 if ($res === false)
977 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
978
979 while ($arCourses = $res->Fetch())
980 {
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'],
990 'LAUNCH' => '',
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']
998 );
999
1000 // Creates new lesson (unprocessed duplicates will be removed first)
1001 $id_of_new_lesson = self::_UnrepeatableCreateLesson ($arFields);
1002
1003 // Link course to this lesson
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 = "",
1008 $debug = false,
1009 $ignore_errors = true
1010 );
1011
1012 if ($rc === false)
1013 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
1014
1015 // Mark this course as processed
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 = "",
1020 $debug = false,
1021 $ignore_errors = true
1022 );
1023
1024 if ($rc === false)
1025 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
1026
1027 ++self::$items_processed;
1028
1029 // This function throws exception CLearnInstall201203ConvertDBTimeOut, if it's low time left.
1031 }
1032 }
1033
1037 public static function avoidTimeout()
1038 {
1039 static $started_at = false;
1040 static $time_limit = false;
1041
1042 if ($started_at === false)
1043 {
1044 $started_at = microtime (true);
1045
1046 $rc = ini_get('max_execution_time');
1047 if (($rc === false) || ($rc === '') || ($rc < 0))
1048 {
1049 // We fail to determine max_execution_time, try to set it
1050 set_time_limit (25);
1051
1052 // Ensure, that max_execution_time was set
1053 $rc = ini_get('max_execution_time');
1054 }
1055
1056 if (($rc === false) || ($rc === '') || ($rc < 0))
1057 {
1064 $time_limit = 25;
1065 }
1066 elseif ($rc == 0)
1067 {
1072 $time_limit = 20;
1073 }
1074 else
1075 {
1076 $time_limit = min(25, ($rc + 0));
1077 }
1078 }
1079
1080 $time_executed = microtime(true) - $started_at;
1081 $time_left = $time_limit - $time_executed;
1082
1083 if ($time_left < 4)
1085 }
1086
1087
1088 public static function _processChapters()
1089 {
1090 global $DB;
1091
1092 $res = $DB->Query ("SELECT * FROM b_learn_chapter WHERE JOURNAL_STATUS != " . self::JOURNAL_STATUS_CHAPTER_COPIED,
1093 $ignore_errors = true);
1094
1095 if ($res === false)
1096 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
1097
1098 while ($arChapter = $res->Fetch())
1099 {
1100 $arFields = array (
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'],
1111 'LAUNCH' => '',
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
1117 );
1118
1119 // Creates new lesson (unprocessed duplicates will be removed first)
1120 $id_of_new_lesson = self::_UnrepeatableCreateLesson ($arFields);
1121
1122 // Now we must replace QUESTIONS_FROM_ID (where now is $arChapter['ID'])
1123 // in b_learn_test for QUESTIONS_FROM=='H'. Replace them to QUESTIONS_FROM=''
1124
1125 // UPDATE b_learn_test SET QUESTIONS_FROM = 'R', QUESTIONS_FROM_ID = 150 WHERE QUESTIONS_FROM = 'H' AND QUESTIONS_FROM_ID = '1'
1126 $rc = $DB->Query(
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
1134 );
1135
1136 if ($rc === false)
1137 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
1138
1139 // Mark this chapter as processed
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 = "",
1144 $debug = false,
1145 $ignore_errors = true
1146 );
1147
1148 if ($rc === false)
1149 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
1150
1151 ++self::$items_processed;
1152
1153 // This function throws exception CLearnInstall201203ConvertDBTimeOut, if it's low time left.
1155 }
1156 }
1157
1163 public static function _UnrepeatableCreateLesson ($arFields)
1164 {
1165 global $DB;
1166
1167 if ( ! is_array($arFields) )
1168 throw new CLearnInstall201203ConvertDBException('EA_PARAMS');
1169
1170 if ( ! isset($arFields['COURSE_ID']) )
1171 $arFields['COURSE_ID'] = 0;
1172
1173 // Determine, from what source import doing (Chapter or Course)
1174 if (array_key_exists('WAS_CHAPTER_ID', $arFields)
1175 && ($arFields['WAS_CHAPTER_ID'] !== false)
1176 )
1177 {
1178 // new lesson will be created from chapter
1179 $sqlWhere = "WAS_CHAPTER_ID = '" . ($arFields['WAS_CHAPTER_ID'] + 0) . "'";
1180 }
1181 elseif (array_key_exists('WAS_COURSE_ID', $arFields)
1182 && ($arFields['WAS_COURSE_ID'] !== false)
1183 )
1184 {
1185 // new lesson will be created from chapter
1186 $sqlWhere = "WAS_COURSE_ID = '" . ($arFields['WAS_COURSE_ID'] + 0) . "'";
1187 }
1188 else
1189 {
1190 throw new CLearnInstall201203ConvertDBException('EA_PARAMS');
1191 }
1192
1193 // Firstly, remove such imported lesson, if exists
1194 $rc = $DB->Query ("DELETE FROM b_learn_lesson WHERE " . $sqlWhere, $ignore_errors = true);
1195 if ($rc === false)
1196 throw new CLearnInstall201203ConvertDBException('EA_SQLERROR');
1197
1198 $arFields['~TIMESTAMP_X'] = $DB->GetNowFunction();
1199 $arFields['~DATE_CREATE'] = $DB->GetNowFunction();
1200 $arFields['~CREATED_BY'] = '1';
1201
1202 $newLessonId = $DB->Add('b_learn_lesson', $arFields);
1203
1204 return ($newLessonId);
1205 }
1206
1218 public static function _IsAlreadyConverted()
1219 {
1220 $rc = (string) COption::GetOptionString(self::MODULE_ID, self::OPTION_ID, self::STATUS_INSTALL_NEVER_START, $site = '');
1221
1222 if ($rc === self::STATUS_INSTALL_NEVER_START)
1223 {
1224 global $DB;
1225
1226 if ($DB->TableExists('b_learn_lesson_edges')
1227 && $DB->TableExists('b_learn_rights_all')
1228 && ( ! $DB->TableExists('b_learn_course_permission') )
1229 )
1230 {
1231 // Mark that db convert process complete
1232 $rc = COption::SetOptionString(self::MODULE_ID, self::OPTION_ID, self::STATUS_INSTALL_COMPLETE);
1233 if ($rc === false)
1234 throw new CLearnInstall201203ConvertDBException('SetOptionString() failed!');
1235
1236 return (true);
1237 }
1238 else
1239 return (false);
1240 }
1241 elseif ($rc === self::STATUS_INSTALL_COMPLETE)
1242 return (true);
1243 elseif ($rc === self::STATUS_INSTALL_INCOMPLETE)
1244 return (false);
1245 else
1246 self::_GiveUp(__LINE__);
1247 }
1248
1249
1250 protected static function _RemoveOrphanedTables()
1251 {
1252 global $DB;
1253
1254 if ( ! $DB->TableExists('b_learn_course_permission') )
1255 return;
1256
1257 $rc = $DB->Query ("DROP TABLE b_learn_course_permission", true);
1258 if ($rc === false)
1259 throw new CLearnInstall201203ConvertDBException('Can\'t DROP `b_learn_course_permission` under database engine: mysql');
1260 }
1261
1262 public static function _CreateEdgesTbl()
1263 {
1264 global $DB;
1265
1266 if ($DB->TableExists('b_learn_lesson_edges'))
1267 return;
1268
1269 $sql
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 )
1275 )";
1276
1277 $rc = $DB->Query ($sql, $ignore_errors = true);
1278 if ($rc === false)
1279 throw new CLearnInstall201203ConvertDBException('Can\'t create `b_learn_lesson_edges` under database engine: mysql');
1280 }
1281
1282 public static function _CreateFieldsInTbls()
1283 {
1284 global $DB;
1285
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')
1290 );
1291
1292 $sql_add = array();
1293 $other_sql_skip_errors = array();
1294 $other_sql = array();
1295
1296 // Prepare sql code for adding fields
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'"
1305 );
1306
1307 $sql_add['b_learn_chapter'] = array (
1308 'JOURNAL_STATUS' => "ALTER TABLE b_learn_chapter ADD JOURNAL_STATUS INT NOT NULL DEFAULT '0'"
1309 );
1310
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'"
1314 );
1315
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 )
1322 )";
1323
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';
1328
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'";
1332
1333 $other_sql_skip_errors[] = "
1334 CREATE TABLE b_learn_publish_prohibition
1335 (
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 )
1339 )";
1340
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
1349 )";
1350
1351 if ( ! $DB->TableExists('b_learn_rights'))
1352 {
1353 $rc = $DB->Query($sql_tbl_b_learn_rights);
1354 if ($rc === false)
1355 throw new CLearnInstall201203ConvertDBException(__LINE__ . '/tbl: sql_tbl_b_learn_rights');
1356 }
1357
1358 foreach ($sql_add as $tableName => $sql_for_table)
1359 {
1360 // Add every field (if not exists yet) to table $tableName
1361 foreach ($sql_for_table as $fieldName => $sql)
1362 {
1363 if ( ! in_array($fieldName, $arTableFields[$tableName], true) )
1364 {
1365 $rc = $DB->Query($sql, $ignore_erros = true);
1366
1367 if ($rc === false)
1368 throw new CLearnInstall201203ConvertDBException(__LINE__.'/tbl:'.mb_strlen($fieldName));
1369 }
1370 }
1371 /*
1372
1373 !!! This does not work correctly (table's fields cache in Database class issue?)
1374 // Now, ensure, that fields was added really
1375 $arTableFields_after = $DB->GetTableFieldsList ($tableName);
1376 foreach ($sql_for_table as $fieldName => $sql)
1377 {
1378 if ( ! in_array($fieldName, $arTableFields_after, true) )
1379 self::_GiveUp(__LINE__ . '/tbl:' . strlen($fieldName));
1380 }
1381 */
1382 }
1383
1384 foreach ($other_sql_skip_errors as $sql)
1385 $rc = $DB->Query($sql, $ignore_erros = true);
1386
1387 foreach ($other_sql as $sql)
1388 {
1389 $rc = $DB->Query($sql, $ignore_erros = true);
1390 if ($rc === false)
1391 throw new CLearnInstall201203ConvertDBException(__LINE__ . '/sql:' . htmlspecialcharsbx($sql));
1392 }
1393
1394 // Drop cache
1395 $rc = $DB->DDL("SELECT * FROM b_learn_lesson WHERE 1=1", true);
1396 if ($rc === false)
1397 throw new CLearnInstall201203ConvertDBException(__LINE__ . ', on DDL\'s cache drop');
1398 }
1399
1400 /*
1401 public static function _RemoveFieldsFromLesson()
1402 {
1403 // ORACLE:
1404 // ALTER TABLE `b_learn_lesson` DROP COLUMN `JOURNAL_ID` ???
1405
1406 global $DB, $DBType;
1407
1408 $arTableFields = $DB->GetTableFieldsList (`b_learn_lesson`);
1409
1410 // Prepare sql code for removing fields
1411 $sql_add = array();
1412 if ($DBType === 'mysql')
1413 {
1414 $sql_add['JOURNAL_ID'] = "ALTER TABLE `b_learn_lesson` DROP `JOURNAL_ID`";
1415 }
1416 else
1417 {
1418 // TODO: do sql code for MSSQL and Oracle
1419
1420 self::_GiveUp ('SQL code not ready for: ' . $DBType);
1421 }
1422
1423 // Remove every field (if exists) from table b_learn_lesson
1424 foreach ($sql_add as $fieldName => $sql)
1425 {
1426 if ( in_array($fieldName, $arTableFields, true) )
1427 {
1428 $rc = $DB->Query($sql, $ignore_erros = true);
1429
1430 if ($rc === false)
1431 self::_GiveUp(__LINE__);
1432 }
1433 }
1434
1435 // Don't ensure, that fields was really removed, because it's not critical for us
1436 }
1437 */
1438
1439 public static function _GiveUp($msg = false)
1440 {
1441 if ($msg !== false)
1442 throw new Exception ('FATAL: ' . $msg);
1443 else
1444 throw new Exception ('Shit happens.');
1445 }
1446 }
1447
$path
Определения access_edit.php:21
global $APPLICATION
Определения include.php:80
$module_id
Определения options.php:6
static GetList($by='c_sort', $order='asc', $arFilter=[], $SHOW_USERS_AMOUNT="N")
Определения group.php:136
const STATUS_INSTALL_COMPLETE
Определения converter_to_11.5.0.php:16
const STATUS_INSTALL_NEVER_START
Определения converter_to_11.5.0.php:17
static _GiveUp($msg=false)
Определения converter_to_11.5.0.php:1439
static _MarkLessonAsProcessed($lessonId)
Определения converter_to_11.5.0.php:877
static InitializeNewRightsModel()
Определения converter_to_11.5.0.php:525
const JOURNAL_STATUS_UNPROCESSED
Определения converter_to_11.5.0.php:20
static _CreateEdgeForNodes($parentNodeId, $childNodeId, $sort)
Определения converter_to_11.5.0.php:895
static StartTransaction()
Определения converter_to_11.5.0.php:85
static _RemoveOrphanedTables()
Определения converter_to_11.5.0.php:1250
static ConvertPermissions()
Определения converter_to_11.5.0.php:627
const JOURNAL_STATUS_CHAPTER_COPIED
Определения converter_to_11.5.0.php:22
const JOURNAL_STATUS_LESSON_EDGES_CREATED
Определения converter_to_11.5.0.php:23
static _RightsModelGetAllOperations()
Определения converter_to_11.5.0.php:187
const STATUS_INSTALL_INCOMPLETE
Определения converter_to_11.5.0.php:18
static _RightsModelCreateOperations()
Определения converter_to_11.5.0.php:355
static _CheckTasksInDB($arTasksOperations)
Определения converter_to_11.5.0.php:246
const JOURNAL_STATUS_COURSE_LINKED
Определения converter_to_11.5.0.php:21
static _GetChapterIdInNewDataModel($b_learn_chapter_ID)
Определения converter_to_11.5.0.php:926
static ReCreateTriggersForMSSQL()
Определения converter_to_11.5.0.php:109
static _UnrepeatableCreateLesson($arFields)
Определения converter_to_11.5.0.php:1163
static _CheckOperationsInDB()
Определения converter_to_11.5.0.php:208
static _GetCourseIdInNewDataModel($b_learn_course_ID)
Определения converter_to_11.5.0.php:948
static _buildEdges(&$errorMessage)
Определения converter_to_11.5.0.php:774
static ConvertDB(&$errorMessage)
Определения converter_to_11.5.0.php:565
static _RightsModelCreateTasksAndRelation($arOperationsInDB)
Определения converter_to_11.5.0.php:396
static _CreateTblRightsAll()
Определения converter_to_11.5.0.php:541
static _RightsModelPurge()
Определения converter_to_11.5.0.php:500
static IsNewRightsModelInitialized(&$step, &$msg)
Определения converter_to_11.5.0.php:330
static _CreateFieldsInTbls()
Определения converter_to_11.5.0.php:1282
static _RightsModelGetTasksWithOperations()
Определения converter_to_11.5.0.php:114
static _CheckTasksOperationsRelations($arOperationsInDB, $arTasksInDB, $arTasksOperations)
Определения converter_to_11.5.0.php:287
static _IsAlreadyConverted()
Определения converter_to_11.5.0.php:1218
$arFields
Определения dblapprove.php:5
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$zr
Определения options.php:5
$query
Определения get_search.php:11
while($arParentIBlockProperty=$dbParentIBlockProperty->Fetch()) $errorMessage
global $DB
Определения cron_frame.php:29
$arTasks
Определения options.php:777
$siteId
Определения ajax.php:8
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения tools.php:2701
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
if(empty($signedUserToken)) $key
Определения quickway.php:257
</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."%"
Определения waybill.php:936
$site_id
Определения sonet_set_content_view.php:9
$k
Определения template_pdf.php:567
$site
Определения yandex_run.php:614