Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 60... Línea 60...
60
        // Now we can call our helper methods to add the content we want to include in the report.
60
        // Now we can call our helper methods to add the content we want to include in the report.
61
        $this->add_columns();
61
        $this->add_columns();
62
        $this->add_filters();
62
        $this->add_filters();
63
        $this->add_actions();
63
        $this->add_actions();
Línea -... Línea 64...
-
 
64
 
-
 
65
        $this->set_initial_sort_column('badge_issued:issued', SORT_DESC);
-
 
66
        $this->set_default_no_results_notice(new lang_string('nomatchingawards', 'core_badges'));
64
 
67
 
65
        // Set if report can be downloaded.
68
        // Set if report can be downloaded.
66
        $this->set_downloadable(false);
69
        $this->set_downloadable(false);
Línea 67... Línea 70...
67
    }
70
    }
68
 
71
 
69
    /**
72
    /**
70
     * Validates access to view this report
73
     * Validates access to view this report
71
     *
74
     *
72
     * @return bool
75
     * @return bool
-
 
76
     */
-
 
77
    protected function can_view(): bool {
73
     */
78
        $badgeid = $this->get_parameter('badgeid', 0, PARAM_INT);
74
    protected function can_view(): bool {
79
        $badge = new \core_badges\badge($badgeid);
Línea 75... Línea 80...
75
        return has_capability('moodle/badges:viewawarded', $this->get_context());
80
        return has_capability('moodle/badges:viewawarded', $badge->get_context());
76
    }
81
    }
77
 
82
 
78
    /**
83
    /**
79
     * Adds the columns we want to display in the report
84
     * Adds the columns we want to display in the report
80
     *
85
     *
81
     * They are provided by the entities we previously added in the {@see initialise} method, referencing each by their
86
     * They are provided by the entities we previously added in the {@see initialise} method, referencing each by their
82
     * unique identifier. If custom columns are needed just for this report, they can be defined here.
87
     * unique identifier. If custom columns are needed just for this report, they can be defined here.
83
     */
88
     */
84
    public function add_columns(): void {
89
    protected function add_columns(): void {
85
        $columns = [
90
        $this->add_columns_from_entities([
86
            'user:fullnamewithlink',
-
 
87
            'badge_issued:issued',
-
 
88
        ];
-
 
89
 
91
            'user:fullnamewithlink',
Línea 90... Línea 92...
90
        $this->add_columns_from_entities($columns);
92
            'badge_issued:issued',
91
        $this->set_initial_sort_column('badge_issued:issued', SORT_DESC);
93
        ]);
92
    }
94
    }
93
 
95
 
94
    /**
96
    /**
95
     * Adds the filters we want to display in the report
97
     * Adds the filters we want to display in the report
96
     *
98
     *
97
     * They are all provided by the entities we previously added in the {@see initialise} method, referencing each by their
99
     * They are all provided by the entities we previously added in the {@see initialise} method, referencing each by their
98
     * unique identifier
100
     * unique identifier
99
     */
101
     */
100
    protected function add_filters(): void {
102
    protected function add_filters(): void {
101
        $filters = [
-
 
102
            'user:fullname',
-
 
103
            'badge_issued:issued',
103
        $this->add_filters_from_entities([
Línea 104... Línea 104...
104
        ];
104
            'user:fullname',
105
 
105
            'badge_issued:issued',
106
        $this->add_filters_from_entities($filters);
106
        ]);