category-less link is always visible. * * @author Patrick Cool, main author, completely rewritten * @author René Haentjens, added CSV file import (October 2004) * @package chamilo.link * @todo improve organisation, tables should come from database library, use formvalidator * @todo Needs serious rewriting here. This doesn't make sense */ /* INIT SECTION */ // Language files that need to be included $language_file = array('link', 'admin'); // Including libraries require_once '../inc/global.inc.php'; require_once api_get_path(LIBRARY_PATH).'link.lib.php'; $this_section = SECTION_COURSES; api_protect_course_script(); $htmlHeadXtra[] = ''; // @todo change the $_REQUEST into $_POST or $_GET // @todo remove this code $link_submitted = isset($_POST['submitLink']); $category_submitted = isset($_POST['submitCategory']); $urlview = !empty($_GET['urlview']) ? $_GET['urlview'] : ''; $submit_import = !empty($_POST['submitImport']) ? $_POST['submitImport'] : ''; $down = !empty($_GET['down']) ? $_GET['down'] : ''; $up = !empty($_GET['up']) ? $_GET['up'] : ''; $catmove = !empty($_GET['catmove']) ? $_GET['catmove'] : ''; $editlink = !empty($_REQUEST['editlink']) ? $_REQUEST['editlink'] : ''; $id = !empty($_REQUEST['id']) ? $_REQUEST['id'] : ''; $urllink = !empty($_REQUEST['urllink']) ? $_REQUEST['urllink'] : ''; $title = !empty($_REQUEST['title']) ? $_REQUEST['title'] : ''; $description = !empty($_REQUEST['description']) ? $_REQUEST['description'] : ''; $selectcategory = !empty($_REQUEST['selectcategory']) ? $_REQUEST['selectcategory'] : ''; $submit_link = isset($_REQUEST['submitLink']); $action = !empty($_REQUEST['action']) ? $_REQUEST['action'] : ''; $category_title = !empty($_REQUEST['category_title']) ? $_REQUEST['category_title'] : ''; $submit_category = isset($_POST['submitCategory']); $target_link = !empty($_REQUEST['target_link']) ? $_REQUEST['target_link'] : '_self'; $nameTools = get_lang('Links'); // Condition for the session $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')); } if (isset($_GET['action']) && $_GET['action'] == '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')); } // Database Table definitions $tbl_link = Database::get_course_table(TABLE_LINK); $tbl_categories = Database::get_course_table(TABLE_LINK_CATEGORY); $course_id = api_get_course_int_id(); // Statistics event_access_tool(TOOL_LINK); Display::display_header($nameTools, 'Links'); ?> '; if (!empty($_GET['lp_id']) || !empty($_POST['lp_id'])){ if (!empty($_POST['lp_id'])){ $lp_id = Security::remove_XSS($_POST['lp_id']); } else { $lp_id = Security::remove_XSS($_GET['lp_id']); } echo "".Display::return_icon('back.png', get_lang("BackTo").' '.get_lang("LearningPaths"),'','32').""; } else { //echo ''.Display::return_icon('back.png', get_lang('BackToLinksOverview'),'','32').''; } echo ''; // Displaying the correct title and the form for adding a category or link. This is only shown when nothing // has been submitted yet, hence !isset($submit_link) if (($_GET['action'] == 'addlink' || $_GET['action'] == 'editlink') && empty($_POST['submitLink'])) { echo '
'; if ($_GET['action'] == 'addlink') { echo '
'.get_lang('LinkAdd').'
'; } else { echo '
'.get_lang('LinkMod').'
'; } echo '
'; if ($category == '') { $category = 0; } echo '
'; echo ''; if ($_GET['action'] == 'editlink') { $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']; } echo ''; } echo '
* '.get_lang('Url').'
'; echo '
'.get_lang('LinkName').'
'; echo '
'.get_lang('Metadata').'
'; echo '
'.get_lang('Description').'
'; $sqlcategories = "SELECT * FROM ".$tbl_categories." WHERE c_id = $course_id $condition_session ORDER BY display_order DESC"; $resultcategories = Database::query($sqlcategories); if (Database::num_rows($resultcategories)) { echo '
'.get_lang('Category').'
'; echo ' '; echo '
'; } echo '
'; echo '
'.get_lang('LinkTarget').'
'.get_lang('AddTargetOfLinkOnHomepage').'
'; if (api_get_setting('search_enabled') == 'true') { require_once api_get_path(LIBRARY_PATH).'specific_fields_manager.lib.php'; $specific_fields = get_specific_field_list(); echo '
'.get_lang('SearchFeatureDoIndexLink').'?
'; foreach ($specific_fields as $specific_field) { $default_values = ''; if ($_GET['action'] == 'editlink') { $filter = array('course_code'=> "'". api_get_course_id() ."'", 'field_id' => $specific_field['id'], 'ref_id' => Security::remove_XSS($_GET['id']), 'tool_id' => '\''. TOOL_LINK .'\''); $values = get_specific_field_values_list($filter, array('value')); if (!empty($values)) { $arr_str_values = array(); foreach ($values as $value) { $arr_str_values[] = $value['value']; } $default_values = implode(', ', $arr_str_values); } } $sf_textbox = '
%s
'; echo sprintf($sf_textbox, $specific_field['name'], $specific_field['code'], $default_values); } } //echo ''; echo ''; echo '
'; echo ''; } elseif(($_GET['action'] == 'addcategory' || $_GET['action'] == 'editcategory') && !$submit_category) { echo '
'; if ($_GET['action'] == 'addcategory') { echo '
'.get_lang('CategoryAdd').'
'; $my_cat_title = get_lang('CategoryAdd'); } else { echo '
'.get_lang('CategoryMod').'
'; $my_cat_title = get_lang('CategoryMod'); } echo "
"; echo '
'; echo ''; if ($_GET['action'] == 'editcategory') { echo ''; } echo '
* '.get_lang('CategoryName').'
'; echo '
'.get_lang('Description').'
'; echo '
'; echo "
"; } } if (!empty($down)) { movecatlink($down); } if (!empty($up)) { movecatlink($up); } if (empty($_GET['action']) || ($_GET['action'] != 'editlink' && $_GET['action'] != 'addcategory' && $_GET['action'] != 'addlink') || $link_submitted || $category_submitted) { /* Action Links */ echo '
'; if (api_is_allowed_to_edit(null, true)) { $urlview = Security::remove_XSS($urlview); echo ''.Display::return_icon('new_link.png', get_lang('LinkAdd'),'','32').''; echo ''.Display::return_icon('new_folder.png', get_lang('CategoryAdd'),'','32').''; /* "".get_lang('CsvImport')."\n", // RH*/ } // Making the show none / show all links. Show none means urlview=0000 (number of zeros depending on the // number of categories). Show all means urlview=1111 (number of 1 depending on teh number of categories). $sqlcategories = "SELECT * FROM ".$tbl_categories." WHERE c_id = $course_id $condition_session ORDER BY display_order DESC"; $resultcategories = Database::query($sqlcategories); $aantalcategories = Database::num_rows($resultcategories); if ($aantalcategories > 0) { $resultcategories = Database::query($sqlcategories); echo ''.Display::return_icon('view_remove.png', $shownone,'','32').''; echo ''.Display::return_icon('view_tree.png', $showall,'','32').''; } echo '
'; // Displaying the links which have no category (thus category = 0 or NULL), if none present this will not be displayed $sqlLinks = "SELECT * FROM ".$tbl_link." WHERE c_id = $course_id AND category_id=0 OR category_id IS NULL"; $result = Database::query($sqlLinks); $numberofzerocategory = Database::num_rows($result); if ($numberofzerocategory !== 0) { echo ''; echo ''; echo '
'.get_lang('General').'
'; showlinksofcategory(0); } $i = 0; $catcounter = 1; $view = '0'; while ($myrow = Database::fetch_array($resultcategories)) { // Validacion when belongs to a session $session_img = api_get_session_image($myrow['session_id'], $_user['status']); //if (!isset($urlview)) { if ($urlview == '') { // No $view set in the url, thus for each category link it should be all zeros except it's own makedefaultviewcode($i); } else { $view = $urlview; $view[$i] = '1'; } // If the $urlview has a 1 for this categorie, this means it is expanded and should be desplayed as a // - instead of a +, the category is no longer clickable and all the links of this category are displayed $myrow['description'] = text_filter($myrow['description']); if (isset($urlview[$i]) && $urlview[$i] == '1') { $newurlview = $urlview; $newurlview[$i] = '0'; echo ''; echo ''; echo ''; echo ''; if (api_is_allowed_to_edit(null, true)) { if ($session_id == $myrow['session_id']) { echo ''; } else { echo ''; echo '
'; echo ''; echo '  '.Security::remove_XSS($myrow['category_title']).'
   '.$myrow['description']; echo '
'; showcategoryadmintools($myrow['id']); echo ''.get_lang('EditionNotAvailableFromSession'); } } echo '
'; echo showlinksofcategory($myrow['id']); echo ''; } else { echo ''; echo ''; echo ''; echo ''; } echo ''; echo ''; echo '
  '.Security::remove_XSS($myrow['category_title']).$session_img; echo'
   '; echo $myrow['description']; if (api_is_allowed_to_edit(null, true)) { echo '
'; showcategoryadmintools($myrow['id']); echo '
'; echo ''; } // Displaying the link of the category $i++; } echo ''; } Display::display_footer();