Should fix bug when editing a link from the course home page see #4135

skala
Julio Montoya 14 years ago
parent 76e43ad6e0
commit 0714f0c565
  1. 22
      main/inc/lib/link.lib.php
  2. 16
      main/link/link.php

@ -271,7 +271,29 @@ function delete_link_from_search_engine($course_id, $link_id) {
}
}
/**
*
* Get link info
* @param int link id
* @return array link info
*
* */
function get_link_info($id) {
$tbl_link = Database :: get_course_table(TABLE_LINK);
$course_id = api_get_course_int_id();
$sql = "SELECT * FROM " . $tbl_link . " WHERE c_id = $course_id AND id='" . intval($id) . "' ";
$result = Database::query($sql);
if (Database::num_rows($result)) {
$data = Database::fetch_array($result);
}
return $data;
}
/**
* Used to edit a link or a category
* @todo Rewrite the whole links tool because it is becoming completely cluttered,
* code does not follow the coding conventions, does not use html_quickform, ...

@ -200,9 +200,21 @@ if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) {
echo '<form method="post" action="'.api_get_self().'?action='.Security::remove_XSS($_GET['action']).'&amp;urlview='.Security::remove_XSS($urlview).'">';
echo '<input type="hidden" name="sec_token" value="'.$token.'" />';
if ($_GET['action'] == 'editlink') {
echo '<input type="hidden" name="id" value="'.intval($_GET['id']).'" />';
$clean_link_id = intval($_GET['id']);
$link_info = get_link_info($_GET['id']);
if ($link_info) {
$urllink = $link_info['url'];
$title = $link_info['title'];
$description = $link_info['description'];
$category = $link_info['category_id'];
$onhomepage = '';
if ($link_info['on_homepage'] != 0) {
$onhomepage = 'checked';
}
$target_link = $link_info['target'];
}
$clean_link_id = trim(Security::remove_XSS($_GET['id']));
echo '<input type="hidden" name="id" value="'.$clean_link_id.'" />';
}
echo ' <div class="row">
<div class="label">

Loading…
Cancel
Save