Merge branch 'MDL-55808_master' of git://github.com/juancs/moodle
authorJun Pataleta <jun@moodle.com>
Sun, 19 Nov 2017 21:34:55 +0000 (10:34 +1300)
committerJun Pataleta <jun@moodle.com>
Sun, 19 Nov 2017 21:34:55 +0000 (10:34 +1300)
1  2 
mod/glossary/lib.php

diff --combined mod/glossary/lib.php
@@@ -2787,9 -2787,6 +2787,9 @@@ function glossary_reset_course_form_def
  
      $mform->addElement('checkbox', 'reset_glossary_comments', get_string('deleteallcomments'));
      $mform->disabledIf('reset_glossary_comments', 'reset_glossary_all', 'checked');
 +
 +    $mform->addElement('checkbox', 'reset_glossary_tags', get_string('removeallglossarytags', 'glossary'));
 +    $mform->disabledIf('reset_glossary_tags', 'reset_glossary_all', 'checked');
  }
  
  /**
@@@ -2879,8 -2876,6 +2879,8 @@@ function glossary_reset_userdata($data
                  //delete ratings
                  $ratingdeloptions->contextid = $context->id;
                  $rm->delete_ratings($ratingdeloptions);
 +
 +                core_tag_tag::delete_instances('mod_glossary', null, $context->id);
              }
          }
  
                      //delete ratings
                      $ratingdeloptions->contextid = $context->id;
                      $rm->delete_ratings($ratingdeloptions);
 +
 +                    core_tag_tag::delete_instances('mod_glossary', null, $context->id);
                  }
              }
  
                      //delete ratings
                      $ratingdeloptions->contextid = $context->id;
                      $rm->delete_ratings($ratingdeloptions);
 +
 +                    core_tag_tag::delete_instances('mod_glossary', null, $context->id);
                  }
              }
  
          $status[] = array('component'=>$componentstr, 'item'=>get_string('deleteallcomments'), 'error'=>false);
      }
  
 +    // Remove all the tags.
 +    if (!empty($data->reset_glossary_tags)) {
 +        if ($glossaries = $DB->get_records_sql($allglossariessql, $params)) {
 +            foreach ($glossaries as $glossaryid => $unused) {
 +                if (!$cm = get_coursemodule_from_instance('glossary', $glossaryid)) {
 +                    continue;
 +                }
 +
 +                $context = context_module::instance($cm->id);
 +                core_tag_tag::delete_instances('mod_glossary', null, $context->id);
 +            }
 +        }
 +
 +        $status[] = array('component' => $componentstr, 'item' => get_string('tagsdeleted', 'glossary'), 'error' => false);
 +    }
 +
      /// updating dates - shift may be negative too
      if ($data->timeshift) {
          // Any changes to the list of dates that needs to be rolled should be same during course restore and course reset.
@@@ -3846,7 -3821,7 +3846,7 @@@ function glossary_get_entries_by_search
      $count = $DB->count_records_sql("SELECT COUNT(DISTINCT(ge.id)) $sqlfrom $sqlwhere", $params);
  
      $query = "$sqlwrapheader $sqlselect $sqlfrom $sqlwhere $sqlwrapfooter $sqlorderby";
-     $entries = $DB->get_recordset_sql($query, $params, $from, $limit);
+     $entries = $DB->get_records_sql($query, $params, $from, $limit);
  
      return array($entries, $count);
  }