public static function remove_excess_backups($course, $now = null) {
        $config = get_config('backup');
        $maxkept = (int)$config->backup_auto_max_kept;
        $storage = $config->backup_auto_storage;
        $deletedays = (int)$config->backup_auto_delete_days;

        if ($maxkept == 0 && $deletedays == 0) {
            // Means keep all backup files and never delete backup after x days.
            return true;
        }

        if (!isset($now)) {
            $now = time();
        }

        // Clean up excess backups in the course backup filearea.
        $deletedcoursebackups = false;
        if ($storage == self::STORAGE_COURSE || $storage == self::STORAGE_COURSE_AND_DIRECTORY) {
            $deletedcoursebackups = self::remove_excess_backups_from_course($course, $now);
        }

        // Clean up excess backups in the specified external directory.
        $deleteddirectorybackups = false;
        if ($storage == self::STORAGE_DIRECTORY || $storage == self::STORAGE_COURSE_AND_DIRECTORY) {
            $deleteddirectorybackups = self::remove_excess_backups_from_directory($course, $now);
        }

        if ($deletedcoursebackups || $deleteddirectorybackups) {
            return true;
        } else {
            return false;
        }
    }
public static function remove_excess_backups($course, $now = null) {
        $config = get_config('backup');
        $maxkept = (int)$config->backup_auto_max_kept;
        $storage = $config->backup_auto_storage;
        $deletedays = (int)$config->backup_auto_delete_days;

        if ($maxkept == 0 && $deletedays == 0) {
            // Means keep all backup files and never delete backup after x days.
            return true;
        }

        if (!isset($now)) {
            $now = time();
        }

        // Clean up excess backups in the course backup filearea.
        $deletedcoursebackups = false;
        if ($storage == self::STORAGE_COURSE || $storage == self::STORAGE_COURSE_AND_DIRECTORY) {
            $deletedcoursebackups = self::remove_excess_backups_from_course($course, $now);
        }

        // Clean up excess backups in the specified external directory.
        $deleteddirectorybackups = false;
        if ($storage == self::STORAGE_DIRECTORY || $storage == self::STORAGE_COURSE_AND_DIRECTORY) {
            $deleteddirectorybackups = self::remove_excess_backups_from_directory($course, $now);
        }

        if ($deletedcoursebackups || $deleteddirectorybackups) {
            return true;
        } else {
            return false;
        }
    }
public static function remove_excess_backups ( $ course , $ now = null ) { $ config = get_config ( 'backup' ) ; $ maxkept = ( int ) $ config -> backup_auto_max_kept ; $ storage = $ config -> backup_auto_storage ; $ deletedays = ( int ) $ config -> backup_auto_delete_days ; if ( $ maxkept == 0 && $ deletedays == 0 ) { // Means keep all backup files and never delete backup after x days. return true ; } if ( ! isset ( $ now ) ) { $ now = time ( ) ; } // Clean up excess backups in the course backup filearea. $ deletedcoursebackups = false ; if ( $ storage == self :: STORAGE_COURSE || $ storage == self :: STORAGE_COURSE_AND_DIRECTORY ) { $ deletedcoursebackups = self :: remove_excess_backups_from_course ( $ course , $ now ) ; } // Clean up excess backups in the specified external directory. $ deleteddirectorybackups = false ; if ( $ storage == self :: STORAGE_DIRECTORY || $ storage == self :: STORAGE_COURSE_AND_DIRECTORY ) { $ deleteddirectorybackups = self :: remove_excess_backups_from_directory ( $ course , $ now ) ; } if ( $ deletedcoursebackups || $ deleteddirectorybackups ) { return true ; } else { return false ; } }
Removes excess backups from a specified course.

@param stdClass $course Course object
@param int $now Starting time of the process
@return bool Whether or not backups is being removed
Removes excess backups from a specified course .