chamilo /
chamilo-lms
| 1 | <?php |
||
| 2 | |||
| 3 | /* For licensing terms, see /license.txt */ |
||
| 4 | |||
| 5 | /** |
||
| 6 | * Main script for the links tool. |
||
| 7 | * |
||
| 8 | * Features: |
||
| 9 | * - Organize links into categories; |
||
| 10 | * - favorites/bookmarks-like interface; |
||
| 11 | * - move links up/down within a category; |
||
| 12 | * - move categories up/down; |
||
| 13 | * - expand/collapse all categories (except the main "non"-category); |
||
| 14 | * - add link to 'root' category => category-less link is always visible. |
||
| 15 | * |
||
| 16 | * @author Julio Montoya code rewritten |
||
| 17 | * @author Patrick Cool |
||
| 18 | * @author René Haentjens, added CSV file import (October 2004) |
||
| 19 | */ |
||
| 20 | require_once __DIR__.'/../inc/global.inc.php'; |
||
| 21 | |||
| 22 | $current_course_tool = TOOL_LINK; |
||
| 23 | $this_section = SECTION_COURSES; |
||
| 24 | api_protect_course_script(true); |
||
| 25 | |||
| 26 | $htmlHeadXtra[] = '<script> |
||
| 27 | $(function() { |
||
| 28 | for (i=0;i<$(".actions").length;i++) { |
||
| 29 | if ($(".actions:eq("+i+")").html()=="<table border=\"0\"></table>" || $(".actions:eq("+i+")").html()=="" || $(".actions:eq("+i+")").html()==null) { |
||
| 30 | $(".actions:eq("+i+")").hide(); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | }); |
||
| 34 | |||
| 35 | function check_url(id, url) { |
||
| 36 | var url = "'.api_get_path(WEB_AJAX_PATH).'link.ajax.php?a=check_url&url=" +url; |
||
| 37 | var loading = " '.addslashes(Display::return_icon('loading1.gif')).'"; |
||
| 38 | $("#url_id_"+id).html(loading); |
||
| 39 | $("#url_id_"+id).load(url); |
||
| 40 | } |
||
| 41 | </script>'; |
||
| 42 | |||
| 43 | $down = !empty($_GET['down']) ? $_GET['down'] : ''; |
||
| 44 | $up = !empty($_GET['up']) ? $_GET['up'] : ''; |
||
| 45 | $id = !empty($_REQUEST['id']) ? $_REQUEST['id'] : ''; |
||
| 46 | $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; |
||
| 47 | |||
| 48 | $nameTools = get_lang('Links'); |
||
| 49 | $course_id = api_get_course_int_id(); |
||
| 50 | $session_id = api_get_session_id(); |
||
| 51 | $courseInfo = api_get_course_info(); |
||
| 52 | $course = api_get_course_entity(); |
||
| 53 | $session = api_get_session_entity(); |
||
| 54 | |||
| 55 | if ('addlink' === $action) { |
||
| 56 | $nameTools = ''; |
||
| 57 | $interbreadcrumb[] = ['url' => 'link.php', 'name' => get_lang('Links')]; |
||
| 58 | $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add a link')]; |
||
| 59 | } |
||
| 60 | |||
| 61 | if ('addcategory' === $action) { |
||
| 62 | $nameTools = ''; |
||
| 63 | $interbreadcrumb[] = ['url' => 'link.php', 'name' => get_lang('Links')]; |
||
| 64 | $interbreadcrumb[] = ['url' => '#', 'name' => get_lang('Add category')]; |
||
| 65 | } |
||
| 66 | |||
| 67 | if ('editlink' === $action) { |
||
| 68 | $nameTools = get_lang('Edit link'); |
||
| 69 | $interbreadcrumb[] = ['url' => 'link.php', 'name' => get_lang('Links')]; |
||
| 70 | } |
||
| 71 | |||
| 72 | Event::event_access_tool(TOOL_LINK); |
||
|
0 ignored issues
–
show
|
|||
| 73 | |||
| 74 | /* Action Handling */ |
||
| 75 | $id = isset($_REQUEST['id']) ? $_REQUEST['id'] : null; |
||
| 76 | $scope = isset($_REQUEST['scope']) ? $_REQUEST['scope'] : null; |
||
| 77 | $show = isset($_REQUEST['show']) && in_array(trim($_REQUEST['show']), ['all', 'none']) ? $_REQUEST['show'] : 'all'; |
||
| 78 | $categoryId = isset($_REQUEST['category_id']) ? (int) $_REQUEST['category_id'] : ''; |
||
| 79 | $linkListUrl = api_get_self().'?'.api_get_cidreq().'&category_id='.$categoryId.'&show='.$show; |
||
| 80 | $content = ''; |
||
| 81 | $token = Security::get_existing_token(); |
||
| 82 | |||
| 83 | $protectedActions = [ |
||
| 84 | 'addlink', |
||
| 85 | 'editlink', |
||
| 86 | 'addcategory', |
||
| 87 | 'editcategory', |
||
| 88 | 'deletelink', |
||
| 89 | 'deletecategory', |
||
| 90 | 'visible', |
||
| 91 | 'invisible', |
||
| 92 | 'up', |
||
| 93 | 'down', |
||
| 94 | 'move_link_up', |
||
| 95 | 'move_link_down', |
||
| 96 | ]; |
||
| 97 | |||
| 98 | // block access |
||
| 99 | if (in_array($action, $protectedActions) && |
||
| 100 | !api_is_allowed_to_edit(null, true) |
||
| 101 | ) { |
||
| 102 | api_not_allowed(true); |
||
| 103 | } |
||
| 104 | |||
| 105 | switch ($action) { |
||
| 106 | case 'addlink': |
||
| 107 | $form = Link::getLinkForm(null, 'addlink', $token); |
||
| 108 | if ($form->validate() && Security::check_token('get')) { |
||
| 109 | $link = new Link(); |
||
| 110 | $link->setCourse($courseInfo); |
||
| 111 | $linkId = $link->save($form->exportValues()); |
||
| 112 | SkillModel::saveSkills($form, ITEM_TYPE_LINK, $linkId); |
||
| 113 | |||
| 114 | Security::clear_token(); |
||
| 115 | header('Location: '.$linkListUrl); |
||
| 116 | exit; |
||
| 117 | } |
||
| 118 | $content = $form->returnForm(); |
||
| 119 | |||
| 120 | break; |
||
| 121 | case 'editlink': |
||
| 122 | $form = Link::getLinkForm($id, 'editlink'); |
||
| 123 | if ($form->validate()) { |
||
| 124 | Link::editLink($id, $form->getSubmitValues()); |
||
| 125 | SkillModel::saveSkills($form, ITEM_TYPE_LINK, $id); |
||
| 126 | header('Location: '.$linkListUrl); |
||
| 127 | exit; |
||
| 128 | } |
||
| 129 | $content = $form->returnForm(); |
||
| 130 | |||
| 131 | break; |
||
| 132 | case 'addcategory': |
||
| 133 | $form = Link::getCategoryForm(null, 'addcategory'); |
||
| 134 | |||
| 135 | if ($form->validate()) { |
||
| 136 | // Here we add a category |
||
| 137 | Link::addCategory(); |
||
| 138 | header('Location: '.$linkListUrl); |
||
| 139 | exit; |
||
| 140 | } |
||
| 141 | $content = $form->returnForm(); |
||
| 142 | |||
| 143 | break; |
||
| 144 | case 'editcategory': |
||
| 145 | $form = Link::getCategoryForm($id, 'editcategory'); |
||
| 146 | |||
| 147 | if ($form->validate()) { |
||
| 148 | // Here we edit a category |
||
| 149 | Link::editCategory($id, $form->getSubmitValues()); |
||
| 150 | |||
| 151 | header('Location: '.$linkListUrl); |
||
| 152 | exit; |
||
| 153 | } |
||
| 154 | $content = $form->returnForm(); |
||
| 155 | |||
| 156 | break; |
||
| 157 | case 'deletelink': |
||
| 158 | // Here we delete a link |
||
| 159 | Link::deleteLink($id); |
||
| 160 | header('Location: '.$linkListUrl); |
||
| 161 | exit; |
||
| 162 | |||
| 163 | break; |
||
| 164 | case 'deletecategory': |
||
| 165 | // Here we delete a category |
||
| 166 | Link::deleteCategory($id); |
||
| 167 | header('Location: '.$linkListUrl); |
||
| 168 | exit; |
||
| 169 | |||
| 170 | break; |
||
| 171 | case 'visible': |
||
| 172 | // Here we edit a category |
||
| 173 | Link::setVisible($id, $scope, $course, $session); |
||
| 174 | header('Location: '.$linkListUrl); |
||
| 175 | exit; |
||
| 176 | |||
| 177 | break; |
||
| 178 | case 'invisible': |
||
| 179 | // Here we edit a category |
||
| 180 | Link::setInvisible($id, $scope, $course, $session); |
||
| 181 | header('Location: '.$linkListUrl); |
||
| 182 | exit; |
||
| 183 | |||
| 184 | break; |
||
| 185 | case 'up': |
||
| 186 | Link::movecatlink('up', $up); |
||
| 187 | header('Location: '.$linkListUrl); |
||
| 188 | exit; |
||
| 189 | |||
| 190 | break; |
||
| 191 | case 'down': |
||
| 192 | Link::movecatlink('down', $down); |
||
| 193 | header('Location: '.$linkListUrl); |
||
| 194 | exit; |
||
| 195 | |||
| 196 | break; |
||
| 197 | case 'move_link_up': |
||
| 198 | Link::moveLinkUp($id); |
||
| 199 | header('Location: '.$linkListUrl); |
||
| 200 | exit; |
||
| 201 | |||
| 202 | break; |
||
| 203 | case 'move_link_down': |
||
| 204 | Link::moveLinkDown($id); |
||
| 205 | header('Location: '.$linkListUrl); |
||
| 206 | exit; |
||
| 207 | |||
| 208 | break; |
||
| 209 | case 'export': |
||
| 210 | $content = Link::listLinksAndCategories($course_id, $session_id, $categoryId, $show, null, false, true); |
||
| 211 | $courseInfo = api_get_course_info_by_id($course_id); |
||
| 212 | if (!empty($session_id)) { |
||
| 213 | $sessionInfo = api_get_session_info($session_id); |
||
| 214 | $courseInfo['title'] .= ' '.$sessionInfo['name']; |
||
| 215 | } |
||
| 216 | $pdf = new PDF(); |
||
| 217 | $pdf->content_to_pdf( |
||
| 218 | $content, |
||
| 219 | null, |
||
| 220 | $courseInfo['title'].'_'.get_lang('Link'), |
||
| 221 | $courseInfo['code'], |
||
| 222 | 'D', |
||
| 223 | false, |
||
| 224 | null, |
||
| 225 | false, |
||
| 226 | true |
||
| 227 | ); |
||
| 228 | |||
| 229 | break; |
||
| 230 | case 'list': |
||
| 231 | default: |
||
| 232 | $content = Link::listLinksAndCategories($course_id, $session_id, $categoryId, $show); |
||
| 233 | |||
| 234 | break; |
||
| 235 | } |
||
| 236 | |||
| 237 | Display::display_header($nameTools, 'Links'); |
||
| 238 | Display::display_introduction_section(TOOL_LINK); |
||
| 239 | echo $content; |
||
| 240 | Display::display_footer(); |
||
| 241 |
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.