Fix edit final lp item see BT#12234

pull/2487/head
jmontoyaa 9 years ago
parent 336fbd60ff
commit 79294a7388
  1. 51
      main/lp/learnpath.class.php

@ -5561,7 +5561,7 @@ class learnpath
$title_cut,
$url,
array(
'class' => 'ajax moved',
'class' => 'ajax moved',
'data-title' => $title_cut
)
);
@ -5578,7 +5578,6 @@ class learnpath
$oddClass = 'row_even';
}
$return_audio .= '<tr id ="lp_item_'.$arrLP[$i]['id'] .'" class="' . $oddClass . '">';
$icon_name = str_replace(' ', '', $arrLP[$i]['item_type']);
if (file_exists('../img/lp_' . $icon_name . '.png')) {
@ -5675,6 +5674,12 @@ class learnpath
$edit_icon .= Display::return_icon('edit.png', get_lang('LearnpathEditModule'), array(), ICON_SIZE_TINY);
$edit_icon .= '</a>';
}
} else {
if ($arrLP[$i]['item_type'] == TOOL_LP_FINAL_ITEM) {
$edit_icon .= '<a href="'.api_get_self().'?'.api_get_cidreq().'&action=edit_item&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id.'" class="btn btn-default">';
$edit_icon .= Display::return_icon('edit.png', get_lang('Edit'), array(), ICON_SIZE_TINY);
$edit_icon .= '</a>';
}
}
$delete_icon .= ' <a href="'.api_get_self().'?'.api_get_cidreq().'&action=delete_item&id=' . $arrLP[$i]['id'] . '&lp_id=' . $this->lp_id . '" onclick="return confirmation(\'' . addslashes($title) . '\');" class="btn btn-default">';
@ -6125,12 +6130,13 @@ class learnpath
$dir = $result['dir'];
if (empty($parentId)) {
$postDir = isset($_POST['dir']) ? $_POST['dir'] : '';
$dir = isset ($_GET['dir']) ? $_GET['dir'] : $postDir; // Please, do not modify this dirname formatting.
$postDir = isset($_POST['dir']) ? $_POST['dir'] : $dir;
$dir = isset($_GET['dir']) ? $_GET['dir'] : $postDir; // Please, do not modify this dirname formatting.
// Please, do not modify this dirname formatting.
if (strstr($dir, '..')) {
$dir = '/';
}
if (!empty($dir[0]) && $dir[0] == '.') {
$dir = substr($dir, 1);
}
@ -6147,11 +6153,10 @@ class learnpath
}
}
$filepath = api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/document'.$dir;
$filepath = api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/document/'.$dir;
if (!is_dir($filepath)) {
$dir = '/';
$filepath = api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/document'.$dir;
$filepath = api_get_path(SYS_COURSE_PATH) . $courseInfo['path'] . '/document/'.$dir;
}
// stripslashes() before calling api_replace_dangerous_char() because $_POST['title']
@ -6276,21 +6281,22 @@ class learnpath
$course_id = api_get_course_int_id();
$urlAppend = api_get_configuration_value('url_append');
// Please, do not modify this dirname formatting.
$dir = isset($_GET['dir']) ? $_GET['dir'] : $_POST['dir'];
$postDir = isset($_POST['dir']) ? $_POST['dir'] : '';
$dir = isset($_GET['dir']) ? $_GET['dir'] : $postDir;
if (strstr($dir, '..')) {
$dir = '/';
}
if ($dir[0] == '.') {
if (isset($dir[0]) && $dir[0] == '.') {
$dir = substr($dir, 1);
}
if ($dir[0] != '/') {
if (isset($dir[0]) && $dir[0] != '/') {
$dir = '/'.$dir;
}
if ($dir[strlen($dir) - 1] != '/') {
if (isset($dir[strlen($dir) - 1] ) && $dir[strlen($dir) - 1] != '/') {
$dir .= '/';
}
@ -6301,6 +6307,7 @@ class learnpath
}
$table_doc = Database::get_course_table(TABLE_DOCUMENT);
if (isset($_POST['path']) && !empty($_POST['path'])) {
$document_id = intval($_POST['path']);
$sql = "SELECT path FROM " . $table_doc . "
@ -6312,7 +6319,6 @@ class learnpath
if ($fp = @ fopen($file, 'w')) {
$content = str_replace(api_get_path(WEB_COURSE_PATH), $urlAppend.api_get_path(REL_COURSE_PATH), $content);
// Change the path of mp3 to absolute.
// The first regexp deals with :// urls.
$content = preg_replace("|(flashvars=\"file=)([^:/]+)/|", "$1" . api_get_path(REL_COURSE_PATH) . $_course['path'] . '/document/', $content);
@ -6324,6 +6330,7 @@ class learnpath
$sql = "UPDATE " . $table_doc ." SET
title='".Database::escape_string($_POST['title'])."'
WHERE c_id = ".$course_id." AND id = " . $document_id;
Database::query($sql);
}
}
@ -6633,7 +6640,7 @@ class learnpath
if ($iframe) {
$return .= '<iframe id="learnpath_preview_frame" frameborder="0" height="400" width="100%" scrolling="auto" src="' . api_get_path(WEB_COURSE_PATH) . $_course['path'] . '/document' . str_replace('%2F', '/', urlencode($row_doc['path'])) . '?' . api_get_cidreq() . '"></iframe>';
} else {
$return .= file_get_contents(api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document' . $row_doc['path']);
$return .= file_get_contents(api_get_path(SYS_COURSE_PATH) . $_course['path'] . '/document/' . $row_doc['path']);
}
return $return;
@ -7815,7 +7822,6 @@ class learnpath
if (isset($_GET['edit']) && $_GET['edit'] == 'true') {
$return .= Display::return_message('<strong>' . get_lang('Warning') . ' !</strong><br />' . get_lang('WarningEditingDocument'), false);
}
$form = new FormValidator(
'form',
'POST',
@ -8069,6 +8075,12 @@ class learnpath
}
}
}
if (isset($extra_info['item_type'] ) &&
$extra_info['item_type'] == TOOL_LP_FINAL_ITEM
) {
$parent_select->freeze();
$position->freeze();
}
if ($action == 'move') {
$form->addElement('hidden', 'title', $item_title);
@ -11487,17 +11499,6 @@ EOD;
break;
case TOOL_LINK:
$link .= $main_dir_path.'link/link_goto.php?'.api_get_cidreq().'&link_id='.$id;
/*$TABLETOOLLINK = Database::get_course_table(TABLE_LINK);
$result = Database::query("SELECT * FROM $TABLETOOLLINK WHERE c_id = $course_id AND id=$id");
$myrow = Database::fetch_array($result);
$thelink = $myrow["url"];
$link = Display::url(
Display::return_icon('preview_view.png', get_lang('Preview')),
api_get_path(WEB_CODE_PATH).'link/link_goto.php?'.api_get_cidreq().'&link_id='.$key,
['target' => '_blank']
);
$link .= $thelink;*/
break;
case TOOL_QUIZ:
if (!empty($id)) {

Loading…
Cancel
Save