$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;
- }
- }
-
- /// 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;
- }
}
+
+ echo '<b>'. strip_tags($entry->concept) . ': </b>';
+ $options->para = false;
+ $definition = format_text('<nolink>' . strip_tags($entry->definition) . '</nolink>', $entry->format,$options);
- /// 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>';
}
}
$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';
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;
}
}
$allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby $sqllimit");
+
?>
$currentpivot = '';
$ratingsmenuused = NULL;
$paging = NULL;
- if ( $hook == 'SPECIAL' ) {
- $alphabet = explode(",", get_string("alphabet"));
- }
+
if ($allentries) {
+
/// printing the paging links
$paging = get_string("allentries","glossary");
} 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) {
}
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 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 ) {
-
- $showentry = 0;
- break;
+ /// 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">';
}
- }
- }
- /// 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 "<strong> $pivottoshow</strong>" ;
+ echo '</td></tr></table>';
- /// 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 ) {
- /// 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;
- }
- }
-
- $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;
- }
+ /// highlight the term if necessary
+ if ($mode == 'search') {
+ $entry->highlight = $hook;
+ }
- $entriesshown++;
+ /// and finally print the entry.
+
+ if ( glossary_print_entry($course, $cm, $glossary, $entry, $mode, $hook,1,$displayformat,$ratings) ) {
+ $ratingsmenuused = true;
}
+
+ $entriesshown++;
}
}
if ( !$entriesshown ) {