| Línea 47... |
Línea 47... |
| 47 |
// Glossary displayformats.
|
47 |
// Glossary displayformats.
|
| 48 |
define('GLOSSARY_CONTINUOUS', 'continuous');
|
48 |
define('GLOSSARY_CONTINUOUS', 'continuous');
|
| 49 |
define('GLOSSARY_DICTIONARY', 'dictionary');
|
49 |
define('GLOSSARY_DICTIONARY', 'dictionary');
|
| 50 |
define('GLOSSARY_FULLWITHOUTAUTHOR', 'fullwithoutauthor');
|
50 |
define('GLOSSARY_FULLWITHOUTAUTHOR', 'fullwithoutauthor');
|
| Línea 51... |
Línea -... |
| 51 |
|
- |
|
| 52 |
require_once(__DIR__ . '/deprecatedlib.php');
|
- |
|
| 53 |
|
51 |
|
| 54 |
/// STANDARD FUNCTIONS ///////////////////////////////////////////////////////////
|
52 |
/// STANDARD FUNCTIONS ///////////////////////////////////////////////////////////
|
| 55 |
/**
|
53 |
/**
|
| 56 |
* @global object
|
54 |
* @global object
|
| 57 |
* @param object $glossary
|
55 |
* @param object $glossary
|
| Línea 861... |
Línea 859... |
| 861 |
|
859 |
|
| 862 |
return grade_update('mod/glossary', $glossary->course, 'mod', 'glossary', $glossary->id, 0, NULL, array('deleted'=>1));
|
860 |
return grade_update('mod/glossary', $glossary->course, 'mod', 'glossary', $glossary->id, 0, NULL, array('deleted'=>1));
|
| Línea 863... |
Línea 861... |
| 863 |
}
|
861 |
}
|
| 864 |
|
- |
|
| 865 |
/**
|
- |
|
| 866 |
* @deprecated since Moodle 3.8
|
- |
|
| 867 |
*/
|
- |
|
| 868 |
function glossary_scale_used() {
|
- |
|
| 869 |
throw new coding_exception('glossary_scale_used() can not be used anymore. Plugins can implement ' .
|
- |
|
| 870 |
'<modname>_scale_used_anywhere, all implementations of <modname>_scale_used are now ignored');
|
- |
|
| 871 |
}
|
- |
|
| 872 |
|
862 |
|
| 873 |
/**
|
863 |
/**
|
| 874 |
* Checks if scale is being used by any instance of glossary
|
864 |
* Checks if scale is being used by any instance of glossary
|
| 875 |
*
|
865 |
*
|
| 876 |
* This is used to find out if scale used anywhere
|
866 |
* This is used to find out if scale used anywhere
|
| Línea 1365... |
Línea 1355... |
| 1365 |
$icons = '';
|
1355 |
$icons = '';
|
| 1366 |
if ($printicons) {
|
1356 |
if ($printicons) {
|
| 1367 |
$icons = glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,'html');
|
1357 |
$icons = glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode, $hook,'html');
|
| 1368 |
}
|
1358 |
}
|
| 1369 |
if ($aliases || $icons || !empty($entry->rating)) {
|
1359 |
if ($aliases || $icons || !empty($entry->rating)) {
|
| 1370 |
echo '<table>';
|
1360 |
echo '<table class="table-reboot">';
|
| 1371 |
if ( $aliases ) {
|
1361 |
if ( $aliases ) {
|
| 1372 |
$id = "keyword-{$entry->id}";
|
1362 |
$id = "keyword-{$entry->id}";
|
| 1373 |
echo '<tr valign="top"><td class="aliases">' .
|
1363 |
echo '<tr valign="top"><td class="aliases hstack gap-2">' .
|
| 1374 |
'<label for="' . $id . '">' . get_string('aliases', 'glossary') . ': </label>' .
|
1364 |
'<label for="' . $id . '">' . get_string('aliases', 'glossary') . ': </label>' .
|
| 1375 |
$aliases . '</td></tr>';
|
1365 |
$aliases . '</td></tr>';
|
| 1376 |
}
|
1366 |
}
|
| 1377 |
if ($icons) {
|
1367 |
if ($icons) {
|
| 1378 |
echo '<tr valign="top"><td class="icons">'.$icons.'</td></tr>';
|
1368 |
echo '<tr valign="top"><td class="icons">'.$icons.'</td></tr>';
|
| Línea 1426... |
Línea 1416... |
| 1426 |
function glossary_print_entry_approval($cm, $entry, $mode, $align="right", $insidetable=true) {
|
1416 |
function glossary_print_entry_approval($cm, $entry, $mode, $align="right", $insidetable=true) {
|
| 1427 |
global $CFG, $OUTPUT;
|
1417 |
global $CFG, $OUTPUT;
|
| Línea 1428... |
Línea 1418... |
| 1428 |
|
1418 |
|
| 1429 |
if ($mode == 'approval' and !$entry->approved) {
|
1419 |
if ($mode == 'approval' and !$entry->approved) {
|
| 1430 |
if ($insidetable) {
|
1420 |
if ($insidetable) {
|
| 1431 |
echo '<table class="glossaryapproval" align="'.$align.'"><tr><td align="'.$align.'">';
|
1421 |
echo '<table class="glossaryapproval table-reboot" align="' . $align . '"><tr><td align="' . $align . '">';
|
| 1432 |
}
|
1422 |
}
|
| 1433 |
echo $OUTPUT->action_icon(
|
1423 |
echo $OUTPUT->action_icon(
|
| 1434 |
new moodle_url('approve.php', array('eid' => $entry->id, 'mode' => $mode, 'sesskey' => sesskey())),
|
1424 |
new moodle_url('approve.php', array('eid' => $entry->id, 'mode' => $mode, 'sesskey' => sesskey())),
|
| 1435 |
new pix_icon('t/approve', get_string('approve','glossary'), '',
|
1425 |
new pix_icon('t/approve', get_string('approve','glossary'), '',
|
| Línea 1492... |
Línea 1482... |
| 1492 |
|
1482 |
|
| 1493 |
|
1483 |
|
| Línea 1494... |
Línea 1484... |
| 1494 |
foreach ($searchterms as $searchterm) {
|
1484 |
foreach ($searchterms as $searchterm) {
|
| 1495 |
$i++;
|
1485 |
$i++;
|
| - |
|
1486 |
|
| Línea 1496... |
Línea 1487... |
| 1496 |
|
1487 |
// Initially we aren't going to perform NOT LIKE searches, only MSSQL
|
| 1497 |
$NOT = false; /// Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle
|
1488 |
// will use it to simulate the "-" operator with LIKE clause.
|
| 1498 |
/// will use it to simulate the "-" operator with LIKE clause
|
1489 |
$NOT = false;
|
| 1499 |
|
1490 |
|
| 1500 |
/// Under Oracle and MSSQL, trim the + and - operators and perform
|
1491 |
// Under MSSQL, trim the + and - operators and perform
|
| 1501 |
/// simpler LIKE (or NOT LIKE) queries
|
1492 |
// simpler LIKE (or NOT LIKE) queries
|
| 1502 |
if (!$DB->sql_regex_supported()) {
|
1493 |
if (!$DB->sql_regex_supported()) {
|
| Línea 1832... |
Línea 1823... |
| 1832 |
|
1823 |
|
| Línea 1833... |
Línea 1824... |
| 1833 |
glossary_print_alphabet_links($cm, $glossary, $mode, $hook,$sortkey, $sortorder);
|
1824 |
glossary_print_alphabet_links($cm, $glossary, $mode, $hook,$sortkey, $sortorder);
|
| Línea 1834... |
Línea 1825... |
| 1834 |
|
1825 |
|
| 1835 |
glossary_print_all_links($cm, $glossary, $mode, $hook);
|
1826 |
glossary_print_all_links($cm, $glossary, $mode, $hook);
|
| 1836 |
|
1827 |
|
| 1837 |
glossary_print_sorting_links($cm, $mode, 'CREATION', 'asc');
|
1828 |
glossary_print_sorting_links($cm, $mode, $sortkey, $sortorder);
|
| 1838 |
}
|
1829 |
}
|
| 1839 |
/**
|
1830 |
/**
|
| Línea 1912... |
Línea 1903... |
| 1912 |
|
1903 |
|
| 1913 |
// Prepare format_string/text options
|
1904 |
// Prepare format_string/text options
|
| 1914 |
$fmtoptions = array(
|
1905 |
$fmtoptions = array(
|
| Línea 1915... |
Línea 1906... |
| 1915 |
'context' => $context);
|
1906 |
'context' => $context);
|
| 1916 |
|
1907 |
|
| Línea 1917... |
Línea 1908... |
| 1917 |
echo '<table border="0" width="100%">';
|
1908 |
echo '<table class="table-reboot" border="0" width="100%">';
|
| 1918 |
echo '<tr>';
|
1909 |
echo '<tr>';
|
| 1919 |
|
1910 |
|
| Línea 2054... |
Línea 2045... |
| 2054 |
$asc = get_string("ascending","glossary");
|
2045 |
$asc = get_string("ascending","glossary");
|
| 2055 |
$desc = get_string("descending","glossary");
|
2046 |
$desc = get_string("descending","glossary");
|
| 2056 |
$bopen = '<b>';
|
2047 |
$bopen = '<b>';
|
| 2057 |
$bclose = '</b>';
|
2048 |
$bclose = '</b>';
|
| Línea 2058... |
Línea 2049... |
| 2058 |
|
2049 |
|
| 2059 |
$neworder = '';
|
2050 |
$neworder = '';
|
| 2060 |
$currentorder = '';
|
2051 |
$currentorder = '';
|
| - |
|
2052 |
$currentsort = '';
|
| - |
|
2053 |
|
| - |
|
2054 |
if ($sortkey === '') {
|
| - |
|
2055 |
$sortkey = 'CREATION';
|
| - |
|
2056 |
}
|
| 2061 |
$currentsort = '';
|
2057 |
|
| 2062 |
if ( $sortorder ) {
|
2058 |
if ( $sortorder ) {
|
| 2063 |
if ( $sortorder == 'asc' ) {
|
2059 |
if ( $sortorder == 'asc' ) {
|
| 2064 |
$currentorder = $asc;
|
2060 |
$currentorder = $asc;
|
| 2065 |
$neworder = '&sortorder=desc';
|
2061 |
$neworder = '&sortorder=desc';
|
| Línea 2079... |
Línea 2075... |
| 2079 |
$newordertitle = $desc;
|
2075 |
$newordertitle = $desc;
|
| 2080 |
$neworder = '&sortorder=desc';
|
2076 |
$neworder = '&sortorder=desc';
|
| 2081 |
$icon = " " . $OUTPUT->pix_icon('asc', $newordertitle, 'glossary');
|
2077 |
$icon = " " . $OUTPUT->pix_icon('asc', $newordertitle, 'glossary');
|
| 2082 |
}
|
2078 |
}
|
| 2083 |
}
|
2079 |
}
|
| 2084 |
$ficon = '';
|
- |
|
| 2085 |
$fneworder = '';
|
- |
|
| 2086 |
$fbtag = '';
|
- |
|
| 2087 |
$fendbtag = '';
|
- |
|
| 2088 |
|
- |
|
| 2089 |
$sicon = '';
|
- |
|
| 2090 |
$sneworder = '';
|
- |
|
| 2091 |
|
- |
|
| 2092 |
$sbtag = '';
|
- |
|
| 2093 |
$fbtag = '';
|
- |
|
| 2094 |
$fendbtag = '';
|
- |
|
| 2095 |
$sendbtag = '';
|
- |
|
| Línea -... |
Línea 2080... |
| - |
|
2080 |
|
| - |
|
2081 |
$ficon = '';
|
| - |
|
2082 |
$fneworder = '';
|
| - |
|
2083 |
|
| - |
|
2084 |
$sicon = '';
|
| - |
|
2085 |
$sneworder = '';
|
| - |
|
2086 |
|
| - |
|
2087 |
$sbtag = '';
|
| - |
|
2088 |
$fbtag = '';
|
| - |
|
2089 |
$fendbtag = '';
|
| 2096 |
|
2090 |
|
| Línea 2097... |
Línea 2091... |
| 2097 |
$sendbtag = '';
|
2091 |
$sendbtag = '';
|
| 2098 |
|
2092 |
|
| 2099 |
if ( $sortkey == 'CREATION' or $sortkey == 'FIRSTNAME' ) {
|
2093 |
if ( $sortkey == 'CREATION' or $sortkey == 'FIRSTNAME' ) {
|
| 2100 |
$ficon = $icon;
|
2094 |
$ficon = $icon;
|
| Línea 2187... |
Línea 2181... |
| 2187 |
*/
|
2181 |
*/
|
| 2188 |
function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) {
|
2182 |
function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) {
|
| 2189 |
global $USER, $CFG, $DB;
|
2183 |
global $USER, $CFG, $DB;
|
| Línea 2190... |
Línea 2184... |
| 2190 |
|
2184 |
|
| 2191 |
echo '<div class="boxaligncenter">';
|
2185 |
echo '<div class="boxaligncenter">';
|
| 2192 |
echo '<table class="glossarypopup" cellspacing="0"><tr>';
|
2186 |
echo '<table class="glossarypopup table-reboot" cellspacing="0"><tr>';
|
| 2193 |
echo '<td>';
|
2187 |
echo '<td>';
|
| 2194 |
if ( $entries ) {
|
2188 |
if ( $entries ) {
|
| 2195 |
foreach ( $entries as $entry ) {
|
2189 |
foreach ( $entries as $entry ) {
|
| 2196 |
if (! $glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid))) {
|
2190 |
if (! $glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid))) {
|
| Línea 2361... |
Línea 2355... |
| 2361 |
if ( $entry->approved and $permissiongranted ) {
|
2355 |
if ( $entry->approved and $permissiongranted ) {
|
| 2362 |
$co .= glossary_start_tag("ENTRY",3,true);
|
2356 |
$co .= glossary_start_tag("ENTRY",3,true);
|
| 2363 |
$co .= glossary_full_tag("CONCEPT",4,false,trim($entry->concept));
|
2357 |
$co .= glossary_full_tag("CONCEPT",4,false,trim($entry->concept));
|
| 2364 |
$co .= glossary_full_tag("DEFINITION",4,false,$entry->definition);
|
2358 |
$co .= glossary_full_tag("DEFINITION",4,false,$entry->definition);
|
| 2365 |
$co .= glossary_full_tag("FORMAT",4,false,$entry->definitionformat); // note: use old name for BC reasons
|
2359 |
$co .= glossary_full_tag("FORMAT",4,false,$entry->definitionformat); // note: use old name for BC reasons
|
| - |
|
2360 |
$co .= glossary_full_tag('DEFINITIONTRUST', 4, false, $entry->definitiontrust);
|
| 2366 |
$co .= glossary_full_tag("USEDYNALINK",4,false,$entry->usedynalink);
|
2361 |
$co .= glossary_full_tag("USEDYNALINK",4,false,$entry->usedynalink);
|
| 2367 |
$co .= glossary_full_tag("CASESENSITIVE",4,false,$entry->casesensitive);
|
2362 |
$co .= glossary_full_tag("CASESENSITIVE",4,false,$entry->casesensitive);
|
| 2368 |
$co .= glossary_full_tag("FULLMATCH",4,false,$entry->fullmatch);
|
2363 |
$co .= glossary_full_tag("FULLMATCH",4,false,$entry->fullmatch);
|
| 2369 |
$co .= glossary_full_tag("TEACHERENTRY",4,false,$entry->teacherentry);
|
2364 |
$co .= glossary_full_tag("TEACHERENTRY",4,false,$entry->teacherentry);
|
| Línea 2793... |
Línea 2788... |
| 2793 |
* whether the course reset functionality affects the glossary.
|
2788 |
* whether the course reset functionality affects the glossary.
|
| 2794 |
* @param MoodleQuickForm $mform form passed by reference
|
2789 |
* @param MoodleQuickForm $mform form passed by reference
|
| 2795 |
*/
|
2790 |
*/
|
| 2796 |
function glossary_reset_course_form_definition(&$mform) {
|
2791 |
function glossary_reset_course_form_definition(&$mform) {
|
| 2797 |
$mform->addElement('header', 'glossaryheader', get_string('modulenameplural', 'glossary'));
|
2792 |
$mform->addElement('header', 'glossaryheader', get_string('modulenameplural', 'glossary'));
|
| - |
|
2793 |
$mform->addElement('static', 'glossarydelete', get_string('delete'));
|
| 2798 |
$mform->addElement('checkbox', 'reset_glossary_all', get_string('resetglossariesall','glossary'));
|
2794 |
$mform->addElement('checkbox', 'reset_glossary_all', get_string('resetglossariesall','glossary'));
|
| Línea 2799... |
Línea 2795... |
| 2799 |
|
2795 |
|
| 2800 |
$mform->addElement('select', 'reset_glossary_types', get_string('resetglossaries', 'glossary'),
|
2796 |
$mform->addElement('select', 'reset_glossary_types', get_string('resetglossaries', 'glossary'),
|
| 2801 |
array('main'=>get_string('mainglossary', 'glossary'), 'secondary'=>get_string('secondaryglossary', 'glossary')), array('multiple' => 'multiple'));
|
- |
|
| 2802 |
$mform->setAdvanced('reset_glossary_types');
|
2797 |
array('main'=>get_string('mainglossary', 'glossary'), 'secondary'=>get_string('secondaryglossary', 'glossary')), array('multiple' => 'multiple'));
|
| Línea 2803... |
Línea 2798... |
| 2803 |
$mform->disabledIf('reset_glossary_types', 'reset_glossary_all', 'checked');
|
2798 |
$mform->hideIf('reset_glossary_types', 'reset_glossary_all', 'checked');
|
| 2804 |
|
2799 |
|
| Línea 2805... |
Línea 2800... |
| 2805 |
$mform->addElement('checkbox', 'reset_glossary_notenrolled', get_string('deletenotenrolled', 'glossary'));
|
2800 |
$mform->addElement('checkbox', 'reset_glossary_notenrolled', get_string('deletenotenrolled', 'glossary'));
|
| 2806 |
$mform->disabledIf('reset_glossary_notenrolled', 'reset_glossary_all', 'checked');
|
2801 |
$mform->hideIf('reset_glossary_notenrolled', 'reset_glossary_all', 'checked');
|
| Línea 2807... |
Línea 2802... |
| 2807 |
|
2802 |
|
| 2808 |
$mform->addElement('checkbox', 'reset_glossary_ratings', get_string('deleteallratings'));
|
2803 |
$mform->addElement('checkbox', 'reset_glossary_ratings', get_string('deleteallratings'));
|
| Línea 2809... |
Línea 2804... |
| 2809 |
$mform->disabledIf('reset_glossary_ratings', 'reset_glossary_all', 'checked');
|
2804 |
$mform->hideIf('reset_glossary_ratings', 'reset_glossary_all', 'checked');
|
| 2810 |
|
2805 |
|
| 2811 |
$mform->addElement('checkbox', 'reset_glossary_comments', get_string('deleteallcomments'));
|
2806 |
$mform->addElement('checkbox', 'reset_glossary_comments', get_string('deleteallcomments'));
|
| Línea 2812... |
Línea 2807... |
| 2812 |
$mform->disabledIf('reset_glossary_comments', 'reset_glossary_all', 'checked');
|
2807 |
$mform->hideIf('reset_glossary_comments', 'reset_glossary_all', 'checked');
|
| 2813 |
|
2808 |
|
| 2814 |
$mform->addElement('checkbox', 'reset_glossary_tags', get_string('removeallglossarytags', 'glossary'));
|
2809 |
$mform->addElement('checkbox', 'reset_glossary_tags', get_string('removeallglossarytags', 'glossary'));
|
| Línea 2859... |
Línea 2854... |
| 2859 |
function glossary_reset_userdata($data) {
|
2854 |
function glossary_reset_userdata($data) {
|
| 2860 |
global $CFG, $DB;
|
2855 |
global $CFG, $DB;
|
| 2861 |
require_once($CFG->dirroot.'/rating/lib.php');
|
2856 |
require_once($CFG->dirroot.'/rating/lib.php');
|
| Línea 2862... |
Línea 2857... |
| 2862 |
|
2857 |
|
| 2863 |
$componentstr = get_string('modulenameplural', 'glossary');
|
2858 |
$componentstr = get_string('modulenameplural', 'glossary');
|
| Línea 2864... |
Línea 2859... |
| 2864 |
$status = array();
|
2859 |
$status = [];
|
| 2865 |
|
2860 |
|
| 2866 |
$allentriessql = "SELECT e.id
|
2861 |
$allentriessql = "SELECT e.id
|
| 2867 |
FROM {glossary_entries} e
|
2862 |
FROM {glossary_entries} e
|
| Línea 2868... |
Línea 2863... |
| 2868 |
JOIN {glossary} g ON e.glossaryid = g.id
|
2863 |
JOIN {glossary} g ON e.glossaryid = g.id
|
| 2869 |
WHERE g.course = ?";
|
2864 |
WHERE g.course = ?";
|
| 2870 |
|
2865 |
|
| Línea 2871... |
Línea 2866... |
| 2871 |
$allglossariessql = "SELECT g.id
|
2866 |
$allglossariessql = "SELECT g.id
|
| Línea 2872... |
Línea 2867... |
| 2872 |
FROM {glossary} g
|
2867 |
FROM {glossary} g
|
| Línea 2873... |
Línea 2868... |
| 2873 |
WHERE g.course = ?";
|
2868 |
WHERE g.course = ?";
|
| 2874 |
|
2869 |
|
| 2875 |
$params = array($data->courseid);
|
2870 |
$params = [$data->courseid];
|
| 2876 |
|
2871 |
|
| Línea 2877... |
Línea 2872... |
| 2877 |
$fs = get_file_storage();
|
2872 |
$fs = get_file_storage();
|
| 2878 |
|
2873 |
|
| 2879 |
$rm = new rating_manager();
|
2874 |
$rm = new rating_manager();
|
| Línea 2880... |
Línea 2875... |
| 2880 |
$ratingdeloptions = new stdClass;
|
2875 |
$ratingdeloptions = new stdClass;
|
| 2881 |
$ratingdeloptions->component = 'mod_glossary';
|
2876 |
$ratingdeloptions->component = 'mod_glossary';
|
| 2882 |
$ratingdeloptions->ratingarea = 'entry';
|
2877 |
$ratingdeloptions->ratingarea = 'entry';
|
| 2883 |
|
2878 |
|
| Línea 2884... |
Línea 2879... |
| 2884 |
// delete entries if requested
|
2879 |
// Delete entries if requested.
|
| 2885 |
if (!empty($data->reset_glossary_all)
|
2880 |
if (!empty($data->reset_glossary_all)
|
| 2886 |
or (!empty($data->reset_glossary_types) and in_array('main', $data->reset_glossary_types) and in_array('secondary', $data->reset_glossary_types))) {
|
2881 |
or (!empty($data->reset_glossary_types) and in_array('main', $data->reset_glossary_types) and in_array('secondary', $data->reset_glossary_types))) {
|
| 2887 |
|
2882 |
|
| 2888 |
$params[] = 'glossary_entry';
|
2883 |
$params[] = 'glossary_entry';
|
| 2889 |
$DB->delete_records_select('comments', "itemid IN ($allentriessql) AND commentarea=?", $params);
|
2884 |
$DB->delete_records_select('comments', "itemid IN ($allentriessql) AND commentarea=?", $params);
|
| 2890 |
$DB->delete_records_select('glossary_alias', "entryid IN ($allentriessql)", $params);
|
2885 |
$DB->delete_records_select('glossary_alias', "entryid IN ($allentriessql)", $params);
|
| 2891 |
$DB->delete_records_select('glossary_entries', "glossaryid IN ($allglossariessql)", $params);
|
2886 |
$DB->delete_records_select('glossary_entries', "glossaryid IN ($allglossariessql)", $params);
|
| Línea 2892... |
Línea 2887... |
| 2892 |
|
2887 |
|
| 2893 |
// now get rid of all attachments
|
2888 |
// Now get rid of all attachments.
|
| 2894 |
if ($glossaries = $DB->get_records_sql($allglossariessql, $params)) {
|
2889 |
if ($glossaries = $DB->get_records_sql($allglossariessql, $params)) {
|
| Línea 2895... |
Línea 2890... |
| 2895 |
foreach ($glossaries as $glossaryid=>$unused) {
|
2890 |
foreach ($glossaries as $glossaryid=>$unused) {
|
| 2896 |
if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
|
2891 |
if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
|
| 2897 |
continue;
|
2892 |
continue;
|
| Línea 2898... |
Línea 2893... |
| 2898 |
}
|
2893 |
}
|
| 2899 |
$context = context_module::instance($cm->id);
|
2894 |
$context = context_module::instance($cm->id);
|
| 2900 |
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment');
|
2895 |
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment');
|
| 2901 |
|
2896 |
|
| Línea -... |
Línea 2897... |
| - |
|
2897 |
// Delete ratings.
|
| - |
|
2898 |
$ratingdeloptions->contextid = $context->id;
|
| 2902 |
//delete ratings
|
2899 |
$rm->delete_ratings($ratingdeloptions);
|
| - |
|
2900 |
|
| - |
|
2901 |
core_tag_tag::delete_instances('mod_glossary', null, $context->id);
|
| Línea 2903... |
Línea 2902... |
| 2903 |
$ratingdeloptions->contextid = $context->id;
|
2902 |
}
|
| 2904 |
$rm->delete_ratings($ratingdeloptions);
|
2903 |
}
|
| 2905 |
|
2904 |
|
| Línea 2906... |
Línea 2905... |
| 2906 |
core_tag_tag::delete_instances('mod_glossary', null, $context->id);
|
2905 |
// Remove all grades from gradebook.
|
| 2907 |
}
|
2906 |
if (empty($data->reset_gradebook_grades)) {
|
| Línea 2908... |
Línea 2907... |
| 2908 |
}
|
2907 |
glossary_reset_gradebook($data->courseid);
|
| 2909 |
|
2908 |
}
|
| 2910 |
// remove all grades from gradebook
|
2909 |
|
| Línea 2932... |
Línea 2931... |
| 2932 |
continue;
|
2931 |
continue;
|
| 2933 |
}
|
2932 |
}
|
| 2934 |
$context = context_module::instance($cm->id);
|
2933 |
$context = context_module::instance($cm->id);
|
| 2935 |
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment');
|
2934 |
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment');
|
| Línea 2936... |
Línea 2935... |
| 2936 |
|
2935 |
|
| 2937 |
//delete ratings
|
2936 |
// Delete ratings.
|
| 2938 |
$ratingdeloptions->contextid = $context->id;
|
2937 |
$ratingdeloptions->contextid = $context->id;
|
| Línea 2939... |
Línea 2938... |
| 2939 |
$rm->delete_ratings($ratingdeloptions);
|
2938 |
$rm->delete_ratings($ratingdeloptions);
|
| 2940 |
|
2939 |
|
| 2941 |
core_tag_tag::delete_instances('mod_glossary', null, $context->id);
|
2940 |
core_tag_tag::delete_instances('mod_glossary', null, $context->id);
|
| Línea 2942... |
Línea 2941... |
| 2942 |
}
|
2941 |
}
|
| 2943 |
}
|
2942 |
}
|
| 2944 |
|
2943 |
|
| 2945 |
// remove all grades from gradebook
|
2944 |
// Remove all grades from gradebook.
|
| Línea -... |
Línea 2945... |
| - |
|
2945 |
if (empty($data->reset_gradebook_grades)) {
|
| - |
|
2946 |
glossary_reset_gradebook($data->courseid, 'main');
|
| 2946 |
if (empty($data->reset_gradebook_grades)) {
|
2947 |
}
|
| - |
|
2948 |
|
| - |
|
2949 |
$status[] = [
|
| Línea 2947... |
Línea 2950... |
| 2947 |
glossary_reset_gradebook($data->courseid, 'main');
|
2950 |
'component' => $componentstr,
|
| 2948 |
}
|
2951 |
'item' => get_string('resetglossaries', 'glossary').': '.get_string('mainglossary', 'glossary'),
|
| 2949 |
|
2952 |
'error' => false,
|
| 2950 |
$status[] = array('component'=>$componentstr, 'item'=>get_string('resetglossaries', 'glossary').': '.get_string('mainglossary', 'glossary'), 'error'=>false);
|
2953 |
];
|
| 2951 |
|
2954 |
|
| 2952 |
} else if (in_array('secondary', $data->reset_glossary_types)) {
|
2955 |
} else if (in_array('secondary', $data->reset_glossary_types)) {
|
| 2953 |
$params[] = 'glossary_entry';
|
2956 |
$params[] = 'glossary_entry';
|
| 2954 |
$DB->delete_records_select('comments', "itemid IN ($secondaryentriessql) AND commentarea=?", $params);
|
2957 |
$DB->delete_records_select('comments', "itemid IN ($secondaryentriessql) AND commentarea=?", $params);
|
| Línea 2955... |
Línea 2958... |
| 2955 |
$DB->delete_records_select('glossary_entries', "glossaryid IN ($secondaryglossariessql)", $params);
|
2958 |
$DB->delete_records_select('glossary_entries', "glossaryid IN ($secondaryglossariessql)", $params);
|
| Línea 2964... |
Línea 2967... |
| 2964 |
continue;
|
2967 |
continue;
|
| 2965 |
}
|
2968 |
}
|
| 2966 |
$context = context_module::instance($cm->id);
|
2969 |
$context = context_module::instance($cm->id);
|
| 2967 |
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment');
|
2970 |
$fs->delete_area_files($context->id, 'mod_glossary', 'attachment');
|
| Línea 2968... |
Línea 2971... |
| 2968 |
|
2971 |
|
| 2969 |
//delete ratings
|
2972 |
// Delete ratings.
|
| 2970 |
$ratingdeloptions->contextid = $context->id;
|
2973 |
$ratingdeloptions->contextid = $context->id;
|
| Línea 2971... |
Línea 2974... |
| 2971 |
$rm->delete_ratings($ratingdeloptions);
|
2974 |
$rm->delete_ratings($ratingdeloptions);
|
| 2972 |
|
2975 |
|
| 2973 |
core_tag_tag::delete_instances('mod_glossary', null, $context->id);
|
2976 |
core_tag_tag::delete_instances('mod_glossary', null, $context->id);
|
| Línea 2974... |
Línea 2977... |
| 2974 |
}
|
2977 |
}
|
| 2975 |
}
|
2978 |
}
|
| 2976 |
|
2979 |
|
| 2977 |
// remove all grades from gradebook
|
2980 |
// Remove all grades from gradebook.
|
| Línea -... |
Línea 2981... |
| - |
|
2981 |
if (empty($data->reset_gradebook_grades)) {
|
| - |
|
2982 |
glossary_reset_gradebook($data->courseid, 'secondary');
|
| 2978 |
if (empty($data->reset_gradebook_grades)) {
|
2983 |
}
|
| - |
|
2984 |
|
| - |
|
2985 |
$status[] = [
|
| 2979 |
glossary_reset_gradebook($data->courseid, 'secondary');
|
2986 |
'component' => $componentstr,
|
| 2980 |
}
|
2987 |
'item' => get_string('resetglossaries', 'glossary').': '.get_string('secondaryglossary', 'glossary'),
|
| Línea 2981... |
Línea 2988... |
| 2981 |
|
2988 |
'error' => false,
|
| 2982 |
$status[] = array('component'=>$componentstr, 'item'=>get_string('resetglossaries', 'glossary').': '.get_string('secondaryglossary', 'glossary'), 'error'=>false);
|
2989 |
];
|
| 2983 |
}
|
2990 |
}
|
| 2984 |
}
|
2991 |
}
|
| 2985 |
|
2992 |
|
| 2986 |
// remove entries by users not enrolled into course
|
2993 |
// Remove entries by users not enrolled into course.
|
| 2987 |
if (!empty($data->reset_glossary_notenrolled)) {
|
2994 |
if (!empty($data->reset_glossary_notenrolled)) {
|
| Línea 2988... |
Línea 2995... |
| 2988 |
$entriessql = "SELECT e.id, e.userid, e.glossaryid, u.id AS userexists, u.deleted AS userdeleted
|
2995 |
$entriessql = "SELECT e.id, e.userid, e.glossaryid, u.id AS userexists, u.deleted AS userdeleted
|
| 2989 |
FROM {glossary_entries} e
|
2996 |
FROM {glossary_entries} e
|
| 2990 |
JOIN {glossary} g ON e.glossaryid = g.id
|
2997 |
JOIN {glossary} g ON e.glossaryid = g.id
|
| 2991 |
LEFT JOIN {user} u ON e.userid = u.id
|
2998 |
LEFT JOIN {user} u ON e.userid = u.id
|
| 2992 |
WHERE g.course = ? AND e.userid > 0";
|
2999 |
WHERE g.course = ? AND e.userid > 0";
|
| 2993 |
|
3000 |
|
| 2994 |
$course_context = context_course::instance($data->courseid);
|
3001 |
$coursecontext = context_course::instance($data->courseid);
|
| 2995 |
$notenrolled = array();
|
3002 |
$notenrolled = [];
|
| 2996 |
$rs = $DB->get_recordset_sql($entriessql, $params);
|
3003 |
$rs = $DB->get_recordset_sql($entriessql, $params);
|
| Línea 2997... |
Línea 3004... |
| 2997 |
if ($rs->valid()) {
|
3004 |
if ($rs->valid()) {
|
| 2998 |
foreach ($rs as $entry) {
|
3005 |
foreach ($rs as $entry) {
|
| 2999 |
if (array_key_exists($entry->userid, $notenrolled) or !$entry->userexists or $entry->userdeleted
|
3006 |
if (array_key_exists($entry->userid, $notenrolled) || !$entry->userexists || $entry->userdeleted
|
| Línea 3009... |
Línea 3016... |
| 3009 |
$ratingdeloptions->contextid = $context->id;
|
3016 |
$ratingdeloptions->contextid = $context->id;
|
| 3010 |
$rm->delete_ratings($ratingdeloptions);
|
3017 |
$rm->delete_ratings($ratingdeloptions);
|
| 3011 |
}
|
3018 |
}
|
| 3012 |
}
|
3019 |
}
|
| 3013 |
}
|
3020 |
}
|
| - |
|
3021 |
$status[] = [
|
| - |
|
3022 |
'component' => $componentstr,
|
| 3014 |
$status[] = array('component'=>$componentstr, 'item'=>get_string('deletenotenrolled', 'glossary'), 'error'=>false);
|
3023 |
'item' => get_string('deletenotenrolled', 'glossary'),
|
| - |
|
3024 |
'error' => false,
|
| - |
|
3025 |
];
|
| 3015 |
}
|
3026 |
}
|
| 3016 |
$rs->close();
|
3027 |
$rs->close();
|
| 3017 |
}
|
3028 |
}
|
| Línea 3018... |
Línea 3029... |
| 3018 |
|
3029 |
|
| 3019 |
// remove all ratings
|
3030 |
// Remove all ratings.
|
| 3020 |
if (!empty($data->reset_glossary_ratings)) {
|
3031 |
if (!empty($data->reset_glossary_ratings)) {
|
| 3021 |
//remove ratings
|
3032 |
// Remove ratings.
|
| 3022 |
if ($glossaries = $DB->get_records_sql($allglossariessql, $params)) {
|
3033 |
if ($glossaries = $DB->get_records_sql($allglossariessql, $params)) {
|
| 3023 |
foreach ($glossaries as $glossaryid=>$unused) {
|
3034 |
foreach ($glossaries as $glossaryid=>$unused) {
|
| 3024 |
if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
|
3035 |
if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
|
| 3025 |
continue;
|
3036 |
continue;
|
| 3026 |
}
|
3037 |
}
|
| Línea 3027... |
Línea 3038... |
| 3027 |
$context = context_module::instance($cm->id);
|
3038 |
$context = context_module::instance($cm->id);
|
| 3028 |
|
3039 |
|
| 3029 |
//delete ratings
|
3040 |
// Delete ratings.
|
| 3030 |
$ratingdeloptions->contextid = $context->id;
|
3041 |
$ratingdeloptions->contextid = $context->id;
|
| 3031 |
$rm->delete_ratings($ratingdeloptions);
|
3042 |
$rm->delete_ratings($ratingdeloptions);
|
| Línea 3032... |
Línea 3043... |
| 3032 |
}
|
3043 |
}
|
| 3033 |
}
|
3044 |
}
|
| 3034 |
|
3045 |
|
| 3035 |
// remove all grades from gradebook
|
3046 |
// Remove all grades from gradebook.
|
| - |
|
3047 |
if (empty($data->reset_gradebook_grades)) {
|
| - |
|
3048 |
glossary_reset_gradebook($data->courseid);
|
| 3036 |
if (empty($data->reset_gradebook_grades)) {
|
3049 |
}
|
| - |
|
3050 |
$status[] = [
|
| - |
|
3051 |
'component' => $componentstr,
|
| 3037 |
glossary_reset_gradebook($data->courseid);
|
3052 |
'item' => get_string('deleteallratings'),
|
| Línea 3038... |
Línea 3053... |
| 3038 |
}
|
3053 |
'error' => false,
|
| 3039 |
$status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallratings'), 'error'=>false);
|
3054 |
];
|
| 3040 |
}
|
3055 |
}
|
| 3041 |
|
3056 |
|
| - |
|
3057 |
// Remove comments.
|
| - |
|
3058 |
if (!empty($data->reset_glossary_comments)) {
|
| 3042 |
// remove comments
|
3059 |
$params[] = 'glossary_entry';
|
| - |
|
3060 |
$DB->delete_records_select('comments', "itemid IN ($allentriessql) AND commentarea= ? ", $params);
|
| - |
|
3061 |
$status[] = [
|
| 3043 |
if (!empty($data->reset_glossary_comments)) {
|
3062 |
'component' => $componentstr,
|
| Línea 3044... |
Línea 3063... |
| 3044 |
$params[] = 'glossary_entry';
|
3063 |
'item' => get_string('deleteallcomments'),
|
| 3045 |
$DB->delete_records_select('comments', "itemid IN ($allentriessql) AND commentarea= ? ", $params);
|
3064 |
'error' => false,
|
| 3046 |
$status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallcomments'), 'error'=>false);
|
3065 |
];
|
| Línea 3057... |
Línea 3076... |
| 3057 |
$context = context_module::instance($cm->id);
|
3076 |
$context = context_module::instance($cm->id);
|
| 3058 |
core_tag_tag::delete_instances('mod_glossary', null, $context->id);
|
3077 |
core_tag_tag::delete_instances('mod_glossary', null, $context->id);
|
| 3059 |
}
|
3078 |
}
|
| 3060 |
}
|
3079 |
}
|
| Línea -... |
Línea 3080... |
| - |
|
3080 |
|
| - |
|
3081 |
$status[] = [
|
| 3061 |
|
3082 |
'component' => $componentstr,
|
| - |
|
3083 |
'item' => get_string('removeallglossarytags', 'glossary'),
|
| - |
|
3084 |
'error' => false,
|
| 3062 |
$status[] = array('component' => $componentstr, 'item' => get_string('tagsdeleted', 'glossary'), 'error' => false);
|
3085 |
];
|
| Línea 3063... |
Línea 3086... |
| 3063 |
}
|
3086 |
}
|
| 3064 |
|
3087 |
|
| 3065 |
/// updating dates - shift may be negative too
|
3088 |
// Updating dates - shift may be negative too.
|
| 3066 |
if ($data->timeshift) {
|
3089 |
if ($data->timeshift) {
|
| 3067 |
// Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
|
3090 |
// Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
|
| - |
|
3091 |
// See MDL-9367.
|
| - |
|
3092 |
shift_course_mod_dates('glossary', ['assesstimestart', 'assesstimefinish'], $data->timeshift, $data->courseid);
|
| 3068 |
// See MDL-9367.
|
3093 |
$status[] = [
|
| - |
|
3094 |
'component' => $componentstr,
|
| - |
|
3095 |
'item' => get_string('date'),
|
| 3069 |
shift_course_mod_dates('glossary', array('assesstimestart', 'assesstimefinish'), $data->timeshift, $data->courseid);
|
3096 |
'error' => false,
|
| Línea 3070... |
Línea 3097... |
| 3070 |
$status[] = array('component'=>$componentstr, 'item'=>get_string('datechanged'), 'error'=>false);
|
3097 |
];
|
| 3071 |
}
|
3098 |
}
|
| Línea 3418... |
Línea 3445... |
| 3418 |
* @param int $from Fetch records from.
|
3445 |
* @param int $from Fetch records from.
|
| 3419 |
* @param int $limit Number of records to fetch.
|
3446 |
* @param int $limit Number of records to fetch.
|
| 3420 |
* @param array $options Accepts:
|
3447 |
* @param array $options Accepts:
|
| 3421 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
3448 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
| 3422 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
3449 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
| 3423 |
* @return array The first element being the recordset, the second the number of entries.
|
3450 |
* @return array The first element being the recordset (taking into account the limit), the second the number of entries the overall
|
| - |
|
3451 |
* array has.
|
| 3424 |
* @since Moodle 3.1
|
3452 |
* @since Moodle 3.1
|
| 3425 |
*/
|
3453 |
*/
|
| 3426 |
function glossary_get_entries_by_letter($glossary, $context, $letter, $from, $limit, $options = array()) {
|
3454 |
function glossary_get_entries_by_letter($glossary, $context, $letter, $from, $limit, $options = array()) {
|
| Línea 3427... |
Línea 3455... |
| 3427 |
|
3455 |
|
| 3428 |
$qb = new mod_glossary_entry_query_builder($glossary);
|
- |
|
| 3429 |
if ($letter != 'ALL' && $letter != 'SPECIAL' && core_text::strlen($letter)) {
|
- |
|
| 3430 |
$qb->filter_by_concept_letter($letter);
|
- |
|
| 3431 |
}
|
- |
|
| 3432 |
if ($letter == 'SPECIAL') {
|
- |
|
| 3433 |
$qb->filter_by_concept_non_letter();
|
- |
|
| Línea 3434... |
Línea 3456... |
| 3434 |
}
|
3456 |
$qb = new mod_glossary_entry_query_builder($glossary);
|
| 3435 |
|
3457 |
|
| 3436 |
if (!empty($options['includenotapproved']) && has_capability('mod/glossary:approve', $context)) {
|
3458 |
if (!empty($options['includenotapproved']) && has_capability('mod/glossary:approve', $context)) {
|
| 3437 |
$qb->filter_by_non_approved(mod_glossary_entry_query_builder::NON_APPROVED_ALL);
|
3459 |
$qb->filter_by_non_approved(mod_glossary_entry_query_builder::NON_APPROVED_ALL);
|
| Línea 3442... |
Línea 3464... |
| 3442 |
$qb->add_field('*', 'entries');
|
3464 |
$qb->add_field('*', 'entries');
|
| 3443 |
$qb->join_user();
|
3465 |
$qb->join_user();
|
| 3444 |
$qb->add_user_fields();
|
3466 |
$qb->add_user_fields();
|
| 3445 |
$qb->order_by('concept', 'entries');
|
3467 |
$qb->order_by('concept', 'entries');
|
| 3446 |
$qb->order_by('id', 'entries', 'ASC'); // Sort on ID to avoid random ordering when entries share an ordering value.
|
3468 |
$qb->order_by('id', 'entries', 'ASC'); // Sort on ID to avoid random ordering when entries share an ordering value.
|
| 3447 |
$qb->limit($from, $limit);
|
- |
|
| Línea 3448... |
Línea 3469... |
| 3448 |
|
3469 |
|
| 3449 |
// Fetching the entries.
|
- |
|
| 3450 |
$count = $qb->count_records();
|
3470 |
// Fetching the entries. Those are all entries.
|
| Línea -... |
Línea 3471... |
| - |
|
3471 |
$entries = $qb->get_records();
|
| - |
|
3472 |
|
| - |
|
3473 |
// Now sorting out the array.
|
| - |
|
3474 |
$filteredentries = [];
|
| - |
|
3475 |
|
| - |
|
3476 |
if ($letter != 'ALL' && $letter != 'SPECIAL' && core_text::strlen($letter)) {
|
| - |
|
3477 |
// Build a new array with the filtered entries.
|
| - |
|
3478 |
foreach ($entries as $key => $entry) {
|
| - |
|
3479 |
if (strtoupper(substr(format_string($entry->concept), 0, 1)) === strtoupper($letter)) {
|
| - |
|
3480 |
// Add it when starting with the correct letter.
|
| - |
|
3481 |
$filteredentries[$key] = $entry;
|
| - |
|
3482 |
}
|
| - |
|
3483 |
}
|
| - |
|
3484 |
$entries = $filteredentries;
|
| - |
|
3485 |
}
|
| - |
|
3486 |
|
| - |
|
3487 |
if ($letter == 'SPECIAL') {
|
| - |
|
3488 |
// Build a new array with the filtered entries.
|
| - |
|
3489 |
foreach ($entries as $key => $entry) {
|
| - |
|
3490 |
if (!ctype_alpha(substr(format_string($entry->concept), 0, 1))) {
|
| - |
|
3491 |
// Add it when starting with a non-letter character.
|
| - |
|
3492 |
$filteredentries[$key] = $entry;
|
| - |
|
3493 |
}
|
| - |
|
3494 |
}
|
| - |
|
3495 |
$entries = $filteredentries;
|
| - |
|
3496 |
}
|
| - |
|
3497 |
|
| - |
|
3498 |
if ($letter == 'ALL') {
|
| - |
|
3499 |
// No filtering needed.
|
| - |
|
3500 |
$filteredentries = $entries;
|
| - |
|
3501 |
}
|
| - |
|
3502 |
|
| - |
|
3503 |
// Now sort the array in regard to the current language.
|
| - |
|
3504 |
usort($filteredentries, function($a, $b) {
|
| - |
|
3505 |
return format_string($a->concept) <=> format_string($b->concept);
|
| - |
|
3506 |
});
|
| - |
|
3507 |
|
| - |
|
3508 |
// Size of the overall array.
|
| - |
|
3509 |
$count = count($entries);
|
| - |
|
3510 |
|
| - |
|
3511 |
// Now applying limit.
|
| - |
|
3512 |
if (isset($limit)) {
|
| - |
|
3513 |
if (isset($from)) {
|
| - |
|
3514 |
$entries = array_slice($filteredentries, $from, $limit);
|
| - |
|
3515 |
} else {
|
| - |
|
3516 |
$entries = array_slice($filteredentries);
|
| - |
|
3517 |
}
|
| - |
|
3518 |
} else {
|
| - |
|
3519 |
$entries = $filteredentries;
|
| 3451 |
$entries = $qb->get_records();
|
3520 |
}
|
| 3452 |
|
3521 |
|
| Línea 3453... |
Línea 3522... |
| 3453 |
return array($entries, $count);
|
3522 |
return array($entries, $count);
|
| 3454 |
}
|
3523 |
}
|
| Línea 3463... |
Línea 3532... |
| 3463 |
* @param int $from Fetch records from.
|
3532 |
* @param int $from Fetch records from.
|
| 3464 |
* @param int $limit Number of records to fetch.
|
3533 |
* @param int $limit Number of records to fetch.
|
| 3465 |
* @param array $options Accepts:
|
3534 |
* @param array $options Accepts:
|
| 3466 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
3535 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
| 3467 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
3536 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
| 3468 |
* @return array The first element being the recordset, the second the number of entries.
|
3537 |
* @return array The first element being the recordset (taking into account the limit), the second the number of entries the overall
|
| - |
|
3538 |
* array has.
|
| 3469 |
* @since Moodle 3.1
|
3539 |
* @since Moodle 3.1
|
| 3470 |
*/
|
3540 |
*/
|
| 3471 |
function glossary_get_entries_by_date($glossary, $context, $order, $sort, $from, $limit, $options = array()) {
|
3541 |
function glossary_get_entries_by_date($glossary, $context, $order, $sort, $from, $limit, $options = array()) {
|
| Línea 3472... |
Línea 3542... |
| 3472 |
|
3542 |
|
| Línea 3505... |
Línea 3575... |
| 3505 |
* @param int $from Fetch records from.
|
3575 |
* @param int $from Fetch records from.
|
| 3506 |
* @param int $limit Number of records to fetch.
|
3576 |
* @param int $limit Number of records to fetch.
|
| 3507 |
* @param array $options Accepts:
|
3577 |
* @param array $options Accepts:
|
| 3508 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
3578 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
| 3509 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
3579 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
| 3510 |
* @return array The first element being the recordset, the second the number of entries.
|
3580 |
* @return array The first element being the recordset (taking into account the limit), the second the number of entries the overall
|
| - |
|
3581 |
* array has.
|
| 3511 |
* @since Moodle 3.1
|
3582 |
* @since Moodle 3.1
|
| 3512 |
*/
|
3583 |
*/
|
| 3513 |
function glossary_get_entries_by_category($glossary, $context, $categoryid, $from, $limit, $options = array()) {
|
3584 |
function glossary_get_entries_by_category($glossary, $context, $categoryid, $from, $limit, $options = array()) {
|
| Línea 3514... |
Línea 3585... |
| 3514 |
|
3585 |
|
| Línea 3562... |
Línea 3633... |
| 3562 |
* @param int $from Fetch records from.
|
3633 |
* @param int $from Fetch records from.
|
| 3563 |
* @param int $limit Number of records to fetch.
|
3634 |
* @param int $limit Number of records to fetch.
|
| 3564 |
* @param array $options Accepts:
|
3635 |
* @param array $options Accepts:
|
| 3565 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
3636 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
| 3566 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
3637 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
| 3567 |
* @return array The first element being the recordset, the second the number of entries.
|
3638 |
* @return array The first element being the recordset (taking into account the limit), the second the number of entries the overall
|
| - |
|
3639 |
* array has.
|
| 3568 |
* @since Moodle 3.1
|
3640 |
* @since Moodle 3.1
|
| 3569 |
*/
|
3641 |
*/
|
| 3570 |
function glossary_get_entries_by_author($glossary, $context, $letter, $field, $sort, $from, $limit, $options = array()) {
|
3642 |
function glossary_get_entries_by_author($glossary, $context, $letter, $field, $sort, $from, $limit, $options = array()) {
|
| Línea 3571... |
Línea 3643... |
| 3571 |
|
3643 |
|
| Línea 3610... |
Línea 3682... |
| 3610 |
* @param int $from Fetch records from.
|
3682 |
* @param int $from Fetch records from.
|
| 3611 |
* @param int $limit Number of records to fetch.
|
3683 |
* @param int $limit Number of records to fetch.
|
| 3612 |
* @param array $options Accepts:
|
3684 |
* @param array $options Accepts:
|
| 3613 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
3685 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
| 3614 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
3686 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
| 3615 |
* @return array The first element being the recordset, the second the number of entries.
|
3687 |
* @return array The first element being the recordset (taking into account the limit), the second the number of entries the overall
|
| - |
|
3688 |
* array has.
|
| 3616 |
* @since Moodle 3.1
|
3689 |
* @since Moodle 3.1
|
| 3617 |
*/
|
3690 |
*/
|
| 3618 |
function glossary_get_entries_by_author_id($glossary, $context, $authorid, $order, $sort, $from, $limit, $options = array()) {
|
3691 |
function glossary_get_entries_by_author_id($glossary, $context, $authorid, $order, $sort, $from, $limit, $options = array()) {
|
| Línea 3619... |
Línea 3692... |
| 3619 |
|
3692 |
|
| Línea 3655... |
Línea 3728... |
| 3655 |
* @param int $limit Number of records to fetch.
|
3728 |
* @param int $limit Number of records to fetch.
|
| 3656 |
* @param int $from Fetch records from.
|
3729 |
* @param int $from Fetch records from.
|
| 3657 |
* @param array $options Accepts:
|
3730 |
* @param array $options Accepts:
|
| 3658 |
* - (bool) includenotapproved. When false, includes self even if all of their entries require approval.
|
3731 |
* - (bool) includenotapproved. When false, includes self even if all of their entries require approval.
|
| 3659 |
* When true, also includes authors only having entries pending approval.
|
3732 |
* When true, also includes authors only having entries pending approval.
|
| 3660 |
* @return array The first element being the recordset, the second the number of entries.
|
3733 |
* @return array The first element being the recordset (taking into account the limit), the second the number of entries the overall
|
| - |
|
3734 |
* array has.
|
| 3661 |
* @since Moodle 3.1
|
3735 |
* @since Moodle 3.1
|
| 3662 |
*/
|
3736 |
*/
|
| 3663 |
function glossary_get_authors($glossary, $context, $limit, $from, $options = array()) {
|
3737 |
function glossary_get_authors($glossary, $context, $limit, $from, $options = array()) {
|
| 3664 |
global $DB, $USER;
|
3738 |
global $DB, $USER;
|
| Línea 3695... |
Línea 3769... |
| 3695 |
* Returns the categories of a glossary.
|
3769 |
* Returns the categories of a glossary.
|
| 3696 |
*
|
3770 |
*
|
| 3697 |
* @param object $glossary The glossary.
|
3771 |
* @param object $glossary The glossary.
|
| 3698 |
* @param int $from Fetch records from.
|
3772 |
* @param int $from Fetch records from.
|
| 3699 |
* @param int $limit Number of records to fetch.
|
3773 |
* @param int $limit Number of records to fetch.
|
| 3700 |
* @return array The first element being the recordset, the second the number of entries.
|
3774 |
* @return array The first element being the recordset (taking into account the limit), the second the number of entries the overall
|
| - |
|
3775 |
* array has.
|
| 3701 |
* @since Moodle 3.1
|
3776 |
* @since Moodle 3.1
|
| 3702 |
*/
|
3777 |
*/
|
| 3703 |
function glossary_get_categories($glossary, $from, $limit) {
|
3778 |
function glossary_get_categories($glossary, $from, $limit) {
|
| 3704 |
global $DB;
|
3779 |
global $DB;
|
| Línea 3733... |
Línea 3808... |
| 3733 |
$conditions = array();
|
3808 |
$conditions = array();
|
| Línea 3734... |
Línea 3809... |
| 3734 |
|
3809 |
|
| 3735 |
foreach ($terms as $searchterm) {
|
3810 |
foreach ($terms as $searchterm) {
|
| Línea 3736... |
Línea 3811... |
| 3736 |
$i++;
|
3811 |
$i++;
|
| 3737 |
|
3812 |
|
| Línea 3738... |
Línea 3813... |
| 3738 |
$not = false; // Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle
|
3813 |
$not = false; // Initially we aren't going to perform NOT LIKE searches, only MSSQL
|
| 3739 |
// will use it to simulate the "-" operator with LIKE clause.
|
3814 |
// will use it to simulate the "-" operator with LIKE clause.
|
| 3740 |
|
3815 |
|
| Línea 3745... |
Línea 3820... |
| 3745 |
// With fullsearch enabled, look also within definitions.
|
3820 |
// With fullsearch enabled, look also within definitions.
|
| 3746 |
$concat = $DB->sql_concat('ge.concept', "' '", 'ge.definition', "' '", "COALESCE(al.alias, :emptychar{$i})");
|
3821 |
$concat = $DB->sql_concat('ge.concept', "' '", 'ge.definition', "' '", "COALESCE(al.alias, :emptychar{$i})");
|
| 3747 |
}
|
3822 |
}
|
| 3748 |
$params['emptychar' . $i] = '';
|
3823 |
$params['emptychar' . $i] = '';
|
| Línea 3749... |
Línea 3824... |
| 3749 |
|
3824 |
|
| 3750 |
// Under Oracle and MSSQL, trim the + and - operators and perform simpler LIKE (or NOT LIKE) queries.
|
3825 |
// Under MSSQL, trim the + and - operators and perform simpler LIKE (or NOT LIKE) queries.
|
| 3751 |
if (!$DB->sql_regex_supported()) {
|
3826 |
if (!$DB->sql_regex_supported()) {
|
| 3752 |
if (substr($searchterm, 0, 1) === '-') {
|
3827 |
if (substr($searchterm, 0, 1) === '-') {
|
| 3753 |
$not = true;
|
3828 |
$not = true;
|
| 3754 |
}
|
3829 |
}
|
| Línea 3799... |
Línea 3874... |
| 3799 |
* @param int $from Fetch records from.
|
3874 |
* @param int $from Fetch records from.
|
| 3800 |
* @param int $limit Number of records to fetch.
|
3875 |
* @param int $limit Number of records to fetch.
|
| 3801 |
* @param array $options Accepts:
|
3876 |
* @param array $options Accepts:
|
| 3802 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
3877 |
* - (bool) includenotapproved. When false, includes the non-approved entries created by
|
| 3803 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
3878 |
* the current user. When true, also includes the ones that the user has the permission to approve.
|
| 3804 |
* @return array The first element being the array of results, the second the number of entries.
|
3879 |
* @return array The first element being the recordset (taking into account the limit), the second the number of entries the overall
|
| - |
|
3880 |
* array has.
|
| 3805 |
* @since Moodle 3.1
|
3881 |
* @since Moodle 3.1
|
| 3806 |
*/
|
3882 |
*/
|
| 3807 |
function glossary_get_entries_by_search($glossary, $context, $query, $fullsearch, $order, $sort, $from, $limit,
|
3883 |
function glossary_get_entries_by_search($glossary, $context, $query, $fullsearch, $order, $sort, $from, $limit,
|
| 3808 |
$options = array()) {
|
3884 |
$options = array()) {
|
| 3809 |
global $DB, $USER;
|
3885 |
global $DB, $USER;
|
| Línea 3881... |
Línea 3957... |
| 3881 |
} else {
|
3957 |
} else {
|
| 3882 |
$qb->filter_by_non_approved(mod_glossary_entry_query_builder::NON_APPROVED_SELF);
|
3958 |
$qb->filter_by_non_approved(mod_glossary_entry_query_builder::NON_APPROVED_SELF);
|
| 3883 |
}
|
3959 |
}
|
| Línea 3884... |
Línea 3960... |
| 3884 |
|
3960 |
|
| - |
|
3961 |
$qb->add_field('*', 'entries');
|
| 3885 |
$qb->add_field('*', 'entries');
|
3962 |
$qb->add_field('alias', 'alias');
|
| 3886 |
$qb->join_alias();
|
3963 |
$qb->join_alias();
|
| 3887 |
$qb->join_user();
|
3964 |
$qb->join_user();
|
| 3888 |
$qb->add_user_fields();
|
3965 |
$qb->add_user_fields();
|
| Línea 3889... |
Línea 3966... |
| 3889 |
$qb->filter_by_term($term);
|
3966 |
$qb->filter_by_term($term);
|
| 3890 |
|
3967 |
|
| 3891 |
$qb->order_by('concept', 'entries');
|
- |
|
| Línea 3892... |
Línea 3968... |
| 3892 |
$qb->order_by('id', 'entries'); // Sort on ID to avoid random ordering when entries share an ordering value.
|
3968 |
$qb->order_by('concept', 'entries');
|
| 3893 |
$qb->limit($from, $limit);
|
- |
|
| 3894 |
|
3969 |
$qb->order_by('id', 'entries'); // Sort on ID to avoid random ordering when entries share an ordering value.
|
| Línea -... |
Línea 3970... |
| - |
|
3970 |
|
| - |
|
3971 |
// Fetching the entries. Those are all entries.
|
| - |
|
3972 |
$entries = $qb->get_records();
|
| - |
|
3973 |
|
| - |
|
3974 |
// Now sorting out the array.
|
| - |
|
3975 |
$filteredentries = [];
|
| - |
|
3976 |
|
| - |
|
3977 |
// Now sorting out the array.
|
| - |
|
3978 |
foreach ($entries as $key => $entry) {
|
| - |
|
3979 |
if (strtoupper(format_string($entry->concept)) === strtoupper($term)) {
|
| - |
|
3980 |
// Add it when matching concept or alias.
|
| - |
|
3981 |
$filteredentries[$key] = $entry;
|
| - |
|
3982 |
}
|
| - |
|
3983 |
if ((isset($entry->alias)) && (strtoupper(format_string($entry->alias)) === strtoupper($term))) {
|
| - |
|
3984 |
// Add it when matching concept or alias.
|
| - |
|
3985 |
$filteredentries[$key] = $entry;
|
| - |
|
3986 |
}
|
| - |
|
3987 |
}
|
| - |
|
3988 |
$entries = $filteredentries;
|
| - |
|
3989 |
// Check whether concept or alias match the term.
|
| - |
|
3990 |
|
| - |
|
3991 |
// Now sort the array in regard to the current language.
|
| - |
|
3992 |
usort($filteredentries, function($a, $b) {
|
| - |
|
3993 |
return format_string($a->concept) <=> format_string($b->concept);
|
| - |
|
3994 |
});
|
| - |
|
3995 |
|
| - |
|
3996 |
// Size of the overall array.
|
| - |
|
3997 |
$count = count($entries);
|
| - |
|
3998 |
|
| - |
|
3999 |
// Now applying limit.
|
| - |
|
4000 |
if (isset($limit)) {
|
| - |
|
4001 |
if (isset($from)) {
|
| - |
|
4002 |
$entries = array_slice($filteredentries, $from, $limit);
|
| - |
|
4003 |
} else {
|
| - |
|
4004 |
$entries = array_slice($filteredentries);
|
| - |
|
4005 |
}
|
| 3895 |
// Fetching the entries.
|
4006 |
} else {
|
| 3896 |
$count = $qb->count_records();
|
4007 |
$entries = $filteredentries;
|
| Línea 3897... |
Línea 4008... |
| 3897 |
$entries = $qb->get_records();
|
4008 |
}
|
| 3898 |
|
4009 |
|
| Línea 3913... |
Línea 4024... |
| 3913 |
* @since Moodle 3.1
|
4024 |
* @since Moodle 3.1
|
| 3914 |
*/
|
4025 |
*/
|
| 3915 |
function glossary_get_entries_to_approve($glossary, $context, $letter, $order, $sort, $from, $limit) {
|
4026 |
function glossary_get_entries_to_approve($glossary, $context, $letter, $order, $sort, $from, $limit) {
|
| Línea 3916... |
Línea 4027... |
| 3916 |
|
4027 |
|
| 3917 |
$qb = new mod_glossary_entry_query_builder($glossary);
|
- |
|
| 3918 |
if ($letter != 'ALL' && $letter != 'SPECIAL' && core_text::strlen($letter)) {
|
- |
|
| 3919 |
$qb->filter_by_concept_letter($letter);
|
- |
|
| 3920 |
}
|
- |
|
| 3921 |
if ($letter == 'SPECIAL') {
|
- |
|
| 3922 |
$qb->filter_by_concept_non_letter();
|
- |
|
| Línea 3923... |
Línea 4028... |
| 3923 |
}
|
4028 |
$qb = new mod_glossary_entry_query_builder($glossary);
|
| 3924 |
|
4029 |
|
| 3925 |
$qb->add_field('*', 'entries');
|
4030 |
$qb->add_field('*', 'entries');
|
| 3926 |
$qb->join_user();
|
4031 |
$qb->join_user();
|
| - |
|
4032 |
$qb->add_user_fields();
|
| - |
|
4033 |
$qb->filter_by_non_approved(mod_glossary_entry_query_builder::NON_APPROVED_ONLY);
|
| - |
|
4034 |
|
| - |
|
4035 |
// Fetching the entries. Those are all non approved entries.
|
| - |
|
4036 |
$entries = $qb->get_records();
|
| - |
|
4037 |
|
| - |
|
4038 |
// Size of the overall array.
|
| - |
|
4039 |
$count = count($entries);
|
| - |
|
4040 |
|
| - |
|
4041 |
// If a some filter is set, restrict by that filter.
|
| - |
|
4042 |
$filteredentries = [];
|
| - |
|
4043 |
|
| - |
|
4044 |
if ($letter != 'ALL' && $letter != 'SPECIAL' && core_text::strlen($letter)) {
|
| - |
|
4045 |
// Build a new array with the filtered entries.
|
| - |
|
4046 |
foreach ($entries as $key => $entry) {
|
| - |
|
4047 |
if (strtoupper(substr(format_string($entry->concept), 0, 1)) === strtoupper($letter)) {
|
| - |
|
4048 |
// Add it when starting with the correct letter.
|
| - |
|
4049 |
$filteredentries[$key] = $entry;
|
| - |
|
4050 |
}
|
| - |
|
4051 |
}
|
| - |
|
4052 |
} else if ($letter == 'SPECIAL') {
|
| - |
|
4053 |
// Build a new array with the filtered entries.
|
| - |
|
4054 |
foreach ($entries as $key => $entry) {
|
| - |
|
4055 |
if (!ctype_alpha(substr(format_string($entry->concept), 0, 1))) {
|
| - |
|
4056 |
// Add it when starting with a non-letter character.
|
| - |
|
4057 |
$filteredentries[$key] = $entry;
|
| - |
|
4058 |
}
|
| - |
|
4059 |
}
|
| - |
|
4060 |
} else {
|
| - |
|
4061 |
// No filtering needed (This means CONCEPT).
|
| - |
|
4062 |
$filteredentries = $entries;
|
| - |
|
4063 |
}
|
| 3927 |
$qb->add_user_fields();
|
4064 |
|
| - |
|
4065 |
// Now sort the array in regard to the current language.
|
| - |
|
4066 |
if ($order == 'CREATION') {
|
| - |
|
4067 |
if (strcasecmp($sort, 'DESC') === 0) {
|
| - |
|
4068 |
usort($filteredentries, function($a, $b) {
|
| - |
|
4069 |
return $b->timecreated <=> $a->timecreated;
|
| - |
|
4070 |
});
|
| 3928 |
$qb->filter_by_non_approved(mod_glossary_entry_query_builder::NON_APPROVED_ONLY);
|
4071 |
} else {
|
| - |
|
4072 |
usort($filteredentries, function($a, $b) {
|
| - |
|
4073 |
return $a->timecreated <=> $b->timecreated;
|
| 3929 |
if ($order == 'CREATION') {
|
4074 |
});
|
| - |
|
4075 |
}
|
| - |
|
4076 |
} else if ($order == 'UPDATE') {
|
| 3930 |
$qb->order_by('timecreated', 'entries', $sort);
|
4077 |
if (strcasecmp($sort, 'DESC') === 0) {
|
| - |
|
4078 |
usort($filteredentries, function($a, $b) {
|
| - |
|
4079 |
return $b->timemodified <=> $a->timemodified;
|
| - |
|
4080 |
});
|
| - |
|
4081 |
} else {
|
| - |
|
4082 |
usort($filteredentries, function($a, $b) {
|
| - |
|
4083 |
return $a->timemodified <=> $b->timemodified;
|
| 3931 |
} else if ($order == 'UPDATE') {
|
4084 |
});
|
| - |
|
4085 |
}
|
| 3932 |
$qb->order_by('timemodified', 'entries', $sort);
|
4086 |
} else {
|
| - |
|
4087 |
// This means CONCEPT.
|
| - |
|
4088 |
if (strcasecmp($sort, 'DESC') === 0) {
|
| - |
|
4089 |
usort($filteredentries, function($a, $b) {
|
| - |
|
4090 |
return format_string($b->concept) <=> format_string($a->concept);
|
| - |
|
4091 |
});
|
| - |
|
4092 |
} else {
|
| - |
|
4093 |
usort($filteredentries, function($a, $b) {
|
| - |
|
4094 |
return format_string($a->concept) <=> format_string($b->concept);
|
| 3933 |
} else {
|
4095 |
});
|
| 3934 |
$qb->order_by('concept', 'entries', $sort);
|
- |
|
| 3935 |
}
|
- |
|
| Línea 3936... |
Línea 4096... |
| 3936 |
$qb->order_by('id', 'entries', $sort); // Sort on ID to avoid random ordering when entries share an ordering value.
|
4096 |
}
|
| - |
|
4097 |
}
|
| 3937 |
$qb->limit($from, $limit);
|
4098 |
|
| 3938 |
|
4099 |
// Now applying limit.
|
| - |
|
4100 |
if (isset($limit)) {
|
| - |
|
4101 |
$count = count($filteredentries);
|
| - |
|
4102 |
if (isset($from)) {
|
| - |
|
4103 |
$filteredentries = array_slice($filteredentries, $from, $limit);
|
| - |
|
4104 |
} else {
|
| Línea 3939... |
Línea 4105... |
| 3939 |
// Fetching the entries.
|
4105 |
$filteredentries = array_slice($filteredentries, 0, $limit);
|
| 3940 |
$count = $qb->count_records();
|
4106 |
}
|
| Línea 3941... |
Línea 4107... |
| 3941 |
$entries = $qb->get_records();
|
4107 |
}
|
| 3942 |
|
4108 |
|
| 3943 |
return array($entries, $count);
|
4109 |
return [$filteredentries, $count];
|
| Línea 4200... |
Línea 4366... |
| 4200 |
*
|
4366 |
*
|
| 4201 |
* @return array
|
4367 |
* @return array
|
| 4202 |
*/
|
4368 |
*/
|
| 4203 |
function mod_glossary_get_fontawesome_icon_map() {
|
4369 |
function mod_glossary_get_fontawesome_icon_map() {
|
| 4204 |
return [
|
4370 |
return [
|
| - |
|
4371 |
'mod_glossary:asc' => 'fa-sort-down',
|
| - |
|
4372 |
'mod_glossary:desc' => 'fa-sort-up',
|
| 4205 |
'mod_glossary:export' => 'fa-download',
|
4373 |
'mod_glossary:export' => 'fa-arrow-turn-up',
|
| 4206 |
'mod_glossary:minus' => 'fa-minus'
|
4374 |
'mod_glossary:minus' => 'fa-minus',
|
| 4207 |
];
|
4375 |
];
|
| 4208 |
}
|
4376 |
}
|
| Línea 4209... |
Línea 4377... |
| 4209 |
|
4377 |
|
| 4210 |
/**
|
4378 |
/**
|