ILIAS  release_7 Revision v7.30-3-g800a261c036
ilWebDAVObjDAVHelper Class Reference

Class ilWebDAVObjDAVHelper. More...

+ Collaboration diagram for ilWebDAVObjDAVHelper:

Public Member Functions

 __construct (ilWebDAVRepositoryHelper $repo_helper)
 ilWebDAVObjDAVHelper constructor. More...
 
 isDAVableObject ($id, $is_reference=true, bool $do_name_check=true)
 Check if given object (either obj_id or ref_id) is compatible to be represented as a WebDAV object. More...
 
 isDAVableObjType (string $type)
 Check if the given object type is compatible to be represented as a WebDAV object. More...
 
 isDAVableObjTitle (string $title)
 Check if title is displayable in WebDAV. More...
 
 hasTitleForbiddenChars (string $title)
 Check for forbidden chars in title that are making trouble if displayed in WebDAV. More...
 
 hasInvalidPrefixInTitle (string $title)
 Forbidden are titles that begin with a single dot. More...
 
 createDAVObjectForRefId (int $ref_id, string $type='')
 Creates a DAV Object for the given ref id. More...
 
 isValidFileNameWithValidFileExtension (string $a_title)
 

Protected Attributes

 $repo_helper
 

Detailed Description

Class ilWebDAVObjDAVHelper.

This class is a helper class for WebDAV functionalities that are used from ilObj*DAV Objects. With this class, the behavior of the objects itself are unit testable.

Author
Raphael Heer rapha.nosp@m.el.h.nosp@m.eer@h.nosp@m.slu..nosp@m.ch $Id$

Definition at line 12 of file class.ilWebDAVObjDAVHelper.php.

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVObjDAVHelper::__construct ( ilWebDAVRepositoryHelper  $repo_helper)

ilWebDAVObjDAVHelper constructor.

Parameters
ilWebDAVRepositoryHelper$repo_helper

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

23 {
24 $this->repo_helper = $repo_helper;
25 }

References $repo_helper.

Member Function Documentation

◆ createDAVObjectForRefId()

ilWebDAVObjDAVHelper::createDAVObjectForRefId ( int  $ref_id,
string  $type = '' 
)

Creates a DAV Object for the given ref id.

Parameters
integer$ref_id
string$type
Returns
ilObjectDAV

Definition at line 124 of file class.ilWebDAVObjDAVHelper.php.

125 {
126 if ($type == '') {
127 $type = $this->repo_helper->getObjectTypeFromRefId($ref_id);
128 }
129
130 if ($this->repo_helper->objectWithRefIdExists($ref_id)) {
131 switch ($type) {
132 case 'cat':
133 return new ilObjCategoryDAV(new ilObjCategory($ref_id, true), $this->repo_helper, $this);
134
135 case 'crs':
136 return new ilObjCourseDAV(new ilObjCourse($ref_id, true), $this->repo_helper, $this);
137
138 case 'grp':
139 return new ilObjGroupDAV(new ilObjGroup($ref_id, true), $this->repo_helper, $this);
140
141 case 'fold':
142 return new ilObjFolderDAV(new ilObjFolder($ref_id, true), $this->repo_helper, $this);
143
144 case 'file':
145 return new ilObjFileDAV(new ilObjFile($ref_id, true), $this->repo_helper, $this);
146 }
147 }
148 throw new BadRequest('Unknown filetype');
149 }
Class ilObjCategoryDAV.
Class ilObjCategory.
Class ilObjCourseDAV.
Class ilObjCourse.
Class ilObjFileDAV.
Class ilObjFile.
Class ilObjFolderDAV.
Class ilObjFolder.
Class ilObjGroupDAV.
Class ilObjGroup.
Class ilObjectDAV.
$type

References $type.

◆ hasInvalidPrefixInTitle()

ilWebDAVObjDAVHelper::hasInvalidPrefixInTitle ( string  $title)

Forbidden are titles that begin with a single dot.

There are also forbidden prefixes like '.$' or '..'. But since they both start with a single dot, we can aim only for that.

Parameters
$title
Returns
bool

Definition at line 111 of file class.ilWebDAVObjDAVHelper.php.

112 {
113 $prefix = substr($title, 0, 1);
114 return $prefix === '.';
115 }

Referenced by isDAVableObjTitle().

+ Here is the caller graph for this function:

◆ hasTitleForbiddenChars()

ilWebDAVObjDAVHelper::hasTitleForbiddenChars ( string  $title)

Check for forbidden chars in title that are making trouble if displayed in WebDAV.

Parameters
$title
Returns
bool

Definition at line 93 of file class.ilWebDAVObjDAVHelper.php.

93 : bool
94 {
95 foreach (str_split('\\<>/:*?"|#') as $forbidden_character) {
96 if (strpos($title, $forbidden_character) !== false) {
97 return true;
98 }
99 }
100
101 return false;
102 }

Referenced by isDAVableObjTitle().

+ Here is the caller graph for this function:

◆ isDAVableObject()

ilWebDAVObjDAVHelper::isDAVableObject (   $id,
  $is_reference = true,
bool  $do_name_check = true 
)

Check if given object (either obj_id or ref_id) is compatible to be represented as a WebDAV object.

Parameters
$id
bool$is_reference
bool$do_name_check
Returns
bool

Definition at line 34 of file class.ilWebDAVObjDAVHelper.php.

35 {
36 $obj_id = $is_reference ? $this->repo_helper->getObjectIdFromRefId($id) : $id;
37
38 $type = $this->repo_helper->getObjectTypeFromObjId($obj_id);
39 $title = $this->repo_helper->getObjectTitleFromObjId($obj_id);
40
41 if($do_name_check) {
42 $is_davable = $this->isDAVableObjType($type) && $this->isDAVableObjTitle($title);
43 } else {
44 $is_davable = $this->isDAVableObjType($type);
45 }
46
47 return $is_davable;
48 }
isDAVableObjTitle(string $title)
Check if title is displayable in WebDAV.
isDAVableObjType(string $type)
Check if the given object type is compatible to be represented as a WebDAV object.

References $type, isDAVableObjTitle(), and isDAVableObjType().

+ Here is the call graph for this function:

◆ isDAVableObjTitle()

ilWebDAVObjDAVHelper::isDAVableObjTitle ( string  $title)

Check if title is displayable in WebDAV.

Parameters
$title
Returns
bool

Definition at line 76 of file class.ilWebDAVObjDAVHelper.php.

76 : bool
77 {
78 if ($this->hasTitleForbiddenChars($title)) {
79 return false;
80 }
81 if ($this->hasInvalidPrefixInTitle($title)) {
82 return false;
83 }
84 return true;
85 }
hasTitleForbiddenChars(string $title)
Check for forbidden chars in title that are making trouble if displayed in WebDAV.
hasInvalidPrefixInTitle(string $title)
Forbidden are titles that begin with a single dot.

References hasInvalidPrefixInTitle(), and hasTitleForbiddenChars().

Referenced by isDAVableObject(), and isValidFileNameWithValidFileExtension().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isDAVableObjType()

ilWebDAVObjDAVHelper::isDAVableObjType ( string  $type)

Check if the given object type is compatible to be represented as a WebDAV object.

Parameters
$type
Returns
bool

Definition at line 56 of file class.ilWebDAVObjDAVHelper.php.

56 : bool
57 {
58 switch ($type) {
59 case 'cat':
60 case 'crs':
61 case 'grp':
62 case 'fold':
63 case 'file':
64 return true;
65
66 default:
67 return false;
68 }
69 }

References $type.

Referenced by isDAVableObject().

+ Here is the caller graph for this function:

◆ isValidFileNameWithValidFileExtension()

ilWebDAVObjDAVHelper::isValidFileNameWithValidFileExtension ( string  $a_title)
Parameters
$a_title
Returns
bool
Exceptions
ilFileUtilsException

Definition at line 157 of file class.ilWebDAVObjDAVHelper.php.

157 : bool
158 {
159 return $a_title == ilFileUtils::getValidFilename($a_title) && $this->isDAVableObjTitle($a_title);
160 }
static getValidFilename($a_filename)
Get valid filename.

References ilFileUtils\getValidFilename(), and isDAVableObjTitle().

+ Here is the call graph for this function:

Field Documentation

◆ $repo_helper

ilWebDAVObjDAVHelper::$repo_helper
protected

Definition at line 15 of file class.ilWebDAVObjDAVHelper.php.

Referenced by __construct().


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