ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilExportLimitation.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4 
11 {
12  const SET_LIMIT_NUMBER = "rep_export_limit_number";
13  const SET_LIMITATION = "rep_export_limitation";
15  const SET_EXPORT_LIMITED = 0;
16 
17 
21  protected $tree;
22 
26  protected $settings;
27 
31  protected $lng;
32 
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 
50  public function getLimitationMode()
51  {
52  return (int) $this->settings->get(self::SET_LIMITATION);
53  }
54 
60  public function getLimitationNumber()
61  {
62  return (int) $this->settings->get(self::SET_LIMIT_NUMBER);
63  }
64 
70  public function checkLimitation($ref_id, $options)
71  {
74  $lng = $this->lng;
75 
76  $max = (int) $settings->get(self::SET_LIMIT_NUMBER);
77 
78  if ($this->getLimitationMode() == self::SET_EXPORT_DISABLED) {
80  $lng->txt("exp_error_disabled")
81  );
82  }
83 
84  $cnt = 0;
85  foreach ($tree->getSubTree($root = $tree->getNodeData($ref_id)) as $node) {
86  if (isset($options[$node["child"]]) && (in_array((int) $options[$node["child"]]["type"], [1,2]))) {
87  $cnt++;
88  }
89  }
90  if ($max > 0 && $cnt > $max) {
91  throw new ilExportLimitationExceptionException(str_replace(
92  "%1",
93  $max,
94  $lng->txt("exp_error_too_many_objects")
95  ));
96  }
97  }
98 }
settings()
Definition: settings.php:2
getLimitationMode()
Get limitation mode.
getLimitationNumber()
Get limitation number.
checkLimitation($ref_id, $options)
Export limitation checker.
$DIC
Definition: xapitoken.php:46