19 declare(strict_types=1);
34 protected int $container_ref_id,
43 throw new Forbidden(
"The error info file is virtual and can therefore not be overwritten");
54 return self::PROBLEM_INFO_FILE_NAME;
74 throw new Forbidden(
"The error info file cannot be renamed");
82 $already_seen_titles = [];
85 self::PROBLEM_DUPLICATE_OBJECTNAME => [],
86 self::PROBLEM_FORBIDDEN_CHARACTERS => [],
87 self::PROBLEM_INFO_NAME_DUPLICATE => false
90 foreach ($this->repo_helper->getChildrenOfRefId($this->container_ref_id) as
$ref_id) {
92 $dav_object = $this->dav_object_factory->retrieveDAVObjectByRefID(
$ref_id);
94 $title = $dav_object->getName();
96 if ($title === self::PROBLEM_INFO_FILE_NAME) {
97 $problem_infos[self::PROBLEM_INFO_NAME_DUPLICATE] =
true;
98 } elseif (in_array($title, $already_seen_titles)) {
99 $problem_infos[self::PROBLEM_DUPLICATE_OBJECTNAME][] = $title;
101 $already_seen_titles[] = $title;
105 $title = $this->repo_helper->getObjectTitleFromRefId(
$ref_id);
106 $problem_infos[self::PROBLEM_FORBIDDEN_CHARACTERS][] = $title;
112 return $problem_infos;
120 $message_string =
"";
122 if ($problem_infos[self::PROBLEM_INFO_NAME_DUPLICATE]) {
123 $message_string .=
"# " . $this->
language->txt(
'webdav_problem_info_duplicate') .
"\n\n";
126 $duplicates_list = $problem_infos[self::PROBLEM_DUPLICATE_OBJECTNAME];
127 if (count($duplicates_list) > 0) {
128 $message_string .=
"# " . $this->
language->txt(
'webdav_duplicate_detected_title') .
"\n";
129 foreach ($duplicates_list as $duplicate_title) {
130 $message_string .= $duplicate_title .
"\n";
132 $message_string .=
"\n";
135 $forbidden_character_titles_list = $problem_infos[self::PROBLEM_FORBIDDEN_CHARACTERS];
136 if (count($forbidden_character_titles_list) > 0) {
137 $message_string .=
"# " . $this->
language->txt(
'webdav_forbidden_chars_title') .
"\n";
138 foreach ($forbidden_character_titles_list as $forbidden_character_title) {
139 $message_string .= $forbidden_character_title .
"\n";
141 $message_string .=
"\n";
144 if ($message_string ===
'') {
145 return $this->
language->txt(
'webdav_problem_free_container');
148 return $message_string;
151 public function delete():
void 153 throw new Forbidden(
"It is not possible to delete this file since it is just virtual.");
const PROBLEM_INFO_FILE_NAME
const OBJECT_TITLE_NOT_DAVABLE
const PROBLEM_INFO_NAME_DUPLICATE
__construct(protected int $container_ref_id, protected ilWebDAVRepositoryHelper $repo_helper, protected ilWebDAVObjFactory $dav_object_factory, protected ilLanguage $language)
createMessageStringFromProblemInfoArray(array $problem_infos)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
analyseObjectsOfDAVContainer()
const PROBLEM_FORBIDDEN_CHARACTERS
const PROBLEM_DUPLICATE_OBJECTNAME
language()
description: > Example for rendring a language glyph.