mirror of
https://github.com/moodle/moodle.git
synced 2025-01-19 06:18:28 +01:00
Important changes about how view.php (and print.php) retrieve records
from BD to be displayed. Some SQL statements have been modified to get target records, avoiding a lot of post-processing causing some bugs like Bug 1912 (http://moodle.org/bugs/bug.php?op=show&bugid=1912) Merged from MOODLE_14_STABLE
This commit is contained in:
parent
797ba17e78
commit
539f698d73
@ -155,74 +155,28 @@
|
||||
$pivot = $pivot[0];
|
||||
}
|
||||
|
||||
///
|
||||
/// Validating special cases not covered by the SQL statement
|
||||
///
|
||||
|
||||
/// if we're browsing by alphabet and the current concept does not begin with
|
||||
/// the letter we are look for.
|
||||
$showentry = 1;
|
||||
if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) {
|
||||
if ( substr($entry->concept, 0, strlen($hook)) != $hook ) {
|
||||
$showentry = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// if we're browsing for letter, looking for special characters not covered
|
||||
/// in the alphabet
|
||||
if ( $showentry and $hook == 'SPECIAL' ) {
|
||||
$initial = $entry->concept[0];
|
||||
for ($i = 0; $i < count($alphabet); $i++) {
|
||||
$curletter = $alphabet[$i];
|
||||
if ( $curletter == $initial ) {
|
||||
|
||||
$showentry = 0;
|
||||
break;
|
||||
if ( $currentpivot != strtoupper($pivot) ) {
|
||||
// print the group break if apply
|
||||
if ( $printpivot ) {
|
||||
$currentpivot = strtoupper($pivot);
|
||||
|
||||
$pivottoshow = $currentpivot;
|
||||
if ( isset($entry->uid) ) {
|
||||
$user = get_record("user","id",$entry->uid);
|
||||
$pivottoshow = fullname($user, isteacher($course->id));
|
||||
}
|
||||
|
||||
echo "<p align=\"center\"><strong><i>$pivottoshow</i></strong></p>" ;
|
||||
}
|
||||
}
|
||||
|
||||
/// if we're browsing categories, looking for entries not categorised.
|
||||
if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
|
||||
if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) {
|
||||
$showentry = 0;
|
||||
}
|
||||
}
|
||||
|
||||
echo '<b>'. strip_tags($entry->concept) . ': </b>';
|
||||
$options->para = false;
|
||||
$definition = format_text('<nolink>' . strip_tags($entry->definition) . '</nolink>', $entry->format,$options);
|
||||
|
||||
/// if the entry is not approved, deal with it based on the current view and
|
||||
/// user.
|
||||
if ( $showentry and $mode != 'approval' ) {
|
||||
if ( !$entry->approved and isteacher($course->id, $entry->userid) ) {
|
||||
$showentry = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// ok, if it's a valid entry.. Print it.
|
||||
if ( $showentry ) {
|
||||
|
||||
if ( $currentpivot != strtoupper($pivot) ) {
|
||||
// print the group break if apply
|
||||
if ( $printpivot ) {
|
||||
$currentpivot = strtoupper($pivot);
|
||||
|
||||
$pivottoshow = $currentpivot;
|
||||
if ( isset($entry->uid) ) {
|
||||
$user = get_record("user","id",$entry->uid);
|
||||
$pivottoshow = fullname($user, isteacher($course->id));
|
||||
}
|
||||
|
||||
echo "<p align=\"center\"><strong><i>$pivottoshow</i></strong></p>" ;
|
||||
}
|
||||
}
|
||||
|
||||
echo '<b>'. strip_tags($entry->concept) . ': </b>';
|
||||
$options->para = false;
|
||||
$definition = format_text('<nolink>' . strip_tags($entry->definition) . '</nolink>', $entry->format,$options);
|
||||
echo ($definition);
|
||||
|
||||
echo ($definition);
|
||||
|
||||
echo '<br><br>';
|
||||
}
|
||||
echo '<br><br>';
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -57,9 +57,10 @@
|
||||
|
||||
$printpivot = 0;
|
||||
$sqlselect = "SELECT ge.*, concept $as pivot";
|
||||
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge";
|
||||
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge LEFT JOIN {$CFG->prefix}glossary_entries_categories gec
|
||||
ON ge.id = gec.entryid";
|
||||
$sqlwhere = "WHERE (glossaryid = '$glossary->id' OR sourceglossaryid = '$glossary->id') AND
|
||||
(ge.approved != 0 $userid)";
|
||||
(ge.approved != 0 $userid) AND gec.entryid IS NULL";
|
||||
|
||||
|
||||
$sqlorderby = ' ORDER BY concept';
|
||||
@ -195,6 +196,25 @@
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ($hook == 'SPECIAL') {
|
||||
//Create appropiate IN contents
|
||||
$alphabet = explode(",", get_string("alphabet"));
|
||||
$sqlalphabet = '';
|
||||
for ($i = 0; $i < count($alphabet); $i++) {
|
||||
if ($i != 0) {
|
||||
$sqlalphabet .= ',';
|
||||
}
|
||||
$sqlalphabet .= '\''.$alphabet[$i].'\'';
|
||||
}
|
||||
switch ($CFG->dbtype) {
|
||||
case 'postgres7':
|
||||
$where = 'AND substr(ucase(concept),1,1) NOT IN (' . strtoupper($sqlalphabet) . ')';
|
||||
break;
|
||||
case 'mysql':
|
||||
$where = 'AND left(ucase(concept),1) NOT IN (' . strtoupper($sqlalphabet) . ')';
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -229,4 +249,5 @@
|
||||
}
|
||||
|
||||
$allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
|
||||
|
||||
?>
|
||||
|
@ -288,10 +288,9 @@
|
||||
$currentpivot = '';
|
||||
$ratingsmenuused = NULL;
|
||||
$paging = NULL;
|
||||
if ( $hook == 'SPECIAL' ) {
|
||||
$alphabet = explode(",", get_string("alphabet"));
|
||||
}
|
||||
|
||||
if ($allentries) {
|
||||
|
||||
/// printing the paging links
|
||||
|
||||
$paging = get_string("allentries","glossary");
|
||||
@ -300,7 +299,7 @@
|
||||
} else {
|
||||
$paging = "<a href=\"view.php?id=$id&mode=$mode&hook=$hook&offset=-1&sortkey=$sortkey&sortorder=$sortorder&fullsearch=$fullsearch\">" . $paging . '</a>';
|
||||
}
|
||||
if ($count > $entriesbypage ) {
|
||||
if ($count > $entriesbypage ) {
|
||||
for ($i = 0; ($i*$entriesbypage) < $count ; $i++ ) {
|
||||
if ( $paging != '' ) {
|
||||
if ($i % 20 == 0 and $i) {
|
||||
@ -340,103 +339,57 @@
|
||||
}
|
||||
|
||||
foreach ($allentries as $entry) {
|
||||
/// Setting the pivot for the current entry
|
||||
|
||||
/// Setting the pivot for the current entry
|
||||
$pivot = $entry->pivot;
|
||||
if ( !$fullpivot ) {
|
||||
$pivot = $pivot[0];
|
||||
}
|
||||
|
||||
///
|
||||
/// Validating special cases not covered by the SQL statement
|
||||
///
|
||||
/// if there's a group break
|
||||
if ( $currentpivot != strtoupper($pivot) ) {
|
||||
|
||||
/// if we're browsing by alphabet and the current concept does not begin with
|
||||
/// the letter we are look for.
|
||||
$showentry = 1;
|
||||
$num = 0;
|
||||
if ( $mode == 'letter' and $hook != 'SPECIAL' and $hook != 'ALL' ) {
|
||||
if ( strtoupper(substr($entry->concept, 0, strlen($hook))) != strtoupper($hook) ) {
|
||||
$showentry = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// if we're browsing for letter, looking for special characters not covered
|
||||
/// in the alphabet
|
||||
if ( $showentry and $hook == 'SPECIAL' ) {
|
||||
$initial = $entry->concept[0];
|
||||
for ($i = 0; $i < count($alphabet); $i++) {
|
||||
$curletter = $alphabet[$i];
|
||||
if ( $curletter == $initial ) {
|
||||
// print the group break if apply
|
||||
if ( $printpivot ) {
|
||||
$currentpivot = strtoupper($pivot);
|
||||
|
||||
$showentry = 0;
|
||||
break;
|
||||
echo '<p>';
|
||||
echo '<table width="95%" border="0" class="generaltabselected" bgcolor="' . $THEME->cellheading2 . '">';
|
||||
|
||||
echo '<tr>';
|
||||
$pivottoshow = $currentpivot;
|
||||
if ( isset($entry->uid) ) {
|
||||
// printing the user icon if defined (only when browsing authors)
|
||||
echo '<td align="left">';
|
||||
|
||||
$user = get_record("user","id",$entry->uid);
|
||||
print_user_picture($user->id, $course->id, $user->picture);
|
||||
$pivottoshow = fullname($user, isteacher($course->id));;
|
||||
} else {
|
||||
echo '<td align="center">';
|
||||
}
|
||||
|
||||
echo "<strong> $pivottoshow</strong>" ;
|
||||
echo '</td></tr></table>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$concept = $entry->concept;
|
||||
$definition = $entry->definition;
|
||||
|
||||
/// highlight the term if necessary
|
||||
if ($mode == 'search') {
|
||||
$entry->highlight = $hook;
|
||||
}
|
||||
|
||||
/// if we're browsing categories, looking for entries not categorised.
|
||||
if ( $showentry and $mode == 'cat' and $hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
|
||||
if ( record_exists("glossary_entries_categories", "entryid", $entry->id)) {
|
||||
$showentry = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// if the entry is not approved, deal with it based on the current view and
|
||||
/// user.
|
||||
if ( $showentry and $mode != 'approval' ) {
|
||||
if ( !$entry->approved and $USER->id != $entry->userid ) {
|
||||
$showentry = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/// ok, if it's a valid entry.. Print it.
|
||||
if ( $showentry ) {
|
||||
/// and finally print the entry.
|
||||
|
||||
/// if there's a group break
|
||||
if ( $currentpivot != strtoupper($pivot) ) {
|
||||
|
||||
// print the group break if apply
|
||||
if ( $printpivot ) {
|
||||
$currentpivot = strtoupper($pivot);
|
||||
|
||||
echo '<p>';
|
||||
echo '<table width="95%" border="0" class="generaltabselected" bgcolor="' . $THEME->cellheading2 . '">';
|
||||
|
||||
echo '<tr>';
|
||||
$pivottoshow = $currentpivot;
|
||||
if ( isset($entry->uid) ) {
|
||||
// printing the user icon if defined (only when browsing authors)
|
||||
echo '<td align="left">';
|
||||
|
||||
$user = get_record("user","id",$entry->uid);
|
||||
print_user_picture($user->id, $course->id, $user->picture);
|
||||
$pivottoshow = fullname($user, isteacher($course->id));;
|
||||
} else {
|
||||
echo '<td align="center">';
|
||||
}
|
||||
|
||||
echo "<strong> $pivottoshow</strong>" ;
|
||||
echo '</td></tr></table>';
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
$concept = $entry->concept;
|
||||
$definition = $entry->definition;
|
||||
|
||||
/// highlight the term if necessary
|
||||
if ($mode == 'search') {
|
||||
$entry->highlight = $hook;
|
||||
}
|
||||
|
||||
/// and finally print the entry.
|
||||
|
||||
if ( glossary_print_entry($course, $cm, $glossary, $entry, $mode, $hook,1,$displayformat,$ratings) ) {
|
||||
$ratingsmenuused = true;
|
||||
}
|
||||
|
||||
$entriesshown++;
|
||||
if ( glossary_print_entry($course, $cm, $glossary, $entry, $mode, $hook,1,$displayformat,$ratings) ) {
|
||||
$ratingsmenuused = true;
|
||||
}
|
||||
|
||||
$entriesshown++;
|
||||
}
|
||||
}
|
||||
if ( !$entriesshown ) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user