/**
  *
  * @global <type> $CFG
  * @param <type> $encodedpath
  * @param <type> $search
  * @return <type>
  */
 public function get_listing($encodedpath = '', $page = '', $search = '')
 {
     global $CFG;
     try {
         return repository::get_user_file_tree($search);
     } catch (Exception $e) {
         throw new repository_exception('emptyfilelist', 'repository_local');
     }
 }
 /**
  * Retrieve file list for a user of the Moodle client calling this function
  * @global <type> $DB
  * @global <type> $USER
  * @global <type> $MNET_REMOTE_CLIENT
  * @global <type> $CFG
  * @param <type> $username
  * @param <type> $search
  * @return <type>
  */
 public function getFileList($username, $search)
 {
     global $DB, $USER, $MNET_REMOTE_CLIENT, $CFG;
     ///check the the user is known
     ///he has to be previously connected to the server site in order to be in the database
     //TODO: this seems weird - is it executed from cron or what? Please review
     $USER = $DB->get_record('user', array('username' => $username, 'mnethostid' => $MNET_REMOTE_CLIENT->id));
     if (empty($USER)) {
         exit(mnet_server_fault(9016, get_string('usernotfound', 'repository_remotemoodle', $username)));
     }
     try {
         return repository::get_user_file_tree($search);
     } catch (Exception $e) {
         exit(mnet_server_fault(9016, get_string('failtoretrievelist', 'repository_remotemoodle')));
     }
 }