Merge branch 'MDL-68758-master' of git://github.com/peterRd/moodle
authorSara Arjona <sara@moodle.com>
Wed, 27 May 2020 07:46:47 +0000 (09:46 +0200)
committerSara Arjona <sara@moodle.com>
Wed, 27 May 2020 07:46:47 +0000 (09:46 +0200)
1  2 
lib/templates/filemanager_page_generallayout.mustache
repository/lib.php

                      </a>
                  </div>
                  <div class="fp-btn-download">
-                     <a role="button" title="{{#str}}downloadselected, repository{{/str}}" class="btn btn-secondary btn-sm" href="#">
+                     <a role="button" title="{{#str}}download, repository{{/str}}" class="btn btn-secondary btn-sm" href="#">
                          {{#pix}}a/download_all{{/pix}}
                      </a>
                  </div>
                  <div class="fp-btn-delete">
-                     <a role="button" title="{{#str}}deleteselected, repository{{/str}}" class="btn btn-secondary btn-sm" href="#">
+                     <a role="button" title="{{#str}}delete{{/str}}" class="btn btn-secondary btn-sm" href="#">
                          {{#pix}}i/trash{{/pix}}
                      </a>
                  </div>
@@@ -72,7 -72,7 +72,7 @@@
              </div>
          </div>
          <div class="fp-pathbar">
 -            <span class="fp-path-folder"><a class="fp-path-folder-name" href="#"></a></span>
 +            <span class="fp-path-folder"><a class="fp-path-folder-name aalink" href="#"></a></span>
          </div>
      </div>
      <div class="filemanager-loading mdl-align">{{#pix}}i/loading_small{{/pix}}<span class="sr-only">{{#str}}loadinghelp{{/str}}</span></div>
diff --combined repository/lib.php
@@@ -3115,14 -3115,21 +3115,14 @@@ final class repository_type_form extend
   *          accepted_types
   */
  function initialise_filepicker($args) {
 -    global $CFG, $USER, $PAGE, $OUTPUT;
 +    global $CFG, $USER, $PAGE;
      static $templatesinitialized = array();
      require_once($CFG->libdir . '/licenselib.php');
  
      $return = new stdClass();
 -    $licenses = array();
 -    if (!empty($CFG->licenses)) {
 -        $array = explode(',', $CFG->licenses);
 -        foreach ($array as $license) {
 -            $l = new stdClass();
 -            $l->shortname = $license;
 -            $l->fullname = get_string($license, 'license');
 -            $licenses[] = $l;
 -        }
 -    }
 +
 +    $licenses = license_manager::get_licenses();
 +
      if (!empty($CFG->sitedefaultlicense)) {
          $return->defaultlicense = $CFG->sitedefaultlicense;
      }
          $return->externallink = true;
      }
  
 +    $return->rememberuserlicensepref = (bool) get_config(null, 'rememberuserlicensepref');
 +
      $return->userprefs = array();
      $return->userprefs['recentrepository'] = get_user_preferences('filepicker_recentrepository', '');
      $return->userprefs['recentlicense'] = get_user_preferences('filepicker_recentlicense', '');
@@@ -3267,7 -3272,7 +3267,7 @@@ function repository_download_selected_f
      $filestoarchive = [];
  
      foreach ($files as $selectedfile) {
-         $filename = clean_filename($selectedfile->filename); // Default to '.' for root.
+         $filename = $selectedfile->filename ? clean_filename($selectedfile->filename) : '.'; // Default to '.' for root.
          $filepath = clean_param($selectedfile->filepath, PARAM_PATH); // Default to '/' for downloadall.
          $filepath = file_correct_filepath($filepath);
          $area = file_get_draft_area_info($itemid, $filepath);
          // If it is empty we are downloading a directory.
          $archivefile = $storedfile->get_filename();
          if (!$filename || $filename == '.' ) {
-             $archivefile = $filepath;
+             $foldername = explode('/', trim($filepath, '/'));
+             $folder = trim(array_pop($foldername), '/');
+             $archivefile = $folder ?? '/';
          }
  
          $filestoarchive[$archivefile] = $storedfile;