mirror of
https://github.com/moodle/moodle.git
synced 2025-08-05 00:46:50 +02:00
MDL-15109 glossary dml conversion
This commit is contained in:
parent
ea05eebf92
commit
ae8c356614
27 changed files with 558 additions and 628 deletions
|
@ -13,11 +13,11 @@
|
|||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
|
@ -26,11 +26,12 @@
|
|||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/glossary:approve', $context);
|
||||
|
||||
$newentry = new object();
|
||||
$newentry->id = $eid;
|
||||
$newentry->approved = 1;
|
||||
$newentry->timemodified = time(); // wee need this date here to speed up recent activity, TODO: use timestamp in approved field instead in 2.0
|
||||
|
||||
if (! update_record("glossary_entries", $newentry)) {
|
||||
if (! $DB->update_record("glossary_entries", $newentry)) {
|
||||
print_error('cantupdateglossary', 'glossary');
|
||||
} else {
|
||||
add_to_log($course->id, "glossary", "approve entry", "showentry.php?id=$cm->id&eid=$eid", "$eid",$cm->id);
|
||||
|
|
|
@ -29,13 +29,12 @@
|
|||
//----------------------------------------------------------------------------------
|
||||
|
||||
function glossary_backup_mods($bf,$preferences) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
//Iterate over glossary table
|
||||
$glossaries = get_records ("glossary","course",$preferences->backup_course,"mainglossary");
|
||||
$glossaries = $DB->get_records ("glossary", array("course"=>$preferences->backup_course), "mainglossary");
|
||||
if ($glossaries) {
|
||||
foreach ($glossaries as $glossary) {
|
||||
if (backup_mod_selected($preferences,'glossary',$glossary->id)) {
|
||||
|
@ -47,11 +46,10 @@
|
|||
}
|
||||
|
||||
function glossary_backup_one_mod($bf,$preferences,$glossary) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
if (is_numeric($glossary)) {
|
||||
$glossary = get_record('glossary','id',$glossary);
|
||||
$glossary = $DB->get_record('glossary', array('id'=>$glossary));
|
||||
}
|
||||
|
||||
$status = true;
|
||||
|
@ -100,12 +98,11 @@
|
|||
|
||||
//Backup glossary_categories and entries_categories contents (executed from glossary_backup_mods)
|
||||
function backup_glossary_categories ($bf,$preferences,$glossary, $userinfo) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$glossary_categories = get_records("glossary_categories","glossaryid",$glossary,"id");
|
||||
$glossary_categories = $DB->get_records("glossary_categories", array("glossaryid"=>$glossary),"id");
|
||||
//If there is categories
|
||||
if ($glossary_categories) {
|
||||
$status =fwrite ($bf,start_tag("CATEGORIES",4,true));
|
||||
|
@ -137,12 +134,11 @@
|
|||
|
||||
//Backup entries_categories contents (executed from backup_glossary_categories)
|
||||
function backup_glossary_entries_categories ($bf,$preferences,$categoryid) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$entries = get_records("glossary_entries_categories","categoryid",$categoryid);
|
||||
$entries = $DB->get_records("glossary_entries_categories", array("categoryid"=>$categoryid));
|
||||
if ($entries) {
|
||||
$status =fwrite ($bf,start_tag("ENTRIES",6,true));
|
||||
foreach ($entries as $entry) {
|
||||
|
@ -157,12 +153,11 @@
|
|||
|
||||
//Backup glossary_entries contents (executed from glossary_backup_mods)
|
||||
function backup_glossary_entries ($bf,$preferences,$glossary, $userinfo) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$glossary_entries = get_records("glossary_entries","glossaryid",$glossary,"id");
|
||||
$glossary_entries = $DB->get_records("glossary_entries", array("glossaryid"=>$glossary),"id");
|
||||
//If there is entries
|
||||
if ($glossary_entries) {
|
||||
$dumped_entries = 0;
|
||||
|
@ -219,12 +214,11 @@
|
|||
|
||||
//Backup glossary_comments contents (executed from backup_glossary_entries)
|
||||
function backup_glossary_comments ($bf,$preferences,$entryid) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$comments = get_records("glossary_comments","entryid",$entryid);
|
||||
$comments = $DB->get_records("glossary_comments", array("entryid"=>$entryid));
|
||||
if ($comments) {
|
||||
$status =fwrite ($bf,start_tag("COMMENTS",6,true));
|
||||
foreach ($comments as $comment) {
|
||||
|
@ -245,12 +239,11 @@
|
|||
|
||||
//Backup glossary_ratings contents (executed from backup_glossary_entries)
|
||||
function backup_glossary_ratings ($bf,$preferences,$entryid) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$ratings = get_records("glossary_ratings","entryid",$entryid);
|
||||
$ratings = $DB->get_records("glossary_ratings", array("entryid"=>$entryid));
|
||||
if ($ratings) {
|
||||
$status =fwrite ($bf,start_tag("RATINGS",6,true));
|
||||
foreach ($ratings as $rating) {
|
||||
|
@ -270,12 +263,11 @@
|
|||
|
||||
//Backup glossary_alias contents (executed from backup_glossary_entries)
|
||||
function backup_glossary_aliases ($bf,$preferences,$entryid) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
$aliases = get_records("glossary_alias","entryid",$entryid);
|
||||
$aliases = $DB->get_records("glossary_alias", array("entryid"=>$entryid));
|
||||
if ($aliases) {
|
||||
$status =fwrite ($bf,start_tag("ALIASES",6,true));
|
||||
foreach ($aliases as $alias) {
|
||||
|
@ -293,7 +285,6 @@
|
|||
//Backup glossary files because we've selected to backup user info
|
||||
//or current entry is a teacher entry
|
||||
function backup_glossary_files($bf,$preferences,$glossary,$entry) {
|
||||
|
||||
global $CFG;
|
||||
|
||||
$status = true;
|
||||
|
@ -399,33 +390,28 @@
|
|||
|
||||
//Returns an array of glossaries id
|
||||
function glossary_ids ($course) {
|
||||
global $DB;
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT a.id, a.course
|
||||
FROM {$CFG->prefix}glossary a
|
||||
WHERE a.course = '$course'");
|
||||
return $DB->get_records_sql ("SELECT a.id, a.course
|
||||
FROM {glossary} a
|
||||
WHERE a.course = ?", array($course));
|
||||
}
|
||||
|
||||
//Returns an array of glossary_answers id
|
||||
function glossary_entries_ids_by_course ($course) {
|
||||
global $DB;
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.glossaryid
|
||||
FROM {$CFG->prefix}glossary_entries s,
|
||||
{$CFG->prefix}glossary a
|
||||
WHERE a.course = '$course' AND
|
||||
s.glossaryid = a.id");
|
||||
return $DB->get_records_sql ("SELECT s.id , s.glossaryid
|
||||
FROM {glossary_entries} s, {glossary} a
|
||||
WHERE a.course = ? AND s.glossaryid = a.id", array($course));
|
||||
}
|
||||
|
||||
//Returns an array of glossary_answers id
|
||||
function glossary_entries_ids_by_instance ($instanceid) {
|
||||
global $DB;
|
||||
|
||||
global $CFG;
|
||||
|
||||
return get_records_sql ("SELECT s.id , s.glossaryid
|
||||
FROM {$CFG->prefix}glossary_entries s
|
||||
WHERE s.glossaryid = $instanceid");
|
||||
return $DB->get_records_sql ("SELECT s.id , s.glossaryid
|
||||
FROM {glossary_entries} s
|
||||
WHERE s.glossaryid = ?", array($instanceid));
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -28,20 +28,20 @@ switch ($action) {
|
|||
* Add new comment
|
||||
*/
|
||||
function glossary_comment_add() {
|
||||
global $USER;
|
||||
global $USER, $DB;
|
||||
|
||||
$eid = optional_param('eid', 0, PARAM_INT); // Entry ID
|
||||
|
||||
if (!$entry = get_record('glossary_entries', 'id', $eid)) {
|
||||
if (!$entry = $DB->get_record('glossary_entries', array('id'=>$eid))) {
|
||||
print_error('invalidentry');
|
||||
}
|
||||
if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) {
|
||||
if (!$glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (!$course = get_record('course', 'id', $cm->course)) {
|
||||
if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
|
@ -59,7 +59,7 @@ function glossary_comment_add() {
|
|||
redirect("comments.php?id=$cm->id&eid=$entry->id");
|
||||
}
|
||||
|
||||
if ($data = $mform->get_data()) {
|
||||
if ($data = $mform->get_data(false)) {
|
||||
trusttext_after_edit($data->entrycomment, $context);
|
||||
|
||||
$newcomment = new object();
|
||||
|
@ -69,7 +69,7 @@ function glossary_comment_add() {
|
|||
$newcomment->timemodified = time();
|
||||
$newcomment->userid = $USER->id;
|
||||
|
||||
if (!$newcomment->id = insert_record('glossary_comments', $newcomment)) {
|
||||
if (!$newcomment->id = $DB->insert_record('glossary_comments', $newcomment)) {
|
||||
print_error('cannotinsertcomment');
|
||||
} else {
|
||||
add_to_log($course->id, 'glossary', 'add comment', "comments.php?id=$cm->id&eid=$entry->id", "$newcomment->id", $cm->id);
|
||||
|
@ -88,24 +88,24 @@ function glossary_comment_add() {
|
|||
* Deleting existing comments
|
||||
*/
|
||||
function glossary_comment_delete() {
|
||||
global $USER;
|
||||
global $USER, $DB;
|
||||
|
||||
$cid = optional_param('cid', 0, PARAM_INT); // Comment ID
|
||||
$confirm = optional_param('confirm', 0, PARAM_BOOL); // delete confirmation
|
||||
|
||||
if (!$comment = get_record('glossary_comments', 'id', $cid)) {
|
||||
if (!$comment = $DB->get_record('glossary_comments', array('id'=>$cid))) {
|
||||
print_error('invalidcomment');
|
||||
}
|
||||
if (!$entry = get_record('glossary_entries', 'id', $comment->entryid)) {
|
||||
if (!$entry = $DB->get_record('glossary_entries', array('id'=>$comment->entryid))) {
|
||||
print_error('invalidentry');
|
||||
}
|
||||
if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) {
|
||||
if (!$glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (!$course = get_record('course', 'id', $cm->course)) {
|
||||
if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
|
@ -119,7 +119,7 @@ function glossary_comment_delete() {
|
|||
}
|
||||
|
||||
if (data_submitted() and $confirm) {
|
||||
delete_records('glossary_comments','id', $cid);
|
||||
$DB->delete_records('glossary_comments', array('id'=>$cid));
|
||||
add_to_log($course->id, 'glossary', 'delete comment', "comments.php?id=$cm->id&eid=$entry->id", "$comment->id",$cm->id);
|
||||
redirect("comments.php?id=$cm->id&eid=$entry->id");
|
||||
|
||||
|
@ -142,23 +142,23 @@ function glossary_comment_delete() {
|
|||
* Edit existing comments
|
||||
*/
|
||||
function glossary_comment_edit() {
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
$cid = optional_param('cid', 0, PARAM_INT); // Comment ID
|
||||
|
||||
if (!$comment = get_record('glossary_comments', 'id', $cid)) {
|
||||
if (!$comment = $DB->get_record('glossary_comments', array('id'=>$cid))) {
|
||||
print_error('invalidcomment');
|
||||
}
|
||||
if (!$entry = get_record('glossary_entries', 'id', $comment->entryid)) {
|
||||
if (!$entry = $DB->get_record('glossary_entries', array('id'=>$comment->entryid))) {
|
||||
print_error('invalidentry');
|
||||
}
|
||||
if (!$glossary = get_record('glossary', 'id', $entry->glossaryid)) {
|
||||
if (!$glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
if (!$cm = get_coursemodule_from_instance('glossary', $glossary->id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (!$course = get_record('course', 'id', $cm->course)) {
|
||||
if (!$course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
|
@ -179,7 +179,7 @@ function glossary_comment_edit() {
|
|||
trusttext_prepare_edit($comment->entrycomment, $comment->format, can_use_html_editor(), $context);
|
||||
$mform->set_data(array('cid'=>$cid, 'action'=>'edit', 'entrycomment'=>$comment->entrycomment, 'format'=>$comment->format));
|
||||
|
||||
if ($data = $mform->get_data()) {
|
||||
if ($data = $mform->get_data(false)) {
|
||||
trusttext_after_edit($data->entrycomment, $context);
|
||||
|
||||
$updatedcomment = new object();
|
||||
|
@ -188,7 +188,7 @@ function glossary_comment_edit() {
|
|||
$updatedcomment->format = $data->format;
|
||||
$updatedcomment->timemodified = time();
|
||||
|
||||
if (!update_record('glossary_comments', $updatedcomment)) {
|
||||
if (!$DB->update_record('glossary_comments', $updatedcomment)) {
|
||||
print_error('cannotupdatecomment');
|
||||
} else {
|
||||
add_to_log($course->id, 'glossary', 'update comment', "comments.php?id=$cm->id&eid=$entry->id", "$updatedcomment->id",$cm->id);
|
||||
|
|
|
@ -7,21 +7,19 @@
|
|||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
$eid = required_param('eid', PARAM_INT); // Entry ID
|
||||
|
||||
global $USER, $CFG;
|
||||
|
||||
if (! $cm = get_coursemodule_from_id('glossary', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcousemodule');
|
||||
}
|
||||
|
||||
if (! $entry = get_record("glossary_entries", "id", $eid)) {
|
||||
if (! $entry = $DB->get_record("glossary_entries", array("id"=>$eid))) {
|
||||
print_error('invalidentry');
|
||||
}
|
||||
|
||||
|
@ -61,7 +59,7 @@
|
|||
print_heading("<a href=\"comment.php?action=add&eid=$entry->id\">$straddcomment <img title=\"$straddcomment\" src=\"comment.gif\" class=\"iconsmall\" alt=\"$straddcomment\" /></a>");
|
||||
}
|
||||
|
||||
if ($comments = get_records("glossary_comments","entryid",$entry->id,"timemodified ASC")) {
|
||||
if ($comments = $DB->get_records("glossary_comments", array("entryid"=>$entry->id), "timemodified ASC")) {
|
||||
foreach ($comments as $comment) {
|
||||
glossary_print_comment($course, $cm, $glossary, $entry, $comment);
|
||||
echo '<br />';
|
||||
|
|
|
@ -20,11 +20,11 @@
|
|||
print_error("invalidcoursemodule");
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if (! $entry = get_record("glossary_entries","id", $entry)) {
|
||||
if (! $entry = $DB->get_record("glossary_entries", array("id"=>$entry))) {
|
||||
print_error('invalidentry');
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@
|
|||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
$manageentries = has_capability('mod/glossary:manageentries', $context);
|
||||
|
||||
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@
|
|||
$dbentry->id = $entry->id;
|
||||
$dbentry->glossaryid = $entry->sourceglossaryid;
|
||||
$dbentry->sourceglossaryid = 0;
|
||||
if (! update_record('glossary_entries', $dbentry)) {
|
||||
if (! $DB->update_record('glossary_entries', $dbentry)) {
|
||||
print_error('cantupdateglossary', 'glossary');
|
||||
}
|
||||
|
||||
|
@ -70,10 +70,10 @@
|
|||
if ( $entry->attachment ) {
|
||||
glossary_delete_old_attachments($entry);
|
||||
}
|
||||
delete_records("glossary_comments", "entryid",$entry->id);
|
||||
delete_records("glossary_alias", "entryid", $entry->id);
|
||||
delete_records("glossary_ratings", "entryid", $entry->id);
|
||||
delete_records("glossary_entries","id", $entry->id);
|
||||
$DB->delete_records("glossary_comments", array("entryid"=>$entry->id));
|
||||
$DB->delete_records("glossary_alias", array("entryid"=>$entry->id));
|
||||
$DB->delete_records("glossary_ratings", array("entryid"=>$entry->id));
|
||||
$DB->delete_records("glossary_entries", array("id"=>$entry->id));
|
||||
}
|
||||
|
||||
add_to_log($course->id, "glossary", "delete entry", "view.php?id=$cm->id&mode=$prevmode&hook=$hook", $entry->id,$cm->id);
|
||||
|
|
|
@ -19,7 +19,7 @@ if (! $cm = get_coursemodule_from_id('glossary', $id)) {
|
|||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
|
@ -29,13 +29,13 @@ if ( isguest() ) {
|
|||
print_error('guestnoedit', 'glossary', $_SERVER["HTTP_REFERER"]);
|
||||
}
|
||||
|
||||
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
|
||||
if ($e) { // if entry is specified
|
||||
if (!$entry = get_record("glossary_entries", "id", $e)) {
|
||||
if (!$entry = $DB->get_record("glossary_entries", array("id"=>$e))) {
|
||||
print_error('invalidentry');
|
||||
}
|
||||
$ineditperiod = ((time() - $entry->timecreated < $CFG->maxeditingtime) || $glossary->editalways);
|
||||
|
@ -47,7 +47,7 @@ if ($e) { // if entry is specified
|
|||
require_capability('mod/glossary:write', $context);
|
||||
}
|
||||
|
||||
$mform =& new mod_glossary_entry_form(null, compact('cm', 'glossary', 'hook', 'mode', 'e', 'context'));
|
||||
$mform = new mod_glossary_entry_form(null, compact('cm', 'glossary', 'hook', 'mode', 'e', 'context'));
|
||||
if ($mform->is_cancelled()){
|
||||
if ($e){
|
||||
redirect("view.php?id=$cm->id&mode=entry&hook=$e");
|
||||
|
@ -55,7 +55,7 @@ if ($mform->is_cancelled()){
|
|||
redirect("view.php?id=$cm->id");
|
||||
}
|
||||
|
||||
} elseif ($fromform = $mform->get_data()) {
|
||||
} elseif ($fromform = $mform->get_data(false)) {
|
||||
trusttext_after_edit($fromform->definition, $context);
|
||||
|
||||
if ( !isset($fromform->usedynalink) ) {
|
||||
|
@ -93,7 +93,7 @@ if ($mform->is_cancelled()){
|
|||
$todb->attachment = $newfilename;
|
||||
}
|
||||
|
||||
if (update_record('glossary_entries', $todb)) {
|
||||
if ($DB->update_record('glossary_entries', $todb)) {
|
||||
add_to_log($course->id, "glossary", "update entry",
|
||||
"view.php?id=$cm->id&mode=entry&hook=$todb->id",
|
||||
$todb->id, $cm->id);
|
||||
|
@ -108,11 +108,11 @@ if ($mform->is_cancelled()){
|
|||
$todb->teacherentry = has_capability('mod/glossary:manageentries', $context);
|
||||
|
||||
|
||||
if ($todb->id = insert_record("glossary_entries", $todb)) {
|
||||
if ($todb->id = $DB->insert_record("glossary_entries", $todb)) {
|
||||
$e = $todb->id;
|
||||
$dir = glossary_file_area_name($todb);
|
||||
if ($mform->save_files($dir) and $newfilename = $mform->get_new_filename()) {
|
||||
set_field("glossary_entries", "attachment", $newfilename, "id", $todb->id);
|
||||
$DB->set_field("glossary_entries", "attachment", $newfilename, array("id"=>$todb->id));
|
||||
}
|
||||
add_to_log($course->id, "glossary", "add entry",
|
||||
"view.php?id=$cm->id&mode=entry&hook=$todb->id", $todb->id,$cm->id);
|
||||
|
@ -122,15 +122,15 @@ if ($mform->is_cancelled()){
|
|||
|
||||
}
|
||||
|
||||
delete_records("glossary_entries_categories", "entryid", $e);
|
||||
delete_records("glossary_alias", "entryid", $e);
|
||||
$DB->delete_records("glossary_entries_categories", array("entryid"=>$e));
|
||||
$DB->delete_records("glossary_alias", array("entryid"=>$e));
|
||||
|
||||
if (empty($fromform->notcategorised) && isset($fromform->categories)) {
|
||||
$newcategory->entryid = $e;
|
||||
foreach ($fromform->categories as $category) {
|
||||
if ( $category > 0 ) {
|
||||
$newcategory->categoryid = $category;
|
||||
insert_record("glossary_entries_categories", $newcategory, false);
|
||||
$DB->insert_record("glossary_entries_categories", $newcategory, false);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
|
@ -141,10 +141,10 @@ if ($mform->is_cancelled()){
|
|||
foreach ($aliases as $alias) {
|
||||
$alias = trim($alias);
|
||||
if ($alias) {
|
||||
unset($newalias);
|
||||
$newalias = new object();
|
||||
$newalias->entryid = $e;
|
||||
$newalias->alias = $alias;
|
||||
insert_record("glossary_alias", $newalias, false);
|
||||
$DB->insert_record("glossary_alias", $newalias, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,7 +153,7 @@ if ($mform->is_cancelled()){
|
|||
|
||||
} else {
|
||||
if ($e) {
|
||||
$fromdb = get_record("glossary_entries", "id", $e);
|
||||
$fromdb = $DB->get_record("glossary_entries", array("id"=>$e));
|
||||
|
||||
$toform = new object();
|
||||
|
||||
|
|
|
@ -20,16 +20,16 @@
|
|||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if ($hook > 0) {
|
||||
if ($category = get_record("glossary_categories","id",$hook)) {
|
||||
if ($category = $DB->get_record("glossary_categories", array("id"=>$hook))) {
|
||||
//Check it belongs to the same glossary
|
||||
if ($category->glossaryid != $glossary->id) {
|
||||
print_error('invalidid', 'glossary');
|
||||
|
@ -63,11 +63,12 @@
|
|||
if ( $action == "edit" ) {
|
||||
if ( $confirm ) {
|
||||
$action = "";
|
||||
$cat = new object();
|
||||
$cat->id = $hook;
|
||||
$cat->name = $name;
|
||||
$cat->usedynalink = $usedynalink;
|
||||
|
||||
if ( !update_record("glossary_categories", $cat) ) {
|
||||
if ( !$DB->update_record("glossary_categories", $cat) ) {
|
||||
print_error('cannotupdatecategory');
|
||||
redirect("editcategories.php?id=$cm->id");
|
||||
} else {
|
||||
|
@ -85,8 +86,8 @@
|
|||
|
||||
} elseif ( $action == "delete" ) {
|
||||
if ( $confirm ) {
|
||||
delete_records("glossary_entries_categories","categoryid", $hook);
|
||||
delete_records("glossary_categories","id", $hook);
|
||||
$DB->delete_records("glossary_entries_categories", array("categoryid"=>$hook));
|
||||
$DB->delete_records("glossary_categories", array("id"=>$hook));
|
||||
|
||||
print_simple_box_start("center","40%", "#FFBBBB");
|
||||
echo "<div style=\"text-align:center\">" . get_string("categorydeleted","glossary") ."</div>";
|
||||
|
@ -103,7 +104,7 @@
|
|||
print_simple_box_start("center","40%", "#FFBBBB");
|
||||
echo "<div class=\"boxaligncenter\"><b>".format_text($category->name, FORMAT_PLAIN)."</b><br/>";
|
||||
|
||||
$num_entries = count_records("glossary_entries_categories","categoryid",$category->id);
|
||||
$num_entries = $DB->count_records("glossary_entries_categories", array("categoryid"=>$category->id));
|
||||
if ( $num_entries ) {
|
||||
print_string("deletingnoneemptycategory","glossary");
|
||||
}
|
||||
|
@ -141,7 +142,7 @@
|
|||
} elseif ( $action == "add" ) {
|
||||
if ( $confirm ) {
|
||||
$ILIKE = sql_ilike();
|
||||
$dupcategory = get_records_sql("SELECT * FROM {$CFG->prefix}glossary_categories WHERE name $ILIKE '$name' AND glossaryid=$glossary->id");
|
||||
$dupcategory = $DB->get_records_sql("SELECT * FROM {glossary_categories} WHERE name $ILIKE ? AND glossaryid=?", array($name, $glossary->id));
|
||||
if ( $dupcategory ) {
|
||||
echo "<p style=\"text-align:center\">" . get_string("add"). " " . get_string("category","glossary");
|
||||
|
||||
|
@ -153,11 +154,12 @@
|
|||
|
||||
} else {
|
||||
$action = "";
|
||||
$cat = new object();
|
||||
$cat->name = $name;
|
||||
$cat->usedynalink = $usedynalink;
|
||||
$cat->glossaryid = $glossary->id;
|
||||
|
||||
if ( ! $cat->id = insert_record("glossary_categories", $cat) ) {
|
||||
if ( ! $cat->id = $DB->insert_record("glossary_categories", $cat) ) {
|
||||
print_error('cannotinsertcategory');
|
||||
|
||||
redirect("editcategories.php?id=$cm->id");
|
||||
|
@ -192,12 +194,12 @@
|
|||
|
||||
|
||||
<?php
|
||||
$categories = get_records("glossary_categories","glossaryid",$glossary->id,"name ASC");
|
||||
$categories = $DB->get_records("glossary_categories", array("glossaryid"=>$glossary->id), "name ASC");
|
||||
|
||||
if ( $categories ) {
|
||||
echo '<table width="100%">';
|
||||
foreach ($categories as $category) {
|
||||
$num_entries = count_records("glossary_entries_categories","categoryid",$category->id);
|
||||
$num_entries = $DB->count_records("glossary_entries_categories", array("categoryid"=>$category->id));
|
||||
?>
|
||||
|
||||
<tr>
|
||||
|
|
|
@ -13,11 +13,11 @@
|
|||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
if ( ! $cm ) {
|
||||
$PermissionGranted = 0;
|
||||
} else {
|
||||
$mainglossary = get_record('glossary','course',$cm->course, 'mainglossary',1);
|
||||
$mainglossary = $DB->get_record('glossary', array('course'=>$cm->course), 'mainglossary',1);
|
||||
if ( ! $mainglossary ) {
|
||||
$PermissionGranted = 0;
|
||||
}
|
||||
|
@ -26,11 +26,11 @@
|
|||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
require_capability('mod/glossary:export', $context);
|
||||
|
||||
if (! $course = get_record('course', 'id', $cm->course)) {
|
||||
if (! $course = $DB->get_record('course', array('id'=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if (! $glossary = get_record('glossary', 'id', $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record('glossary', array('id'=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,7 @@
|
|||
print_header_simple(format_string($glossary->name), '', $navigation, '', '', true, '', navmenu($course, $cm));
|
||||
|
||||
if ( $PermissionGranted ) {
|
||||
$entry = get_record('glossary_entries', 'id', $entry);
|
||||
$entry = $DB->get_record('glossary_entries', array('id'=>$entry));
|
||||
|
||||
if ( !$confirm ) {
|
||||
echo '<div class="boxaligncenter">';
|
||||
|
@ -53,7 +53,7 @@
|
|||
echo '</div>';
|
||||
} else {
|
||||
if ( ! $mainglossary->allowduplicatedentries ) {
|
||||
$dupentry = get_record('glossary_entries','glossaryid', $mainglossary->id, 'lower(concept)',moodle_strtolower(addslashes($entry->concept)));
|
||||
$dupentry = $DB->get_record('glossary_entries', array('glossaryid'=>$mainglossary->id, 'lower(concept)'=>moodle_strtolower($entry->concept)));
|
||||
if ( $dupentry ) {
|
||||
$PermissionGranted = 0;
|
||||
}
|
||||
|
@ -65,7 +65,7 @@
|
|||
$dbentry->glossaryid = $mainglossary->id;
|
||||
$dbentry->sourceglossaryid = $glossary->id;
|
||||
|
||||
if (! update_record('glossary_entries', $dbentry)) {
|
||||
if (! $DB->update_record('glossary_entries', $dbentry)) {
|
||||
print_error('cantexportentry', 'glossary');
|
||||
} else {
|
||||
print_simple_box_start('center', '60%');
|
||||
|
|
|
@ -15,11 +15,11 @@
|
|||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
|
|
|
@ -42,30 +42,26 @@ function glossary_filter($courseid, $text) {
|
|||
}
|
||||
|
||||
/// Make a list of glossary IDs for searching
|
||||
$glossarylist = '';
|
||||
foreach ($glossaries as $glossaryid => $glossaryname) {
|
||||
$glossarylist .= $glossaryid.',';
|
||||
}
|
||||
$glossarylist = substr($glossarylist,0,-1);
|
||||
$glossarylist = implode(',', array_keys($glossaries));
|
||||
|
||||
|
||||
/// Pull out all the raw data from the database for entries, categories and aliases
|
||||
$entries = get_records_select('glossary_entries',
|
||||
'glossaryid IN ('.$glossarylist.') AND usedynalink != 0 AND approved != 0 ', '',
|
||||
'id,glossaryid, concept, casesensitive, 0 AS category, fullmatch');
|
||||
$entries = $DB->get_records_select('glossary_entries',
|
||||
'glossaryid IN ('.$glossarylist.') AND usedynalink != 0 AND approved != 0 ', '',
|
||||
'id,glossaryid, concept, casesensitive, 0 AS category, fullmatch');
|
||||
|
||||
$categories = get_records_select('glossary_categories',
|
||||
'glossaryid IN ('.$glossarylist.') AND usedynalink != 0', '',
|
||||
'id,glossaryid,name AS concept, 1 AS casesensitive, 1 AS category, 1 AS fullmatch');
|
||||
$categories = $DB->get_records_select('glossary_categories',
|
||||
'glossaryid IN ('.$glossarylist.') AND usedynalink != 0', '',
|
||||
'id,glossaryid,name AS concept, 1 AS casesensitive, 1 AS category, 1 AS fullmatch');
|
||||
|
||||
$aliases = get_records_sql('SELECT ga.id, ge.glossaryid, ga.alias as concept, ge.concept as originalconcept,
|
||||
casesensitive, 0 AS category, fullmatch
|
||||
FROM '.$CFG->prefix.'glossary_alias ga,
|
||||
'.$CFG->prefix.'glossary_entries ge
|
||||
WHERE ga.entryid = ge.id
|
||||
AND ge.glossaryid IN ('.$glossarylist.')
|
||||
AND ge.usedynalink != 0
|
||||
AND ge.approved != 0');
|
||||
$aliases = $DB->get_records_sql('SELECT ga.id, ge.glossaryid, ga.alias as concept, ge.concept as originalconcept,
|
||||
casesensitive, 0 AS category, fullmatch
|
||||
FROM {glossary_alias} ga,
|
||||
{glossary_entries} ge
|
||||
WHERE ga.entryid = ge.id
|
||||
AND ge.glossaryid IN ('.$glossarylist.')
|
||||
AND ge.usedynalink != 0
|
||||
AND ge.approved != 0');
|
||||
|
||||
|
||||
/// Combine them into one big list
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
admin_externalpage_setup('managemodules'); // this is hacky, tehre should be a special hidden page for it
|
||||
|
||||
if ( !$displayformat = get_record("glossary_formats","id",$id) ) {
|
||||
if ( !$displayformat = $DB->get_record("glossary_formats", array("id"=>$id))) {
|
||||
error ("Invalid Glossary Format");
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
|||
} else {
|
||||
$displayformat->visible = 1;
|
||||
}
|
||||
update_record("glossary_formats",$displayformat);
|
||||
$DB->update_record("glossary_formats",$displayformat);
|
||||
}
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header");
|
||||
die;
|
||||
|
@ -35,7 +35,7 @@
|
|||
$displayformat->sortkey = $form->sortkey;
|
||||
$displayformat->sortorder = $form->sortorder;
|
||||
|
||||
update_record("glossary_formats",$displayformat);
|
||||
$DB->update_record("glossary_formats",$displayformat);
|
||||
redirect("$CFG->wwwroot/$CFG->admin/settings.php?section=modsettingglossary#glossary_formats_header");
|
||||
die;
|
||||
}
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
<?php // $Id$
|
||||
|
||||
function glossary_show_entry_TEMPLATE($course, $cm, $glossary, $entry, $mode='', $hook='', $printicons=1, $ratings=NULL, $aliases=true) {
|
||||
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
|
||||
$user = get_record('user', 'id', $entry->userid);
|
||||
$user = $DB->get_record('user', array('id'=>$entry->userid));
|
||||
$strby = get_string('writtenby', 'glossary');
|
||||
|
||||
if ($entry) {
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php // $Id$
|
||||
|
||||
function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode='',$hook='',$printicons=1,$ratings=NULL, $aliases=true) {
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
|
||||
$user = get_record('user', 'id', $entry->userid);
|
||||
$user = $DB->get_record('user', array('id'=>$entry->userid));
|
||||
$strby = get_string('writtenby', 'glossary');
|
||||
|
||||
$return = false;
|
||||
|
@ -22,6 +22,7 @@ function glossary_show_entry_encyclopedia($course, $cm, $glossary, $entry, $mode
|
|||
echo '</div>';
|
||||
|
||||
$fullname = fullname($user);
|
||||
$by = new object();
|
||||
$by->name = '<a href="'.$CFG->wwwroot.'/user/view.php?id='.$user->id.'&course='.$course->id.'">'.$fullname.'</a>';
|
||||
$by->date = userdate($entry->timemodified);
|
||||
echo '<span class="author">'.get_string('bynameondate', 'forum', $by).'</span>';
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
<?php // $Id$
|
||||
|
||||
function glossary_show_entry_fullwithauthor($course, $cm, $glossary, $entry, $mode="", $hook="", $printicons=1, $ratings=NULL, $aliases=true) {
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
|
||||
$user = get_record('user', 'id', $entry->userid);
|
||||
$user = $DB->get_record('user', array('id'=>$entry->userid));
|
||||
$strby = get_string('writtenby', 'glossary');
|
||||
|
||||
$return = false;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
require_once("../../config.php");
|
||||
require_once("lib.php");
|
||||
require_once("$CFG->dirroot/course/lib.php");
|
||||
global $CFG, $USER;
|
||||
|
||||
$id = required_param('id', PARAM_INT); // Course Module ID
|
||||
|
||||
|
@ -19,11 +18,11 @@
|
|||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
|
@ -146,7 +145,7 @@
|
|||
// course_modules and course_sections each contain a reference
|
||||
// to each other, so we have to update one of them twice.
|
||||
|
||||
if (! $currmodule = get_record("modules", "name", 'glossary')) {
|
||||
if (! $currmodule = $DB->get_record("modules", array("name"=>'glossary'))) {
|
||||
print_error('modulenotexist', 'debug', '', 'Glossary');
|
||||
}
|
||||
$mod->module = $currmodule->id;
|
||||
|
@ -162,13 +161,13 @@
|
|||
print_error('cannotaddcoursemoduletosection');
|
||||
}
|
||||
//We get the section's visible field status
|
||||
$visible = get_field("course_sections","visible","id",$sectionid);
|
||||
$visible = $DB->get_field("course_sections", "visible", array("id"=>$sectionid));
|
||||
|
||||
if (! set_field("course_modules", "visible", $visible, "id", $mod->coursemodule)) {
|
||||
if (! $DB->set_field("course_modules", "visible", $visible, array("id"=>$mod->coursemodule))) {
|
||||
print_error('cannotupdatemod', '', '', $mod->coursemodule);
|
||||
}
|
||||
|
||||
if (! set_field("course_modules", "section", $sectionid, "id", $mod->coursemodule)) {
|
||||
if (! $DB->set_field("course_modules", "section", $sectionid, array("id"=>$mod->coursemodule))) {
|
||||
print_error('cannotupdatemod', '', '', $mod->coursemodule);
|
||||
}
|
||||
add_to_log($course->id, "course", "add mod",
|
||||
|
@ -208,9 +207,9 @@
|
|||
if ( !$glossary->allowduplicatedentries ) {
|
||||
// checking if the entry is valid (checking if it is duplicated when should not be)
|
||||
if ( $newentry->casesensitive ) {
|
||||
$dupentry = get_record("glossary_entries","concept",$newentry->concept,"glossaryid",$glossary->id);
|
||||
$dupentry = $DB->get_record("glossary_entries", array("concept"=>$newentry->concept, "glossaryid"=>$glossary->id));
|
||||
} else {
|
||||
$dupentry = get_record("glossary_entries","lower(concept)",moodle_strtolower($newentry->concept),"glossaryid",$glossary->id);
|
||||
$dupentry = $DB->get_record("glossary_entries", array("lower(concept)"=>moodle_strtolower($newentry->concept)), array("glossaryid"=>$glossary->id));
|
||||
}
|
||||
if ($dupentry) {
|
||||
$permissiongranted = 0;
|
||||
|
@ -225,23 +224,23 @@
|
|||
$newentry->approved = 1;
|
||||
$newentry->userid = $USER->id;
|
||||
$newentry->teacherentry = 1;
|
||||
$newentry->format = addslashes($xmlentry['#']['FORMAT'][0]['#']);
|
||||
$newentry->format = $xmlentry['#']['FORMAT'][0]['#'];
|
||||
$newentry->timecreated = time();
|
||||
$newentry->timemodified = time();
|
||||
|
||||
// Setting the default values if no values were passed
|
||||
if ( isset($xmlentry['#']['USEDYNALINK'][0]['#']) ) {
|
||||
$newentry->usedynalink = addslashes($xmlentry['#']['USEDYNALINK'][0]['#']);
|
||||
$newentry->usedynalink = $xmlentry['#']['USEDYNALINK'][0]['#'];
|
||||
} else {
|
||||
$newentry->usedynalink = $CFG->glossary_linkentries;
|
||||
}
|
||||
if ( isset($xmlentry['#']['FULLMATCH'][0]['#']) ) {
|
||||
$newentry->fullmatch = addslashes($xmlentry['#']['FULLMATCH'][0]['#']);
|
||||
$newentry->fullmatch = $xmlentry['#']['FULLMATCH'][0]['#'];
|
||||
} else {
|
||||
$newentry->fullmatch = $CFG->glossary_fullmatch;
|
||||
}
|
||||
|
||||
if ( $newentry->id = insert_record("glossary_entries",$newentry) ) {
|
||||
if ( $newentry->id = $DB->insert_record("glossary_entries",$newentry) ) {
|
||||
$importedentries++;
|
||||
|
||||
$xmlaliases = @$xmlentry['#']['ALIASES'][0]['#']['ALIAS']; // ignore missing ALIASES
|
||||
|
@ -251,10 +250,10 @@
|
|||
$aliasname = $xmlalias['#']['NAME'][0]['#'];
|
||||
|
||||
if (!empty($aliasname)) {
|
||||
unset($newalias);
|
||||
$newalias = new object();
|
||||
$newalias->entryid = $newentry->id;
|
||||
$newalias->alias = trim(addslashes($aliasname));
|
||||
$newalias->id = insert_record("glossary_alias",$newalias);
|
||||
$newalias->alias = trim($aliasname);
|
||||
$newalias->id = $DB->insert_record("glossary_alias",$newalias);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -263,16 +262,16 @@
|
|||
$xmlcats = @$xmlentry['#']['CATEGORIES'][0]['#']['CATEGORY']; // ignore missing CATEGORIES
|
||||
for($k = 0; $k < sizeof($xmlcats); $k++) {
|
||||
$xmlcat = $xmlcats[$k];
|
||||
unset($newcat);
|
||||
|
||||
$newcat->name = addslashes($xmlcat['#']['NAME'][0]['#']);
|
||||
$newcat->usedynalink = addslashes($xmlcat['#']['USEDYNALINK'][0]['#']);
|
||||
if ( !$category = get_record("glossary_categories","glossaryid",$glossary->id,"name",$newcat->name) ) {
|
||||
$newcat = new object();
|
||||
$newcat->name = $xmlcat['#']['NAME'][0]['#'];
|
||||
$newcat->usedynalink = $xmlcat['#']['USEDYNALINK'][0]['#'];
|
||||
if ( !$category = $DB->get_record("glossary_categories", array("glossaryid"=>$glossary->id,"name"=>$newcat->name))) {
|
||||
// Create the category if it does not exist
|
||||
unset($category);
|
||||
$category = new object();
|
||||
$category->name = $newcat->name;
|
||||
$category->glossaryid = $glossary->id;
|
||||
if ( !$category->id = insert_record("glossary_categories",$category)) {
|
||||
if ( !$category->id = $DB->insert_record("glossary_categories",$category)) {
|
||||
// add to exception report (can't insert category)
|
||||
$rejections .= "<tr><td> <strong>" . get_string("category","glossary") . ":</strong>$newcat->name</td>" .
|
||||
"<td>" . get_string("cantinsertcat","glossary"). "</td></tr>";
|
||||
|
@ -282,10 +281,10 @@
|
|||
}
|
||||
if ( $category ) {
|
||||
// inserting the new relation
|
||||
unset($entrycat);
|
||||
$entrycat = new opbject();
|
||||
$entrycat->entryid = $newentry->id;
|
||||
$entrycat->categoryid = $category->id;
|
||||
if ( !insert_record("glossary_entries_categories",$entrycat) ) {
|
||||
if ( !$DB->insert_record("glossary_entries_categories",$entrycat) ) {
|
||||
// add to exception report (can't insert relation)
|
||||
$rejections .= "<tr><td> <strong>" . get_string("category","glossary") . ":</strong>$newcat->name</td>" .
|
||||
"<td>" . get_string("cantinsertrel","glossary"). "</td></tr>";
|
||||
|
|
|
@ -92,7 +92,7 @@
|
|||
|
||||
// TODO: count only approved if not allowed to see them
|
||||
|
||||
$count = count_records_sql("SELECT COUNT(*) FROM {$CFG->prefix}glossary_entries where (glossaryid = $glossary->id or sourceglossaryid = $glossary->id)");
|
||||
$count = $DB->count_records_sql("SELECT COUNT(*) FROM {glossary_entries} WHERE (glossaryid = ? OR sourceglossaryid = ?)", array($glossary->id, $glossary->id));
|
||||
|
||||
//If this glossary has RSS activated, calculate it
|
||||
if ($show_rss) {
|
||||
|
|
|
@ -180,17 +180,15 @@ function glossary_user_outline($course, $user, $mod, $glossary) {
|
|||
|
||||
function glossary_get_user_entries($glossaryid, $userid) {
|
||||
/// Get all the entries for a user in a glossary
|
||||
global $CFG;
|
||||
global $DB;
|
||||
|
||||
return get_records_sql("SELECT e.*, u.firstname, u.lastname, u.email, u.picture
|
||||
FROM {$CFG->prefix}glossary g,
|
||||
{$CFG->prefix}glossary_entries e,
|
||||
{$CFG->prefix}user u
|
||||
WHERE g.id = '$glossaryid'
|
||||
return $DB->get_records_sql("SELECT e.*, u.firstname, u.lastname, u.email, u.picture
|
||||
FROM {glossary} g, {glossary_entries} e, {user} u
|
||||
WHERE g.id = ?
|
||||
AND e.glossaryid = g.id
|
||||
AND e.userid = '$userid'
|
||||
AND e.userid = ?
|
||||
AND e.userid = u.id
|
||||
ORDER BY e.timemodified ASC");
|
||||
ORDER BY e.timemodified ASC", array($glossaryid, $userid));
|
||||
}
|
||||
|
||||
function glossary_user_complete($course, $user, $mod, $glossary) {
|
||||
|
@ -214,7 +212,7 @@ function glossary_print_recent_activity($course, $viewfullnames, $timestart) {
|
|||
/// that has occurred in glossary activities and print it out.
|
||||
/// Return true if there was output, or false is there was none.
|
||||
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
//TODO: use timestamp in approved field instead of changing timemodified when approving in 2.0
|
||||
|
||||
|
@ -236,12 +234,12 @@ function glossary_print_recent_activity($course, $viewfullnames, $timestart) {
|
|||
|
||||
$glist = implode(',', $ids); // there should not be hundreds of glossaries in one course, right?
|
||||
|
||||
if (!$entries = get_records_sql("SELECT ge.id, ge.concept, ge.approved, ge.timemodified, ge.glossaryid,
|
||||
ge.userid, u.firstname, u.lastname, u.email, u.picture
|
||||
FROM {$CFG->prefix}glossary_entries ge
|
||||
JOIN {$CFG->prefix}user u ON u.id = ge.userid
|
||||
WHERE ge.glossaryid IN ($glist) AND ge.timemodified > $timestart
|
||||
ORDER BY ge.timemodified ASC")) {
|
||||
if (!$entries = $DB->get_records_sql("SELECT ge.id, ge.concept, ge.approved, ge.timemodified, ge.glossaryid,
|
||||
ge.userid, u.firstname, u.lastname, u.email, u.picture
|
||||
FROM {glossary_entries} ge
|
||||
JOIN {user} u ON u.id = ge.userid
|
||||
WHERE ge.glossaryid IN ($glist) AND ge.timemodified > ?
|
||||
ORDER BY ge.timemodified ASC", array($timestart))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -286,22 +284,17 @@ function glossary_print_recent_activity($course, $viewfullnames, $timestart) {
|
|||
|
||||
|
||||
function glossary_log_info($log) {
|
||||
global $CFG;
|
||||
global $DB;
|
||||
|
||||
return get_record_sql("SELECT e.*, u.firstname, u.lastname
|
||||
FROM {$CFG->prefix}glossary_entries e,
|
||||
{$CFG->prefix}user u
|
||||
WHERE e.id = '$log->info'
|
||||
AND u.id = '$log->userid'");
|
||||
return $DB->get_record_sql("SELECT e.*, u.firstname, u.lastname
|
||||
FROM {glossary_entries} e, {user} u
|
||||
WHERE e.id = ? AND u.id = ?", array($log->info, $log->userid));
|
||||
}
|
||||
|
||||
function glossary_cron () {
|
||||
/// Function to be run periodically according to the moodle cron
|
||||
/// This function searches for things that need to be done, such
|
||||
/// as sending out mail, toggling flags etc ...
|
||||
|
||||
global $CFG;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -313,19 +306,20 @@ function glossary_cron () {
|
|||
* @return array array of grades, false if none
|
||||
*/
|
||||
function glossary_get_user_grades($glossary, $userid=0) {
|
||||
global $CFG;
|
||||
global $DB;
|
||||
|
||||
$user = $userid ? "AND u.id = $userid" : "";
|
||||
$params = array('userid'=>$userid, 'gid'=>$glossary->id);
|
||||
|
||||
$user = $userid ? "AND u.id = :userid" : "";
|
||||
|
||||
$sql = "SELECT u.id, u.id AS userid, avg(gr.rating) AS rawgrade
|
||||
FROM {$CFG->prefix}user u, {$CFG->prefix}glossary_entries ge,
|
||||
{$CFG->prefix}glossary_ratings gr
|
||||
FROM {user} u, {glossary_entries} ge, {glossary_ratings} gr
|
||||
WHERE u.id = ge.userid AND ge.id = gr.entryid
|
||||
AND gr.userid != u.id AND ge.glossaryid = $glossary->id
|
||||
AND gr.userid != u.id AND ge.glossaryid = :gid
|
||||
$user
|
||||
GROUP BY u.id";
|
||||
|
||||
return get_records_sql($sql);
|
||||
return $DB->get_records_sql($sql, $params);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -335,7 +329,7 @@ function glossary_get_user_grades($glossary, $userid=0) {
|
|||
* @param int $userid specific user only, 0 mean all
|
||||
*/
|
||||
function glossary_update_grades($glossary=null, $userid=0, $nullifnone=true) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
if ($glossary != null) {
|
||||
|
@ -354,17 +348,17 @@ function glossary_update_grades($glossary=null, $userid=0, $nullifnone=true) {
|
|||
|
||||
} else {
|
||||
$sql = "SELECT g.*, cm.idnumber as cmidnumber
|
||||
FROM {$CFG->prefix}glossary g, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m
|
||||
FROM {glossary} g, {course_modules} cm, {modules} m
|
||||
WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id";
|
||||
if ($rs = get_recordset_sql($sql)) {
|
||||
while ($glossary = rs_fetch_next_record($rs)) {
|
||||
if ($rs = $DB->get_recordset_sql($sql)) {
|
||||
foreach ($rs as $glossary) {
|
||||
if ($glossary->assessed) {
|
||||
glossary_update_grades($glossary, 0, false);
|
||||
} else {
|
||||
glossary_grade_item_update($glossary);
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
$rs->close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -378,9 +372,8 @@ function glossary_update_grades($glossary=null, $userid=0, $nullifnone=true) {
|
|||
*/
|
||||
function glossary_grade_item_update($glossary, $grades=NULL) {
|
||||
global $CFG;
|
||||
if (!function_exists('grade_update')) { //workaround for buggy PHP versions
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
}
|
||||
require_once($CFG->libdir.'/gradelib.php');
|
||||
|
||||
if(!empty($glossary->cmidnumber)){
|
||||
$params = array('itemname'=>$glossary->name, 'idnumber'=>$glossary->cmidnumber);
|
||||
}else{
|
||||
|
@ -425,26 +418,24 @@ function glossary_grade_item_delete($glossary) {
|
|||
function glossary_get_participants($glossaryid) {
|
||||
//Returns the users with data in one glossary
|
||||
//(users with records in glossary_entries, students)
|
||||
|
||||
global $CFG;
|
||||
global $DB;
|
||||
|
||||
//Get students
|
||||
$students = get_records_sql("SELECT DISTINCT u.id, u.id
|
||||
FROM {$CFG->prefix}user u,
|
||||
{$CFG->prefix}glossary_entries g
|
||||
WHERE g.glossaryid = '$glossaryid' and
|
||||
u.id = g.userid");
|
||||
$students = $DB->get_records_sql("SELECT DISTINCT u.id, u.id
|
||||
FROM {user} u, {glossary_entries} g
|
||||
WHERE g.glossaryid = : AND u.id = g.userid", array($glossaryid));
|
||||
|
||||
//Return students array (it contains an array of unique users)
|
||||
return ($students);
|
||||
return $students;
|
||||
}
|
||||
|
||||
function glossary_scale_used ($glossaryid,$scaleid) {
|
||||
//This function returns if a scale is being used by one glossary
|
||||
global $DB;
|
||||
|
||||
$return = false;
|
||||
|
||||
$rec = get_record("glossary","id","$glossaryid","scale","-$scaleid");
|
||||
$rec = $DB->get_record("glossary", array("id"=>$glossaryid, "scale"=>-$scaleid));
|
||||
|
||||
if (!empty($rec) && !empty($scaleid)) {
|
||||
$return = true;
|
||||
|
@ -461,7 +452,9 @@ function glossary_scale_used ($glossaryid,$scaleid) {
|
|||
* @return boolean True if the scale is used by any glossary
|
||||
*/
|
||||
function glossary_scale_used_anywhere($scaleid) {
|
||||
if ($scaleid and record_exists('glossary', 'scale', -$scaleid)) {
|
||||
global $DB;
|
||||
|
||||
if ($scaleid and $DB->record_exists('glossary', array('scale'=>-$scaleid))) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
@ -477,8 +470,7 @@ function glossary_scale_used_anywhere($scaleid) {
|
|||
//are included if detected and old formats are deleted and any glossary
|
||||
//using an invalid format is updated to the default (dictionary).
|
||||
function glossary_get_available_formats() {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
//Get available formats (plugin) and insert (if necessary) them into glossary_formats
|
||||
$formats = get_list_of_plugins('mod/glossary/formats', 'TEMPLATE');
|
||||
|
@ -492,20 +484,20 @@ function glossary_get_available_formats() {
|
|||
//Acummulate it as a valid format
|
||||
$pluginformats[] = $format;
|
||||
//If the format doesn't exist in the table
|
||||
if (!$rec = get_record('glossary_formats','name',$format)) {
|
||||
if (!$rec = $DB->get_record('glossary_formats', array('name'=>$format))) {
|
||||
//Insert the record in glossary_formats
|
||||
$gf = new object();
|
||||
$gf->name = $format;
|
||||
$gf->popupformatname = $format;
|
||||
$gf->visible = 1;
|
||||
insert_record("glossary_formats",$gf);
|
||||
$DB->insert_record("glossary_formats",$gf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Delete non_existent formats from glossary_formats table
|
||||
$formats = get_records("glossary_formats");
|
||||
$formats = $DB->get_records("glossary_formats");
|
||||
foreach ($formats as $format) {
|
||||
$todelete = false;
|
||||
//If the format in DB isn't a valid previously detected format then delete the record
|
||||
|
@ -515,18 +507,18 @@ function glossary_get_available_formats() {
|
|||
|
||||
if ($todelete) {
|
||||
//Delete the format
|
||||
delete_records('glossary_formats','name',$format->name);
|
||||
$DB->delete_records('glossary_formats', array('name'=>$format->name));
|
||||
//Reasign existing glossaries to default (dictionary) format
|
||||
if ($glossaries = get_records('glossary','displayformat',$format->name)) {
|
||||
if ($glossaries = $DB->get_records('glossary', array('displayformat'=>$format->name))) {
|
||||
foreach($glossaries as $glossary) {
|
||||
set_field('glossary','displayformat','dictionary','id',$glossary->id);
|
||||
$DB->set_field('glossary','displayformat','dictionary', array('id'=>$glossary->id));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Now everything is ready in glossary_formats table
|
||||
$formats = get_records("glossary_formats");
|
||||
$formats = $DB->get_records("glossary_formats");
|
||||
|
||||
return $formats;
|
||||
}
|
||||
|
@ -541,20 +533,19 @@ function glossary_debug($debug,$text,$br=1) {
|
|||
}
|
||||
|
||||
function glossary_get_entries($glossaryid, $entrylist, $pivot = "") {
|
||||
global $CFG;
|
||||
global $DB;
|
||||
if ($pivot) {
|
||||
$pivot .= ",";
|
||||
}
|
||||
|
||||
return get_records_sql("SELECT $pivot id,userid,concept,definition,format
|
||||
FROM {$CFG->prefix}glossary_entries
|
||||
WHERE glossaryid = '$glossaryid'
|
||||
AND id IN ($entrylist)");
|
||||
return $DB->get_records_sql("SELECT $pivot id,userid,concept,definition,format
|
||||
FROM {glossary_entries}
|
||||
WHERE glossaryid = ?
|
||||
AND id IN ($entrylist)", array($glossaryid));
|
||||
}
|
||||
|
||||
function glossary_get_entries_search($concept, $courseid) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
//Check if the user is an admin
|
||||
$bypassadmin = 1; //This means NO (by default)
|
||||
|
@ -570,55 +561,22 @@ function glossary_get_entries_search($concept, $courseid) {
|
|||
|
||||
$conceptlower = moodle_strtolower(trim($concept));
|
||||
|
||||
return get_records_sql("SELECT e.*, g.name as glossaryname, cm.id as cmid, cm.course as courseid
|
||||
FROM {$CFG->prefix}glossary_entries e,
|
||||
{$CFG->prefix}glossary g,
|
||||
{$CFG->prefix}course_modules cm,
|
||||
{$CFG->prefix}modules m
|
||||
WHERE m.name = 'glossary' AND
|
||||
cm.module = m.id AND
|
||||
(cm.visible = 1 OR cm.visible = $bypassadmin OR
|
||||
(cm.course = '$courseid' AND cm.visible = $bypassteacher)) AND
|
||||
g.id = cm.instance AND
|
||||
e.glossaryid = g.id AND
|
||||
( (e.casesensitive != 0 AND LOWER(concept) = '$conceptlower') OR
|
||||
(e.casesensitive = 0 and concept = '$concept')) AND
|
||||
(g.course = '$courseid' OR g.globalglossary = 1) AND
|
||||
e.usedynalink != 0 AND
|
||||
g.usedynalink != 0");
|
||||
}
|
||||
$params = array('courseid1'=>$courseid, 'courseid2'=>$courseid, 'conceptlower'=>$conceptlower, 'concept'=>$concept);
|
||||
|
||||
function glossary_get_entries_sorted($glossary, $where="", $orderby="", $pivot = "") {
|
||||
global $CFG;
|
||||
if ($where) {
|
||||
$where = " and $where";
|
||||
}
|
||||
if ($orderby) {
|
||||
$orderby = " ORDER BY $orderby";
|
||||
}
|
||||
if ($pivot) {
|
||||
$pivot .= ",";
|
||||
}
|
||||
return get_records_sql("SELECT $pivot *
|
||||
FROM {$CFG->prefix}glossary_entries
|
||||
WHERE (glossaryid = $glossary->id or sourceglossaryid = $glossary->id) $where $orderby");
|
||||
}
|
||||
|
||||
function glossary_get_entries_by_category($glossary, $hook, $where="", $orderby="", $pivot = "") {
|
||||
global $CFG;
|
||||
if ($where) {
|
||||
$where = " and $where";
|
||||
}
|
||||
if ($orderby) {
|
||||
$orderby = " ORDER BY $orderby";
|
||||
}
|
||||
if ($pivot) {
|
||||
$pivot .= ",";
|
||||
}
|
||||
return get_records_sql("SELECT $pivot ge.*
|
||||
FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories c
|
||||
WHERE (ge.id = c.entryidid and c.categoryid = $hook) and
|
||||
(ge.glossaryid = $glossary->id or ge.sourceglossaryid = $glossary->id) $where $orderby");
|
||||
return $DB->get_records_sql("SELECT e.*, g.name as glossaryname, cm.id as cmid, cm.course as courseid
|
||||
FROM {glossary_entries} e, {glossary} g,
|
||||
{course_modules} cm, {modules} m
|
||||
WHERE m.name = 'glossary' AND
|
||||
cm.module = m.id AND
|
||||
(cm.visible = 1 OR cm.visible = $bypassadmin OR
|
||||
(cm.course = :courseid1 AND cm.visible = $bypassteacher)) AND
|
||||
g.id = cm.instance AND
|
||||
e.glossaryid = g.id AND
|
||||
( (e.casesensitive != 0 AND LOWER(concept) = :conceptlower) OR
|
||||
(e.casesensitive = 0 and concept = :concept)) AND
|
||||
(g.course = courseid2 OR g.globalglossary = 1) AND
|
||||
e.usedynalink != 0 AND
|
||||
g.usedynalink != 0", $params);
|
||||
}
|
||||
|
||||
function glossary_print_entry($course, $cm, $glossary, $entry, $mode='',$hook='',$printicons = 1, $displayformat = -1, $ratings = NULL, $printview = false) {
|
||||
|
@ -693,6 +651,7 @@ function glossary_print_entry_concept($entry) {
|
|||
}
|
||||
|
||||
function glossary_print_entry_definition($entry) {
|
||||
global $DB;
|
||||
|
||||
$definition = $entry->definition;
|
||||
|
||||
|
@ -715,7 +674,7 @@ function glossary_print_entry_definition($entry) {
|
|||
$pat = '/('.$term.')/is';
|
||||
$doNolinks[] = $pat;
|
||||
//Now the aliases
|
||||
if ( $aliases = get_records('glossary_alias','entryid',$entry->id) ) {
|
||||
if ( $aliases = $DB->get_records('glossary_alias', array('entryid'=>$entry->id))) {
|
||||
foreach ($aliases as $alias) {
|
||||
$term = preg_quote(trim($alias->alias),'/');
|
||||
$pat = '/('.$term.')/is';
|
||||
|
@ -821,8 +780,10 @@ function glossary_print_entry_definition($entry) {
|
|||
}
|
||||
|
||||
function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$mode='',$hook='', $type = 'print') {
|
||||
global $DB;
|
||||
|
||||
$return = '';
|
||||
if ( $aliases = get_records('glossary_alias','entryid',$entry->id) ) {
|
||||
if ( $aliases = $DB->get_records('glossary_alias', array('entryid'=>$entry->id))) {
|
||||
foreach ($aliases as $alias) {
|
||||
if (trim($alias->alias)) {
|
||||
if ($return == '') {
|
||||
|
@ -843,7 +804,7 @@ function glossary_print_entry_aliases($course, $cm, $glossary, $entry,$mode='',
|
|||
}
|
||||
|
||||
function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$hook='', $type = 'print') {
|
||||
global $USER, $CFG;
|
||||
global $USER, $CFG, $DB;
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
|
@ -871,7 +832,7 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h
|
|||
if (has_capability('mod/glossary:manageentries', $context) or (!empty($USER->id) and has_capability('mod/glossary:write', $context) and $entry->userid == $USER->id)) {
|
||||
// only teachers can export entries so check it out
|
||||
if (has_capability('mod/glossary:export', $context) and !$ismainglossary and !$importedentry) {
|
||||
$mainglossary = get_record('glossary','mainglossary',1,'course',$course->id);
|
||||
$mainglossary = $DB->get_record('glossary', array('mainglossary'=>1,'course'=>$course->id));
|
||||
if ( $mainglossary ) { // if there is a main glossary defined, allow to export the current entry
|
||||
$output = true;
|
||||
$return .= ' <a title="'.get_string('exporttomainglossary','glossary') . '" href="exportentry.php?id='.$cm->id.'&entry='.$entry->id.'&mode='.$mode.'&hook='.$hook.'"><img src="export.gif" class="iconsmall" alt="'.get_string('exporttomainglossary','glossary').$altsuffix.'" /></a>';
|
||||
|
@ -916,9 +877,11 @@ function glossary_print_entry_icons($course, $cm, $glossary, $entry, $mode='',$h
|
|||
}
|
||||
|
||||
function glossary_print_entry_commentslink($course, $cm, $glossary, $entry,$mode,$hook, $type = 'print') {
|
||||
global $DB;
|
||||
|
||||
$return = '';
|
||||
|
||||
$count = count_records('glossary_comments','entryid',$entry->id);
|
||||
$count = $DB->count_records('glossary_comments', array('entryid'=>$entry->id));
|
||||
if ($count) {
|
||||
$return = '';
|
||||
$return .= "<a href=\"comments.php?id=$cm->id&eid=$entry->id\">$count ";
|
||||
|
@ -970,8 +933,10 @@ function glossary_print_entry_attachment($entry,$format=NULL,$align="right",$ins
|
|||
/// valid format values: html : Return the HTML link for the attachment as an icon
|
||||
/// text : Return the HTML link for tha attachment as text
|
||||
/// blank : Print the output to the screen
|
||||
global $DB;
|
||||
|
||||
if ($entry->attachment) {
|
||||
$glossary = get_record("glossary","id",$entry->glossaryid);
|
||||
$glossary = $DB->get_record("glossary", array("id"=>$entry->glossaryid));
|
||||
$entry->course = $glossary->course; //used inside print_attachment
|
||||
if ($insidetable) {
|
||||
echo "<table border=\"0\" width=\"100%\" align=\"$align\"><tr><td align=\"$align\" nowrap=\"nowrap\">\n";
|
||||
|
@ -1001,10 +966,10 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
|
|||
// It returns all entries from all glossaries that matches the specified criteria
|
||||
// within a given $course. It performs an $extended search if necessary.
|
||||
// It restrict the search to only one $glossary if the $glossary parameter is set.
|
||||
global $CFG, $DB;
|
||||
|
||||
global $CFG;
|
||||
if ( !$glossary ) {
|
||||
if ( $glossaries = get_records("glossary", "course", $course->id) ) {
|
||||
if ( $glossaries = $DB->get_records("glossary", array("course"=>$course->id)) ) {
|
||||
$glos = "";
|
||||
foreach ( $glossaries as $glossary ) {
|
||||
$glos .= "$glossary->id,";
|
||||
|
@ -1016,90 +981,95 @@ function glossary_search($course, $searchterms, $extended = 0, $glossary = NULL)
|
|||
}
|
||||
|
||||
if (!has_capability('mod/glossary:manageentries', get_context_instance(CONTEXT_COURSE, $glossary->course))) {
|
||||
$glossarymodule = get_record("modules", "name", "glossary");
|
||||
$glossarymodule = $DB->get_record("modules", array("name"=>"glossary"));
|
||||
$onlyvisible = " AND g.id = cm.instance AND cm.visible = 1 AND cm.module = $glossarymodule->id";
|
||||
$onlyvisibletable = ", {$CFG->prefix}course_modules cm";
|
||||
$onlyvisibletable = ", {course_modules} cm";
|
||||
} else {
|
||||
|
||||
$onlyvisible = "";
|
||||
$onlyvisibletable = "";
|
||||
}
|
||||
|
||||
/// Some differences in syntax for entrygreSQL
|
||||
switch ($CFG->dbfamily) {
|
||||
case 'postgres':
|
||||
$LIKE = "ILIKE"; // case-insensitive
|
||||
$NOTLIKE = "NOT ILIKE"; // case-insensitive
|
||||
$REGEXP = "~*";
|
||||
$NOTREGEXP = "!~*";
|
||||
break;
|
||||
case 'mysql':
|
||||
default:
|
||||
$LIKE = "LIKE";
|
||||
$NOTLIKE = "NOT LIKE";
|
||||
$REGEXP = "REGEXP";
|
||||
$NOTREGEXP = "NOT REGEXP";
|
||||
break;
|
||||
if ($DB->sql_regex_supported()) {
|
||||
$REGEXP = $DB->sql_regex(true);
|
||||
$NOTREGEXP = $DB->sql_regex(false);
|
||||
}
|
||||
$LIKE = $DB->sql_ilike(); // case-insensitive
|
||||
|
||||
$conceptsearch = "";
|
||||
$definitionsearch = "";
|
||||
$searchcond = array();
|
||||
$params = array();
|
||||
$i = 0;
|
||||
|
||||
$concat = $DB->sql_concat('e.concept', "' '", 'e.definition');
|
||||
|
||||
|
||||
foreach ($searchterms as $searchterm) {
|
||||
if ($conceptsearch) {
|
||||
$conceptsearch.= " OR ";
|
||||
}
|
||||
if ($definitionsearch) {
|
||||
$definitionsearch.= " OR ";
|
||||
}
|
||||
$i++;
|
||||
|
||||
$NOT = ''; /// Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle
|
||||
/// will use it to simulate the "-" operator with LIKE clause
|
||||
|
||||
/// Under Oracle and MSSQL, trim the + and - operators and perform
|
||||
/// simpler LIKE search
|
||||
if ($CFG->dbfamily == 'oracle' || $CFG->dbfamily == 'mssql') {
|
||||
/// simpler LIKE (or NOT LIKE) queries
|
||||
if (!$DB->sql_regex_supported()) {
|
||||
if (substr($searchterm, 0, 1) == '-') {
|
||||
$NOT = ' NOT ';
|
||||
}
|
||||
$searchterm = trim($searchterm, '+-');
|
||||
}
|
||||
|
||||
if (substr($searchterm,0,1) == "+") {
|
||||
$searchterm = substr($searchterm,1);
|
||||
$conceptsearch.= " e.concept $REGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
$definitionsearch .= " e.definition $REGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
// TODO: +- may not work for non latin languages
|
||||
|
||||
if (substr($searchterm,0,1) == '+') {
|
||||
$searchterm = trim($searchterm, '+-');
|
||||
$searchterm = preg_quote($searchterm, '|');
|
||||
$searchcond[] = "$concat $REGEXP :ss$i";
|
||||
$params['ss'.$i] = "(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)";
|
||||
|
||||
} else if (substr($searchterm,0,1) == "-") {
|
||||
$searchterm = substr($searchterm,1);
|
||||
$conceptsearch .= " e.concept $NOTREGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
$definitionsearch .= " e.definition $NOTREGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
$searchterm = trim($searchterm, '+-');
|
||||
$searchterm = preg_quote($searchterm, '|');
|
||||
$searchcond[] = "$concat $NOTREGEXP :ss$i";
|
||||
$params['ss'.$i] = "(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)";
|
||||
|
||||
} else {
|
||||
$conceptsearch .= " e.concept $LIKE '%$searchterm%' ";
|
||||
$definitionsearch .= " e.definition $LIKE '%$searchterm%' ";
|
||||
$searchcond[] = "$concat $NOT $LIKE :ss$i";
|
||||
$params['ss'.$i] = "%$searchterm%";
|
||||
}
|
||||
}
|
||||
|
||||
$definitionsearch = !empty($extended) ? "OR $definitionsearch" : '';
|
||||
if (empty($searchcond)) {
|
||||
$totalcount = 0;
|
||||
return array();
|
||||
}
|
||||
|
||||
$selectsql = "{$CFG->prefix}glossary_entries e,
|
||||
{$CFG->prefix}glossary g $onlyvisibletable
|
||||
WHERE ($conceptsearch $definitionsearch)
|
||||
$searchcond = implode(" AND ", $searchcond);
|
||||
|
||||
$sql = "SELECT e.*
|
||||
FROM {glossary_entries} e, {glossary} g $onlyvisibletable
|
||||
WHERE $searchcond
|
||||
AND (e.glossaryid = g.id or e.sourceglossaryid = g.id) $onlyvisible
|
||||
AND g.id IN ($glos) AND e.approved != 0";
|
||||
AND g.id IN ($glos) AND e.approved <> 0";
|
||||
|
||||
return get_records_sql("SELECT e.*
|
||||
FROM $selectsql ORDER BY e.concept ASC");
|
||||
return $DB->get_records_sql($sql, $params);
|
||||
}
|
||||
|
||||
function glossary_search_entries($searchterms, $glossary, $extended) {
|
||||
$course = get_record("course","id",$glossary->course);
|
||||
global $DB;
|
||||
|
||||
$course = $DB->get_record("course", array("id"=>$glossary->course));
|
||||
return glossary_search($course,$searchterms,$extended,$glossary);
|
||||
}
|
||||
|
||||
function glossary_file_area_name($entry) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
// Creates a directory file name, suitable for make_upload_directory()
|
||||
|
||||
// I'm doing this workaround for make it works for delete_instance also
|
||||
// (when called from delete_instance, glossary is already deleted so
|
||||
// getting the course from mdl_glossary does not work)
|
||||
$module = get_record("modules","name","glossary");
|
||||
$cm = get_record("course_modules","module",$module->id,"instance",$entry->glossaryid);
|
||||
$module = $DB->get_record("modules", array("name"=>"glossary"));
|
||||
$cm = $DB->get_record("course_modules", array("module"=>$module->id, "instance"=>$entry->glossaryid));
|
||||
return "$cm->course/$CFG->moddata/glossary/$entry->glossaryid/$entry->id";
|
||||
}
|
||||
|
||||
|
@ -1137,8 +1107,9 @@ function glossary_delete_old_attachments($entry, $exception="") {
|
|||
}
|
||||
}
|
||||
function glossary_delete_attachments($glossary) {
|
||||
global $DB;
|
||||
// Deletes all the user files in the attachments area for the glossary
|
||||
if ( $entries = get_records("glossary_entries","glossaryid",$glossary->id) ) {
|
||||
if ( $entries = $DB->get_records("glossary_entries", array("glossaryid"=>$glossary->id))) {
|
||||
$deleted = 0;
|
||||
foreach ($entries as $entry) {
|
||||
if ( $entry->attachment ) {
|
||||
|
@ -1170,12 +1141,11 @@ function glossary_copy_attachments($entry, $newentry) {
|
|||
/// this function checks that entry
|
||||
/// for attachments, and if any are found, these are
|
||||
/// copied to the new glossary directory.
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$return = true;
|
||||
|
||||
if ($entries = get_records_select("glossary_entries", "id = '$entry->id' AND attachment <> ''")) {
|
||||
if ($entries = $DB->get_records_select("glossary_entries", "id = ? AND attachment <> ''", array($entry->id))) {
|
||||
foreach ($entries as $curentry) {
|
||||
$oldentry = new object();
|
||||
$oldentry->id = $entry->id;
|
||||
|
@ -1200,13 +1170,13 @@ function glossary_move_attachments($entry, $glossaryid) {
|
|||
/// for attachments, and if any are found, these are
|
||||
/// moved to the new glossary directory.
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
require_once($CFG->dirroot.'/lib/uploadlib.php');
|
||||
|
||||
$return = true;
|
||||
|
||||
if ($entries = get_records_select("glossary_entries", "glossaryid = '$entry->id' AND attachment <> ''")) {
|
||||
if ($entries = $DB->get_records_select("glossary_entries", "glossaryid = ? AND attachment <> ''", array($entry->id))) {
|
||||
foreach ($entries as $entry) {
|
||||
$oldentry = new object();
|
||||
$oldentry->course = $entry->course;
|
||||
|
@ -1337,8 +1307,7 @@ function glossary_print_author_menu($cm, $glossary,$mode, $hook, $sortkey = '',
|
|||
}
|
||||
|
||||
function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
|
@ -1360,7 +1329,7 @@ function glossary_print_categories_menu($cm, $glossary, $hook, $category) {
|
|||
$menu[GLOSSARY_SHOW_ALL_CATEGORIES] = get_string("allcategories","glossary");
|
||||
$menu[GLOSSARY_SHOW_NOT_CATEGORISED] = get_string("notcategorised","glossary");
|
||||
|
||||
$categories = get_records("glossary_categories", "glossaryid", $glossary->id, "name ASC");
|
||||
$categories = $DB->get_records("glossary_categories", array("glossaryid"=>$glossary->id), "name ASC");
|
||||
$selected = '';
|
||||
if ( $categories ) {
|
||||
foreach ($categories as $currentcategory) {
|
||||
|
@ -1557,11 +1526,11 @@ function glossary_sort_entries ( $entry0, $entry1 ) {
|
|||
}
|
||||
|
||||
function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
|
||||
global $CFG, $USER;
|
||||
global $CFG, $USER, $DB;
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
$user = get_record('user', 'id', $comment->userid);
|
||||
$user = $DB->get_record('user', array('id'=>$comment->userid));
|
||||
$strby = get_string('writtenby','glossary');
|
||||
$fullname = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
|
||||
|
@ -1607,13 +1576,13 @@ function glossary_print_comment($course, $cm, $glossary, $entry, $comment) {
|
|||
}
|
||||
|
||||
function glossary_print_entry_ratings($course, $entry, $ratings = NULL) {
|
||||
global $USER, $CFG, $DB;
|
||||
|
||||
global $USER, $CFG;
|
||||
|
||||
$glossary = get_record('glossary', 'id', $entry->glossaryid);
|
||||
$glossarymod = get_record('modules','name','glossary');
|
||||
$cm = get_record_sql("select * from {$CFG->prefix}course_modules where course = $course->id
|
||||
and module = $glossarymod->id and instance = $glossary->id");
|
||||
$glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid));
|
||||
$glossarymod = $DB->get_record('modules', array('name'=>'glossary'));
|
||||
$cm = $DB->get_record_sql("SELECT *
|
||||
FROM {course_modules}
|
||||
WHERE course = ? AND module = ? and instance = ?", array($course->id, $glossarymod->id, $glossary->id));
|
||||
|
||||
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
|
||||
|
||||
|
@ -1644,17 +1613,17 @@ function glossary_print_entry_ratings($course, $entry, $ratings = NULL) {
|
|||
}
|
||||
|
||||
function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) {
|
||||
global $USER,$CFG;
|
||||
global $USER,$CFG, $DB;
|
||||
|
||||
echo '<div class="boxaligncenter">';
|
||||
echo '<table class="glossarypopup" cellspacing="0"><tr>';
|
||||
echo '<td>';
|
||||
if ( $entries ) {
|
||||
foreach ( $entries as $entry ) {
|
||||
if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) {
|
||||
if (! $glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
if (! $course = get_record('course', 'id', $glossary->course)) {
|
||||
if (! $course = $DB->get_record('course', array('id'=>$glossary->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (!$cm = get_coursemodule_from_instance('glossary', $entry->glossaryid, $glossary->course) ) {
|
||||
|
@ -1669,7 +1638,7 @@ function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) {
|
|||
}
|
||||
|
||||
//Get popupformatname
|
||||
$format = get_record('glossary_formats','name',$dp);
|
||||
$format = $DB->get_record('glossary_formats', array('name'=>$dp));
|
||||
$displayformat = $format->popupformatname;
|
||||
|
||||
//Check displayformat variable and set to default if necessary
|
||||
|
@ -1693,7 +1662,7 @@ function glossary_print_dynaentry($courseid, $entries, $displayformat = -1) {
|
|||
}
|
||||
|
||||
function glossary_generate_export_file($glossary, $hook = "", $hook = 0) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$co = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
|
||||
|
||||
|
@ -1712,7 +1681,7 @@ function glossary_generate_export_file($glossary, $hook = "", $hook = 0) {
|
|||
$co .= glossary_full_tag("GLOBALGLOSSARY",2,false,$glossary->globalglossary);
|
||||
$co .= glossary_full_tag("ENTBYPAGE",2,false,$glossary->entbypage);
|
||||
|
||||
if ( $entries = get_records("glossary_entries","glossaryid",$glossary->id) ) {
|
||||
if ( $entries = $DB->get_records("glossary_entries", array("glossaryid"=>$glossary->id))) {
|
||||
$co .= glossary_start_tag("ENTRIES",2,true);
|
||||
foreach ($entries as $entry) {
|
||||
$permissiongranted = 1;
|
||||
|
@ -1731,10 +1700,10 @@ function glossary_generate_export_file($glossary, $hook = "", $hook = 0) {
|
|||
case GLOSSARY_SHOW_ALL_CATEGORIES:
|
||||
break;
|
||||
case GLOSSARY_SHOW_NOT_CATEGORISED:
|
||||
$permissiongranted = !record_exists("glossary_entries_categories","entryid",$entry->id);
|
||||
$permissiongranted = !$DB->record_exists("glossary_entries_categories", array("entryid"=>$entry->id));
|
||||
break;
|
||||
default:
|
||||
$permissiongranted = record_exists("glossary_entries_categories","entryid",$entry->id, "categoryid",$hook);
|
||||
$permissiongranted = $DB->record_exists("glossary_entries_categories", array("entryid"=>$entry->id, "categoryid"=>$hook));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1748,7 +1717,7 @@ function glossary_generate_export_file($glossary, $hook = "", $hook = 0) {
|
|||
$co .= glossary_full_tag("FULLMATCH",4,false,$entry->fullmatch);
|
||||
$co .= glossary_full_tag("TEACHERENTRY",4,false,$entry->teacherentry);
|
||||
|
||||
if ( $aliases = get_records("glossary_alias","entryid",$entry->id) ) {
|
||||
if ( $aliases = $DB->get_records("glossary_alias", array("entryid"=>$entry->id))) {
|
||||
$co .= glossary_start_tag("ALIASES",4,true);
|
||||
foreach ($aliases as $alias) {
|
||||
$co .= glossary_start_tag("ALIAS",5,true);
|
||||
|
@ -1757,10 +1726,10 @@ function glossary_generate_export_file($glossary, $hook = "", $hook = 0) {
|
|||
}
|
||||
$co .= glossary_end_tag("ALIASES",4,true);
|
||||
}
|
||||
if ( $catentries = get_records("glossary_entries_categories","entryid",$entry->id) ) {
|
||||
if ( $catentries = $DB->get_records("glossary_entries_categories", array("entryid"=>$entry->id))) {
|
||||
$co .= glossary_start_tag("CATEGORIES",4,true);
|
||||
foreach ($catentries as $catentry) {
|
||||
$category = get_record("glossary_categories","id",$catentry->categoryid);
|
||||
$category = $DB->get_record("glossary_categories", array("id"=>$catentry->categoryid));
|
||||
|
||||
$co .= glossary_start_tag("CATEGORY",5,true);
|
||||
$co .= glossary_full_tag("NAME",6,false,$category->name);
|
||||
|
@ -1839,29 +1808,24 @@ function glossary_full_tag($tag,$level=0,$endline=true,$content) {
|
|||
|
||||
function glossary_get_ratings($entryid, $sort="u.firstname ASC") {
|
||||
/// Returns a list of ratings for a particular entry - sorted.
|
||||
global $CFG;
|
||||
return get_records_sql("SELECT u.*, r.rating, r.time
|
||||
FROM {$CFG->prefix}glossary_ratings r,
|
||||
{$CFG->prefix}user u
|
||||
WHERE r.entryid = '$entryid'
|
||||
AND r.userid = u.id
|
||||
ORDER BY $sort");
|
||||
global $DB;
|
||||
return $DB->get_records_sql("SELECT u.*, r.rating, r.time
|
||||
FROM {glossary_ratings} r, {user} u
|
||||
WHERE r.entryid = ? AND r.userid = u.id
|
||||
ORDER BY $sort", array($entryid));
|
||||
}
|
||||
|
||||
function glossary_count_unrated_entries($glossaryid, $userid) {
|
||||
// How many unrated entries are in the given glossary for a given user?
|
||||
global $CFG;
|
||||
if ($entries = get_record_sql("SELECT count(*) as num
|
||||
FROM {$CFG->prefix}glossary_entries
|
||||
WHERE glossaryid = '$glossaryid'
|
||||
AND userid <> '$userid' ")) {
|
||||
global $DB;
|
||||
if ($entries = $DB->get_record_sql("SELECT count('x') as num
|
||||
FROM {glossary_entries}
|
||||
WHERE glossaryid = ? AND userid <> ?", array($glossaryid, $userid))) {
|
||||
|
||||
if ($rated = get_record_sql("SELECT count(*) as num
|
||||
FROM {$CFG->prefix}glossary_entries e,
|
||||
{$CFG->prefix}glossary_ratings r
|
||||
WHERE e.glossaryid = '$glossaryid'
|
||||
AND e.id = r.entryid
|
||||
AND r.userid = '$userid'")) {
|
||||
if ($rated = $DB->get_record_sql("SELECT count(*) as num
|
||||
FROM {glossary_entries} e, {glossary_ratings} r
|
||||
WHERE e.glossaryid = ? AND e.id = r.entryid
|
||||
AND r.userid = ?", array($glossaryid, $userid))) {
|
||||
$difference = $entries->num - $rated->num;
|
||||
if ($difference > 0) {
|
||||
return $difference;
|
||||
|
@ -1900,10 +1864,11 @@ function glossary_get_ratings_mean($entryid, $scale, $ratings=NULL) {
|
|||
/// Return the mean rating of a entry given to the current user by others.
|
||||
/// Scale is an array of possible ratings in the scale
|
||||
/// Ratings is an optional simple array of actual ratings (just integers)
|
||||
global $DB;
|
||||
|
||||
if (!$ratings) {
|
||||
$ratings = array();
|
||||
if ($rates = get_records("glossary_ratings", "entryid", $entryid)) {
|
||||
if ($rates = $DB->get_records("glossary_ratings", array("entryid"=>$entryid))) {
|
||||
foreach ($rates as $rate) {
|
||||
$ratings[] = $rate->rating;
|
||||
}
|
||||
|
@ -1937,10 +1902,11 @@ function glossary_get_ratings_summary($entryid, $scale, $ratings=NULL) {
|
|||
/// Return a summary of entry ratings given to the current user by others.
|
||||
/// Scale is an array of possible ratings in the scale
|
||||
/// Ratings is an optional simple array of actual ratings (just integers)
|
||||
global $DB;
|
||||
|
||||
if (!$ratings) {
|
||||
$ratings = array();
|
||||
if ($rates = get_records("glossary_ratings", "entryid", $entryid)) {
|
||||
if ($rates = $DB->get_records("glossary_ratings", array("entryid"=>$entryid))) {
|
||||
foreach ($rates as $rate) {
|
||||
$rating[] = $rate->rating;
|
||||
}
|
||||
|
@ -1975,10 +1941,11 @@ function glossary_print_rating_menu($entryid, $userid, $scale) {
|
|||
/// Print the menu of ratings as part of a larger form.
|
||||
/// If the entry has already been - set that value.
|
||||
/// Scale is an array of ratings
|
||||
global $DB;
|
||||
|
||||
static $strrate;
|
||||
|
||||
if (!$rating = get_record("glossary_ratings", "userid", $userid, "entryid", $entryid)) {
|
||||
if (!$rating = $DB->get_record("glossary_ratings", array("userid"=>$userid, "entryid"=>$entryid))) {
|
||||
$rating->rating = -999;
|
||||
}
|
||||
|
||||
|
@ -2173,7 +2140,7 @@ function glossary_reset_course_form_defaults($course) {
|
|||
* @param string optional type
|
||||
*/
|
||||
function glossary_reset_gradebook($courseid, $type='') {
|
||||
global $CFG;
|
||||
global $DB;
|
||||
|
||||
switch ($type) {
|
||||
case 'main' : $type = "AND g.mainglossary=1"; break;
|
||||
|
@ -2182,10 +2149,10 @@ function glossary_reset_gradebook($courseid, $type='') {
|
|||
}
|
||||
|
||||
$sql = "SELECT g.*, cm.idnumber as cmidnumber, g.course as courseid
|
||||
FROM {$CFG->prefix}glossary g, {$CFG->prefix}course_modules cm, {$CFG->prefix}modules m
|
||||
WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id AND g.course=$courseid $type";
|
||||
FROM {glossary} g, {course_modules} cm, {modules} m
|
||||
WHERE m.name='glossary' AND m.id=cm.module AND cm.instance=g.id AND g.course=? $type";
|
||||
|
||||
if ($glossarys = get_records_sql($sql)) {
|
||||
if ($glossarys = $DB->get_records_sql($sql, array($courseid))) {
|
||||
foreach ($glossarys as $glossary) {
|
||||
glossary_grade_item_update($glossary, 'reset');
|
||||
}
|
||||
|
@ -2198,30 +2165,32 @@ function glossary_reset_gradebook($courseid, $type='') {
|
|||
* @return array status array
|
||||
*/
|
||||
function glossary_reset_userdata($data) {
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
require_once($CFG->libdir.'/filelib.php');
|
||||
|
||||
$componentstr = get_string('modulenameplural', 'glossary');
|
||||
$status = array();
|
||||
|
||||
$allentriessql = "SELECT e.id
|
||||
FROM {$CFG->prefix}glossary_entries e
|
||||
INNER JOIN {$CFG->prefix}glossary g ON e.glossaryid = g.id
|
||||
WHERE g.course = {$data->courseid}";
|
||||
FROM {glossary_entries} e
|
||||
JOIN {glossary} g ON e.glossaryid = g.id
|
||||
WHERE g.course = ?";
|
||||
|
||||
$allglossariessql = "SELECT g.id
|
||||
FROM {$CFG->prefix}glossary g
|
||||
WHERE g.course={$data->courseid}";
|
||||
FROM {glossary} g
|
||||
WHERE g.course = ?";
|
||||
|
||||
$params = array($data->courseid);
|
||||
|
||||
// delete entries if requested
|
||||
if (!empty($data->reset_glossary_all)
|
||||
or (!empty($data->reset_glossary_types) and in_array('main', $data->reset_glossary_types) and in_array('secondary', $data->reset_glossary_types))) {
|
||||
|
||||
delete_records_select('glossary_ratings', "entryid IN ($allentriessql)");
|
||||
delete_records_select('glossary_comments', "entryid IN ($allentriessql)");
|
||||
delete_records_select('glossary_entries', "glossaryid IN ($allglossariessql)");
|
||||
$DB->delete_records_select('glossary_ratings', "entryid IN ($allentriessql)", $params);
|
||||
$DB->delete_records_select('glossary_comments', "entryid IN ($allentriessql)", $params);
|
||||
$DB->delete_records_select('glossary_entries', "glossaryid IN ($allglossariessql)", $params);
|
||||
|
||||
if ($glossaries = get_records_sql($allglossariessql)) {
|
||||
if ($glossaries = $DB->get_records_sql($allglossariessql, $params)) {
|
||||
foreach ($glossaries as $glossaryid=>$unused) {
|
||||
fulldelete($CFG->dataroot."/$data->courseid/moddata/glossary/$glossaryid");
|
||||
}
|
||||
|
@ -2242,11 +2211,11 @@ function glossary_reset_userdata($data) {
|
|||
$secondaryglossariessql = "$allglossariessql AND g.mainglossary=0";
|
||||
|
||||
if (in_array('main', $data->reset_glossary_types)) {
|
||||
delete_records_select('glossary_ratings', "entryid IN ($mainentriessql)");
|
||||
delete_records_select('glossary_comments', "entryid IN ($mainentriessql)");
|
||||
delete_records_select('glossary_entries', "glossaryid IN ($mainglossariessql)");
|
||||
$DB->delete_records_select('glossary_ratings', "entryid IN ($mainentriessql)", $params);
|
||||
$DB->delete_records_select('glossary_comments', "entryid IN ($mainentriessql)", $params);
|
||||
$DB->delete_records_select('glossary_entries', "glossaryid IN ($mainglossariessql)", $params);
|
||||
|
||||
if ($glossaries = get_records_sql($mainglossariessql)) {
|
||||
if ($glossaries = $DB->get_records_sql($mainglossariessql, $params)) {
|
||||
foreach ($glossaries as $glossaryid=>$unused) {
|
||||
fulldelete("$CFG->dataroot/$data->courseid/moddata/glossary/$glossaryid");
|
||||
}
|
||||
|
@ -2260,15 +2229,15 @@ function glossary_reset_userdata($data) {
|
|||
$status[] = array('component'=>$componentstr, 'item'=>get_string('resetglossaries', 'glossary'), 'error'=>false);
|
||||
|
||||
} else if (in_array('secondary', $data->reset_glossary_types)) {
|
||||
delete_records_select('glossary_ratings', "entryid IN ($secondaryentriessql)");
|
||||
delete_records_select('glossary_comments', "entryid IN ($secondaryentriessql)");
|
||||
delete_records_select('glossary_entries', "glossaryid IN ($secondaryglossariessql)");
|
||||
$DB->delete_records_select('glossary_ratings', "entryid IN ($secondaryentriessql)", $params);
|
||||
$DB->delete_records_select('glossary_comments', "entryid IN ($secondaryentriessql)", $params);
|
||||
$DB->delete_records_select('glossary_entries', "glossaryid IN ($secondaryglossariessql)", $params);
|
||||
// remove exported source flag from entries in main glossary
|
||||
execute_sql("UPDATE {$CFG->prefix}glossary_entries
|
||||
SET sourceglossaryid=0
|
||||
WHERE glossaryid IN ($mainglossariessql)", false);
|
||||
$DB->execute("UPDATE {glossary_entries
|
||||
SET sourceglossaryid=0
|
||||
WHERE glossaryid IN ($mainglossariessql)", $params);
|
||||
|
||||
if ($glossaries = get_records_sql($secondaryglossariessql)) {
|
||||
if ($glossaries = $DB->get_records_sql($secondaryglossariessql, $params)) {
|
||||
foreach ($glossaries as $glossaryid=>$unused) {
|
||||
fulldelete("$CFG->dataroot/$data->courseid/moddata/glossary/$glossaryid");
|
||||
}
|
||||
|
@ -2286,32 +2255,32 @@ function glossary_reset_userdata($data) {
|
|||
// remove entries by users not enrolled into course
|
||||
if (!empty($data->reset_glossary_notenrolled)) {
|
||||
$entriessql = "SELECT e.id, e.userid, e.glossaryid, u.id AS userexists, u.deleted AS userdeleted
|
||||
FROM {$CFG->prefix}glossary_entries e
|
||||
INNER JOIN {$CFG->prefix}glossary g ON e.glossaryid = g.id
|
||||
LEFT OUTER JOIN {$CFG->prefix}user u ON e.userid = u.id
|
||||
WHERE g.course = {$data->courseid} AND e.userid > 0";
|
||||
FROM {glossary_entries} e
|
||||
JOIN {glossary} g ON e.glossaryid = g.id
|
||||
LEFT JOIN {user} u ON e.userid = u.id
|
||||
WHERE g.course = ? AND e.userid > 0";
|
||||
|
||||
$course_context = get_context_instance(CONTEXT_COURSE, $data->courseid);
|
||||
$notenrolled = array();
|
||||
if ($rs = get_recordset_sql($entriessql)) {
|
||||
while ($entry = rs_fetch_next_record($rs)) {
|
||||
if ($rs = $DB->get_recordset_sql($entriessql, $params)) {
|
||||
foreach ($rs as $entry) {
|
||||
if (array_key_exists($entry->userid, $notenrolled) or !$entry->userexists or $entry->userdeleted
|
||||
or !has_capability('moodle/course:view', $course_context , $entry->userid)) {
|
||||
delete_records('glossary_ratings', 'entryid', $entry->id);
|
||||
delete_records('glossary_comments', 'entryid', $entry->id);
|
||||
delete_records('glossary_entries', 'id', $entry->id);
|
||||
$DB->delete_records('glossary_ratings', array('entryid'=>$entry->id));
|
||||
$DB->delete_records('glossary_comments', array('entryid'=>$entry->id));
|
||||
$DB->delete_records('glossary_entries', array('id'=>$entry->id));
|
||||
fulldelete("$CFG->dataroot/$data->courseid/moddata/glossary/$entry->glossaryid");
|
||||
$notenrolled[$entry->userid] = true;
|
||||
}
|
||||
}
|
||||
rs_close($rs);
|
||||
$rs->close();
|
||||
$status[] = array('component'=>$componentstr, 'item'=>get_string('deletenotenrolled', 'glossary'), 'error'=>false);
|
||||
}
|
||||
}
|
||||
|
||||
// remove all ratings
|
||||
if (!empty($data->reset_glossary_ratings)) {
|
||||
delete_records_select('glossary_ratings', "entryid IN ($allentriessql)");
|
||||
$DB->delete_records_select('glossary_ratings', "entryid IN ($allentriessql)", $params);
|
||||
// remove all grades from gradebook
|
||||
if (empty($data->reset_gradebook_grades)) {
|
||||
glossary_reset_gradebook($data->courseid);
|
||||
|
@ -2321,7 +2290,7 @@ function glossary_reset_userdata($data) {
|
|||
|
||||
// remove all comments
|
||||
if (!empty($data->reset_glossary_comments)) {
|
||||
delete_records_select('glossary_comments', "entryid IN ($allentriessql)");
|
||||
$DB->delete_records_select('glossary_comments', "entryid IN ($allentriessql)", $params);
|
||||
$status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallcomments'), 'error'=>false);
|
||||
}
|
||||
|
||||
|
|
|
@ -151,11 +151,12 @@ class mod_glossary_mod_form extends moodleform_mod {
|
|||
}
|
||||
|
||||
function definition_after_data() {
|
||||
global $COURSE, $DB;
|
||||
|
||||
parent::definition_after_data();
|
||||
global $COURSE;
|
||||
$mform =& $this->_form;
|
||||
$mainglossaryel =& $mform->getElement('mainglossary');
|
||||
$mainglossary = get_record('glossary', 'mainglossary', 1, 'course', $COURSE->id);
|
||||
$mainglossary = $DB->get_record('glossary', array('mainglossary'=>1, 'course'=>$COURSE->id));
|
||||
if ($mainglossary && ($mainglossary->id != $mform->getElementValue('instance'))){
|
||||
//secondary glossary, a main one already exists in this course.
|
||||
$mainglossaryel->setValue(0);
|
||||
|
|
|
@ -18,11 +18,11 @@
|
|||
print_error('invalidcoursemodule');
|
||||
}
|
||||
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
|
||||
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,7 @@
|
|||
|
||||
/// setting the default values for the display mode of the current glossary
|
||||
/// only if the glossary is viewed by the first time
|
||||
if ( $dp = get_record('glossary_formats','name', addslashes($glossary->displayformat)) ) {
|
||||
if ( $dp = $DB->get_record('glossary_formats', array('name'=>$glossary->displayformat)) ) {
|
||||
$printpivot = $dp->showgroup;
|
||||
if ( $mode == '' and $hook == '' and $show == '') {
|
||||
$mode = $dp->defaultmode;
|
||||
|
@ -88,7 +88,7 @@
|
|||
case 'cat': /// Looking for a certain cat
|
||||
$tab = GLOSSARY_CATEGORY_VIEW;
|
||||
if ( $hook > 0 ) {
|
||||
$category = get_record("glossary_categories","id",$hook);
|
||||
$category = $DB->get_record("glossary_categories", array("id"=>$hook));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -143,7 +143,7 @@
|
|||
$alphabet = explode(",", get_string("alphabet"));
|
||||
}
|
||||
|
||||
$site = get_record("course","id",1);
|
||||
$site = $DB->get_record("course", array("id"=>1));
|
||||
echo '<p style="text-align:right"><span style="font-size:0.75em">' . userdate(time()) . '</span></p>';
|
||||
echo get_string("site") . ': <strong>' . format_string($site->fullname) . '</strong><br />';
|
||||
echo get_string("course") . ': <strong>' . format_string($course->fullname) . ' ('. format_string($course->shortname) . ')</strong><br />';
|
||||
|
@ -169,7 +169,7 @@
|
|||
$pivottoshow = $currentpivot;
|
||||
if ( isset($entry->userispivot) ) {
|
||||
// printing the user icon if defined (only when browsing authors)
|
||||
$user = get_record("user","id",$entry->userid);
|
||||
$user = $DB->get_record("user", array("id"=>$entry->userid));
|
||||
$pivottoshow = fullname($user);
|
||||
}
|
||||
|
||||
|
|
|
@ -8,11 +8,11 @@
|
|||
|
||||
$glossaryid = required_param('glossaryid', PARAM_INT); // The forum the rated posts are from
|
||||
|
||||
if (!$glossary = get_record('glossary', 'id', $glossaryid)) {
|
||||
if (!$glossary = $DB->get_record('glossary', array('id'=>$glossaryid))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
if (!$course = get_record('course', 'id', $glossary->course)) {
|
||||
if (!$course = $DB->get_record('course', array('id'=>$glossary->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
|
@ -42,12 +42,12 @@
|
|||
$returnurl = $CFG->wwwroot.'/mod/glossary/view.php?id='.$cm->id;
|
||||
}
|
||||
|
||||
if ($data = data_submitted()) { // form submitted
|
||||
if ($data = data_submitted(false)) { // form submitted
|
||||
foreach ((array)$data as $entryid => $rating) {
|
||||
if (!is_numeric($entryid)) {
|
||||
continue;
|
||||
}
|
||||
if (!$entry = get_record('glossary_entries', 'id', $entryid)) {
|
||||
if (!$entry = $DB->get_record('glossary_entries', array('id'=>$entryid))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -67,16 +67,16 @@
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($oldrating = get_record("glossary_ratings", "userid", $USER->id, "entryid", $entry->id)) {
|
||||
if ($oldrating = $DB->get_record("glossary_ratings", array("userid"=>$USER->id, "entryid"=>$entry->id))) {
|
||||
//Check if we must delete the rate
|
||||
if ($rating == -999) {
|
||||
delete_records('glossary_ratings','userid',$oldrating->userid, 'entryid',$oldrating->entryid);
|
||||
$DB->delete_records('glossary_ratings', array('userid'=>$oldrating->userid, 'entryid'=>$oldrating->entryid));
|
||||
glossary_update_grades($glossary, $entry->userid);
|
||||
|
||||
} else if ($rating != $oldrating->rating) {
|
||||
$oldrating->rating = $rating;
|
||||
$oldrating->time = time();
|
||||
if (! update_record("glossary_ratings", $oldrating)) {
|
||||
if (! $DB->update_record("glossary_ratings", $oldrating)) {
|
||||
print_error('cannotinsertrate', '', '', array($entry, $rating));
|
||||
}
|
||||
glossary_update_grades($glossary, $entry->userid);
|
||||
|
@ -89,7 +89,7 @@
|
|||
$newrating->entryid = $entry->id;
|
||||
$newrating->rating = $rating;
|
||||
|
||||
if (! insert_record("glossary_ratings", $newrating)) {
|
||||
if (! $DB->insert_record("glossary_ratings", $newrating)) {
|
||||
print_error('cannotinsertrate', '', '', array($entry->id, $rating));
|
||||
}
|
||||
glossary_update_grades($glossary, $entry->userid);
|
||||
|
|
|
@ -8,15 +8,15 @@
|
|||
$id = required_param('id', PARAM_INT);
|
||||
$sort = optional_param('sort', '', PARAM_ALPHA);
|
||||
|
||||
if (! $entry = get_record('glossary_entries', 'id', $id)) {
|
||||
if (! $entry = $DB->get_record('glossary_entries', array('id'=>$id))) {
|
||||
print_error('invalidentry');
|
||||
}
|
||||
|
||||
if (! $glossary = get_record('glossary', 'id', $entry->glossaryid)) {
|
||||
if (! $glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
|
||||
if (! $course = get_record('course', 'id', $glossary->course)) {
|
||||
if (! $course = $DB->get_record('course', array('id'=>$glossary->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
|
||||
|
|
|
@ -5,8 +5,7 @@
|
|||
//rss feeds generation. Foreach site glossary with rss enabled
|
||||
//build one XML rss structure.
|
||||
function glossary_rss_feeds() {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
|
@ -19,7 +18,7 @@
|
|||
//It's working so we start...
|
||||
} else {
|
||||
//Iterate over all glossaries
|
||||
if ($glossaries = get_records("glossary")) {
|
||||
if ($glossaries = $DB->get_records("glossary")) {
|
||||
foreach ($glossaries as $glossary) {
|
||||
if (!empty($glossary->rsstype) && !empty($glossary->rssarticles) && $status) {
|
||||
|
||||
|
@ -83,8 +82,7 @@
|
|||
//This function return the XML rss contents about the glossary record passed as parameter
|
||||
//It returns false if something is wrong
|
||||
function glossary_rss_feed($glossary) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$status = true;
|
||||
|
||||
|
@ -136,31 +134,32 @@
|
|||
//This function returns "items" record array to be used to build the rss feed
|
||||
//for a Type=with author glossary
|
||||
function glossary_rss_feed_withauthor($glossary, $newsince=0) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$items = array();
|
||||
|
||||
$params = array('gid'=>$glossary->id, 'newsince'=>$newsince);
|
||||
|
||||
if ($newsince) {
|
||||
$newsince = " AND e.timecreated > '$newsince'";
|
||||
$newsince = "AND e.timecreated > :newsince";
|
||||
} else {
|
||||
$newsince = "";
|
||||
}
|
||||
|
||||
if ($recs = get_records_sql ("SELECT e.id AS entryid,
|
||||
e.concept AS entryconcept,
|
||||
e.definition AS entrydefinition,
|
||||
e.format AS entryformat,
|
||||
e.timecreated AS entrytimecreated,
|
||||
u.id AS userid,
|
||||
u.firstname AS userfirstname,
|
||||
u.lastname AS userlastname
|
||||
FROM {$CFG->prefix}glossary_entries e,
|
||||
{$CFG->prefix}user u
|
||||
WHERE e.glossaryid = '$glossary->id' AND
|
||||
u.id = e.userid AND
|
||||
e.approved = 1 $newsince
|
||||
ORDER BY e.timecreated desc")) {
|
||||
if ($recs = $DB->get_records_sql ("SELECT e.id AS entryid,
|
||||
e.concept AS entryconcept,
|
||||
e.definition AS entrydefinition,
|
||||
e.format AS entryformat,
|
||||
e.timecreated AS entrytimecreated,
|
||||
u.id AS userid,
|
||||
u.firstname AS userfirstname,
|
||||
u.lastname AS userlastname
|
||||
FROM {glossary_entries} e,
|
||||
{user} u
|
||||
WHERE e.glossaryid = :gid AND
|
||||
u.id = e.userid AND
|
||||
e.approved = 1 $newsince
|
||||
ORDER BY e.timecreated desc", $params)) {
|
||||
|
||||
//Are we just looking for new ones? If so, then return now.
|
||||
if ($newsince) {
|
||||
|
@ -168,15 +167,13 @@
|
|||
}
|
||||
//Iterate over each entry to get glossary->rssarticles records
|
||||
$articlesleft = $glossary->rssarticles;
|
||||
$item = NULL;
|
||||
$user = NULL;
|
||||
|
||||
$formatoptions = new object;
|
||||
$formatoptions->trusttext = true;
|
||||
|
||||
foreach ($recs as $rec) {
|
||||
unset($item);
|
||||
unset($user);
|
||||
$item = new object();
|
||||
$user = new user();
|
||||
$item->title = $rec->entryconcept;
|
||||
$user->firstname = $rec->userfirstname;
|
||||
$user->lastname = $rec->userlastname;
|
||||
|
@ -197,31 +194,32 @@
|
|||
//This function returns "items" record array to be used to build the rss feed
|
||||
//for a Type=without author glossary
|
||||
function glossary_rss_feed_withoutauthor($glossary, $newsince=0) {
|
||||
|
||||
global $CFG;
|
||||
global $CFG, $DB;
|
||||
|
||||
$items = array();
|
||||
|
||||
$params = array('gid'=>$glossary->id, 'newsince'=>$newsince);
|
||||
|
||||
if ($newsince) {
|
||||
$newsince = " AND e.timecreated > '$newsince'";
|
||||
$newsince = "AND e.timecreated > :newsince";
|
||||
} else {
|
||||
$newsince = "";
|
||||
}
|
||||
|
||||
if ($recs = get_records_sql ("SELECT e.id AS entryid,
|
||||
e.concept AS entryconcept,
|
||||
e.definition AS entrydefinition,
|
||||
e.format AS entryformat,
|
||||
e.timecreated AS entrytimecreated,
|
||||
u.id AS userid,
|
||||
u.firstname AS userfirstname,
|
||||
u.lastname AS userlastname
|
||||
FROM {$CFG->prefix}glossary_entries e,
|
||||
{$CFG->prefix}user u
|
||||
WHERE e.glossaryid = '$glossary->id' AND
|
||||
u.id = e.userid AND
|
||||
e.approved = 1 $newsince
|
||||
ORDER BY e.timecreated desc")) {
|
||||
if ($recs = $DB->get_records_sql ("SELECT e.id AS entryid,
|
||||
e.concept AS entryconcept,
|
||||
e.definition AS entrydefinition,
|
||||
e.format AS entryformat,
|
||||
e.timecreated AS entrytimecreated,
|
||||
u.id AS userid,
|
||||
u.firstname AS userfirstname,
|
||||
u.lastname AS userlastname
|
||||
FROM {glossary_entries} e,
|
||||
{user} u
|
||||
WHERE e.glossaryid = :gid AND
|
||||
u.id = e.userid AND
|
||||
e.approved = 1 $newsince
|
||||
ORDER BY e.timecreated desc", $params)) {
|
||||
|
||||
//Are we just looking for new ones? If so, then return now.
|
||||
if ($newsince) {
|
||||
|
@ -230,15 +228,13 @@
|
|||
|
||||
//Iterate over each entry to get glossary->rssarticles records
|
||||
$articlesleft = $glossary->rssarticles;
|
||||
$item = NULL;
|
||||
$user = NULL;
|
||||
|
||||
$formatoptions = new object;
|
||||
$formatoptions->trusttext = true;
|
||||
|
||||
foreach ($recs as $rec) {
|
||||
unset($item);
|
||||
unset($user);
|
||||
$item = new object();
|
||||
$user = new object();
|
||||
$item->title = $rec->entryconcept;
|
||||
$user->firstname = $rec->userfirstname;
|
||||
$user->lastname = $rec->userlastname;
|
||||
|
|
|
@ -56,7 +56,7 @@ asort($formats);
|
|||
|
||||
$str = '<table>';
|
||||
foreach ($formats as $formatid=>$formatname) {
|
||||
$recformat = get_record('glossary_formats','id',$formatid);
|
||||
$recformat = $DB->get_record('glossary_formats', array('id'=>$formatid));
|
||||
$str .= '<tr>';
|
||||
$str .= '<td>' . $formatname . '</td>';
|
||||
$eicon = "<a title=\"".get_string("edit")."\" href=\"$CFG->wwwroot/mod/glossary/formats.php?id=$formatid&mode=edit\"><img class=\"iconsmall\" src=\"../pix/t/edit.gif\" alt=\"".get_string("edit")."\" /></a>";
|
||||
|
|
|
@ -12,8 +12,8 @@
|
|||
}
|
||||
|
||||
if ($eid) {
|
||||
$entry = get_record("glossary_entries", "id", $eid);
|
||||
$glossary = get_record('glossary','id',$entry->glossaryid);
|
||||
$entry = $DB->get_record("glossary_entries", array("id"=>$eid));
|
||||
$glossary = $DB->get_record('glossary', array('id'=>$entry->glossaryid));
|
||||
$entry->glossaryname = format_string($glossary->name,true);
|
||||
if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id)) {
|
||||
print_error("invalidcoursemodule");
|
||||
|
@ -39,7 +39,7 @@
|
|||
}
|
||||
|
||||
if (!empty($courseid)) {
|
||||
$course = get_record("course", "id", $courseid);
|
||||
$course = $DB->get_record("course", array("id"=>$courseid));
|
||||
if ($course->id != SITEID) {
|
||||
require_login($courseid);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* SQL.PHP
|
||||
* This file is include from view.php and print.php
|
||||
* @version $Id$
|
||||
* @copyright 2003
|
||||
* @copyright 2003
|
||||
**/
|
||||
|
||||
/// Creating the SQL statements
|
||||
|
@ -15,17 +15,17 @@
|
|||
$textlib = textlib_get_instance();
|
||||
|
||||
/// Calculate the SQL sortkey to be used by the SQL statements later
|
||||
switch ( $sortkey ) {
|
||||
case "CREATION":
|
||||
switch ( $sortkey ) {
|
||||
case "CREATION":
|
||||
$sqlsortkey = "timecreated";
|
||||
break;
|
||||
case "UPDATE":
|
||||
case "UPDATE":
|
||||
$sqlsortkey = "timemodified";
|
||||
break;
|
||||
case "FIRSTNAME":
|
||||
case "FIRSTNAME":
|
||||
$sqlsortkey = "firstname";
|
||||
break;
|
||||
case "LASTNAME":
|
||||
case "LASTNAME":
|
||||
$sqlsortkey = "lastname";
|
||||
break;
|
||||
}
|
||||
|
@ -37,33 +37,34 @@
|
|||
/// printpivot indicate if the pivot should be printed or not
|
||||
|
||||
$fullpivot = 1;
|
||||
$params = array('gid1'=>$glossary->id, 'gid2'=>$glossary->id, 'myid'=>$USER->id, 'hook'=>$hook);
|
||||
|
||||
$userid = '';
|
||||
if ( !empty($USER->id) ) {
|
||||
$userid = "OR ge.userid = $USER->id";
|
||||
$userid = "OR ge.userid = :myid";
|
||||
}
|
||||
switch ($tab) {
|
||||
case GLOSSARY_CATEGORY_VIEW:
|
||||
if ($hook == GLOSSARY_SHOW_ALL_CATEGORIES ) {
|
||||
if ($hook == GLOSSARY_SHOW_ALL_CATEGORIES ) {
|
||||
|
||||
$sqlselect = "SELECT gec.id AS cid, ge.*, gec.entryid, gc.name AS glossarypivot";
|
||||
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge,
|
||||
{$CFG->prefix}glossary_entries_categories gec,
|
||||
{$CFG->prefix}glossary_categories gc";
|
||||
$sqlwhere = "WHERE (ge.glossaryid = '$glossary->id' OR ge.sourceglossaryid = '$glossary->id') AND
|
||||
$sqlfrom = "FROM {glossary_entries} ge,
|
||||
{glossary_entries_categories} gec,
|
||||
{glossary_categories} gc";
|
||||
$sqlwhere = "WHERE (ge.glossaryid = :gid1 OR ge.sourceglossaryid = :gid2) AND
|
||||
ge.id = gec.entryid AND gc.id = gec.categoryid AND
|
||||
(ge.approved != 0 $userid)";
|
||||
(ge.approved <> 0 $userid)";
|
||||
|
||||
$sqlorderby = ' ORDER BY gc.name, ge.concept';
|
||||
|
||||
} elseif ($hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
|
||||
} elseif ($hook == GLOSSARY_SHOW_NOT_CATEGORISED ) {
|
||||
|
||||
$printpivot = 0;
|
||||
$sqlselect = "SELECT ge.*, concept AS glossarypivot";
|
||||
$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) AND gec.entryid IS NULL";
|
||||
$sqlfrom = "FROM {glossary_entries} ge LEFT JOIN {glossary_entries_categories} gec
|
||||
ON ge.id = gec.entryid";
|
||||
$sqlwhere = "WHERE (glossaryid = :gid1 OR sourceglossaryid = :gid2) AND
|
||||
(ge.approved <> 0 $userid) AND gec.entryid IS NULL";
|
||||
|
||||
|
||||
$sqlorderby = ' ORDER BY concept';
|
||||
|
@ -72,11 +73,11 @@
|
|||
|
||||
$printpivot = 0;
|
||||
$sqlselect = "SELECT ge.*, ce.entryid, c.name AS glossarypivot";
|
||||
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}glossary_entries_categories ce, {$CFG->prefix}glossary_categories c";
|
||||
$sqlwhere = "WHERE ge.id = ce.entryid AND ce.categoryid = '$hook' AND
|
||||
$sqlfrom = "FROM {glossary_entries} ge, {glossary_entries_categories} ce, {glossary_categories} c";
|
||||
$sqlwhere = "WHERE ge.id = ce.entryid AND ce.categoryid = :hook AND
|
||||
ce.categoryid = c.id AND ge.approved != 0 AND
|
||||
(ge.glossaryid = '$glossary->id' OR ge.sourceglossaryid = '$glossary->id') AND
|
||||
(ge.approved != 0 $userid)";
|
||||
(ge.glossaryid = :gid1 OR ge.sourceglossaryid = :gid2) AND
|
||||
(ge.approved <> 0 $userid)";
|
||||
|
||||
$sqlorderby = ' ORDER BY c.name, ge.concept';
|
||||
|
||||
|
@ -85,24 +86,25 @@
|
|||
case GLOSSARY_AUTHOR_VIEW:
|
||||
|
||||
$where = '';
|
||||
$params['hookup'] = $textlib->strtoupper($hook);
|
||||
|
||||
if ( $sqlsortkey == 'firstname' ) {
|
||||
$usernamefield = sql_fullname('u.firstname' , 'u.lastname');
|
||||
$usernamefield = $DB->sql_fullname('u.firstname' , 'u.lastname');
|
||||
} else {
|
||||
$usernamefield = sql_fullname('u.lastname' , 'u.firstname');
|
||||
$usernamefield = $DB->sql_fullname('u.lastname' , 'u.firstname');
|
||||
}
|
||||
$where = "AND " . sql_substr() . "(upper($usernamefield),1," . $textlib->strlen($hook) . ") = '" . $textlib->strtoupper($hook) . "'";
|
||||
$where = "AND " . $DB->sql_substr() . "(upper($usernamefield),1," . $textlib->strlen($hook) . ") = :hookup";
|
||||
|
||||
if ( $hook == 'ALL' ) {
|
||||
$where = '';
|
||||
}
|
||||
|
||||
$sqlselect = "SELECT ge.*, $usernamefield AS glossarypivot, 1 AS userispivot ";
|
||||
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge, {$CFG->prefix}user u";
|
||||
$sqlfrom = "FROM {glossary_entries} ge, {user} u";
|
||||
$sqlwhere = "WHERE ge.userid = u.id AND
|
||||
(ge.approved != 0 $userid)
|
||||
$where AND
|
||||
(ge.glossaryid = '$glossary->id' OR ge.sourceglossaryid = '$glossary->id')";
|
||||
(ge.approved <> 0 $userid)
|
||||
$where AND
|
||||
(ge.glossaryid = :gid1 OR ge.sourceglossaryid = :gid2)";
|
||||
$sqlorderby = "ORDER BY $usernamefield $sqlsortorder, ge.concept";
|
||||
break;
|
||||
case GLOSSARY_APPROVAL_VIEW:
|
||||
|
@ -110,15 +112,17 @@
|
|||
$printpivot = 0;
|
||||
|
||||
$where = '';
|
||||
$params['hookup'] = $textlib->strtoupper($hook);
|
||||
|
||||
if ($hook != 'ALL' and $hook != 'SPECIAL') {
|
||||
$where = 'AND ' . sql_substr() . '(upper(concept),1,' . $textlib->strlen($hook) . ') = \'' . $textlib->strtoupper($hook) . '\'';
|
||||
$where = 'AND ' . $DB->sql_substr() . '(upper(concept),1,' . $textlib->strlen($hook) . ') = :hookup';
|
||||
}
|
||||
|
||||
$sqlselect = "SELECT ge.*, ge.concept AS glossarypivot";
|
||||
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge";
|
||||
$sqlwhere = "WHERE (ge.glossaryid = '$glossary->id' OR ge.sourceglossaryid = '$glossary->id') AND
|
||||
$sqlfrom = "FROM {glossary_entries} ge";
|
||||
$sqlwhere = "WHERE (ge.glossaryid = :gid1 OR ge.sourceglossaryid = :gid2) AND
|
||||
ge.approved = 0 $where";
|
||||
|
||||
|
||||
if ( $sqlsortkey ) {
|
||||
$sqlorderby = "ORDER BY $sqlsortkey $sqlsortorder";
|
||||
} else {
|
||||
|
@ -130,157 +134,135 @@
|
|||
case GLOSSARY_STANDARD_VIEW:
|
||||
default:
|
||||
$sqlselect = "SELECT ge.*, ge.concept AS glossarypivot";
|
||||
$sqlfrom = "FROM {$CFG->prefix}glossary_entries ge";
|
||||
$sqlfrom = "FROM {glossary_entries} ge";
|
||||
|
||||
$where = '';
|
||||
$fullpivot = 0;
|
||||
$LIKE = sql_ilike();
|
||||
$NOTLIKE = 'NOT ' . $LIKE;
|
||||
|
||||
switch ( $mode ) {
|
||||
case 'search':
|
||||
case 'search':
|
||||
|
||||
/// Some differences in syntax for PostgreSQL
|
||||
if ($CFG->dbfamily == "postgres") {
|
||||
$REGEXP = "~*";
|
||||
$NOTREGEXP = "!~*";
|
||||
} else {
|
||||
$REGEXP = "REGEXP";
|
||||
$NOTREGEXP = "NOT REGEXP";
|
||||
if ($DB->sql_regex_supported()) {
|
||||
$REGEXP = $DB->sql_regex(true);
|
||||
$NOTREGEXP = $DB->sql_regex(false);
|
||||
}
|
||||
$LIKE = $DB->sql_ilike(); // case-insensitive
|
||||
|
||||
$conceptsearch = "";
|
||||
$aliassearch = "";
|
||||
$definitionsearch = "";
|
||||
$searchcond = array();
|
||||
$alcond = array();
|
||||
$params = array();
|
||||
$i = 0;
|
||||
|
||||
$concat = $DB->sql_concat('ge.concept', "' '", 'ge.definition',"' '", "COALESCE(al.alial, '')");
|
||||
|
||||
$searchterms = explode(" ",$hook);
|
||||
|
||||
foreach ($searchterms as $searchterm) {
|
||||
$i++;
|
||||
|
||||
if ($conceptsearch) {
|
||||
$conceptsearch .= " AND ";
|
||||
}
|
||||
if ($aliassearch) {
|
||||
$aliassearch .= " AND ";
|
||||
}
|
||||
if ($definitionsearch) {
|
||||
$definitionsearch .= " AND ";
|
||||
}
|
||||
$NOT = ''; /// Initially we aren't going to perform NOT LIKE searches, only MSSQL and Oracle
|
||||
/// will use it to simulate the "-" operator with LIKE clause
|
||||
|
||||
/// Under Oracle and MSSQL, trim the + and - operators and perform
|
||||
/// simpler LIKE search
|
||||
if ($CFG->dbfamily == 'oracle' || $CFG->dbfamily == 'mssql') {
|
||||
/// simpler LIKE (or NOT LIKE) queries
|
||||
if (!$DB->sql_regex_supported()) {
|
||||
if (substr($searchterm, 0, 1) == '-') {
|
||||
$NOT = ' NOT ';
|
||||
}
|
||||
$searchterm = trim($searchterm, '+-');
|
||||
}
|
||||
|
||||
if (substr($searchterm,0,1) == "+") {
|
||||
$searchterm = substr($searchterm,1);
|
||||
$conceptsearch .= " ge.concept $REGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
$aliassearch .= " al.alias $REGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
$definitionsearch .= " ge.definition $REGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
if (substr($searchterm,0,1) == '+') {
|
||||
$searchterm = trim($searchterm, '+-');
|
||||
if ($textlib->strlen($searchterm) < 2) {
|
||||
continue;
|
||||
}
|
||||
$searchterm = preg_quote($searchterm, '|');
|
||||
$searchcond[] = "$concat $REGEXP :ss$i";
|
||||
$params['ss'.$i] = "(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)";
|
||||
|
||||
} else if (substr($searchterm,0,1) == "-") {
|
||||
$searchterm = substr($searchterm,1);
|
||||
$conceptsearch .= " ge.concept $NOTREGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
$aliassearch .= " al.alias $NOTREGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
$definitionsearch .= " ge.definition $NOTREGEXP '(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)' ";
|
||||
$searchterm = trim($searchterm, '+-');
|
||||
if ($textlib->strlen($searchterm) < 2) {
|
||||
continue;
|
||||
}
|
||||
$searchterm = preg_quote($searchterm, '|');
|
||||
$searchcond[] = "$concat $NOTREGEXP :ss$i";
|
||||
$params['ss'.$i] = "(^|[^a-zA-Z0-9])$searchterm([^a-zA-Z0-9]|$)";
|
||||
|
||||
} else {
|
||||
$conceptsearch .= " ge.concept $LIKE '%$searchterm%' ";
|
||||
$aliassearch .= " al.alias $LIKE '%$searchterm%' ";
|
||||
$definitionsearch .= " ge.definition $LIKE '%$searchterm%' ";
|
||||
if ($textlib->strlen($searchterm) < 2) {
|
||||
continue;
|
||||
}
|
||||
$searchcond[] = "$concat $NOT $LIKE :ss$i";
|
||||
$params['ss'.$i] = "%$searchterm%";
|
||||
}
|
||||
}
|
||||
|
||||
//Search in aliases first
|
||||
$idaliases = '';
|
||||
$listaliases = array();
|
||||
$recaliases = get_records_sql ("SELECT al.id, al.entryid
|
||||
FROM {$CFG->prefix}glossary_alias al,
|
||||
{$CFG->prefix}glossary_entries ge
|
||||
WHERE (ge.glossaryid = '$glossary->id' OR
|
||||
ge.sourceglossaryid = '$glossary->id') AND
|
||||
(ge.approved != 0 $userid) AND
|
||||
ge.id = al.entryid AND
|
||||
$aliassearch");
|
||||
//Process aliases id
|
||||
if ($recaliases) {
|
||||
foreach ($recaliases as $recalias) {
|
||||
$listaliases[] = $recalias->entryid;
|
||||
}
|
||||
$idaliases = implode (',',$listaliases);
|
||||
}
|
||||
|
||||
//Add seach conditions in concepts and, if needed, in definitions
|
||||
$printpivot = 0;
|
||||
$where = "AND (( $conceptsearch) ";
|
||||
|
||||
//Include aliases id if found
|
||||
if (!empty($idaliases)) {
|
||||
$where .= " OR ge.id IN ($idaliases) ";
|
||||
}
|
||||
if (empty($searchcond)) {
|
||||
$where = " 1=2 "; // no search result
|
||||
|
||||
//Include search in definitions if requested
|
||||
if ( $fullsearch ) {
|
||||
$where .= " OR ($definitionsearch) )";
|
||||
} else {
|
||||
$where .= ")";
|
||||
$searchcond = implode(" AND ", $searchcond);
|
||||
|
||||
$sqlselect = "SELECT DISTINCT ge.*, ge.concept AS glossarypivot";
|
||||
$sqlfrom = "FROM {glossary_entries} ge
|
||||
LEFT JOIN {glossary_alias} al ON al.entryid = ge.id";
|
||||
$where = "AND ($searchcond)";
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 'term':
|
||||
|
||||
case 'term':
|
||||
$params['hook2'] = $hook;
|
||||
$printpivot = 0;
|
||||
$sqlfrom .= " left join {$CFG->prefix}glossary_alias ga on ge.id = ga.entryid ";
|
||||
$where = "AND (ge.concept = '$hook' OR ga.alias = '$hook' )
|
||||
";
|
||||
$sqlfrom .= " LEFT JOIN {glossary_alias} ga on ge.id = ga.entryid";
|
||||
$where = "AND (ge.concept = :hook OR ga.alias = :hook2) ";
|
||||
break;
|
||||
|
||||
case 'entry':
|
||||
case 'entry':
|
||||
$printpivot = 0;
|
||||
$where = "AND ge.id = '$hook'";
|
||||
$where = "AND ge.id = :hook";
|
||||
break;
|
||||
|
||||
case 'letter':
|
||||
case 'letter':
|
||||
if ($hook != 'ALL' and $hook != 'SPECIAL') {
|
||||
$where = 'AND ' . sql_substr() . '(upper(concept),1,' . $textlib->strlen($hook) . ') = \'' . $textlib->strtoupper($hook) . '\'';
|
||||
$params['hookup'] = $textlib->strtoupper($hook);
|
||||
$where = 'AND ' . $DB->sql_substr() . '(upper(concept),1,' . $textlib->strlen($hook) . ') = :hookup';
|
||||
}
|
||||
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].'\'';
|
||||
}
|
||||
$where = 'AND ' . sql_substr() . '(upper(concept),1,1) NOT IN (' . $textlib->strtoupper($sqlalphabet) . ')';
|
||||
list($nia, $aparams) = $DB->get_in_or_equal($alphabet, SQL_PARAMS_NAMED, $start='a0', false);
|
||||
$params = array_merge($params, $aparams);
|
||||
$where = 'AND ' . $DB->sql_substr() . "(upper(concept),1,1) $nia";
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
$sqlwhere = "WHERE (ge.glossaryid = '$glossary->id' or ge.sourceglossaryid = '$glossary->id') AND
|
||||
(ge.approved != 0 $userid)
|
||||
|
||||
$sqlwhere = "WHERE (ge.glossaryid = :gid1 or ge.sourceglossaryid = :gid2) AND
|
||||
(ge.approved <> 0 $userid)
|
||||
$where";
|
||||
switch ( $tab ) {
|
||||
case GLOSSARY_DATE_VIEW:
|
||||
case GLOSSARY_DATE_VIEW:
|
||||
$sqlorderby = "ORDER BY $sqlsortkey $sqlsortorder";
|
||||
break;
|
||||
|
||||
case GLOSSARY_STANDARD_VIEW:
|
||||
|
||||
case GLOSSARY_STANDARD_VIEW:
|
||||
$sqlorderby = "ORDER BY ge.concept";
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
$count = count_records_sql("select count(*) $sqlfrom $sqlwhere");
|
||||
}
|
||||
$count = $DB->count_records_sql("SELECT COUNT(DISTINCT(ge.id)) $sqlfrom $sqlwhere", $params);
|
||||
|
||||
$limitfrom = $offset;
|
||||
$limitnum = 0;
|
||||
|
||||
|
||||
if ( $offset >= 0 ) {
|
||||
$limitnum = $entriesbypage;
|
||||
}
|
||||
|
||||
$allentries = get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby", $limitfrom, $limitnum);
|
||||
$allentries = $DB->get_records_sql("$sqlselect $sqlfrom $sqlwhere $sqlorderby", $params, $limitfrom, $limitnum);
|
||||
?>
|
||||
|
|
|
@ -23,17 +23,17 @@
|
|||
if (! $cm = get_coursemodule_from_id('glossary', $id)) {
|
||||
print_error('invalidcoursemodule');
|
||||
}
|
||||
if (! $course = get_record("course", "id", $cm->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$cm->course))) {
|
||||
print_error('coursemisconf');
|
||||
}
|
||||
if (! $glossary = get_record("glossary", "id", $cm->instance)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$cm->instance))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
} else if (!empty($g)) {
|
||||
if (! $glossary = get_record("glossary", "id", $g)) {
|
||||
if (! $glossary = $DB->get_record("glossary", array("id"=>$g))) {
|
||||
print_error('invalidid', 'glossary');
|
||||
}
|
||||
if (! $course = get_record("course", "id", $glossary->course)) {
|
||||
if (! $course = $DB->get_record("course", array("id"=>$glossary->course))) {
|
||||
print_error('invalidcourseid');
|
||||
}
|
||||
if (!$cm = get_coursemodule_from_instance("glossary", $glossary->id, $course->id)) {
|
||||
|
@ -68,7 +68,7 @@
|
|||
|
||||
/// setting the default values for the display mode of the current glossary
|
||||
/// only if the glossary is viewed by the first time
|
||||
if ( $dp = get_record('glossary_formats','name', addslashes($glossary->displayformat)) ) {
|
||||
if ( $dp = $DB->get_record('glossary_formats', array('name'=>$glossary->displayformat)) ) {
|
||||
/// Based on format->defaultmode, we build the defaulttab to be showed sometimes
|
||||
switch ($dp->defaultmode) {
|
||||
case 'cat':
|
||||
|
@ -146,7 +146,7 @@
|
|||
|
||||
case 'entry': /// Looking for a certain entry id
|
||||
$tab = GLOSSARY_STANDARD_VIEW;
|
||||
if ( $dp = get_record("glossary_formats","name", $glossary->displayformat) ) {
|
||||
if ( $dp = $DB->get_record("glossary_formats", array("name"=>$glossary->displayformat)) ) {
|
||||
$displayformat = $dp->popupformatname;
|
||||
}
|
||||
break;
|
||||
|
@ -154,7 +154,7 @@
|
|||
case 'cat': /// Looking for a certain cat
|
||||
$tab = GLOSSARY_CATEGORY_VIEW;
|
||||
if ( $hook > 0 ) {
|
||||
$category = get_record("glossary_categories","id",$hook);
|
||||
$category = $DB->get_record("glossary_categories", array("id"=>$hook));
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -268,7 +268,7 @@
|
|||
/// Decide about to print the approval link
|
||||
if (has_capability('mod/glossary:approve', $context)) {
|
||||
/// Check we have pending entries
|
||||
if ($hiddenentries = count_records_select('glossary_entries',"glossaryid = $glossary->id and approved = 0")) {
|
||||
if ($hiddenentries = $DB->count_records('glossary_entries', array('glossaryid'=>$glossary->id, 'approved'=>0))) {
|
||||
if ($availableoptions) {
|
||||
$availableoptions .= '<br />';
|
||||
}
|
||||
|
@ -441,7 +441,7 @@
|
|||
// printing the user icon if defined (only when browsing authors)
|
||||
echo '<th align="left">';
|
||||
|
||||
$user = get_record("user","id",$entry->userid);
|
||||
$user = $DB->get_record("user", array("id"=>$entry->userid));
|
||||
print_user_picture($user, $course->id, $user->picture);
|
||||
$pivottoshow = fullname($user, has_capability('moodle/site:viewfullnames', get_context_instance(CONTEXT_COURSE, $course->id)));
|
||||
} else {
|
||||
|
@ -495,7 +495,7 @@
|
|||
|
||||
echo "<div class=\"boxaligncenter\"><input type=\"submit\" value=\"".get_string("sendinratings", "glossary")."\" />";
|
||||
if ($glossary->scale < 0) {
|
||||
if ($scale = get_record("scale", "id", abs($glossary->scale))) {
|
||||
if ($scale = $DB->get_record("scale", array("id"=>abs($glossary->scale)))) {
|
||||
print_scale_menu_helpbutton($course->id, $scale );
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue