@@ -365,815 +365,815 @@ discard block |
||
| 365 | 365 | } |
| 366 | 366 | |
| 367 | 367 | switch ($action) { |
| 368 | - case 'add_item': |
|
| 369 | - if (!$is_allowed_to_edit) { |
|
| 370 | - api_not_allowed(true); |
|
| 371 | - } |
|
| 372 | - if ($debug > 0) error_log('New LP - add item action triggered', 0); |
|
| 373 | - |
|
| 374 | - if (!$lp_found) { |
|
| 375 | - //check if the learnpath ID was defined, otherwise send back to list |
|
| 376 | - if ($debug > 0) error_log('New LP - No learnpath given for add item', 0); |
|
| 377 | - require 'lp_list.php'; |
|
| 378 | - } else { |
|
| 379 | - $_SESSION['refresh'] = 1; |
|
| 368 | + case 'add_item': |
|
| 369 | + if (!$is_allowed_to_edit) { |
|
| 370 | + api_not_allowed(true); |
|
| 371 | + } |
|
| 372 | + if ($debug > 0) error_log('New LP - add item action triggered', 0); |
|
| 380 | 373 | |
| 381 | - if (isset($_POST['submit_button']) && !empty($post_title)) { |
|
| 382 | - // If a title was sumbitted: |
|
| 374 | + if (!$lp_found) { |
|
| 375 | + //check if the learnpath ID was defined, otherwise send back to list |
|
| 376 | + if ($debug > 0) error_log('New LP - No learnpath given for add item', 0); |
|
| 377 | + require 'lp_list.php'; |
|
| 378 | + } else { |
|
| 379 | + $_SESSION['refresh'] = 1; |
|
| 383 | 380 | |
| 384 | - //Updating the lp.modified_on |
|
| 385 | - $_SESSION['oLP']->set_modified_on(); |
|
| 381 | + if (isset($_POST['submit_button']) && !empty($post_title)) { |
|
| 382 | + // If a title was sumbitted: |
|
| 386 | 383 | |
| 387 | - if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_POST['post_time']) { |
|
| 388 | - // Check post_time to ensure ??? (counter-hacking measure?) |
|
| 389 | - require 'lp_add_item.php'; |
|
| 390 | - } else { |
|
| 384 | + //Updating the lp.modified_on |
|
| 385 | + $_SESSION['oLP']->set_modified_on(); |
|
| 391 | 386 | |
| 392 | - $_SESSION['post_time'] = $_POST['post_time']; |
|
| 387 | + if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_POST['post_time']) { |
|
| 388 | + // Check post_time to ensure ??? (counter-hacking measure?) |
|
| 389 | + require 'lp_add_item.php'; |
|
| 390 | + } else { |
|
| 393 | 391 | |
| 394 | - $parent = isset($_POST['parent']) ? $_POST['parent'] : ''; |
|
| 395 | - $previous = isset($_POST['previous']) ? $_POST['previous'] : ''; |
|
| 396 | - $type = isset($_POST['type']) ? $_POST['type'] : ''; |
|
| 397 | - $path = isset($_POST['path']) ? $_POST['path'] : ''; |
|
| 398 | - $description = isset($_POST['description']) ? $_POST['description'] : ''; |
|
| 399 | - $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : ''; |
|
| 400 | - $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : ''; |
|
| 392 | + $_SESSION['post_time'] = $_POST['post_time']; |
|
| 393 | + |
|
| 394 | + $parent = isset($_POST['parent']) ? $_POST['parent'] : ''; |
|
| 395 | + $previous = isset($_POST['previous']) ? $_POST['previous'] : ''; |
|
| 396 | + $type = isset($_POST['type']) ? $_POST['type'] : ''; |
|
| 397 | + $path = isset($_POST['path']) ? $_POST['path'] : ''; |
|
| 398 | + $description = isset($_POST['description']) ? $_POST['description'] : ''; |
|
| 399 | + $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : ''; |
|
| 400 | + $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : ''; |
|
| 401 | + |
|
| 402 | + if ($_POST['type'] == TOOL_DOCUMENT) { |
|
| 403 | + if (isset($_POST['path']) && $_GET['edit'] != 'true') { |
|
| 404 | + $document_id = $_POST['path']; |
|
| 405 | + } else { |
|
| 406 | + if ($_POST['content_lp']) { |
|
| 407 | + $document_id = $_SESSION['oLP']->create_document( |
|
| 408 | + $_course, |
|
| 409 | + $_POST['content_lp'], |
|
| 410 | + $_POST['title'] |
|
| 411 | + ); |
|
| 412 | + } |
|
| 413 | + } |
|
| 401 | 414 | |
| 402 | - if ($_POST['type'] == TOOL_DOCUMENT) { |
|
| 403 | - if (isset($_POST['path']) && $_GET['edit'] != 'true') { |
|
| 404 | - $document_id = $_POST['path']; |
|
| 415 | + $new_item_id = $_SESSION['oLP']->add_item( |
|
| 416 | + $parent, |
|
| 417 | + $previous, |
|
| 418 | + $type, |
|
| 419 | + $document_id, |
|
| 420 | + $post_title, |
|
| 421 | + $description, |
|
| 422 | + $prerequisites |
|
| 423 | + ); |
|
| 405 | 424 | } else { |
| 406 | - if ($_POST['content_lp']) { |
|
| 407 | - $document_id = $_SESSION['oLP']->create_document( |
|
| 408 | - $_course, |
|
| 409 | - $_POST['content_lp'], |
|
| 410 | - $_POST['title'] |
|
| 411 | - ); |
|
| 412 | - } |
|
| 425 | + // For all other item types than documents, load the item using the item type and path rather than its ID. |
|
| 426 | + $new_item_id = $_SESSION['oLP']->add_item( |
|
| 427 | + $parent, |
|
| 428 | + $previous, |
|
| 429 | + $type, |
|
| 430 | + $path, |
|
| 431 | + $post_title, |
|
| 432 | + $description, |
|
| 433 | + $prerequisites, |
|
| 434 | + $maxTimeAllowed |
|
| 435 | + ); |
|
| 413 | 436 | } |
| 414 | - |
|
| 415 | - $new_item_id = $_SESSION['oLP']->add_item( |
|
| 416 | - $parent, |
|
| 417 | - $previous, |
|
| 418 | - $type, |
|
| 419 | - $document_id, |
|
| 420 | - $post_title, |
|
| 421 | - $description, |
|
| 422 | - $prerequisites |
|
| 423 | - ); |
|
| 424 | - } else { |
|
| 425 | - // For all other item types than documents, load the item using the item type and path rather than its ID. |
|
| 426 | - $new_item_id = $_SESSION['oLP']->add_item( |
|
| 427 | - $parent, |
|
| 428 | - $previous, |
|
| 429 | - $type, |
|
| 430 | - $path, |
|
| 431 | - $post_title, |
|
| 432 | - $description, |
|
| 433 | - $prerequisites, |
|
| 434 | - $maxTimeAllowed |
|
| 435 | - ); |
|
| 437 | + $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id); |
|
| 438 | + header('Location: '.$url); |
|
| 439 | + exit; |
|
| 436 | 440 | } |
| 437 | - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id); |
|
| 438 | - header('Location: '.$url); |
|
| 439 | - exit; |
|
| 441 | + } else { |
|
| 442 | + require 'lp_add_item.php'; |
|
| 440 | 443 | } |
| 441 | - } else { |
|
| 442 | - require 'lp_add_item.php'; |
|
| 443 | 444 | } |
| 444 | - } |
|
| 445 | - break; |
|
| 446 | - case 'add_audio': |
|
| 447 | - if (!$is_allowed_to_edit) { |
|
| 448 | - api_not_allowed(true); |
|
| 449 | - } |
|
| 450 | - if ($debug > 0) error_log('New LP - add audio action triggered', 0); |
|
| 451 | - |
|
| 452 | - if (!$lp_found) { |
|
| 453 | - //check if the learnpath ID was defined, otherwise send back to list |
|
| 454 | - if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0); |
|
| 455 | - require 'lp_list.php'; |
|
| 456 | - } else { |
|
| 457 | - $_SESSION['refresh'] = 1; |
|
| 458 | - |
|
| 459 | - if (isset($_REQUEST['id'])) { |
|
| 460 | - $lp_item_obj = new learnpathItem($_REQUEST['id']); |
|
| 445 | + break; |
|
| 446 | + case 'add_audio': |
|
| 447 | + if (!$is_allowed_to_edit) { |
|
| 448 | + api_not_allowed(true); |
|
| 449 | + } |
|
| 450 | + if ($debug > 0) error_log('New LP - add audio action triggered', 0); |
|
| 461 | 451 | |
| 462 | - // Remove audio |
|
| 463 | - if (isset($_GET['delete_file']) && $_GET['delete_file'] == 1) { |
|
| 464 | - $lp_item_obj->remove_audio(); |
|
| 452 | + if (!$lp_found) { |
|
| 453 | + //check if the learnpath ID was defined, otherwise send back to list |
|
| 454 | + if ($debug > 0) error_log('New LP - No learnpath given for add audio', 0); |
|
| 455 | + require 'lp_list.php'; |
|
| 456 | + } else { |
|
| 457 | + $_SESSION['refresh'] = 1; |
|
| 465 | 458 | |
| 466 | - $url = api_get_self().'?action=add_audio&lp_id='.intval($_SESSION['oLP']->lp_id).'&id='.$lp_item_obj->get_id().'&'.api_get_cidreq(); |
|
| 467 | - header('Location: '.$url); |
|
| 468 | - exit; |
|
| 469 | - } |
|
| 459 | + if (isset($_REQUEST['id'])) { |
|
| 460 | + $lp_item_obj = new learnpathItem($_REQUEST['id']); |
|
| 470 | 461 | |
| 471 | - // Upload audio |
|
| 472 | - if (isset($_FILES['file']) && !empty($_FILES['file'])) { |
|
| 473 | - // Updating the lp.modified_on |
|
| 474 | - $_SESSION['oLP']->set_modified_on(); |
|
| 475 | - $lp_item_obj->add_audio(); |
|
| 476 | - } |
|
| 462 | + // Remove audio |
|
| 463 | + if (isset($_GET['delete_file']) && $_GET['delete_file'] == 1) { |
|
| 464 | + $lp_item_obj->remove_audio(); |
|
| 477 | 465 | |
| 478 | - //Add audio file from documents |
|
| 479 | - if (isset($_REQUEST['document_id']) && !empty($_REQUEST['document_id'])) { |
|
| 480 | - $_SESSION['oLP']->set_modified_on(); |
|
| 481 | - $lp_item_obj->add_audio_from_documents($_REQUEST['document_id']); |
|
| 482 | - } |
|
| 466 | + $url = api_get_self().'?action=add_audio&lp_id='.intval($_SESSION['oLP']->lp_id).'&id='.$lp_item_obj->get_id().'&'.api_get_cidreq(); |
|
| 467 | + header('Location: '.$url); |
|
| 468 | + exit; |
|
| 469 | + } |
|
| 483 | 470 | |
| 484 | - // Display. |
|
| 485 | - require 'lp_add_audio.php'; |
|
| 486 | - } else { |
|
| 487 | - require 'lp_add_audio.php'; |
|
| 488 | - } |
|
| 489 | - } |
|
| 490 | - break; |
|
| 491 | - case 'add_lp_category': |
|
| 492 | - if (!$is_allowed_to_edit) { |
|
| 493 | - api_not_allowed(true); |
|
| 494 | - } |
|
| 495 | - require 'lp_add_category.php'; |
|
| 496 | - break; |
|
| 497 | - case 'move_up_category': |
|
| 498 | - if (!$is_allowed_to_edit) { |
|
| 499 | - api_not_allowed(true); |
|
| 500 | - } |
|
| 501 | - if (isset($_REQUEST['id'])) { |
|
| 502 | - learnpath::moveUpCategory($_REQUEST['id']); |
|
| 503 | - } |
|
| 504 | - require 'lp_list.php'; |
|
| 505 | - break; |
|
| 506 | - case 'move_down_category': |
|
| 507 | - if (!$is_allowed_to_edit) { |
|
| 508 | - api_not_allowed(true); |
|
| 509 | - } |
|
| 510 | - if (isset($_REQUEST['id'])) { |
|
| 511 | - learnpath::moveDownCategory($_REQUEST['id']); |
|
| 512 | - } |
|
| 513 | - require 'lp_list.php'; |
|
| 514 | - break; |
|
| 515 | - case 'delete_lp_category': |
|
| 516 | - if (!$is_allowed_to_edit) { |
|
| 517 | - api_not_allowed(true); |
|
| 518 | - } |
|
| 519 | - if (isset($_REQUEST['id'])) { |
|
| 520 | - learnpath::deleteCategory($_REQUEST['id']); |
|
| 521 | - } |
|
| 522 | - require 'lp_list.php'; |
|
| 523 | - break; |
|
| 524 | - case 'add_lp': |
|
| 525 | - if (!$is_allowed_to_edit) { |
|
| 526 | - api_not_allowed(true); |
|
| 527 | - } |
|
| 528 | - if ($debug > 0) error_log('New LP - add_lp action triggered', 0); |
|
| 529 | - if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) { |
|
| 530 | - $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']); |
|
| 531 | - $_SESSION['refresh'] = 1; |
|
| 471 | + // Upload audio |
|
| 472 | + if (isset($_FILES['file']) && !empty($_FILES['file'])) { |
|
| 473 | + // Updating the lp.modified_on |
|
| 474 | + $_SESSION['oLP']->set_modified_on(); |
|
| 475 | + $lp_item_obj->add_audio(); |
|
| 476 | + } |
|
| 532 | 477 | |
| 533 | - if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_REQUEST['post_time']) { |
|
| 534 | - require 'lp_add.php'; |
|
| 535 | - } else { |
|
| 536 | - $_SESSION['post_time'] = $_REQUEST['post_time']; |
|
| 478 | + //Add audio file from documents |
|
| 479 | + if (isset($_REQUEST['document_id']) && !empty($_REQUEST['document_id'])) { |
|
| 480 | + $_SESSION['oLP']->set_modified_on(); |
|
| 481 | + $lp_item_obj->add_audio_from_documents($_REQUEST['document_id']); |
|
| 482 | + } |
|
| 537 | 483 | |
| 538 | - if (isset($_REQUEST['activate_start_date_check']) && |
|
| 539 | - $_REQUEST['activate_start_date_check'] == 1 |
|
| 540 | - ) { |
|
| 541 | - $publicated_on = $_REQUEST['publicated_on']; |
|
| 484 | + // Display. |
|
| 485 | + require 'lp_add_audio.php'; |
|
| 542 | 486 | } else { |
| 543 | - $publicated_on = null; |
|
| 487 | + require 'lp_add_audio.php'; |
|
| 544 | 488 | } |
| 489 | + } |
|
| 490 | + break; |
|
| 491 | + case 'add_lp_category': |
|
| 492 | + if (!$is_allowed_to_edit) { |
|
| 493 | + api_not_allowed(true); |
|
| 494 | + } |
|
| 495 | + require 'lp_add_category.php'; |
|
| 496 | + break; |
|
| 497 | + case 'move_up_category': |
|
| 498 | + if (!$is_allowed_to_edit) { |
|
| 499 | + api_not_allowed(true); |
|
| 500 | + } |
|
| 501 | + if (isset($_REQUEST['id'])) { |
|
| 502 | + learnpath::moveUpCategory($_REQUEST['id']); |
|
| 503 | + } |
|
| 504 | + require 'lp_list.php'; |
|
| 505 | + break; |
|
| 506 | + case 'move_down_category': |
|
| 507 | + if (!$is_allowed_to_edit) { |
|
| 508 | + api_not_allowed(true); |
|
| 509 | + } |
|
| 510 | + if (isset($_REQUEST['id'])) { |
|
| 511 | + learnpath::moveDownCategory($_REQUEST['id']); |
|
| 512 | + } |
|
| 513 | + require 'lp_list.php'; |
|
| 514 | + break; |
|
| 515 | + case 'delete_lp_category': |
|
| 516 | + if (!$is_allowed_to_edit) { |
|
| 517 | + api_not_allowed(true); |
|
| 518 | + } |
|
| 519 | + if (isset($_REQUEST['id'])) { |
|
| 520 | + learnpath::deleteCategory($_REQUEST['id']); |
|
| 521 | + } |
|
| 522 | + require 'lp_list.php'; |
|
| 523 | + break; |
|
| 524 | + case 'add_lp': |
|
| 525 | + if (!$is_allowed_to_edit) { |
|
| 526 | + api_not_allowed(true); |
|
| 527 | + } |
|
| 528 | + if ($debug > 0) error_log('New LP - add_lp action triggered', 0); |
|
| 529 | + if (isset($_REQUEST['lp_name']) && !empty($_REQUEST['lp_name'])) { |
|
| 530 | + $_REQUEST['lp_name'] = trim($_REQUEST['lp_name']); |
|
| 531 | + $_SESSION['refresh'] = 1; |
|
| 545 | 532 | |
| 546 | - if (isset($_REQUEST['activate_end_date_check']) && |
|
| 547 | - $_REQUEST['activate_end_date_check'] == 1 |
|
| 548 | - ) { |
|
| 549 | - $expired_on = $_REQUEST['expired_on']; |
|
| 533 | + if (isset($_SESSION['post_time']) && $_SESSION['post_time'] == $_REQUEST['post_time']) { |
|
| 534 | + require 'lp_add.php'; |
|
| 550 | 535 | } else { |
| 551 | - $expired_on = null; |
|
| 552 | - } |
|
| 536 | + $_SESSION['post_time'] = $_REQUEST['post_time']; |
|
| 553 | 537 | |
| 554 | - $new_lp_id = learnpath::add_lp( |
|
| 555 | - api_get_course_id(), |
|
| 556 | - Security::remove_XSS($_REQUEST['lp_name']), |
|
| 557 | - '', |
|
| 558 | - 'chamilo', |
|
| 559 | - 'manual', |
|
| 560 | - '', |
|
| 561 | - $publicated_on, |
|
| 562 | - $expired_on, |
|
| 563 | - $_REQUEST['category_id'] |
|
| 564 | - ); |
|
| 538 | + if (isset($_REQUEST['activate_start_date_check']) && |
|
| 539 | + $_REQUEST['activate_start_date_check'] == 1 |
|
| 540 | + ) { |
|
| 541 | + $publicated_on = $_REQUEST['publicated_on']; |
|
| 542 | + } else { |
|
| 543 | + $publicated_on = null; |
|
| 544 | + } |
|
| 565 | 545 | |
| 566 | - if (is_numeric($new_lp_id)) { |
|
| 567 | - // TODO: Maybe create a first module directly to avoid bugging the user with useless queries |
|
| 568 | - $_SESSION['oLP'] = new learnpath( |
|
| 546 | + if (isset($_REQUEST['activate_end_date_check']) && |
|
| 547 | + $_REQUEST['activate_end_date_check'] == 1 |
|
| 548 | + ) { |
|
| 549 | + $expired_on = $_REQUEST['expired_on']; |
|
| 550 | + } else { |
|
| 551 | + $expired_on = null; |
|
| 552 | + } |
|
| 553 | + |
|
| 554 | + $new_lp_id = learnpath::add_lp( |
|
| 569 | 555 | api_get_course_id(), |
| 570 | - $new_lp_id, |
|
| 571 | - api_get_user_id() |
|
| 556 | + Security::remove_XSS($_REQUEST['lp_name']), |
|
| 557 | + '', |
|
| 558 | + 'chamilo', |
|
| 559 | + 'manual', |
|
| 560 | + '', |
|
| 561 | + $publicated_on, |
|
| 562 | + $expired_on, |
|
| 563 | + $_REQUEST['category_id'] |
|
| 572 | 564 | ); |
| 573 | - //require 'lp_build.php'; |
|
| 574 | - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id).'&'.api_get_cidreq(); |
|
| 575 | - header("Location: $url&isStudentView=false"); |
|
| 565 | + |
|
| 566 | + if (is_numeric($new_lp_id)) { |
|
| 567 | + // TODO: Maybe create a first module directly to avoid bugging the user with useless queries |
|
| 568 | + $_SESSION['oLP'] = new learnpath( |
|
| 569 | + api_get_course_id(), |
|
| 570 | + $new_lp_id, |
|
| 571 | + api_get_user_id() |
|
| 572 | + ); |
|
| 573 | + //require 'lp_build.php'; |
|
| 574 | + $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($new_lp_id).'&'.api_get_cidreq(); |
|
| 575 | + header("Location: $url&isStudentView=false"); |
|
| 576 | + exit; |
|
| 577 | + } |
|
| 578 | + } |
|
| 579 | + } else { |
|
| 580 | + require 'lp_add.php'; |
|
| 581 | + } |
|
| 582 | + break; |
|
| 583 | + case 'admin_view': |
|
| 584 | + if (!$is_allowed_to_edit) { |
|
| 585 | + api_not_allowed(true); |
|
| 586 | + } |
|
| 587 | + if ($debug > 0) error_log('New LP - admin_view action triggered', 0); |
|
| 588 | + if (!$lp_found) { error_log('New LP - No learnpath given for admin_view', 0); require 'lp_list.php'; } |
|
| 589 | + else { |
|
| 590 | + $_SESSION['refresh'] = 1; |
|
| 591 | + require 'lp_admin_view.php'; |
|
| 592 | + } |
|
| 593 | + break; |
|
| 594 | + case 'auto_launch': |
|
| 595 | + if (api_get_course_setting('enable_lp_auto_launch') == 1) { //Redirect to a specific LP |
|
| 596 | + if (!$is_allowed_to_edit) { |
|
| 597 | + api_not_allowed(true); |
|
| 598 | + } |
|
| 599 | + if ($debug > 0) error_log('New LP - auto_launch action triggered', 0); |
|
| 600 | + if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; } |
|
| 601 | + else { |
|
| 602 | + $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']); |
|
| 603 | + require 'lp_list.php'; |
|
| 576 | 604 | exit; |
| 577 | 605 | } |
| 578 | 606 | } |
| 579 | - } else { |
|
| 580 | - require 'lp_add.php'; |
|
| 581 | - } |
|
| 582 | - break; |
|
| 583 | - case 'admin_view': |
|
| 584 | - if (!$is_allowed_to_edit) { |
|
| 585 | - api_not_allowed(true); |
|
| 586 | - } |
|
| 587 | - if ($debug > 0) error_log('New LP - admin_view action triggered', 0); |
|
| 588 | - if (!$lp_found) { error_log('New LP - No learnpath given for admin_view', 0); require 'lp_list.php'; } |
|
| 589 | - else { |
|
| 590 | - $_SESSION['refresh'] = 1; |
|
| 591 | - require 'lp_admin_view.php'; |
|
| 592 | - } |
|
| 593 | - break; |
|
| 594 | - case 'auto_launch': |
|
| 595 | - if (api_get_course_setting('enable_lp_auto_launch') == 1) { //Redirect to a specific LP |
|
| 607 | + break; |
|
| 608 | + case 'build': |
|
| 596 | 609 | if (!$is_allowed_to_edit) { |
| 597 | 610 | api_not_allowed(true); |
| 598 | 611 | } |
| 599 | - if ($debug > 0) error_log('New LP - auto_launch action triggered', 0); |
|
| 600 | - if (!$lp_found) { error_log('New LP - No learnpath given for set_autolaunch', 0); require 'lp_list.php'; } |
|
| 612 | + if ($debug > 0) error_log('New LP - build action triggered', 0); |
|
| 613 | + |
|
| 614 | + if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; } |
|
| 601 | 615 | else { |
| 602 | - $_SESSION['oLP']->set_autolaunch($_GET['lp_id'], $_GET['status']); |
|
| 603 | - require 'lp_list.php'; |
|
| 616 | + $_SESSION['refresh'] = 1; |
|
| 617 | + //require 'lp_build.php'; |
|
| 618 | + $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id); |
|
| 619 | + header('Location: '.$url); |
|
| 604 | 620 | exit; |
| 605 | 621 | } |
| 606 | - } |
|
| 607 | - break; |
|
| 608 | - case 'build': |
|
| 609 | - if (!$is_allowed_to_edit) { |
|
| 610 | - api_not_allowed(true); |
|
| 611 | - } |
|
| 612 | - if ($debug > 0) error_log('New LP - build action triggered', 0); |
|
| 622 | + break; |
|
| 623 | + case 'edit_item': |
|
| 624 | + if (!$is_allowed_to_edit) { |
|
| 625 | + api_not_allowed(true); |
|
| 626 | + } |
|
| 627 | + if ($debug > 0) error_log('New LP - edit item action triggered', 0); |
|
| 613 | 628 | |
| 614 | - if (!$lp_found) { error_log('New LP - No learnpath given for build', 0); require 'lp_list.php'; } |
|
| 615 | - else { |
|
| 616 | - $_SESSION['refresh'] = 1; |
|
| 617 | - //require 'lp_build.php'; |
|
| 618 | - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id); |
|
| 619 | - header('Location: '.$url); |
|
| 620 | - exit; |
|
| 621 | - } |
|
| 622 | - break; |
|
| 623 | - case 'edit_item': |
|
| 624 | - if (!$is_allowed_to_edit) { |
|
| 625 | - api_not_allowed(true); |
|
| 626 | - } |
|
| 627 | - if ($debug > 0) error_log('New LP - edit item action triggered', 0); |
|
| 629 | + if (!$lp_found) { error_log('New LP - No learnpath given for edit item', 0); require 'lp_list.php'; } |
|
| 630 | + else { |
|
| 631 | + $_SESSION['refresh'] = 1; |
|
| 632 | + if (isset($_POST['submit_button']) && !empty($post_title)) { |
|
| 628 | 633 | |
| 629 | - if (!$lp_found) { error_log('New LP - No learnpath given for edit item', 0); require 'lp_list.php'; } |
|
| 630 | - else { |
|
| 631 | - $_SESSION['refresh'] = 1; |
|
| 632 | - if (isset($_POST['submit_button']) && !empty($post_title)) { |
|
| 634 | + //Updating the lp.modified_on |
|
| 635 | + $_SESSION['oLP']->set_modified_on(); |
|
| 633 | 636 | |
| 634 | - //Updating the lp.modified_on |
|
| 635 | - $_SESSION['oLP']->set_modified_on(); |
|
| 637 | + // TODO: mp3 edit |
|
| 638 | + $audio = array(); |
|
| 639 | + if (isset($_FILES['mp3'])) { |
|
| 640 | + $audio = $_FILES['mp3']; |
|
| 641 | + } |
|
| 636 | 642 | |
| 637 | - // TODO: mp3 edit |
|
| 638 | - $audio = array(); |
|
| 639 | - if (isset($_FILES['mp3'])) { |
|
| 640 | - $audio = $_FILES['mp3']; |
|
| 641 | - } |
|
| 643 | + $description = isset($_POST['description']) ? $_POST['description'] : ''; |
|
| 644 | + $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : ''; |
|
| 645 | + $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : ''; |
|
| 646 | + $url = isset($_POST['url']) ? $_POST['url'] : ''; |
|
| 647 | + |
|
| 648 | + $_SESSION['oLP']->edit_item( |
|
| 649 | + $_REQUEST['id'], |
|
| 650 | + $_POST['parent'], |
|
| 651 | + $_POST['previous'], |
|
| 652 | + $post_title, |
|
| 653 | + $description, |
|
| 654 | + $prerequisites, |
|
| 655 | + $audio, |
|
| 656 | + $maxTimeAllowed, |
|
| 657 | + $url |
|
| 658 | + ); |
|
| 642 | 659 | |
| 643 | - $description = isset($_POST['description']) ? $_POST['description'] : ''; |
|
| 644 | - $prerequisites = isset($_POST['prerequisites']) ? $_POST['prerequisites'] : ''; |
|
| 645 | - $maxTimeAllowed = isset($_POST['maxTimeAllowed']) ? $_POST['maxTimeAllowed'] : ''; |
|
| 646 | - $url = isset($_POST['url']) ? $_POST['url'] : ''; |
|
| 647 | - |
|
| 648 | - $_SESSION['oLP']->edit_item( |
|
| 649 | - $_REQUEST['id'], |
|
| 650 | - $_POST['parent'], |
|
| 651 | - $_POST['previous'], |
|
| 652 | - $post_title, |
|
| 653 | - $description, |
|
| 654 | - $prerequisites, |
|
| 655 | - $audio, |
|
| 656 | - $maxTimeAllowed, |
|
| 657 | - $url |
|
| 658 | - ); |
|
| 660 | + if (isset($_POST['content_lp'])) { |
|
| 661 | + $_SESSION['oLP']->edit_document($_course); |
|
| 662 | + } |
|
| 663 | + $is_success = true; |
|
| 659 | 664 | |
| 660 | - if (isset($_POST['content_lp'])) { |
|
| 661 | - $_SESSION['oLP']->edit_document($_course); |
|
| 665 | + $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id); |
|
| 666 | + header('Location: '.$url); |
|
| 667 | + exit; |
|
| 662 | 668 | } |
| 663 | - $is_success = true; |
|
| 669 | + if (isset($_GET['view']) && $_GET['view'] == 'build') { |
|
| 670 | + require 'lp_edit_item.php'; |
|
| 671 | + } else { |
|
| 672 | + require 'lp_admin_view.php'; |
|
| 673 | + } |
|
| 674 | + } |
|
| 675 | + break; |
|
| 676 | + case 'edit_item_prereq': |
|
| 677 | + if (!$is_allowed_to_edit) { |
|
| 678 | + api_not_allowed(true); |
|
| 679 | + } |
|
| 680 | + if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0); |
|
| 681 | + if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } |
|
| 682 | + else { |
|
| 683 | + if (isset($_POST['submit_button'])) { |
|
| 684 | + //Updating the lp.modified_on |
|
| 685 | + $_SESSION['oLP']->set_modified_on(); |
|
| 686 | + $_SESSION['refresh'] = 1; |
|
| 687 | + $editPrerequisite = $_SESSION['oLP']->edit_item_prereq( |
|
| 688 | + $_GET['id'], |
|
| 689 | + $_POST['prerequisites'], |
|
| 690 | + $_POST['min_' . $_POST['prerequisites']], |
|
| 691 | + $_POST['max_' . $_POST['prerequisites']] |
|
| 692 | + ); |
|
| 664 | 693 | |
| 665 | - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id); |
|
| 666 | - header('Location: '.$url); |
|
| 667 | - exit; |
|
| 694 | + if ($editPrerequisite) { |
|
| 695 | + $is_success = true; |
|
| 696 | + } |
|
| 697 | + |
|
| 698 | + $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
| 699 | + header('Location: '.$url); |
|
| 700 | + exit; |
|
| 701 | + } else { |
|
| 702 | + require 'lp_edit_item_prereq.php'; |
|
| 703 | + } |
|
| 668 | 704 | } |
| 669 | - if (isset($_GET['view']) && $_GET['view'] == 'build') { |
|
| 670 | - require 'lp_edit_item.php'; |
|
| 671 | - } else { |
|
| 672 | - require 'lp_admin_view.php'; |
|
| 705 | + break; |
|
| 706 | + case 'move_item': |
|
| 707 | + if (!$is_allowed_to_edit) { |
|
| 708 | + api_not_allowed(true); |
|
| 673 | 709 | } |
| 674 | - } |
|
| 675 | - break; |
|
| 676 | - case 'edit_item_prereq': |
|
| 677 | - if (!$is_allowed_to_edit) { |
|
| 678 | - api_not_allowed(true); |
|
| 679 | - } |
|
| 680 | - if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0); |
|
| 681 | - if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } |
|
| 682 | - else { |
|
| 683 | - if (isset($_POST['submit_button'])) { |
|
| 684 | - //Updating the lp.modified_on |
|
| 685 | - $_SESSION['oLP']->set_modified_on(); |
|
| 710 | + if ($debug > 0) error_log('New LP - move item action triggered', 0); |
|
| 711 | + if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; } |
|
| 712 | + else { |
|
| 686 | 713 | $_SESSION['refresh'] = 1; |
| 687 | - $editPrerequisite = $_SESSION['oLP']->edit_item_prereq( |
|
| 688 | - $_GET['id'], |
|
| 689 | - $_POST['prerequisites'], |
|
| 690 | - $_POST['min_' . $_POST['prerequisites']], |
|
| 691 | - $_POST['max_' . $_POST['prerequisites']] |
|
| 692 | - ); |
|
| 693 | - |
|
| 694 | - if ($editPrerequisite) { |
|
| 714 | + if (isset($_POST['submit_button'])) { |
|
| 715 | + //Updating the lp.modified_on |
|
| 716 | + $_SESSION['oLP']->set_modified_on(); |
|
| 717 | + $_SESSION['oLP']->edit_item( |
|
| 718 | + $_GET['id'], |
|
| 719 | + $_POST['parent'], |
|
| 720 | + $_POST['previous'], |
|
| 721 | + $post_title, |
|
| 722 | + $_POST['description'] |
|
| 723 | + ); |
|
| 695 | 724 | $is_success = true; |
| 725 | + $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
| 726 | + header('Location: '.$url); |
|
| 727 | + } |
|
| 728 | + if (isset($_GET['view']) && $_GET['view'] == 'build') { |
|
| 729 | + require 'lp_move_item.php'; |
|
| 730 | + } else { |
|
| 731 | + // Avoids weird behaviours see CT#967. |
|
| 732 | + $check = Security::check_token('get'); |
|
| 733 | + if ($check) { |
|
| 734 | + $_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']); |
|
| 735 | + } |
|
| 736 | + Security::clear_token(); |
|
| 737 | + require 'lp_admin_view.php'; |
|
| 696 | 738 | } |
| 697 | - |
|
| 698 | - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
| 699 | - header('Location: '.$url); |
|
| 700 | - exit; |
|
| 701 | - } else { |
|
| 702 | - require 'lp_edit_item_prereq.php'; |
|
| 703 | 739 | } |
| 704 | - } |
|
| 705 | - break; |
|
| 706 | - case 'move_item': |
|
| 707 | - if (!$is_allowed_to_edit) { |
|
| 708 | - api_not_allowed(true); |
|
| 709 | - } |
|
| 710 | - if ($debug > 0) error_log('New LP - move item action triggered', 0); |
|
| 711 | - if (!$lp_found) { error_log('New LP - No learnpath given for move item', 0); require 'lp_list.php'; } |
|
| 712 | - else { |
|
| 713 | - $_SESSION['refresh'] = 1; |
|
| 714 | - if (isset($_POST['submit_button'])) { |
|
| 715 | - //Updating the lp.modified_on |
|
| 716 | - $_SESSION['oLP']->set_modified_on(); |
|
| 717 | - $_SESSION['oLP']->edit_item( |
|
| 718 | - $_GET['id'], |
|
| 719 | - $_POST['parent'], |
|
| 720 | - $_POST['previous'], |
|
| 721 | - $post_title, |
|
| 722 | - $_POST['description'] |
|
| 723 | - ); |
|
| 724 | - $is_success = true; |
|
| 725 | - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
| 726 | - header('Location: '.$url); |
|
| 740 | + break; |
|
| 741 | + case 'view_item': |
|
| 742 | + if (!$is_allowed_to_edit) { |
|
| 743 | + api_not_allowed(true); |
|
| 727 | 744 | } |
| 728 | - if (isset($_GET['view']) && $_GET['view'] == 'build') { |
|
| 729 | - require 'lp_move_item.php'; |
|
| 745 | + if ($debug > 0) error_log('New LP - view_item action triggered', 0); |
|
| 746 | + if (!$lp_found) { |
|
| 747 | + error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php'; |
|
| 730 | 748 | } else { |
| 731 | - // Avoids weird behaviours see CT#967. |
|
| 732 | - $check = Security::check_token('get'); |
|
| 733 | - if ($check) { |
|
| 734 | - $_SESSION['oLP']->move_item($_GET['id'], $_GET['direction']); |
|
| 735 | - } |
|
| 736 | - Security::clear_token(); |
|
| 737 | - require 'lp_admin_view.php'; |
|
| 749 | + $_SESSION['refresh'] = 1; |
|
| 750 | + require 'lp_view_item.php'; |
|
| 751 | + } |
|
| 752 | + break; |
|
| 753 | + case 'upload': |
|
| 754 | + if (!$is_allowed_to_edit) { |
|
| 755 | + api_not_allowed(true); |
|
| 756 | + } |
|
| 757 | + if ($debug > 0) error_log('New LP - upload action triggered', 0); |
|
| 758 | + $cwdir = getcwd(); |
|
| 759 | + require 'lp_upload.php'; |
|
| 760 | + // Reinit current working directory as many functions in upload change it. |
|
| 761 | + chdir($cwdir); |
|
| 762 | + require 'lp_list.php'; |
|
| 763 | + break; |
|
| 764 | + case 'copy': |
|
| 765 | + if (!$is_allowed_to_edit) { |
|
| 766 | + api_not_allowed(true); |
|
| 738 | 767 | } |
| 739 | - } |
|
| 740 | - break; |
|
| 741 | - case 'view_item': |
|
| 742 | - if (!$is_allowed_to_edit) { |
|
| 743 | - api_not_allowed(true); |
|
| 744 | - } |
|
| 745 | - if ($debug > 0) error_log('New LP - view_item action triggered', 0); |
|
| 746 | - if (!$lp_found) { |
|
| 747 | - error_log('New LP - No learnpath given for view item', 0); require 'lp_list.php'; |
|
| 748 | - } else { |
|
| 749 | - $_SESSION['refresh'] = 1; |
|
| 750 | - require 'lp_view_item.php'; |
|
| 751 | - } |
|
| 752 | - break; |
|
| 753 | - case 'upload': |
|
| 754 | - if (!$is_allowed_to_edit) { |
|
| 755 | - api_not_allowed(true); |
|
| 756 | - } |
|
| 757 | - if ($debug > 0) error_log('New LP - upload action triggered', 0); |
|
| 758 | - $cwdir = getcwd(); |
|
| 759 | - require 'lp_upload.php'; |
|
| 760 | - // Reinit current working directory as many functions in upload change it. |
|
| 761 | - chdir($cwdir); |
|
| 762 | - require 'lp_list.php'; |
|
| 763 | - break; |
|
| 764 | - case 'copy': |
|
| 765 | - if (!$is_allowed_to_edit) { |
|
| 766 | - api_not_allowed(true); |
|
| 767 | - } |
|
| 768 | 768 | |
| 769 | - $hideScormCopyLink = api_get_setting('hide_scorm_copy_link'); |
|
| 770 | - if ($hideScormCopyLink === 'true') { |
|
| 771 | - api_not_allowed(true); |
|
| 772 | - } |
|
| 769 | + $hideScormCopyLink = api_get_setting('hide_scorm_copy_link'); |
|
| 770 | + if ($hideScormCopyLink === 'true') { |
|
| 771 | + api_not_allowed(true); |
|
| 772 | + } |
|
| 773 | 773 | |
| 774 | - if ($debug > 0) error_log('New LP - export action triggered', 0); |
|
| 775 | - if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; } |
|
| 776 | - else { |
|
| 777 | - $_SESSION['oLP']->copy(); |
|
| 778 | - } |
|
| 779 | - require 'lp_list.php'; |
|
| 780 | - break; |
|
| 781 | - case 'export': |
|
| 782 | - if (!$is_allowed_to_edit) { |
|
| 783 | - api_not_allowed(true); |
|
| 784 | - } |
|
| 785 | - $hideScormExportLink = api_get_setting('hide_scorm_export_link'); |
|
| 786 | - if ($hideScormExportLink === 'true') { |
|
| 787 | - api_not_allowed(true); |
|
| 788 | - } |
|
| 789 | - if ($debug > 0) error_log('New LP - export action triggered', 0); |
|
| 790 | - if (!$lp_found) { error_log('New LP - No learnpath given for export', 0); require 'lp_list.php'; } |
|
| 791 | - else { |
|
| 792 | - $_SESSION['oLP']->scorm_export(); |
|
| 793 | - exit(); |
|
| 794 | - //require 'lp_list.php'; |
|
| 795 | - } |
|
| 796 | - break; |
|
| 797 | - case 'export_to_pdf': |
|
| 798 | - if (!learnpath::is_lp_visible_for_student($_SESSION['oLP']->lp_id, api_get_user_id())) { |
|
| 799 | - api_not_allowed(); |
|
| 800 | - } |
|
| 801 | - $hideScormPdfLink = api_get_setting('hide_scorm_pdf_link'); |
|
| 802 | - if ($hideScormPdfLink === 'true') { |
|
| 803 | - api_not_allowed(true); |
|
| 804 | - } |
|
| 774 | + if ($debug > 0) error_log('New LP - export action triggered', 0); |
|
| 775 | + if (!$lp_found) { error_log('New LP - No learnpath given for copy', 0); require 'lp_list.php'; } |
|
| 776 | + else { |
|
| 777 | + $_SESSION['oLP']->copy(); |
|
| 778 | + } |
|
| 779 | + require 'lp_list.php'; |
|
| 780 | + break; |
|
| 781 | + case 'export': |
|
| 782 | + if (!$is_allowed_to_edit) { |
|
| 783 | + api_not_allowed(true); |
|
| 784 | + } |
|
| 785 | + $hideScormExportLink = api_get_setting('hide_scorm_export_link'); |
|
| 786 | + if ($hideScormExportLink === 'true') { |
|
| 787 | + api_not_allowed(true); |
|
| 788 | + } |
|
| 789 | + if ($debug > 0) error_log('New LP - export action triggered', 0); |
|
| 790 | + if (!$lp_found) { error_log('New LP - No learnpath given for export', 0); require 'lp_list.php'; } |
|
| 791 | + else { |
|
| 792 | + $_SESSION['oLP']->scorm_export(); |
|
| 793 | + exit(); |
|
| 794 | + //require 'lp_list.php'; |
|
| 795 | + } |
|
| 796 | + break; |
|
| 797 | + case 'export_to_pdf': |
|
| 798 | + if (!learnpath::is_lp_visible_for_student($_SESSION['oLP']->lp_id, api_get_user_id())) { |
|
| 799 | + api_not_allowed(); |
|
| 800 | + } |
|
| 801 | + $hideScormPdfLink = api_get_setting('hide_scorm_pdf_link'); |
|
| 802 | + if ($hideScormPdfLink === 'true') { |
|
| 803 | + api_not_allowed(true); |
|
| 804 | + } |
|
| 805 | 805 | |
| 806 | - if ($debug > 0) error_log('New LP - export action triggered', 0); |
|
| 807 | - if (!$lp_found) { error_log('New LP - No learnpath given for export_to_pdf', 0); require 'lp_list.php'; |
|
| 808 | - } else { |
|
| 809 | - $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']); |
|
| 810 | - if (!$result) { |
|
| 806 | + if ($debug > 0) error_log('New LP - export action triggered', 0); |
|
| 807 | + if (!$lp_found) { error_log('New LP - No learnpath given for export_to_pdf', 0); require 'lp_list.php'; |
|
| 808 | + } else { |
|
| 809 | + $result = $_SESSION['oLP']->scorm_export_to_pdf($_GET['lp_id']); |
|
| 810 | + if (!$result) { |
|
| 811 | + require 'lp_list.php'; |
|
| 812 | + } |
|
| 813 | + exit; |
|
| 814 | + } |
|
| 815 | + break; |
|
| 816 | + case 'delete': |
|
| 817 | + if (!$is_allowed_to_edit) { |
|
| 818 | + api_not_allowed(true); |
|
| 819 | + } |
|
| 820 | + if ($debug > 0) error_log('New LP - delete action triggered', 0); |
|
| 821 | + if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; } |
|
| 822 | + else { |
|
| 823 | + $_SESSION['refresh'] = 1; |
|
| 824 | + $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove'); |
|
| 825 | + Session::erase('oLP'); |
|
| 811 | 826 | require 'lp_list.php'; |
| 812 | 827 | } |
| 813 | - exit; |
|
| 814 | - } |
|
| 815 | - break; |
|
| 816 | - case 'delete': |
|
| 817 | - if (!$is_allowed_to_edit) { |
|
| 818 | - api_not_allowed(true); |
|
| 819 | - } |
|
| 820 | - if ($debug > 0) error_log('New LP - delete action triggered', 0); |
|
| 821 | - if (!$lp_found) { error_log('New LP - No learnpath given for delete', 0); require 'lp_list.php'; } |
|
| 822 | - else { |
|
| 823 | - $_SESSION['refresh'] = 1; |
|
| 824 | - $_SESSION['oLP']->delete(null, $_GET['lp_id'], 'remove'); |
|
| 825 | - Session::erase('oLP'); |
|
| 826 | - require 'lp_list.php'; |
|
| 827 | - } |
|
| 828 | - break; |
|
| 829 | - case 'toggle_visible': |
|
| 830 | - // Change lp visibility (inside lp tool). |
|
| 831 | - if (!$is_allowed_to_edit) { |
|
| 832 | - api_not_allowed(true); |
|
| 833 | - } |
|
| 834 | - if ($debug > 0) error_log('New LP - visibility action triggered', 0); |
|
| 835 | - if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; } |
|
| 836 | - else { |
|
| 837 | - learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']); |
|
| 838 | - require 'lp_list.php'; |
|
| 839 | - } |
|
| 840 | - break; |
|
| 841 | - case 'toggle_publish': |
|
| 842 | - // Change lp published status (visibility on homepage). |
|
| 843 | - if (!$is_allowed_to_edit) { |
|
| 844 | - api_not_allowed(true); |
|
| 845 | - } |
|
| 846 | - if ($debug > 0) error_log('New LP - publish action triggered', 0); |
|
| 847 | - if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; } |
|
| 848 | - else { |
|
| 849 | - learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']); |
|
| 850 | - require 'lp_list.php'; |
|
| 851 | - } |
|
| 852 | - break; |
|
| 853 | - case 'move_lp_up': |
|
| 854 | - // Change lp published status (visibility on homepage) |
|
| 855 | - if (!$is_allowed_to_edit) { |
|
| 856 | - api_not_allowed(true); |
|
| 857 | - } |
|
| 858 | - if ($debug > 0) error_log('New LP - publish action triggered', 0); |
|
| 859 | - if (!$lp_found) { |
|
| 860 | - error_log('New LP - No learnpath given for publish', 0); |
|
| 861 | - require 'lp_list.php'; |
|
| 862 | - } else { |
|
| 863 | - learnpath::move_up($_REQUEST['lp_id']); |
|
| 864 | - require 'lp_list.php'; |
|
| 865 | - } |
|
| 866 | - break; |
|
| 867 | - case 'move_lp_down': |
|
| 868 | - // Change lp published status (visibility on homepage) |
|
| 869 | - if (!$is_allowed_to_edit) { |
|
| 870 | - api_not_allowed(true); |
|
| 871 | - } |
|
| 872 | - if ($debug > 0) error_log('New LP - publish action triggered', 0); |
|
| 873 | - if (!$lp_found) { |
|
| 874 | - error_log('New LP - No learnpath given for publish', 0); |
|
| 875 | - require 'lp_list.php'; |
|
| 876 | - } else { |
|
| 877 | - learnpath::move_down($_REQUEST['lp_id']); |
|
| 878 | - require 'lp_list.php'; |
|
| 879 | - } |
|
| 880 | - break; |
|
| 881 | - case 'edit': |
|
| 882 | - if (!$is_allowed_to_edit) { |
|
| 883 | - api_not_allowed(true); |
|
| 884 | - } |
|
| 885 | - if ($debug > 0) error_log('New LP - edit action triggered', 0); |
|
| 886 | - if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } |
|
| 887 | - else { |
|
| 888 | - $_SESSION['refresh'] = 1; |
|
| 889 | - require 'lp_edit.php'; |
|
| 890 | - } |
|
| 891 | - break; |
|
| 892 | - case 'update_lp': |
|
| 893 | - if (!$is_allowed_to_edit) { |
|
| 894 | - api_not_allowed(true); |
|
| 895 | - } |
|
| 896 | - if ($debug > 0) error_log('New LP - update_lp action triggered', 0); |
|
| 897 | - if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } |
|
| 898 | - else { |
|
| 899 | - $_SESSION['refresh'] = 1; |
|
| 900 | - $lp_name = Security::remove_XSS($_REQUEST['lp_name']); |
|
| 901 | - $_SESSION['oLP']->set_name($lp_name); |
|
| 902 | - $author = $_REQUEST['lp_author']; |
|
| 903 | - // Fixing the author name (no body or html tags). |
|
| 904 | - $auth_init = stripos($author, '<p>'); |
|
| 905 | - if ($auth_init === false) { |
|
| 906 | - $auth_init = stripos($author, '<body>'); |
|
| 907 | - $auth_end = $auth_init + stripos(substr($author, $auth_init + 6), '</body>') + 7; |
|
| 908 | - $len = $auth_end - $auth_init + 6; |
|
| 828 | + break; |
|
| 829 | + case 'toggle_visible': |
|
| 830 | + // Change lp visibility (inside lp tool). |
|
| 831 | + if (!$is_allowed_to_edit) { |
|
| 832 | + api_not_allowed(true); |
|
| 833 | + } |
|
| 834 | + if ($debug > 0) error_log('New LP - visibility action triggered', 0); |
|
| 835 | + if (!$lp_found) { error_log('New LP - No learnpath given for visibility', 0); require 'lp_list.php'; } |
|
| 836 | + else { |
|
| 837 | + learnpath::toggle_visibility($_REQUEST['lp_id'], $_REQUEST['new_status']); |
|
| 838 | + require 'lp_list.php'; |
|
| 839 | + } |
|
| 840 | + break; |
|
| 841 | + case 'toggle_publish': |
|
| 842 | + // Change lp published status (visibility on homepage). |
|
| 843 | + if (!$is_allowed_to_edit) { |
|
| 844 | + api_not_allowed(true); |
|
| 845 | + } |
|
| 846 | + if ($debug > 0) error_log('New LP - publish action triggered', 0); |
|
| 847 | + if (!$lp_found) { error_log('New LP - No learnpath given for publish', 0); require 'lp_list.php'; } |
|
| 848 | + else { |
|
| 849 | + learnpath::toggle_publish($_REQUEST['lp_id'], $_REQUEST['new_status']); |
|
| 850 | + require 'lp_list.php'; |
|
| 851 | + } |
|
| 852 | + break; |
|
| 853 | + case 'move_lp_up': |
|
| 854 | + // Change lp published status (visibility on homepage) |
|
| 855 | + if (!$is_allowed_to_edit) { |
|
| 856 | + api_not_allowed(true); |
|
| 857 | + } |
|
| 858 | + if ($debug > 0) error_log('New LP - publish action triggered', 0); |
|
| 859 | + if (!$lp_found) { |
|
| 860 | + error_log('New LP - No learnpath given for publish', 0); |
|
| 861 | + require 'lp_list.php'; |
|
| 862 | + } else { |
|
| 863 | + learnpath::move_up($_REQUEST['lp_id']); |
|
| 864 | + require 'lp_list.php'; |
|
| 865 | + } |
|
| 866 | + break; |
|
| 867 | + case 'move_lp_down': |
|
| 868 | + // Change lp published status (visibility on homepage) |
|
| 869 | + if (!$is_allowed_to_edit) { |
|
| 870 | + api_not_allowed(true); |
|
| 871 | + } |
|
| 872 | + if ($debug > 0) error_log('New LP - publish action triggered', 0); |
|
| 873 | + if (!$lp_found) { |
|
| 874 | + error_log('New LP - No learnpath given for publish', 0); |
|
| 875 | + require 'lp_list.php'; |
|
| 909 | 876 | } else { |
| 910 | - $auth_end = strripos($author, '</p>'); |
|
| 911 | - $len = $auth_end - $auth_init + 4; |
|
| 877 | + learnpath::move_down($_REQUEST['lp_id']); |
|
| 878 | + require 'lp_list.php'; |
|
| 879 | + } |
|
| 880 | + break; |
|
| 881 | + case 'edit': |
|
| 882 | + if (!$is_allowed_to_edit) { |
|
| 883 | + api_not_allowed(true); |
|
| 884 | + } |
|
| 885 | + if ($debug > 0) error_log('New LP - edit action triggered', 0); |
|
| 886 | + if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } |
|
| 887 | + else { |
|
| 888 | + $_SESSION['refresh'] = 1; |
|
| 889 | + require 'lp_edit.php'; |
|
| 890 | + } |
|
| 891 | + break; |
|
| 892 | + case 'update_lp': |
|
| 893 | + if (!$is_allowed_to_edit) { |
|
| 894 | + api_not_allowed(true); |
|
| 912 | 895 | } |
| 896 | + if ($debug > 0) error_log('New LP - update_lp action triggered', 0); |
|
| 897 | + if (!$lp_found) { error_log('New LP - No learnpath given for edit', 0); require 'lp_list.php'; } |
|
| 898 | + else { |
|
| 899 | + $_SESSION['refresh'] = 1; |
|
| 900 | + $lp_name = Security::remove_XSS($_REQUEST['lp_name']); |
|
| 901 | + $_SESSION['oLP']->set_name($lp_name); |
|
| 902 | + $author = $_REQUEST['lp_author']; |
|
| 903 | + // Fixing the author name (no body or html tags). |
|
| 904 | + $auth_init = stripos($author, '<p>'); |
|
| 905 | + if ($auth_init === false) { |
|
| 906 | + $auth_init = stripos($author, '<body>'); |
|
| 907 | + $auth_end = $auth_init + stripos(substr($author, $auth_init + 6), '</body>') + 7; |
|
| 908 | + $len = $auth_end - $auth_init + 6; |
|
| 909 | + } else { |
|
| 910 | + $auth_end = strripos($author, '</p>'); |
|
| 911 | + $len = $auth_end - $auth_init + 4; |
|
| 912 | + } |
|
| 913 | 913 | |
| 914 | - $author_fixed = substr($author, $auth_init, $len); |
|
| 915 | - //$author_fixed = $author; |
|
| 914 | + $author_fixed = substr($author, $auth_init, $len); |
|
| 915 | + //$author_fixed = $author; |
|
| 916 | 916 | |
| 917 | - $_SESSION['oLP']->set_author($author_fixed); |
|
| 918 | - // TODO (as of Chamilo 1.8.8): Check in the future whether this field is needed. |
|
| 919 | - $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']); |
|
| 917 | + $_SESSION['oLP']->set_author($author_fixed); |
|
| 918 | + // TODO (as of Chamilo 1.8.8): Check in the future whether this field is needed. |
|
| 919 | + $_SESSION['oLP']->set_encoding($_REQUEST['lp_encoding']); |
|
| 920 | 920 | |
| 921 | - if (isset($_REQUEST['lp_maker'])) { |
|
| 922 | - $_SESSION['oLP']->set_maker($_REQUEST['lp_maker']); |
|
| 923 | - } |
|
| 924 | - if (isset($_REQUEST['lp_proximity'])) { |
|
| 925 | - $_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']); |
|
| 926 | - } |
|
| 927 | - $_SESSION['oLP']->set_theme($_REQUEST['lp_theme']); |
|
| 921 | + if (isset($_REQUEST['lp_maker'])) { |
|
| 922 | + $_SESSION['oLP']->set_maker($_REQUEST['lp_maker']); |
|
| 923 | + } |
|
| 924 | + if (isset($_REQUEST['lp_proximity'])) { |
|
| 925 | + $_SESSION['oLP']->set_proximity($_REQUEST['lp_proximity']); |
|
| 926 | + } |
|
| 927 | + $_SESSION['oLP']->set_theme($_REQUEST['lp_theme']); |
|
| 928 | 928 | |
| 929 | - if (isset($_REQUEST['hide_toc_frame']) && $_REQUEST['hide_toc_frame'] == 1) { |
|
| 930 | - $hide_toc_frame = $_REQUEST['hide_toc_frame']; |
|
| 931 | - } else { |
|
| 932 | - $hide_toc_frame = null; |
|
| 933 | - } |
|
| 934 | - $_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame); |
|
| 935 | - $_SESSION['oLP']->set_prerequisite($_REQUEST['prerequisites']); |
|
| 936 | - $_SESSION['oLP']->set_use_max_score($_REQUEST['use_max_score']); |
|
| 937 | - $_SESSION['oLP']->setSubscribeUsers($_REQUEST['subscribe_users']); |
|
| 929 | + if (isset($_REQUEST['hide_toc_frame']) && $_REQUEST['hide_toc_frame'] == 1) { |
|
| 930 | + $hide_toc_frame = $_REQUEST['hide_toc_frame']; |
|
| 931 | + } else { |
|
| 932 | + $hide_toc_frame = null; |
|
| 933 | + } |
|
| 934 | + $_SESSION['oLP']->set_hide_toc_frame($hide_toc_frame); |
|
| 935 | + $_SESSION['oLP']->set_prerequisite($_REQUEST['prerequisites']); |
|
| 936 | + $_SESSION['oLP']->set_use_max_score($_REQUEST['use_max_score']); |
|
| 937 | + $_SESSION['oLP']->setSubscribeUsers($_REQUEST['subscribe_users']); |
|
| 938 | 938 | |
| 939 | - if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) { |
|
| 940 | - $publicated_on = $_REQUEST['publicated_on']; |
|
| 941 | - } else { |
|
| 942 | - $publicated_on = null; |
|
| 943 | - } |
|
| 939 | + if (isset($_REQUEST['activate_start_date_check']) && $_REQUEST['activate_start_date_check'] == 1) { |
|
| 940 | + $publicated_on = $_REQUEST['publicated_on']; |
|
| 941 | + } else { |
|
| 942 | + $publicated_on = null; |
|
| 943 | + } |
|
| 944 | 944 | |
| 945 | - if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) { |
|
| 946 | - $expired_on = $_REQUEST['expired_on']; |
|
| 947 | - } else { |
|
| 948 | - $expired_on = null; |
|
| 949 | - } |
|
| 950 | - $_SESSION['oLP']->setCategoryId($_REQUEST['category_id']); |
|
| 951 | - $_SESSION['oLP']->set_modified_on(); |
|
| 952 | - $_SESSION['oLP']->set_publicated_on($publicated_on); |
|
| 953 | - $_SESSION['oLP']->set_expired_on($expired_on); |
|
| 954 | - |
|
| 955 | - if (isset($_REQUEST['remove_picture']) && $_REQUEST['remove_picture']) { |
|
| 956 | - $_SESSION['oLP']->delete_lp_image(); |
|
| 957 | - } |
|
| 958 | - |
|
| 959 | - $extraFieldValue = new ExtraFieldValue('lp'); |
|
| 960 | - $params = array( |
|
| 961 | - 'lp_id' => $_SESSION['oLP']->id |
|
| 962 | - ); |
|
| 963 | - $extraFieldValue->saveFieldValues($_REQUEST); |
|
| 964 | - |
|
| 965 | - if ($_FILES['lp_preview_image']['size'] > 0) |
|
| 966 | - $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']); |
|
| 967 | - |
|
| 968 | - if (api_get_setting('search_enabled') === 'true') { |
|
| 969 | - require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
| 970 | - $specific_fields = get_specific_field_list(); |
|
| 971 | - foreach ($specific_fields as $specific_field) { |
|
| 972 | - $_SESSION['oLP']->set_terms_by_prefix($_REQUEST[$specific_field['code']], $specific_field['code']); |
|
| 973 | - $new_values = explode(',', trim($_REQUEST[$specific_field['code']])); |
|
| 974 | - if (!empty($new_values)) { |
|
| 975 | - array_walk($new_values, 'trim'); |
|
| 976 | - delete_all_specific_field_value( |
|
| 977 | - api_get_course_id(), |
|
| 978 | - $specific_field['id'], |
|
| 979 | - TOOL_LEARNPATH, |
|
| 980 | - $_SESSION['oLP']->lp_id |
|
| 981 | - ); |
|
| 945 | + if (isset($_REQUEST['activate_end_date_check']) && $_REQUEST['activate_end_date_check'] == 1) { |
|
| 946 | + $expired_on = $_REQUEST['expired_on']; |
|
| 947 | + } else { |
|
| 948 | + $expired_on = null; |
|
| 949 | + } |
|
| 950 | + $_SESSION['oLP']->setCategoryId($_REQUEST['category_id']); |
|
| 951 | + $_SESSION['oLP']->set_modified_on(); |
|
| 952 | + $_SESSION['oLP']->set_publicated_on($publicated_on); |
|
| 953 | + $_SESSION['oLP']->set_expired_on($expired_on); |
|
| 954 | + |
|
| 955 | + if (isset($_REQUEST['remove_picture']) && $_REQUEST['remove_picture']) { |
|
| 956 | + $_SESSION['oLP']->delete_lp_image(); |
|
| 957 | + } |
|
| 982 | 958 | |
| 983 | - foreach ($new_values as $value) { |
|
| 984 | - if (!empty($value)) { |
|
| 985 | - add_specific_field_value( |
|
| 986 | - $specific_field['id'], |
|
| 987 | - api_get_course_id(), |
|
| 988 | - TOOL_LEARNPATH, |
|
| 989 | - $_SESSION['oLP']->lp_id, |
|
| 990 | - $value |
|
| 991 | - ); |
|
| 959 | + $extraFieldValue = new ExtraFieldValue('lp'); |
|
| 960 | + $params = array( |
|
| 961 | + 'lp_id' => $_SESSION['oLP']->id |
|
| 962 | + ); |
|
| 963 | + $extraFieldValue->saveFieldValues($_REQUEST); |
|
| 964 | + |
|
| 965 | + if ($_FILES['lp_preview_image']['size'] > 0) |
|
| 966 | + $_SESSION['oLP']->upload_image($_FILES['lp_preview_image']); |
|
| 967 | + |
|
| 968 | + if (api_get_setting('search_enabled') === 'true') { |
|
| 969 | + require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; |
|
| 970 | + $specific_fields = get_specific_field_list(); |
|
| 971 | + foreach ($specific_fields as $specific_field) { |
|
| 972 | + $_SESSION['oLP']->set_terms_by_prefix($_REQUEST[$specific_field['code']], $specific_field['code']); |
|
| 973 | + $new_values = explode(',', trim($_REQUEST[$specific_field['code']])); |
|
| 974 | + if (!empty($new_values)) { |
|
| 975 | + array_walk($new_values, 'trim'); |
|
| 976 | + delete_all_specific_field_value( |
|
| 977 | + api_get_course_id(), |
|
| 978 | + $specific_field['id'], |
|
| 979 | + TOOL_LEARNPATH, |
|
| 980 | + $_SESSION['oLP']->lp_id |
|
| 981 | + ); |
|
| 982 | + |
|
| 983 | + foreach ($new_values as $value) { |
|
| 984 | + if (!empty($value)) { |
|
| 985 | + add_specific_field_value( |
|
| 986 | + $specific_field['id'], |
|
| 987 | + api_get_course_id(), |
|
| 988 | + TOOL_LEARNPATH, |
|
| 989 | + $_SESSION['oLP']->lp_id, |
|
| 990 | + $value |
|
| 991 | + ); |
|
| 992 | + } |
|
| 992 | 993 | } |
| 993 | 994 | } |
| 994 | 995 | } |
| 995 | 996 | } |
| 997 | + $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
| 998 | + header('Location: '.$url); |
|
| 999 | + exit; |
|
| 996 | 1000 | } |
| 997 | - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id).'&'.api_get_cidreq(); |
|
| 998 | - header('Location: '.$url); |
|
| 999 | - exit; |
|
| 1000 | - } |
|
| 1001 | - break; |
|
| 1002 | - case 'add_sub_item': // Add an item inside a chapter. |
|
| 1003 | - if (!$is_allowed_to_edit) { |
|
| 1004 | - api_not_allowed(true); |
|
| 1005 | - } |
|
| 1006 | - if ($debug > 0) error_log('New LP - add sub item action triggered', 0); |
|
| 1007 | - if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; } |
|
| 1008 | - else { |
|
| 1009 | - $_SESSION['refresh'] = 1; |
|
| 1010 | - if (!empty($_REQUEST['parent_item_id'])) { |
|
| 1011 | - $_SESSION['from_learnpath']='yes'; |
|
| 1012 | - $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.Security::remove_XSS($_REQUEST['lp_id']); |
|
| 1013 | - require 'resourcelinker.php'; |
|
| 1014 | - } else { |
|
| 1001 | + break; |
|
| 1002 | + case 'add_sub_item': // Add an item inside a chapter. |
|
| 1003 | + if (!$is_allowed_to_edit) { |
|
| 1004 | + api_not_allowed(true); |
|
| 1005 | + } |
|
| 1006 | + if ($debug > 0) error_log('New LP - add sub item action triggered', 0); |
|
| 1007 | + if (!$lp_found) { error_log('New LP - No learnpath given for add sub item', 0); require 'lp_list.php'; } |
|
| 1008 | + else { |
|
| 1009 | + $_SESSION['refresh'] = 1; |
|
| 1010 | + if (!empty($_REQUEST['parent_item_id'])) { |
|
| 1011 | + $_SESSION['from_learnpath']='yes'; |
|
| 1012 | + $_SESSION['origintoolurl'] = 'lp_controller.php?action=admin_view&lp_id='.Security::remove_XSS($_REQUEST['lp_id']); |
|
| 1013 | + require 'resourcelinker.php'; |
|
| 1014 | + } else { |
|
| 1015 | + require 'lp_admin_view.php'; |
|
| 1016 | + } |
|
| 1017 | + } |
|
| 1018 | + break; |
|
| 1019 | + case 'deleteitem': |
|
| 1020 | + case 'delete_item': |
|
| 1021 | + if (!$is_allowed_to_edit) { |
|
| 1022 | + api_not_allowed(true); |
|
| 1023 | + } |
|
| 1024 | + if ($debug > 0) error_log('New LP - delete item action triggered', 0); |
|
| 1025 | + if (!$lp_found) { error_log('New LP - No learnpath given for delete item', 0); require 'lp_list.php'; } |
|
| 1026 | + else { |
|
| 1027 | + //$_SESSION['refresh'] = 1; |
|
| 1028 | + if (!empty($_REQUEST['id'])) { |
|
| 1029 | + $_SESSION['oLP']->delete_item($_REQUEST['id']); |
|
| 1030 | + } |
|
| 1031 | + $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_REQUEST['lp_id']).api_get_cidreq(); |
|
| 1032 | + header('Location: '.$url); |
|
| 1033 | + exit; |
|
| 1034 | + } |
|
| 1035 | + break; |
|
| 1036 | + case 'edititemprereq': |
|
| 1037 | + case 'edit_item_prereq': |
|
| 1038 | + if (!$is_allowed_to_edit) { |
|
| 1039 | + api_not_allowed(true); |
|
| 1040 | + } |
|
| 1041 | + if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0); |
|
| 1042 | + if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } |
|
| 1043 | + else { |
|
| 1044 | + if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) { |
|
| 1045 | + $_SESSION['refresh'] = 1; |
|
| 1046 | + $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']); |
|
| 1047 | + } |
|
| 1015 | 1048 | require 'lp_admin_view.php'; |
| 1016 | 1049 | } |
| 1017 | - } |
|
| 1018 | - break; |
|
| 1019 | - case 'deleteitem': |
|
| 1020 | - case 'delete_item': |
|
| 1021 | - if (!$is_allowed_to_edit) { |
|
| 1022 | - api_not_allowed(true); |
|
| 1023 | - } |
|
| 1024 | - if ($debug > 0) error_log('New LP - delete item action triggered', 0); |
|
| 1025 | - if (!$lp_found) { error_log('New LP - No learnpath given for delete item', 0); require 'lp_list.php'; } |
|
| 1026 | - else { |
|
| 1027 | - //$_SESSION['refresh'] = 1; |
|
| 1028 | - if (!empty($_REQUEST['id'])) { |
|
| 1029 | - $_SESSION['oLP']->delete_item($_REQUEST['id']); |
|
| 1030 | - } |
|
| 1031 | - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_REQUEST['lp_id']).api_get_cidreq(); |
|
| 1032 | - header('Location: '.$url); |
|
| 1033 | - exit; |
|
| 1034 | - } |
|
| 1035 | - break; |
|
| 1036 | - case 'edititemprereq': |
|
| 1037 | - case 'edit_item_prereq': |
|
| 1038 | - if (!$is_allowed_to_edit) { |
|
| 1039 | - api_not_allowed(true); |
|
| 1040 | - } |
|
| 1041 | - if ($debug > 0) error_log('New LP - edit item prereq action triggered', 0); |
|
| 1042 | - if (!$lp_found) { error_log('New LP - No learnpath given for edit item prereq', 0); require 'lp_list.php'; } |
|
| 1043 | - else { |
|
| 1044 | - if (!empty($_REQUEST['id']) && !empty($_REQUEST['submit_item'])) { |
|
| 1050 | + break; |
|
| 1051 | + case 'restart': |
|
| 1052 | + if ($debug > 0) error_log('New LP - restart action triggered', 0); |
|
| 1053 | + if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; } |
|
| 1054 | + else { |
|
| 1055 | + $_SESSION['oLP']->restart(); |
|
| 1056 | + require 'lp_view.php'; |
|
| 1057 | + } |
|
| 1058 | + break; |
|
| 1059 | + case 'last': |
|
| 1060 | + if ($debug > 0) error_log('New LP - last action triggered', 0); |
|
| 1061 | + if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; } |
|
| 1062 | + else { |
|
| 1063 | + $_SESSION['oLP']->last(); |
|
| 1064 | + require 'lp_view.php'; |
|
| 1065 | + } |
|
| 1066 | + break; |
|
| 1067 | + case 'first': |
|
| 1068 | + if ($debug > 0) error_log('New LP - first action triggered', 0); |
|
| 1069 | + if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; } |
|
| 1070 | + else { |
|
| 1071 | + $_SESSION['oLP']->first(); |
|
| 1072 | + require 'lp_view.php'; |
|
| 1073 | + } |
|
| 1074 | + break; |
|
| 1075 | + case 'next': |
|
| 1076 | + if ($debug > 0) error_log('New LP - next action triggered', 0); |
|
| 1077 | + if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; } |
|
| 1078 | + else { |
|
| 1079 | + $_SESSION['oLP']->next(); |
|
| 1080 | + require 'lp_view.php'; |
|
| 1081 | + } |
|
| 1082 | + break; |
|
| 1083 | + case 'previous': |
|
| 1084 | + if ($debug > 0) error_log('New LP - previous action triggered', 0); |
|
| 1085 | + if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; } |
|
| 1086 | + else { |
|
| 1087 | + $_SESSION['oLP']->previous(); |
|
| 1088 | + require 'lp_view.php'; |
|
| 1089 | + } |
|
| 1090 | + break; |
|
| 1091 | + case 'content': |
|
| 1092 | + if ($debug > 0) error_log('New LP - content action triggered', 0); |
|
| 1093 | + if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0); |
|
| 1094 | + if (!$lp_found) { |
|
| 1095 | + error_log('New LP - No learnpath given for content', 0); |
|
| 1096 | + require 'lp_list.php'; |
|
| 1097 | + } |
|
| 1098 | + else { |
|
| 1099 | + $_SESSION['oLP']->save_last(); |
|
| 1100 | + $_SESSION['oLP']->set_current_item($_GET['item_id']); |
|
| 1101 | + $_SESSION['oLP']->start_current_item(); |
|
| 1102 | + require 'lp_content.php'; |
|
| 1103 | + } |
|
| 1104 | + break; |
|
| 1105 | + case 'view': |
|
| 1106 | + if ($debug > 0) |
|
| 1107 | + error_log('New LP - view action triggered', 0); |
|
| 1108 | + if (!$lp_found) { |
|
| 1109 | + error_log('New LP - No learnpath given for view', 0); |
|
| 1110 | + require 'lp_list.php'; |
|
| 1111 | + } else { |
|
| 1112 | + if ($debug > 0) {error_log('New LP - Trying to set current item to ' . $_REQUEST['item_id'], 0); } |
|
| 1113 | + if ( !empty($_REQUEST['item_id']) ) { |
|
| 1114 | + $_SESSION['oLP']->set_current_item($_REQUEST['item_id']); |
|
| 1115 | + } |
|
| 1116 | + require 'lp_view.php'; |
|
| 1117 | + } |
|
| 1118 | + break; |
|
| 1119 | + case 'save': |
|
| 1120 | + if ($debug > 0) error_log('New LP - save action triggered', 0); |
|
| 1121 | + if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; } |
|
| 1122 | + else { |
|
| 1123 | + $_SESSION['oLP']->save_item(); |
|
| 1124 | + require 'lp_save.php'; |
|
| 1125 | + } |
|
| 1126 | + break; |
|
| 1127 | + case 'stats': |
|
| 1128 | + if ($debug > 0) error_log('New LP - stats action triggered', 0); |
|
| 1129 | + if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } |
|
| 1130 | + else { |
|
| 1131 | + $_SESSION['oLP']->save_current(); |
|
| 1132 | + $_SESSION['oLP']->save_last(); |
|
| 1133 | + $output = require 'lp_stats.php'; |
|
| 1134 | + echo $output; |
|
| 1135 | + } |
|
| 1136 | + break; |
|
| 1137 | + case 'list': |
|
| 1138 | + if ($debug > 0) error_log('New LP - list action triggered', 0); |
|
| 1139 | + if ($lp_found) { |
|
| 1045 | 1140 | $_SESSION['refresh'] = 1; |
| 1046 | - $_SESSION['oLP']->edit_item_prereq($_REQUEST['id'], $_REQUEST['prereq']); |
|
| 1141 | + $_SESSION['oLP']->save_last(); |
|
| 1047 | 1142 | } |
| 1048 | - require 'lp_admin_view.php'; |
|
| 1049 | - } |
|
| 1050 | - break; |
|
| 1051 | - case 'restart': |
|
| 1052 | - if ($debug > 0) error_log('New LP - restart action triggered', 0); |
|
| 1053 | - if (!$lp_found) { error_log('New LP - No learnpath given for restart', 0); require 'lp_list.php'; } |
|
| 1054 | - else { |
|
| 1055 | - $_SESSION['oLP']->restart(); |
|
| 1056 | - require 'lp_view.php'; |
|
| 1057 | - } |
|
| 1058 | - break; |
|
| 1059 | - case 'last': |
|
| 1060 | - if ($debug > 0) error_log('New LP - last action triggered', 0); |
|
| 1061 | - if (!$lp_found) { error_log('New LP - No learnpath given for last', 0); require 'lp_list.php'; } |
|
| 1062 | - else { |
|
| 1063 | - $_SESSION['oLP']->last(); |
|
| 1064 | - require 'lp_view.php'; |
|
| 1065 | - } |
|
| 1066 | - break; |
|
| 1067 | - case 'first': |
|
| 1068 | - if ($debug > 0) error_log('New LP - first action triggered', 0); |
|
| 1069 | - if (!$lp_found) { error_log('New LP - No learnpath given for first', 0); require 'lp_list.php'; } |
|
| 1070 | - else { |
|
| 1071 | - $_SESSION['oLP']->first(); |
|
| 1072 | - require 'lp_view.php'; |
|
| 1073 | - } |
|
| 1074 | - break; |
|
| 1075 | - case 'next': |
|
| 1076 | - if ($debug > 0) error_log('New LP - next action triggered', 0); |
|
| 1077 | - if (!$lp_found) { error_log('New LP - No learnpath given for next', 0); require 'lp_list.php'; } |
|
| 1078 | - else { |
|
| 1079 | - $_SESSION['oLP']->next(); |
|
| 1080 | - require 'lp_view.php'; |
|
| 1081 | - } |
|
| 1082 | - break; |
|
| 1083 | - case 'previous': |
|
| 1084 | - if ($debug > 0) error_log('New LP - previous action triggered', 0); |
|
| 1085 | - if (!$lp_found) { error_log('New LP - No learnpath given for previous', 0); require 'lp_list.php'; } |
|
| 1086 | - else { |
|
| 1087 | - $_SESSION['oLP']->previous(); |
|
| 1088 | - require 'lp_view.php'; |
|
| 1089 | - } |
|
| 1090 | - break; |
|
| 1091 | - case 'content': |
|
| 1092 | - if ($debug > 0) error_log('New LP - content action triggered', 0); |
|
| 1093 | - if ($debug > 0) error_log('New LP - Item id is '.intval($_GET['item_id']), 0); |
|
| 1094 | - if (!$lp_found) { |
|
| 1095 | - error_log('New LP - No learnpath given for content', 0); |
|
| 1096 | - require 'lp_list.php'; |
|
| 1097 | - } |
|
| 1098 | - else { |
|
| 1099 | - $_SESSION['oLP']->save_last(); |
|
| 1100 | - $_SESSION['oLP']->set_current_item($_GET['item_id']); |
|
| 1101 | - $_SESSION['oLP']->start_current_item(); |
|
| 1102 | - require 'lp_content.php'; |
|
| 1103 | - } |
|
| 1104 | - break; |
|
| 1105 | - case 'view': |
|
| 1106 | - if ($debug > 0) |
|
| 1107 | - error_log('New LP - view action triggered', 0); |
|
| 1108 | - if (!$lp_found) { |
|
| 1109 | - error_log('New LP - No learnpath given for view', 0); |
|
| 1110 | 1143 | require 'lp_list.php'; |
| 1111 | - } else { |
|
| 1112 | - if ($debug > 0) {error_log('New LP - Trying to set current item to ' . $_REQUEST['item_id'], 0); } |
|
| 1113 | - if ( !empty($_REQUEST['item_id']) ) { |
|
| 1114 | - $_SESSION['oLP']->set_current_item($_REQUEST['item_id']); |
|
| 1144 | + break; |
|
| 1145 | + case 'mode': |
|
| 1146 | + // Switch between fullscreen and embedded mode. |
|
| 1147 | + if ($debug > 0) error_log('New LP - mode change triggered', 0); |
|
| 1148 | + $mode = $_REQUEST['mode']; |
|
| 1149 | + if ($mode == 'fullscreen') { |
|
| 1150 | + $_SESSION['oLP']->mode = 'fullscreen'; |
|
| 1151 | + } elseif ($mode == 'embedded') { |
|
| 1152 | + $_SESSION['oLP']->mode = 'embedded'; |
|
| 1153 | + } elseif ($mode == 'embedframe') { |
|
| 1154 | + $_SESSION['oLP']->mode = 'embedframe'; |
|
| 1155 | + } elseif ($mode == 'impress') { |
|
| 1156 | + $_SESSION['oLP']->mode = 'impress'; |
|
| 1115 | 1157 | } |
| 1116 | 1158 | require 'lp_view.php'; |
| 1117 | - } |
|
| 1118 | - break; |
|
| 1119 | - case 'save': |
|
| 1120 | - if ($debug > 0) error_log('New LP - save action triggered', 0); |
|
| 1121 | - if (!$lp_found) { error_log('New LP - No learnpath given for save', 0); require 'lp_list.php'; } |
|
| 1122 | - else { |
|
| 1123 | - $_SESSION['oLP']->save_item(); |
|
| 1124 | - require 'lp_save.php'; |
|
| 1125 | - } |
|
| 1126 | - break; |
|
| 1127 | - case 'stats': |
|
| 1128 | - if ($debug > 0) error_log('New LP - stats action triggered', 0); |
|
| 1129 | - if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } |
|
| 1130 | - else { |
|
| 1131 | - $_SESSION['oLP']->save_current(); |
|
| 1132 | - $_SESSION['oLP']->save_last(); |
|
| 1133 | - $output = require 'lp_stats.php'; |
|
| 1134 | - echo $output; |
|
| 1135 | - } |
|
| 1136 | - break; |
|
| 1137 | - case 'list': |
|
| 1138 | - if ($debug > 0) error_log('New LP - list action triggered', 0); |
|
| 1139 | - if ($lp_found) { |
|
| 1140 | - $_SESSION['refresh'] = 1; |
|
| 1141 | - $_SESSION['oLP']->save_last(); |
|
| 1142 | - } |
|
| 1143 | - require 'lp_list.php'; |
|
| 1144 | - break; |
|
| 1145 | - case 'mode': |
|
| 1146 | - // Switch between fullscreen and embedded mode. |
|
| 1147 | - if ($debug > 0) error_log('New LP - mode change triggered', 0); |
|
| 1148 | - $mode = $_REQUEST['mode']; |
|
| 1149 | - if ($mode == 'fullscreen') { |
|
| 1150 | - $_SESSION['oLP']->mode = 'fullscreen'; |
|
| 1151 | - } elseif ($mode == 'embedded') { |
|
| 1152 | - $_SESSION['oLP']->mode = 'embedded'; |
|
| 1153 | - } elseif ($mode == 'embedframe') { |
|
| 1154 | - $_SESSION['oLP']->mode = 'embedframe'; |
|
| 1155 | - } elseif ($mode == 'impress') { |
|
| 1156 | - $_SESSION['oLP']->mode = 'impress'; |
|
| 1157 | - } |
|
| 1158 | - require 'lp_view.php'; |
|
| 1159 | - break; |
|
| 1160 | - case 'switch_view_mode': |
|
| 1161 | - if ($debug > 0) error_log('New LP - switch_view_mode action triggered', 0); |
|
| 1162 | - if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; } |
|
| 1163 | - if (Security::check_token('get')) { |
|
| 1159 | + break; |
|
| 1160 | + case 'switch_view_mode': |
|
| 1161 | + if ($debug > 0) error_log('New LP - switch_view_mode action triggered', 0); |
|
| 1162 | + if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; } |
|
| 1163 | + if (Security::check_token('get')) { |
|
| 1164 | + $_SESSION['refresh'] = 1; |
|
| 1165 | + $_SESSION['oLP']->update_default_view_mode(); |
|
| 1166 | + } |
|
| 1167 | + require 'lp_list.php'; |
|
| 1168 | + break; |
|
| 1169 | + case 'switch_force_commit': |
|
| 1170 | + if ($debug > 0) error_log('New LP - switch_force_commit action triggered', 0); |
|
| 1171 | + if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; } |
|
| 1164 | 1172 | $_SESSION['refresh'] = 1; |
| 1165 | - $_SESSION['oLP']->update_default_view_mode(); |
|
| 1166 | - } |
|
| 1167 | - require 'lp_list.php'; |
|
| 1168 | - break; |
|
| 1169 | - case 'switch_force_commit': |
|
| 1170 | - if ($debug > 0) error_log('New LP - switch_force_commit action triggered', 0); |
|
| 1171 | - if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; } |
|
| 1172 | - $_SESSION['refresh'] = 1; |
|
| 1173 | - $_SESSION['oLP']->update_default_scorm_commit(); |
|
| 1174 | - require 'lp_list.php'; |
|
| 1175 | - break; |
|
| 1176 | - /* Those 2 switches have been replaced by switc_attempt_mode switch |
|
| 1173 | + $_SESSION['oLP']->update_default_scorm_commit(); |
|
| 1174 | + require 'lp_list.php'; |
|
| 1175 | + break; |
|
| 1176 | + /* Those 2 switches have been replaced by switc_attempt_mode switch |
|
| 1177 | 1177 | case 'switch_reinit': |
| 1178 | 1178 | if ($debug > 0) error_log('New LP - switch_reinit action triggered', 0); |
| 1179 | 1179 | if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; } |
@@ -1196,199 +1196,199 @@ discard block |
||
| 1196 | 1196 | $_SESSION['oLP']->switch_attempt_mode(); |
| 1197 | 1197 | require 'lp_list.php'; |
| 1198 | 1198 | break; |
| 1199 | - case 'switch_scorm_debug': |
|
| 1200 | - if ($debug > 0) error_log('New LP - switch_scorm_debug action triggered', 0); |
|
| 1201 | - if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; } |
|
| 1202 | - $_SESSION['refresh'] = 1; |
|
| 1203 | - $_SESSION['oLP']->update_scorm_debug(); |
|
| 1204 | - require 'lp_list.php'; |
|
| 1205 | - break; |
|
| 1206 | - case 'intro_cmdAdd': |
|
| 1207 | - if ($debug > 0) error_log('New LP - intro_cmdAdd action triggered', 0); |
|
| 1208 | - // Add introduction section page. |
|
| 1209 | - break; |
|
| 1210 | - case 'js_api_refresh': |
|
| 1211 | - if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0); |
|
| 1212 | - if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; } |
|
| 1213 | - if (isset($_REQUEST['item_id'])) { |
|
| 1214 | - $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']); |
|
| 1215 | - } |
|
| 1216 | - require 'lp_message.php'; |
|
| 1217 | - break; |
|
| 1218 | - case 'return_to_course_homepage': |
|
| 1219 | - if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } |
|
| 1220 | - else { |
|
| 1221 | - $_SESSION['oLP']->save_current(); |
|
| 1222 | - $_SESSION['oLP']->save_last(); |
|
| 1223 | - $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id(); |
|
| 1224 | - if (isset($_GET['redirectTo']) && $_GET['redirectTo'] == 'lp_list') { |
|
| 1225 | - $url = 'lp_controller.php?'.api_get_cidreq(); |
|
| 1226 | - } |
|
| 1227 | - header('location: '.$url); |
|
| 1228 | - exit; |
|
| 1229 | - } |
|
| 1230 | - break; |
|
| 1231 | - case 'search': |
|
| 1232 | - /* Include the search script, it's smart enough to know when we are |
|
| 1199 | + case 'switch_scorm_debug': |
|
| 1200 | + if ($debug > 0) error_log('New LP - switch_scorm_debug action triggered', 0); |
|
| 1201 | + if (!$lp_found) { error_log('New LP - No learnpath given for switch', 0); require 'lp_list.php'; } |
|
| 1202 | + $_SESSION['refresh'] = 1; |
|
| 1203 | + $_SESSION['oLP']->update_scorm_debug(); |
|
| 1204 | + require 'lp_list.php'; |
|
| 1205 | + break; |
|
| 1206 | + case 'intro_cmdAdd': |
|
| 1207 | + if ($debug > 0) error_log('New LP - intro_cmdAdd action triggered', 0); |
|
| 1208 | + // Add introduction section page. |
|
| 1209 | + break; |
|
| 1210 | + case 'js_api_refresh': |
|
| 1211 | + if ($debug > 0) error_log('New LP - js_api_refresh action triggered', 0); |
|
| 1212 | + if (!$lp_found) { error_log('New LP - No learnpath given for js_api_refresh', 0); require 'lp_message.php'; } |
|
| 1213 | + if (isset($_REQUEST['item_id'])) { |
|
| 1214 | + $htmlHeadXtra[] = $_SESSION['oLP']->get_js_info($_REQUEST['item_id']); |
|
| 1215 | + } |
|
| 1216 | + require 'lp_message.php'; |
|
| 1217 | + break; |
|
| 1218 | + case 'return_to_course_homepage': |
|
| 1219 | + if (!$lp_found) { error_log('New LP - No learnpath given for stats', 0); require 'lp_list.php'; } |
|
| 1220 | + else { |
|
| 1221 | + $_SESSION['oLP']->save_current(); |
|
| 1222 | + $_SESSION['oLP']->save_last(); |
|
| 1223 | + $url = api_get_path(WEB_COURSE_PATH).api_get_course_path().'/index.php?id_session='.api_get_session_id(); |
|
| 1224 | + if (isset($_GET['redirectTo']) && $_GET['redirectTo'] == 'lp_list') { |
|
| 1225 | + $url = 'lp_controller.php?'.api_get_cidreq(); |
|
| 1226 | + } |
|
| 1227 | + header('location: '.$url); |
|
| 1228 | + exit; |
|
| 1229 | + } |
|
| 1230 | + break; |
|
| 1231 | + case 'search': |
|
| 1232 | + /* Include the search script, it's smart enough to know when we are |
|
| 1233 | 1233 | * searching or not. |
| 1234 | 1234 | */ |
| 1235 | - require 'lp_list_search.php'; |
|
| 1236 | - break; |
|
| 1237 | - case 'impress': |
|
| 1238 | - if ($debug > 0) |
|
| 1239 | - error_log('New LP - view action triggered', 0); |
|
| 1240 | - if (!$lp_found) { |
|
| 1241 | - error_log('New LP - No learnpath given for view', 0); |
|
| 1242 | - require 'lp_list.php'; |
|
| 1243 | - } else { |
|
| 1244 | - if ($debug > 0) {error_log('New LP - Trying to impress this LP item to ' . $_REQUEST['item_id'], 0); } |
|
| 1245 | - if (!empty($_REQUEST['item_id']) ) { |
|
| 1246 | - $_SESSION['oLP']->set_current_item($_REQUEST['item_id']); |
|
| 1235 | + require 'lp_list_search.php'; |
|
| 1236 | + break; |
|
| 1237 | + case 'impress': |
|
| 1238 | + if ($debug > 0) |
|
| 1239 | + error_log('New LP - view action triggered', 0); |
|
| 1240 | + if (!$lp_found) { |
|
| 1241 | + error_log('New LP - No learnpath given for view', 0); |
|
| 1242 | + require 'lp_list.php'; |
|
| 1243 | + } else { |
|
| 1244 | + if ($debug > 0) {error_log('New LP - Trying to impress this LP item to ' . $_REQUEST['item_id'], 0); } |
|
| 1245 | + if (!empty($_REQUEST['item_id']) ) { |
|
| 1246 | + $_SESSION['oLP']->set_current_item($_REQUEST['item_id']); |
|
| 1247 | + } |
|
| 1248 | + require 'lp_impress.php'; |
|
| 1249 | + } |
|
| 1250 | + break; |
|
| 1251 | + case 'set_previous_step_as_prerequisite': |
|
| 1252 | + $_SESSION['oLP']->set_previous_step_as_prerequisite_for_all_items(); |
|
| 1253 | + $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated"; |
|
| 1254 | + header('Location: '.$url); |
|
| 1255 | + break; |
|
| 1256 | + case 'clear_prerequisites': |
|
| 1257 | + $_SESSION['oLP']->clear_prerequisites(); |
|
| 1258 | + $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated"; |
|
| 1259 | + header('Location: '.$url); |
|
| 1260 | + break; |
|
| 1261 | + case 'toggle_seriousgame': //activate/deactive seriousgame_mode |
|
| 1262 | + if (!$is_allowed_to_edit) { |
|
| 1263 | + api_not_allowed(true); |
|
| 1247 | 1264 | } |
| 1248 | - require 'lp_impress.php'; |
|
| 1249 | - } |
|
| 1250 | - break; |
|
| 1251 | - case 'set_previous_step_as_prerequisite': |
|
| 1252 | - $_SESSION['oLP']->set_previous_step_as_prerequisite_for_all_items(); |
|
| 1253 | - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated"; |
|
| 1254 | - header('Location: '.$url); |
|
| 1255 | - break; |
|
| 1256 | - case 'clear_prerequisites': |
|
| 1257 | - $_SESSION['oLP']->clear_prerequisites(); |
|
| 1258 | - $url = api_get_self().'?action=add_item&type=step&lp_id='.intval($_SESSION['oLP']->lp_id)."&message=ItemUpdated"; |
|
| 1259 | - header('Location: '.$url); |
|
| 1260 | - break; |
|
| 1261 | - case 'toggle_seriousgame': //activate/deactive seriousgame_mode |
|
| 1262 | - if (!$is_allowed_to_edit) { |
|
| 1263 | - api_not_allowed(true); |
|
| 1264 | - } |
|
| 1265 | 1265 | |
| 1266 | - if ($debug > 0) { |
|
| 1267 | - error_log('New LP - seriousgame_mode action triggered'); |
|
| 1268 | - } |
|
| 1266 | + if ($debug > 0) { |
|
| 1267 | + error_log('New LP - seriousgame_mode action triggered'); |
|
| 1268 | + } |
|
| 1269 | 1269 | |
| 1270 | - if (!$lp_found) { |
|
| 1271 | - error_log('New LP - No learnpath given for visibility'); |
|
| 1270 | + if (!$lp_found) { |
|
| 1271 | + error_log('New LP - No learnpath given for visibility'); |
|
| 1272 | 1272 | |
| 1273 | - require 'lp_list.php'; |
|
| 1274 | - } |
|
| 1273 | + require 'lp_list.php'; |
|
| 1274 | + } |
|
| 1275 | 1275 | |
| 1276 | - $_SESSION['refresh'] = 1; |
|
| 1277 | - $_SESSION['oLP']->set_seriousgame_mode(); |
|
| 1278 | - require 'lp_list.php'; |
|
| 1279 | - break; |
|
| 1280 | - case 'create_forum': |
|
| 1281 | - if (!isset($_GET['id'])) { |
|
| 1276 | + $_SESSION['refresh'] = 1; |
|
| 1277 | + $_SESSION['oLP']->set_seriousgame_mode(); |
|
| 1278 | + require 'lp_list.php'; |
|
| 1282 | 1279 | break; |
| 1283 | - } |
|
| 1284 | - |
|
| 1285 | - $selectedItem = null; |
|
| 1286 | - |
|
| 1287 | - foreach ($_SESSION['oLP']->items as $item) { |
|
| 1288 | - if ($item->db_id == $_GET['id']) { |
|
| 1289 | - $selectedItem = $item; |
|
| 1280 | + case 'create_forum': |
|
| 1281 | + if (!isset($_GET['id'])) { |
|
| 1282 | + break; |
|
| 1290 | 1283 | } |
| 1291 | - } |
|
| 1292 | 1284 | |
| 1293 | - if (!empty($selectedItem)) { |
|
| 1294 | - $forumThread = $selectedItem->getForumThread( |
|
| 1295 | - $_SESSION['oLP']->course_int_id, |
|
| 1296 | - $_SESSION['oLP']->lp_session_id |
|
| 1297 | - ); |
|
| 1285 | + $selectedItem = null; |
|
| 1298 | 1286 | |
| 1299 | - if (empty($forumThread)) { |
|
| 1300 | - require '../forum/forumfunction.inc.php'; |
|
| 1287 | + foreach ($_SESSION['oLP']->items as $item) { |
|
| 1288 | + if ($item->db_id == $_GET['id']) { |
|
| 1289 | + $selectedItem = $item; |
|
| 1290 | + } |
|
| 1291 | + } |
|
| 1301 | 1292 | |
| 1302 | - $forumCategory = getForumCategoryByTitle( |
|
| 1303 | - get_lang('LearningPaths'), |
|
| 1293 | + if (!empty($selectedItem)) { |
|
| 1294 | + $forumThread = $selectedItem->getForumThread( |
|
| 1304 | 1295 | $_SESSION['oLP']->course_int_id, |
| 1305 | 1296 | $_SESSION['oLP']->lp_session_id |
| 1306 | 1297 | ); |
| 1307 | 1298 | |
| 1308 | - $forumCategoryId = !empty($forumCategory) ? $forumCategory['cat_id']: 0; |
|
| 1309 | - |
|
| 1310 | - if (empty($forumCategoryId)) { |
|
| 1311 | - $forumCategoryId = store_forumcategory( |
|
| 1312 | - [ |
|
| 1313 | - 'lp_id' => 0, |
|
| 1314 | - 'forum_category_title' => get_lang('LearningPaths'), |
|
| 1315 | - 'forum_category_comment' => null |
|
| 1316 | - ], |
|
| 1317 | - [], |
|
| 1318 | - false |
|
| 1319 | - ); |
|
| 1320 | - } |
|
| 1299 | + if (empty($forumThread)) { |
|
| 1300 | + require '../forum/forumfunction.inc.php'; |
|
| 1321 | 1301 | |
| 1322 | - if (!empty($forumCategoryId)) { |
|
| 1323 | - $forum = $_SESSION['oLP']->getForum( |
|
| 1302 | + $forumCategory = getForumCategoryByTitle( |
|
| 1303 | + get_lang('LearningPaths'), |
|
| 1304 | + $_SESSION['oLP']->course_int_id, |
|
| 1324 | 1305 | $_SESSION['oLP']->lp_session_id |
| 1325 | 1306 | ); |
| 1326 | 1307 | |
| 1327 | - $forumId = !empty($forum) ? $forum['forum_id'] : 0; |
|
| 1328 | - |
|
| 1329 | - if (empty($forumId)) { |
|
| 1330 | - $forumId = $_SESSION['oLP']->createForum($forumCategoryId); |
|
| 1308 | + $forumCategoryId = !empty($forumCategory) ? $forumCategory['cat_id']: 0; |
|
| 1309 | + |
|
| 1310 | + if (empty($forumCategoryId)) { |
|
| 1311 | + $forumCategoryId = store_forumcategory( |
|
| 1312 | + [ |
|
| 1313 | + 'lp_id' => 0, |
|
| 1314 | + 'forum_category_title' => get_lang('LearningPaths'), |
|
| 1315 | + 'forum_category_comment' => null |
|
| 1316 | + ], |
|
| 1317 | + [], |
|
| 1318 | + false |
|
| 1319 | + ); |
|
| 1331 | 1320 | } |
| 1332 | 1321 | |
| 1333 | - if (!empty($forumId)) { |
|
| 1334 | - $selectedItem->createForumThread($forumId); |
|
| 1322 | + if (!empty($forumCategoryId)) { |
|
| 1323 | + $forum = $_SESSION['oLP']->getForum( |
|
| 1324 | + $_SESSION['oLP']->lp_session_id |
|
| 1325 | + ); |
|
| 1326 | + |
|
| 1327 | + $forumId = !empty($forum) ? $forum['forum_id'] : 0; |
|
| 1328 | + |
|
| 1329 | + if (empty($forumId)) { |
|
| 1330 | + $forumId = $_SESSION['oLP']->createForum($forumCategoryId); |
|
| 1331 | + } |
|
| 1332 | + |
|
| 1333 | + if (!empty($forumId)) { |
|
| 1334 | + $selectedItem->createForumThread($forumId); |
|
| 1335 | + } |
|
| 1335 | 1336 | } |
| 1336 | 1337 | } |
| 1337 | 1338 | } |
| 1338 | - } |
|
| 1339 | 1339 | |
| 1340 | - header('Location:' . api_get_self() . '?' . http_build_query([ |
|
| 1341 | - 'action' => 'add_item', |
|
| 1342 | - 'type' => 'step', |
|
| 1343 | - 'lp_id' => $_SESSION['oLP']->lp_id |
|
| 1344 | - ])); |
|
| 1340 | + header('Location:' . api_get_self() . '?' . http_build_query([ |
|
| 1341 | + 'action' => 'add_item', |
|
| 1342 | + 'type' => 'step', |
|
| 1343 | + 'lp_id' => $_SESSION['oLP']->lp_id |
|
| 1344 | + ])); |
|
| 1345 | 1345 | |
| 1346 | - break; |
|
| 1347 | - case 'report': |
|
| 1348 | - require 'lp_report.php'; |
|
| 1349 | - break; |
|
| 1350 | - case 'dissociate_forum': |
|
| 1351 | - if (!isset($_GET['id'])) { |
|
| 1352 | 1346 | break; |
| 1353 | - } |
|
| 1347 | + case 'report': |
|
| 1348 | + require 'lp_report.php'; |
|
| 1349 | + break; |
|
| 1350 | + case 'dissociate_forum': |
|
| 1351 | + if (!isset($_GET['id'])) { |
|
| 1352 | + break; |
|
| 1353 | + } |
|
| 1354 | 1354 | |
| 1355 | - $selectedItem = null; |
|
| 1355 | + $selectedItem = null; |
|
| 1356 | 1356 | |
| 1357 | - foreach ($_SESSION['oLP']->items as $item) { |
|
| 1358 | - if ($item->db_id != $_GET['id']) { |
|
| 1359 | - continue; |
|
| 1360 | - } |
|
| 1357 | + foreach ($_SESSION['oLP']->items as $item) { |
|
| 1358 | + if ($item->db_id != $_GET['id']) { |
|
| 1359 | + continue; |
|
| 1360 | + } |
|
| 1361 | 1361 | |
| 1362 | - $selectedItem = $item; |
|
| 1363 | - } |
|
| 1362 | + $selectedItem = $item; |
|
| 1363 | + } |
|
| 1364 | 1364 | |
| 1365 | - if (!empty($selectedItem)) { |
|
| 1366 | - $forumThread = $selectedItem->getForumThread( |
|
| 1367 | - $_SESSION['oLP']->course_int_id, |
|
| 1368 | - $_SESSION['oLP']->lp_session_id |
|
| 1369 | - ); |
|
| 1365 | + if (!empty($selectedItem)) { |
|
| 1366 | + $forumThread = $selectedItem->getForumThread( |
|
| 1367 | + $_SESSION['oLP']->course_int_id, |
|
| 1368 | + $_SESSION['oLP']->lp_session_id |
|
| 1369 | + ); |
|
| 1370 | 1370 | |
| 1371 | - if (!empty($forumThread)) { |
|
| 1372 | - $dissoaciated = $selectedItem->dissociateForumThread($forumThread['iid']); |
|
| 1371 | + if (!empty($forumThread)) { |
|
| 1372 | + $dissoaciated = $selectedItem->dissociateForumThread($forumThread['iid']); |
|
| 1373 | 1373 | |
| 1374 | - if ($dissoaciated) { |
|
| 1375 | - Display::addFlash( |
|
| 1376 | - Display::return_message(get_lang('ForumDissociate'), 'success') |
|
| 1377 | - ); |
|
| 1374 | + if ($dissoaciated) { |
|
| 1375 | + Display::addFlash( |
|
| 1376 | + Display::return_message(get_lang('ForumDissociate'), 'success') |
|
| 1377 | + ); |
|
| 1378 | + } |
|
| 1378 | 1379 | } |
| 1379 | 1380 | } |
| 1380 | - } |
|
| 1381 | 1381 | |
| 1382 | - header('Location:' . api_get_self() . '?' . http_build_query([ |
|
| 1383 | - 'action' => 'add_item', |
|
| 1384 | - 'type' => 'step', |
|
| 1385 | - 'lp_id' => $_SESSION['oLP']->lp_id |
|
| 1386 | - ])); |
|
| 1387 | - break; |
|
| 1388 | - default: |
|
| 1389 | - if ($debug > 0) error_log('New LP - default action triggered', 0); |
|
| 1390 | - require 'lp_list.php'; |
|
| 1391 | - break; |
|
| 1382 | + header('Location:' . api_get_self() . '?' . http_build_query([ |
|
| 1383 | + 'action' => 'add_item', |
|
| 1384 | + 'type' => 'step', |
|
| 1385 | + 'lp_id' => $_SESSION['oLP']->lp_id |
|
| 1386 | + ])); |
|
| 1387 | + break; |
|
| 1388 | + default: |
|
| 1389 | + if ($debug > 0) error_log('New LP - default action triggered', 0); |
|
| 1390 | + require 'lp_list.php'; |
|
| 1391 | + break; |
|
| 1392 | 1392 | } |
| 1393 | 1393 | |
| 1394 | 1394 | if (!empty($_SESSION['oLP'])) { |