original_string: protected static function remove_excess_backups_from_course($course, $now) {
          $fs = get_file_storage();
          $context = context_course::instance($course->id);
          $component = 'backup';
          $filearea = 'automated';
          $itemid = 0;
          $backupfiles = array();
          $backupfilesarea = $fs->get_area_files($context->id, $component, $filearea, $itemid, 'timemodified DESC', false);
          // Store all the matching files into timemodified => stored_file array.
          foreach ($backupfilesarea as $backupfile) {
              $backupfiles[$backupfile->get_timemodified()] = $backupfile;
          }
  
          $backupstodelete = self::get_backups_to_delete($backupfiles, $now);
          if ($backupstodelete) {
              foreach ($backupstodelete as $backuptodelete) {
                  $backuptodelete->delete();
              }
              mtrace('Deleted ' . count($backupstodelete) . ' old backup file(s) from the automated filearea');
              return true;
          } else {
              return false;
          }
      }
code: protected static function remove_excess_backups_from_course($course, $now) {
          $fs = get_file_storage();
          $context = context_course::instance($course->id);
          $component = 'backup';
          $filearea = 'automated';
          $itemid = 0;
          $backupfiles = array();
          $backupfilesarea = $fs->get_area_files($context->id, $component, $filearea, $itemid, 'timemodified DESC', false);
          // Store all the matching files into timemodified => stored_file array.
          foreach ($backupfilesarea as $backupfile) {
              $backupfiles[$backupfile->get_timemodified()] = $backupfile;
          }
  
          $backupstodelete = self::get_backups_to_delete($backupfiles, $now);
          if ($backupstodelete) {
              foreach ($backupstodelete as $backuptodelete) {
                  $backuptodelete->delete();
              }
              mtrace('Deleted ' . count($backupstodelete) . ' old backup file(s) from the automated filearea');
              return true;
          } else {
              return false;
          }
      }
code_tokens: protected static function remove_excess_backups_from_course ( $ course , $ now ) { $ fs = get_file_storage ( ) ; $ context = context_course :: instance ( $ course -> id ) ; $ component = 'backup' ; $ filearea = 'automated' ; $ itemid = 0 ; $ backupfiles = array ( ) ; $ backupfilesarea = $ fs -> get_area_files ( $ context -> id , $ component , $ filearea , $ itemid , 'timemodified DESC' , false ) ; // Store all the matching files into timemodified => stored_file array. foreach ( $ backupfilesarea as $ backupfile ) { $ backupfiles [ $ backupfile -> get_timemodified ( ) ] = $ backupfile ; } $ backupstodelete = self :: get_backups_to_delete ( $ backupfiles , $ now ) ; if ( $ backupstodelete ) { foreach ( $ backupstodelete as $ backuptodelete ) { $ backuptodelete -> delete ( ) ; } mtrace ( 'Deleted ' . count ( $ backupstodelete ) . ' old backup file(s) from the automated filearea' ) ; return true ; } else { return false ; } }
docstring: Removes excess backups in the course backup filearea from a specified course.
  
  @param stdClass $course Course object
  @param int $now Starting time of the process
  @return bool Whether or not backups are being removed
docstring_tokens: Removes excess backups in the course backup filearea from a specified course .