Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 18... Línea 18...
18
 
18
 
Línea 19... Línea 19...
19
namespace core_reportbuilder;
19
namespace core_reportbuilder;
20
 
20
 
-
 
21
use context;
21
use context;
22
use context_system;
22
use context_system;
23
use core_reportbuilder\exception\report_access_exception;
23
use core_reportbuilder\local\helpers\audience;
24
use core_reportbuilder\local\helpers\audience;
Línea 24... Línea 25...
24
use core_reportbuilder\local\models\report;
25
use core_reportbuilder\local\models\report;
Línea 180... Línea 181...
180
    public static function require_can_create_report(?int $userid = null, ?context $context = null): void {
181
    public static function require_can_create_report(?int $userid = null, ?context $context = null): void {
181
        if (!static::can_create_report($userid, $context)) {
182
        if (!static::can_create_report($userid, $context)) {
182
            throw new report_access_exception('errorreportcreate');
183
            throw new report_access_exception('errorreportcreate');
183
        }
184
        }
184
    }
185
    }
-
 
186
 
-
 
187
    /**
-
 
188
     * Whether given user can duplicate a report
-
 
189
     *
-
 
190
     * @param report $report
-
 
191
     * @param int|null $userid User ID to check, or the current user if omitted
-
 
192
     * @param context|null $context
-
 
193
     * @return bool
-
 
194
     */
-
 
195
    public static function can_duplicate_report(report $report, ?int $userid = null, ?context $context = null): bool {
-
 
196
        return static::can_edit_report($report, $userid) && static::can_create_report($userid, $context);
-
 
197
    }
-
 
198
 
-
 
199
    /**
-
 
200
     * Require given user can duplicate a report
-
 
201
     *
-
 
202
     * @param report $report
-
 
203
     * @param int|null $userid User ID to check, or the current user if omitted
-
 
204
     * @param context|null $context
-
 
205
     * @throws report_access_exception
-
 
206
     */
-
 
207
    public static function require_can_duplicate_report(report $report, ?int $userid = null, ?context $context = null): void {
-
 
208
        if (!static::can_duplicate_report($report, $userid, $context)) {
-
 
209
            throw new report_access_exception('errorreportduplicate');
-
 
210
        }
-
 
211
    }
185
}
212
}