ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilProblemInfoFileDAV Class Reference
+ Inheritance diagram for ilProblemInfoFileDAV:
+ Collaboration diagram for ilProblemInfoFileDAV:

Public Member Functions

 __construct (ilObjContainerDAV $a_dav_container, ilWebDAVRepositoryHelper $a_repo_helper, ilWebDAVObjDAVHelper $a_dav_helper)
 
 put ($data)
 Since this is a virtual file, put is not possible. More...
 
 get ()
 Get the information about problems in the DAV directory. More...
 
 getName ()
 Returns the title of the problem info file. More...
 
 getContentType ()
 Returns the mime-type for a file which is 'txt/plain'. More...
 
 getETag ()
 Returns the ETag for a file. More...
 
 getSize ()
 Returns the size of the node, in bytes. More...
 
 setName ($a_name)
 
 delete ()
 Deleted the current node. More...
 
 getLastModified ()
 Returns the last modification time, as a unix timestamp. More...
 

Data Fields

const PROBLEM_INFO_FILE_NAME = '#!_WEBDAV_INFORMATION.txt'
 
const PROBLEM_DUPLICATE_OBJECTNAME = 'duplicate'
 
const PROBLEM_FORBIDDEN_CHARACTERS = 'forbidden_characters'
 
const PROBLEM_INFO_NAME_DUPLICATE = 'info_name_duplicate'
 

Protected Member Functions

 analyseObjectsOfDAVContainer ()
 Analyses objects of the in the constructor given DAV container. More...
 
 createMessageStringFromProblemInfoArray (array $problem_infos)
 Creates a message string out of the found problems in the DAV container. More...
 

Protected Attributes

 $dav_container
 
 $repo_helper
 
 $dav_helper
 

Detailed Description

Definition at line 5 of file class.ilProblemInfoFileDAV.php.

Constructor & Destructor Documentation

◆ __construct()

ilProblemInfoFileDAV::__construct ( ilObjContainerDAV  $a_dav_container,
ilWebDAVRepositoryHelper  $a_repo_helper,
ilWebDAVObjDAVHelper  $a_dav_helper 
)

Definition at line 22 of file class.ilProblemInfoFileDAV.php.

26  {
27  $this->dav_container = $a_dav_container;
28  $this->repo_helper = $a_repo_helper;
29  $this->dav_helper = $a_dav_helper;
30  }

Member Function Documentation

◆ analyseObjectsOfDAVContainer()

ilProblemInfoFileDAV::analyseObjectsOfDAVContainer ( )
protected

Analyses objects of the in the constructor given DAV container.

Returns
array

Definition at line 118 of file class.ilProblemInfoFileDAV.php.

References $type.

Referenced by get().

118  : array
119  {
120  // list of titles that were already checked (used for duplicate checking)
121  $already_seen_titles = array();
122 
123  // Array with 3 different problem topics
124  $problem_infos = array(
125  self::PROBLEM_DUPLICATE_OBJECTNAME => array(),
126  self::PROBLEM_FORBIDDEN_CHARACTERS => array(),
127  self::PROBLEM_INFO_NAME_DUPLICATE => false // if a file is already named #!_WEBDAV_INFORMATION.txt (should not be the case)
128  );
129 
130  // Loop to check every child of the container
131  foreach ($this->repo_helper->getChildrenOfRefId($this->dav_container->getRefId()) as $ref_id) {
132  $type = $this->repo_helper->getObjectTypeFromRefId($ref_id);
133  if ($this->dav_helper->isDAVableObjType($type) && $this->repo_helper->checkAccess('read', $ref_id)) {
134  $title = $this->repo_helper->getObjectTitleFromRefId($ref_id);
135  if (!$this->dav_helper->hasInvalidPrefixInTitle($title)) {
136  // Check if object is a file with the same name as this info file
137  if ($title == self::PROBLEM_INFO_FILE_NAME) {
138  $problem_infos[self::PROBLEM_INFO_NAME_DUPLICATE] = true;
139  }
140  // Check if title contains forbidden characters
141  elseif ($this->dav_helper->hasTitleForbiddenChars($title)) {
142  $problem_infos[self::PROBLEM_FORBIDDEN_CHARACTERS][] = $title;
143  }
144  // Check for duplicates
145  elseif (in_array($title, $already_seen_titles)) {
146  $problem_infos[self::PROBLEM_DUPLICATE_OBJECTNAME][] = $title;
147  } else {
148  $already_seen_titles[] = $title;
149  }
150  }
151  }
152  }
153 
154  return $problem_infos;
155  }
$type
+ Here is the caller graph for this function:

◆ createMessageStringFromProblemInfoArray()

ilProblemInfoFileDAV::createMessageStringFromProblemInfoArray ( array  $problem_infos)
protected

Creates a message string out of the found problems in the DAV container.

Parameters
array$problem_infos
Returns
string

Definition at line 163 of file class.ilProblemInfoFileDAV.php.

References $DIC, and $lng.

Referenced by get().

164  {
165  global $DIC;
166 
167  $lng = $DIC->language();
168  $message_string = "";
169 
170  // If there is a file with the same name of the problem info file -> print message about it
171  if ($problem_infos[self::PROBLEM_INFO_NAME_DUPLICATE]) {
172  $message_string .= "# " . $lng->txt('webdav_problem_info_duplicate') . "\n\n";
173  }
174 
175  // Print list with duplicate file names
176  $duplicates_list = $problem_infos[self::PROBLEM_DUPLICATE_OBJECTNAME];
177  if (count($duplicates_list) > 0) {
178  $message_string .= "# " . $lng->txt('webdav_duplicate_detected_title') . "\n";
179  foreach ($duplicates_list as $duplicate_title) {
180  $message_string .= $duplicate_title . "\n";
181  }
182  $message_string .= "\n";
183  }
184 
185  // Print list of files with forbidden characters
186  $forbidden_character_titles_list = $problem_infos[self::PROBLEM_FORBIDDEN_CHARACTERS];
187  if (count($forbidden_character_titles_list) > 0) {
188  $message_string .= "# " . $lng->txt('webdav_forbidden_chars_title') . "\n";
189  foreach ($forbidden_character_titles_list as $forbidden_character_title) {
190  $message_string .= $forbidden_character_title . "\n";
191  }
192  $message_string .= "\n";
193  }
194 
195  // If no problems were found -> create a default message (this happens only if the file is called directly)
196  if (strlen($message_string) == 0) {
197  $message_string = $lng->txt('webdav_problem_free_container');
198  }
199 
200  return $message_string;
201  }
$lng
$DIC
Definition: xapitoken.php:46
+ Here is the caller graph for this function:

◆ delete()

ilProblemInfoFileDAV::delete ( )

Deleted the current node.

Returns
void

Definition at line 208 of file class.ilProblemInfoFileDAV.php.

209  {
210  throw new \Sabre\DAV\Exception\Forbidden("It is not possible to delete this file since it is just virtual.");
211  }

◆ get()

ilProblemInfoFileDAV::get ( )

Get the information about problems in the DAV directory.

Returns
mixed

Definition at line 49 of file class.ilProblemInfoFileDAV.php.

References analyseObjectsOfDAVContainer(), and createMessageStringFromProblemInfoArray().

50  {
51  $problem_infos = $this->analyseObjectsOfDAVContainer();
52  return $this->createMessageStringFromProblemInfoArray($problem_infos);
53  }
analyseObjectsOfDAVContainer()
Analyses objects of the in the constructor given DAV container.
createMessageStringFromProblemInfoArray(array $problem_infos)
Creates a message string out of the found problems in the DAV container.
+ Here is the call graph for this function:

◆ getContentType()

ilProblemInfoFileDAV::getContentType ( )

Returns the mime-type for a file which is 'txt/plain'.

Returns
string|null

Definition at line 70 of file class.ilProblemInfoFileDAV.php.

71  {
72  return 'text/plain';
73  }

◆ getETag()

ilProblemInfoFileDAV::getETag ( )

Returns the ETag for a file.

An ETag is a unique identifier representing the current version of the file. If the file changes, the ETag MUST change.

Return null if the ETag can not effectively be determined.

The ETag must be surrounded by double-quotes, so something like this would make a valid ETag:

return '"someetag"';

Returns
string|null

Definition at line 89 of file class.ilProblemInfoFileDAV.php.

90  {
91  return null;
92  }

◆ getLastModified()

ilProblemInfoFileDAV::getLastModified ( )

Returns the last modification time, as a unix timestamp.

Return null if the information is not available.

Returns
int|null

Definition at line 219 of file class.ilProblemInfoFileDAV.php.

220  {
221  return null;
222  }

◆ getName()

ilProblemInfoFileDAV::getName ( )

Returns the title of the problem info file.

Returns
string

Definition at line 60 of file class.ilProblemInfoFileDAV.php.

61  {
62  return self::PROBLEM_INFO_FILE_NAME;
63  }

◆ getSize()

ilProblemInfoFileDAV::getSize ( )

Returns the size of the node, in bytes.

Returns
int

Definition at line 99 of file class.ilProblemInfoFileDAV.php.

100  {
101  return 0;
102  }

◆ put()

ilProblemInfoFileDAV::put (   $data)

Since this is a virtual file, put is not possible.

Parameters
resource | string$data
Returns
string|null
Exceptions
Forbidden

Definition at line 39 of file class.ilProblemInfoFileDAV.php.

40  {
41  throw new Forbidden("The error info file is virtual and can therefore not be overwritten");
42  }

◆ setName()

ilProblemInfoFileDAV::setName (   $a_name)
Parameters
string$a_name
Exceptions
Forbidden

Definition at line 108 of file class.ilProblemInfoFileDAV.php.

109  {
110  throw new Exception\Forbidden("The error info file cannot be renamed");
111  }

Field Documentation

◆ $dav_container

ilProblemInfoFileDAV::$dav_container
protected

Definition at line 14 of file class.ilProblemInfoFileDAV.php.

◆ $dav_helper

ilProblemInfoFileDAV::$dav_helper
protected

Definition at line 20 of file class.ilProblemInfoFileDAV.php.

◆ $repo_helper

ilProblemInfoFileDAV::$repo_helper
protected

Definition at line 17 of file class.ilProblemInfoFileDAV.php.

◆ PROBLEM_DUPLICATE_OBJECTNAME

const ilProblemInfoFileDAV::PROBLEM_DUPLICATE_OBJECTNAME = 'duplicate'

Definition at line 9 of file class.ilProblemInfoFileDAV.php.

◆ PROBLEM_FORBIDDEN_CHARACTERS

const ilProblemInfoFileDAV::PROBLEM_FORBIDDEN_CHARACTERS = 'forbidden_characters'

Definition at line 10 of file class.ilProblemInfoFileDAV.php.

◆ PROBLEM_INFO_FILE_NAME

const ilProblemInfoFileDAV::PROBLEM_INFO_FILE_NAME = '#!_WEBDAV_INFORMATION.txt'

Definition at line 7 of file class.ilProblemInfoFileDAV.php.

Referenced by ilObjContainerDAV\getChild().

◆ PROBLEM_INFO_NAME_DUPLICATE

const ilProblemInfoFileDAV::PROBLEM_INFO_NAME_DUPLICATE = 'info_name_duplicate'

Definition at line 11 of file class.ilProblemInfoFileDAV.php.


The documentation for this class was generated from the following file: