ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilExportLimitation.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
26{
27 protected const SET_LIMIT_NUMBER = "rep_export_limit_number";
28 protected const SET_LIMITATION = "rep_export_limitation";
29 public const SET_EXPORT_DISABLED = 1;
30 public const SET_EXPORT_LIMITED = 0;
31
32 protected ilTree $tree;
34 protected ilLanguage $lng;
35
36 public function __construct()
37 {
38 global $DIC;
39
40 $this->tree = $DIC->repositoryTree();
41 $this->settings = $DIC->settings();
42 $this->lng = $DIC->language();
43 }
44
45 public function getLimitationMode(): int
46 {
47 return (int) $this->settings->get(self::SET_LIMITATION);
48 }
49
50 public function getLimitationNumber(): int
51 {
52 return (int) $this->settings->get(self::SET_LIMIT_NUMBER);
53 }
54
55 public function checkLimitation(int $ref_id, array $options): void
56 {
57 $max = (int) $this->settings->get(self::SET_LIMIT_NUMBER);
58
61 $this->lng->txt("exp_error_disabled")
62 );
63 }
64
65 $cnt = 0;
66 foreach ($this->tree->getSubTree($root = $this->tree->getNodeData($ref_id)) as $node) {
67 if (isset($options[$node["child"]]) && (in_array((int) $options[$node["child"]]["type"], [1, 2]))) {
68 $cnt++;
69 }
70 }
71 if ($max > 0 && $cnt > $max) {
72 throw new ilExportLimitationExceptionException(str_replace(
73 "%1",
74 (string) $max,
75 $this->lng->txt("exp_error_too_many_objects")
76 ));
77 }
78 }
79}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Export limitation checker.
checkLimitation(int $ref_id, array $options)
language handling
ILIAS Setting Class.
Tree class data representation in hierachical trees using the Nested Set Model with Gaps by Joe Celco...
$ref_id
Definition: ltiauth.php:66
global $DIC
Definition: shib_login.php:26