ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
class.ilFileUploadSettings.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2013 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
16 {
19 
24  private static $instance = null;
25 
30  private $settings = null;
31 
36  private $dndUploadEnabled = true;
37 
43 
48  private $concurrentUploads = self::CONCURRENT_UPLOADS_DEFAULT;
49 
53  private function __construct()
54  {
55  $this->settings = new ilSetting("fileupload");
56  $this->dndUploadEnabled = $this->settings->get("dnd_upload_enabled", true) == true;
57  $this->repositoryDndUploadEnabled = $this->settings->get("repository_dnd_upload_enabled", true) == true;
58  $this->concurrentUploads = $this->settings->get("concurrent_upload_count", self::CONCURRENT_UPLOADS_DEFAULT);
59  }
60 
67  public static function setDragAndDropUploadEnabled($newValue)
68  {
69  $instance = self::getInstance();
70  $instance->dndUploadEnabled = $newValue == true;
71  $instance->settings->set("dnd_upload_enabled", $instance->dndUploadEnabled);
72  }
73 
79  public static function isDragAndDropUploadEnabled()
80  {
81  return self::getInstance()->dndUploadEnabled;
82  }
83 
90  public static function setRepositoryDragAndDropUploadEnabled($newValue)
91  {
92  $instance = self::getInstance();
93  $instance->repositoryDndUploadEnabled = $newValue == true;
94  $instance->settings->set("repository_dnd_upload_enabled", $instance->repositoryDndUploadEnabled);
95  }
96 
102  public static function isRepositoryDragAndDropUploadEnabled()
103  {
104  return self::getInstance()->repositoryDndUploadEnabled;
105  }
106 
113  public static function setConcurrentUploads($newValue)
114  {
115  // is number?
116  if (is_numeric($newValue)) {
117  // don't allow to large numbers
118  $newValue = (int) $newValue;
119  if ($newValue < 1) {
120  $newValue = 1;
121  } elseif ($newValue > self::CONCURRENT_UPLOADS_MAX) {
122  $newValue = self::CONCURRENT_UPLOADS_MAX;
123  }
124  } else {
125  $newValue = self::CONCURRENT_UPLOADS_DEFAULT;
126  }
127 
128  $instance = self::getInstance();
129  $instance->concurrentUploads = $newValue;
130  $instance->settings->set("concurrent_upload_count", $instance->concurrentUploads);
131  }
132 
138  public static function getConcurrentUploads()
139  {
140  return self::getInstance()->concurrentUploads;
141  }
142 
147  private static function getInstance()
148  {
149  if (self::$instance == null) {
150  self::$instance = new ilFileUploadSettings();
151  }
152 
153  return self::$instance;
154  }
155 }
static setDragAndDropUploadEnabled($newValue)
Sets whether drag and drop file upload is enabled.
static setRepositoryDragAndDropUploadEnabled($newValue)
Sets whether drag and drop file upload in the repository is enabled.
settings()
Definition: settings.php:2
static getConcurrentUploads()
Gets the number of files that can be uploaded at the same time.
static setConcurrentUploads($newValue)
Sets the number of files that can be uploaded at the same time.
static getInstance()
Gets the instance of the ilFileUploadSettings.
static isRepositoryDragAndDropUploadEnabled()
Gets whether drag and drop file upload in the repository is enabled.
__construct()
Private constructor.
static isDragAndDropUploadEnabled()
Gets whether drag and drop file upload is enabled.