diff --git a/main/inc/lib/link.lib.php b/main/inc/lib/link.lib.php index 9ba6bc1ac4..fc872a46ba 100755 --- a/main/inc/lib/link.lib.php +++ b/main/inc/lib/link.lib.php @@ -264,6 +264,7 @@ function deletelinkcategory($type) { global $catlinkstatus; global $_course; + $session_id = api_get_session_id(); $tbl_link = Database :: get_course_table(TABLE_LINK); $tbl_categories = Database :: get_course_table(TABLE_LINK_CATEGORY); $TABLE_ITEM_PROPERTY = Database :: get_course_table(TABLE_ITEM_PROPERTY); @@ -295,6 +296,11 @@ function deletelinkcategory($type) $catlinkstatus = get_lang('CategoryDeleted'); unset ($id); Database :: query($sql); + // Delete relation link_category : item_property : link_category not exist delete Logic. + $sqlP = "DELETE FROM $TABLE_ITEM_PROPERTY WHERE c_id = $course_id AND tool = '". TOOL_LINK_CATEGORY ."' " + . "AND ref = '" . intval($_GET['id']) . "' AND id_session = '$session_id' "; + Database :: query($sqlP); + Display :: display_confirmation_message(get_lang('CategoryDeleted')); } } @@ -609,7 +615,10 @@ function change_visibility($id, $scope) { if ($scope == 'link') { api_item_property_update($_course, TOOL_LINK, $id, $_GET['action'], $_user['user_id']); Display :: display_confirmation_message(get_lang('VisibilityChanged')); - } + } elseif ($scope == TOOL_LINK_CATEGORY) { + api_item_property_update($_course, TOOL_LINK_CATEGORY, $id, $_GET['action'], $_user['user_id']); + Display :: display_confirmation_message(get_lang('VisibilityChanged')); + } } /** diff --git a/main/link/link.php b/main/link/link.php index 9d91abbb58..18db122b6e 100755 --- a/main/link/link.php +++ b/main/link/link.php @@ -35,18 +35,18 @@ api_protect_course_script(); $htmlHeadXtra[] = ''; @@ -78,21 +78,21 @@ $session_id = api_get_session_id(); $condition_session = api_get_session_condition($session_id, true, true); if (isset($_GET['action']) && $_GET['action'] == 'addlink') { - $nameTools = ''; - $interbreadcrumb[] = array('url' => 'link.php', 'name' => get_lang('Links')); - $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AddLink')); + $nameTools = ''; + $interbreadcrumb[] = array('url' => 'link.php', 'name' => get_lang('Links')); + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AddLink')); } if (isset($_GET['action']) && $_GET['action'] == 'addcategory') { - $nameTools = ''; - $interbreadcrumb[] = array('url' => 'link.php', 'name' => get_lang('Links')); - $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AddCategory')); + $nameTools = ''; + $interbreadcrumb[] = array('url' => 'link.php', 'name' => get_lang('Links')); + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('AddCategory')); } if (isset($_GET['action']) && $_GET['action'] == 'editlink') { - $nameTools = ''; - $interbreadcrumb[] = array('url' => 'link.php', 'name' => get_lang('Links')); - $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('EditLink')); + $nameTools = ''; + $interbreadcrumb[] = array('url' => 'link.php', 'name' => get_lang('Links')); + $interbreadcrumb[] = array('url' => '#', 'name' => get_lang('EditLink')); } // Database Table definitions @@ -122,49 +122,49 @@ function MM_popupMsg(msg) { //v1.0 $nameTools = get_lang('Links'); if (isset($_GET['action'])) { - $check_token = Security::check_token('request'); - if ($check_token) { - switch ($_GET['action']) { - case 'addlink': - if ($link_submitted) { - if (!addlinkcategory("link")) { // Here we add a link - unset($submit_link); - } - } - break; - case 'addcategory': - if ($category_submitted) { - if (!addlinkcategory('category')) { // Here we add a category - unset($submit_category); - } - } - break; - case 'importcsv': - if ($_POST['submitImport']) { - import_csvfile(); - } - break; - case 'deletelink': - deletelinkcategory('link'); // Here we delete a link - break; - case 'deletecategory': - deletelinkcategory('category'); // Here we delete a category - break; - case 'editlink': - editlinkcategory('link'); // Here we edit a link - break; - case 'editcategory': - editlinkcategory('category'); // Here we edit a category - break; - case 'visible': - change_visibility($_GET['id'], $_GET['scope']); // Here we edit a category - break; - case 'invisible': - change_visibility($_GET['id'], $_GET['scope']); // Here we edit a category - break; - } - Security::clear_token(); - } + $check_token = Security::check_token('request'); + if ($check_token) { + switch ($_GET['action']) { + case 'addlink': + if ($link_submitted) { + if (!addlinkcategory("link")) { // Here we add a link + unset($submit_link); + } + } + break; + case 'addcategory': + if ($category_submitted) { + if (!addlinkcategory('category')) { // Here we add a category + unset($submit_category); + } + } + break; + case 'importcsv': + if ($_POST['submitImport']) { + import_csvfile(); + } + break; + case 'deletelink': + deletelinkcategory('link'); // Here we delete a link + break; + case 'deletecategory': + deletelinkcategory('category'); // Here we delete a category + break; + case 'editlink': + editlinkcategory('link'); // Here we edit a link + break; + case 'editcategory': + editlinkcategory('category'); // Here we edit a category + break; + case 'visible': + change_visibility($_GET['id'], $_GET['scope']); // Here we edit a category + break; + case 'invisible': + change_visibility($_GET['id'], $_GET['scope']); // Here we edit a category + break; + } + Security::clear_token(); + } } $token = Security::get_token(); @@ -173,38 +173,38 @@ $token = Security::get_token(); Display::display_introduction_section(TOOL_LINK); if (api_is_allowed_to_edit(null, true) && isset($_GET['action'])) { - echo '