ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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, $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.

References $repo_helper.

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

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 119 of file class.ilWebDAVObjDAVHelper.php.

References $type.

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

◆ 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 106 of file class.ilWebDAVObjDAVHelper.php.

Referenced by isDAVableObjTitle().

107  {
108  $prefix = substr($title, 0, 1);
109  return $prefix === '.';
110  }
+ 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 88 of file class.ilWebDAVObjDAVHelper.php.

Referenced by isDAVableObjTitle().

88  : bool
89  {
90  foreach (str_split('\\<>/:*?"|#') as $forbidden_character) {
91  if (strpos($title, $forbidden_character) !== false) {
92  return true;
93  }
94  }
95 
96  return false;
97  }
+ Here is the caller graph for this function:

◆ isDAVableObject()

ilWebDAVObjDAVHelper::isDAVableObject (   $id,
  $is_reference = true,
  $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.

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

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.
$type
isDAVableObjType(string $type)
Check if the given object type is compatible to be represented as a WebDAV object.
if(!array_key_exists('StateId', $_REQUEST)) $id
+ 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.

References hasInvalidPrefixInTitle(), and hasTitleForbiddenChars().

Referenced by isDAVableObject(), and isValidFileNameWithValidFileExtension().

76  : bool
77  {
78  return ($this->hasTitleForbiddenChars($title) === false)
79  && ($this->hasInvalidPrefixInTitle($title) === false);
80  }
hasInvalidPrefixInTitle(string $title)
Forbidden are titles that begin with a single dot.
hasTitleForbiddenChars(string $title)
Check for forbidden chars in title that are making trouble if displayed in WebDAV.
+ 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.

Referenced by isDAVableObject().

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  }
$type
+ Here is the caller graph for this function:

◆ isValidFileNameWithValidFileExtension()

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

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

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

152  : bool
153  {
154  include_once("./Services/Utilities/classes/class.ilFileUtils.php");
155  return $a_title == ilFileUtils::getValidFilename($a_title) && $this->isDAVableObjTitle($a_title);
156  }
isDAVableObjTitle(string $title)
Check if title is displayable in WebDAV.
static getValidFilename($a_filename)
Get valid filename.
+ 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: