Project

General

Profile

Bug #5395 » lp_edit_item_prereq.php

Yoselyn Castillo, 14/09/2012 17:23

 
1
<?php
2
/* For licensing terms, see /license.txt */
3
/**
4
 * This is a learning path creation and player tool in Chamilo - previously learnpath_handler.php
5
 *
6
 * @author Patrick Cool
7
 * @author Denes Nagy
8
 * @author Roan Embrechts, refactoring and code cleaning
9
 * @author Yannick Warnier <ywarnier@beeznest.org> - cleaning and update for new SCORM tool
10
 * @package chamilo.learnpath
11
 */
12

    
13
$this_section = SECTION_COURSES;
14

    
15
api_protect_course_script();
16

    
17
/* Libraries */
18

    
19
include 'learnpath_functions.inc.php';
20
//include '../resourcelinker/resourcelinker.inc.php';
21
include 'resourcelinker.inc.php';
22
// Rewrite the language file, sadly overwritten by resourcelinker.inc.php.
23
// Name of the language file that needs to be included.
24
$language_file = 'learnpath';
25

    
26
/* Constants and variables */
27

    
28
$is_allowed_to_edit = api_is_allowed_to_edit(null, true);
29

    
30
$tbl_lp = Database::get_course_table(TABLE_LP_MAIN);
31
$tbl_lp_item = Database::get_course_table(TABLE_LP_ITEM);
32
$tbl_lp_view = Database::get_course_table(TABLE_LP_VIEW);
33

    
34
$isStudentView  = (int) $_REQUEST['isStudentView'];
35
$learnpath_id   = (int) $_REQUEST['lp_id'];
36
$submit			= $_POST['submit_button'];
37

    
38
/* MAIN CODE */
39

    
40
// Using the resource linker as a tool for adding resources to the learning path.
41
if ($action == 'add' and $type == 'learnpathitem') {
42
     $htmlHeadXtra[] = "<script language='JavaScript' type='text/javascript'> window.location=\"../resourcelinker/resourcelinker.php?source_id=5&action=$action&learnpath_id=$learnpath_id&chapter_id=$chapter_id&originalresource=no\"; </script>";
43
}
44
if ((! $is_allowed_to_edit) || ($isStudentView)) {
45
    error_log('New LP - User not authorized in lp_edit_item_prereq.php');
46
    header('location:lp_controller.php?action=view&lp_id='.$learnpath_id);
47
}
48
$course_id = api_get_course_int_id();
49

    
50

    
51
$sql_query = "SELECT * FROM $tbl_lp WHERE c_id = $course_id AND id = $learnpath_id";
52
$result = Database::query($sql_query);
53
$therow = Database::fetch_array($result);
54

    
55
/* SHOWING THE ADMIN TOOLS */
56

    
57
if (isset($_SESSION['gradebook'])){
58
    $gradebook = $_SESSION['gradebook'];
59
}
60

    
61
if (!empty($gradebook) && $gradebook == 'view') {
62
    $interbreadcrumb[] = array (
63
            'url' => '../gradebook/'.$_SESSION['gradebook_dest'],
64
            'name' => get_lang('ToolGradebook')
65
        );
66
}
67

    
68
$interbreadcrumb[] = array('url' => 'lp_controller.php?action=list', 'name' => get_lang('LearningPaths'));
69
$interbreadcrumb[] = array('url' => api_get_self()."?action=build&lp_id=$learnpath_id", 'name' => stripslashes("{$therow['name']}"));
70
$interbreadcrumb[] = array('url' => api_get_self()."?action=add_item&type=step&lp_id=$learnpath_id", 'name' => get_lang('NewStep'));
71

    
72
// Theme calls.
73
$show_learn_path = true;
74
$lp_theme_css = $_SESSION['oLP']->get_theme();
75

    
76
Display::display_header(get_lang('Prerequisites'),'Path');
77

    
78
$suredel = trim(get_lang('AreYouSureToDelete'));
79
?>
80
<script type='text/javascript'>
81
/* <![CDATA[ */
82
function stripslashes(str) {
83
    str=str.replace(/\\'/g,'\'');
84
    str=str.replace(/\\"/g,'"');
85
    str=str.replace(/\\\\/g,'\\');
86
    str=str.replace(/\\0/g,'\0');
87
    return str;
88
}
89
function confirmation(name)
90
{
91
    name=stripslashes(name);
92
    if (confirm("<?php echo $suredel; ?> " + name + " ?"))
93
    {
94
        return true;
95
    }
96
    else
97
    {
98
        return false;
99
    }
100
}
101
</script>
102
<?php
103

    
104
//echo $admin_output;
105

    
106
/* DISPLAY SECTION */
107

    
108
echo $_SESSION['oLP']->build_action_menu();
109

    
110
echo '<div class="row-fluid">';
111
echo '<div class="span3">';
112
    echo $_SESSION['oLP']->return_new_tree();
113
echo '</div>';
114
echo '<div class="span9">';
115

    
116
if (isset($is_success) && $is_success == true) {
117
    echo $_SESSION['oLP']->display_manipulate($_GET['id'], null);
118
    echo '<div class="normal-message" style="margin:3px 10px;">';
119
    echo get_lang("PrerequisitesAdded");
120
    echo '</div>';
121
} else {
122
    echo $_SESSION['oLP']->display_manipulate($_GET['id'], null);
123
    echo $_SESSION['oLP']->display_item_prerequisites_form($_GET['id']);
124
}
125
echo '</div>';
126

    
127
/* FOOTER */
128
Display::display_footer();
(3-3/4)