Fixes queries + fixing double link categories see BT#9281

1.9.x
Julio Montoya 10 years ago
parent b104f04d4c
commit 80bcc765ea
  1. 13
      main/inc/lib/link.lib.php
  2. 33
      main/link/link.php

@ -857,8 +857,7 @@ function getLinkCategories($courseId, $sessionId)
itemproperties.tool = '" . TOOL_LINK_CATEGORY . "' AND itemproperties.tool = '" . TOOL_LINK_CATEGORY . "' AND
(itemproperties.visibility = '0' OR itemproperties.visibility = '1') (itemproperties.visibility = '0' OR itemproperties.visibility = '1')
$sessionCondition AND $sessionCondition AND
linkcat.c_id = " . $courseId . " AND linkcat.c_id = " . $courseId . "
itemproperties.c_id = " . $courseId . "
ORDER BY linkcat.display_order DESC"; ORDER BY linkcat.display_order DESC";
$result = Database::query($sql); $result = Database::query($sql);
@ -876,7 +875,7 @@ function getLinkCategories($courseId, $sessionId)
} }
} }
$sql = "SELECT *, linkcat.id $sql = "SELECT DISTINCT linkcat.*, visibility
FROM $tblLinkCategory linkcat FROM $tblLinkCategory linkcat
INNER JOIN $tblItemProperty itemproperties INNER JOIN $tblItemProperty itemproperties
ON (linkcat.id = itemproperties.ref AND linkcat.c_id = itemproperties.c_id) ON (linkcat.id = itemproperties.ref AND linkcat.c_id = itemproperties.c_id)
@ -884,10 +883,12 @@ function getLinkCategories($courseId, $sessionId)
itemproperties.tool = '" . TOOL_LINK_CATEGORY . "' AND itemproperties.tool = '" . TOOL_LINK_CATEGORY . "' AND
(itemproperties.visibility = '0' OR itemproperties.visibility = '1') (itemproperties.visibility = '0' OR itemproperties.visibility = '1')
$sessionCondition AND $sessionCondition AND
linkcat.c_id = " . $courseId . " AND linkcat.c_id = " . $courseId . "
itemproperties.c_id = " . $courseId . " GROUP BY c_id, id
ORDER BY linkcat.display_order DESC"; ORDER BY linkcat.display_order DESC
";
$result = Database::query($sql); $result = Database::query($sql);
return Database::store_result($result, 'ASSOC'); return Database::store_result($result, 'ASSOC');
} }

@ -476,9 +476,6 @@ if (empty($_GET['action']) ||
// - instead of a +, the category is no longer clickable and all the links of this category are displayed // - instead of a +, the category is no longer clickable and all the links of this category are displayed
$myrow['description'] = text_filter($myrow['description']); $myrow['description'] = text_filter($myrow['description']);
// Link categories are always visible.
//$myrow['visibility'] = 1;
$strVisibility = ''; $strVisibility = '';
if ($myrow['visibility'] == '1') { if ($myrow['visibility'] == '1') {
$strVisibility = '<a href="link.php?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=invisible&amp;id=' . $myrow['id'] . '&amp;scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Hide') . '">' . $strVisibility = '<a href="link.php?' . api_get_cidreq() . '&amp;sec_token='.$token.'&amp;action=invisible&amp;id=' . $myrow['id'] . '&amp;scope=' . TOOL_LINK_CATEGORY . '" title="' . get_lang('Hide') . '">' .
@ -489,7 +486,6 @@ if (empty($_GET['action']) ||
} }
if ($myrow['visibility'] == '1') { if ($myrow['visibility'] == '1') {
if (isset($urlview[$i]) && $urlview[$i] == '1') { if (isset($urlview[$i]) && $urlview[$i] == '1') {
$newurlview = $urlview; $newurlview = $urlview;
$newurlview[$i] = '0'; $newurlview[$i] = '0';
@ -502,7 +498,10 @@ if (empty($_GET['action']) ||
echo '</th>'; echo '</th>';
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
if ($session_id == $myrow['session_id']) { if ($session_id == $myrow['session_id']) {
echo '<th>'; echo $strVisibility; showcategoryadmintools($myrow['id']); echo '</th>'; echo '<th>';
echo $strVisibility;
showcategoryadmintools($myrow['id']);
echo '</th>';
} else { } else {
echo '<th>'.get_lang('EditionNotAvailableFromSession'); echo '<th>'.get_lang('EditionNotAvailableFromSession');
} }
@ -515,20 +514,27 @@ if (empty($_GET['action']) ||
echo '<tr>'; echo '<tr>';
echo '<table class="data_table">'; echo '<table class="data_table">';
echo '<tr>'; echo '<tr>';
echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;"><a href="'.api_get_self().'?'.api_get_cidreq().'&amp;urlview='; echo '<th width="81%" style="font-weight: bold; text-align:left;padding-left: 5px;">
<a href="'.api_get_self().'?'.api_get_cidreq().'&amp;urlview=';
echo is_array($view) ? implode('', $view) : $view; echo is_array($view) ? implode('', $view) : $view;
echo '"><img src="../img/icons/22/view_tree.png" />&nbsp;&nbsp;'.Security::remove_XSS($myrow['category_title']).$session_img; echo '"><img src="../img/icons/22/view_tree.png" />&nbsp;&nbsp;'.
Security::remove_XSS($myrow['category_title']).$session_img;
echo'</a><br />&nbsp;&nbsp;&nbsp;'; echo'</a><br />&nbsp;&nbsp;&nbsp;';
echo $myrow['description']; echo $myrow['description'];
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
echo '<th style="text-align:center;">'; echo $strVisibility; showcategoryadmintools($myrow['id']); echo '</th>'; if ($session_id == $myrow['session_id']) {
echo '<th style="text-align:center;">';
echo $strVisibility;
showcategoryadmintools($myrow['id']);
echo '</th>';
}
} }
echo '</th>'; echo '</th>';
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';
echo '</tr>'; echo '</tr>';
} }
} else { } else {
// NO VISIBLE // NO VISIBLE
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
@ -562,9 +568,16 @@ if (empty($_GET['action']) ||
echo '"><img src="../img/icons/22/view_tree_na.png" />&nbsp;&nbsp;'.Security::remove_XSS($myrow['category_title']).$session_img; echo '"><img src="../img/icons/22/view_tree_na.png" />&nbsp;&nbsp;'.Security::remove_XSS($myrow['category_title']).$session_img;
echo'</a><br />&nbsp;&nbsp;&nbsp;'; echo'</a><br />&nbsp;&nbsp;&nbsp;';
echo $myrow['description']; echo $myrow['description'];
if (api_is_allowed_to_edit(null, true)) { if (api_is_allowed_to_edit(null, true)) {
echo '<th style="text-align:center;">'; echo $strVisibility; showcategoryadmintools($myrow['id']); echo '</th>'; if ($session_id == $myrow['session_id']) {
echo '<th style="text-align:center;">';
echo $strVisibility;
showcategoryadmintools($myrow['id']);
echo '</th>';
}
} }
echo '</th>'; echo '</th>';
echo '</tr>'; echo '</tr>';
echo '</table>'; echo '</table>';

Loading…
Cancel
Save