ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ilWebDAVRepositoryHelper Class Reference

Class ilWebDAVRepositoryHelper. More...

+ Collaboration diagram for ilWebDAVRepositoryHelper:

Public Member Functions

 __construct (ilAccessHandler $access, ilTree $tree)
 ilWebDAVRepositoryHelper constructor. More...
 
 deleteObject (int $a_ref_id)
 I stole this method of deleting objects from ilObjectGUI->confirmedDeleteObject() More...
 
 checkAccess (string $a_permission, int $a_ref_id)
 Just a redirect to the checkAccess method of ilAccess. More...
 
 checkCreateAccessForType (int $a_ref_id, string $a_type)
 Just a redirect to the checkAccess method of ilAccess to check for creation of certain obj types. More...
 
 objectWithRefIdExists (int $a_ref_id)
 Just a redirect to the ilObject::_exists. More...
 
 getObjectIdFromRefId (int $a_ref_id)
 Just a redirect to the ilObject::_lookupObjectId function. More...
 
 getObjectTitleFromObjId (int $a_obj_id, bool $escape_forbidden_fileextension=false)
 Just a redirect to the ilObject::_lookupTitle function. More...
 
 getFilenameWithSanitizedFileExtension (int $a_obj_id)
 Wraps the static call to ilObject::_lookupTitle. More...
 
 getObjectTypeFromObjId (int $a_obj_id)
 Just a redirect to the ilObject::_lookupType function. More...
 
 getObjectTitleFromRefId (int $a_ref_id, bool $escape_forbidden_fileextension=false)
 Just a shortcut and redirect to get a title from a given ref_id. More...
 
 getObjectTypeFromRefId (int $a_ref_id)
 Just a redirect to the ilObject::_lookupType function. More...
 
 getChildrenOfRefId (int $a_ref_id)
 Just a redirect to getChildIds of ilTree. More...
 

Protected Member Functions

 getRawObjectTitleFromObjId (int $a_obj_id)
 Wraps the static call to ilObject::_lookupTitle. More...
 

Protected Attributes

 $access
 
 $tree
 

Detailed Description

Class ilWebDAVRepositoryHelper.

This is a helper class and mostly also a wrapper class for repository actions. It is used by ilObj*DAV objects and makes them more unit testable. This is really helpful since static calls like ilObject::_exists() are not mockable

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.ilWebDAVRepositoryHelper.php.

Constructor & Destructor Documentation

◆ __construct()

ilWebDAVRepositoryHelper::__construct ( ilAccessHandler  $access,
ilTree  $tree 
)

ilWebDAVRepositoryHelper constructor.

Parameters
ilAccessHandler$access
ilTree$tree

Definition at line 26 of file class.ilWebDAVRepositoryHelper.php.

References $access, and $tree.

Member Function Documentation

◆ checkAccess()

ilWebDAVRepositoryHelper::checkAccess ( string  $a_permission,
int  $a_ref_id 
)

Just a redirect to the checkAccess method of ilAccess.

Parameters
$a_permission
$a_ref_id
Returns
bool

Definition at line 52 of file class.ilWebDAVRepositoryHelper.php.

52  : bool
53  {
54  return $this->access->checkAccess($a_permission, '', $a_ref_id);
55  }

◆ checkCreateAccessForType()

ilWebDAVRepositoryHelper::checkCreateAccessForType ( int  $a_ref_id,
string  $a_type 
)

Just a redirect to the checkAccess method of ilAccess to check for creation of certain obj types.

Parameters
int$a_ref_id
string$a_type
Returns
bool

Definition at line 64 of file class.ilWebDAVRepositoryHelper.php.

64  : bool
65  {
66  return $this->access->checkAccess('create', '', $a_ref_id, $a_type);
67  }

◆ deleteObject()

ilWebDAVRepositoryHelper::deleteObject ( int  $a_ref_id)

I stole this method of deleting objects from ilObjectGUI->confirmedDeleteObject()

Parameters
$a_ref_idref_id of object to delete
Exceptions
ilRepositoryException

Definition at line 38 of file class.ilWebDAVRepositoryHelper.php.

39  {
40  $repository_util = new ilRepUtil($this);
41  $parent = $this->tree->getParentId($a_ref_id);
42  $repository_util->deleteObjects($parent, array($a_ref_id));
43  }
Repository Utilities (application layer, put GUI related stuff into ilRepUtilGUI) ...

◆ getChildrenOfRefId()

ilWebDAVRepositoryHelper::getChildrenOfRefId ( int  $a_ref_id)

Just a redirect to getChildIds of ilTree.

Parameters
$a_ref_id
Returns
mixed

Definition at line 185 of file class.ilWebDAVRepositoryHelper.php.

186  {
187  return $this->tree->getChildIds($a_ref_id);
188  }

◆ getFilenameWithSanitizedFileExtension()

ilWebDAVRepositoryHelper::getFilenameWithSanitizedFileExtension ( int  $a_obj_id)

Wraps the static call to ilObject::_lookupTitle.

This is on one hand necessary to create unit tests. And on the other hand, it guarantees the return of a string, which ilObject::_lookupTitle() doesn't.

Parameters
int$a_obj_id
Returns
string
Exceptions
ilFileUtilsException

Definition at line 115 of file class.ilWebDAVRepositoryHelper.php.

References Vendor\Package\$e, getRawObjectTitleFromObjId(), and ilFileUtils\getValidFilename().

Referenced by getObjectTitleFromObjId().

115  : string
116  {
117  $unescaped_title = $this->getRawObjectTitleFromObjId($a_obj_id);
118 
119  try {
120  $escaped_title = ilFileUtils::getValidFilename($unescaped_title);
121  } catch (ilFileUtilsException $e) {
122  $escaped_title = "";
123  }
124 
125  return is_string($escaped_title) ? $escaped_title : '';
126  }
getRawObjectTitleFromObjId(int $a_obj_id)
Wraps the static call to ilObject::_lookupTitle.
static getValidFilename($a_filename)
Get valid filename.
Class to report exception.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjectIdFromRefId()

ilWebDAVRepositoryHelper::getObjectIdFromRefId ( int  $a_ref_id)

Just a redirect to the ilObject::_lookupObjectId function.

Parameters
$a_ref_id
Returns
int+

Definition at line 86 of file class.ilWebDAVRepositoryHelper.php.

References ilObject\_lookupObjectId().

Referenced by getObjectTitleFromRefId().

86  : int
87  {
88  return ilObject::_lookupObjectId($a_ref_id);
89  }
static _lookupObjectId($a_ref_id)
lookup object id
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjectTitleFromObjId()

ilWebDAVRepositoryHelper::getObjectTitleFromObjId ( int  $a_obj_id,
bool  $escape_forbidden_fileextension = false 
)

Just a redirect to the ilObject::_lookupTitle function.

Parameters
$a_obj_id
Returns

Definition at line 97 of file class.ilWebDAVRepositoryHelper.php.

References ilObject\_lookupType(), getFilenameWithSanitizedFileExtension(), and getRawObjectTitleFromObjId().

Referenced by getObjectTitleFromRefId().

97  : string
98  {
99  if ($escape_forbidden_fileextension && ilObject::_lookupType($a_obj_id) == 'file') {
100  $title = $this->getFilenameWithSanitizedFileExtension($a_obj_id);
101  } else {
102  $title = $this->getRawObjectTitleFromObjId($a_obj_id);
103  }
104 
105  return is_string($title)? $title : '';
106  }
getFilenameWithSanitizedFileExtension(int $a_obj_id)
Wraps the static call to ilObject::_lookupTitle.
getRawObjectTitleFromObjId(int $a_obj_id)
Wraps the static call to ilObject::_lookupTitle.
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getObjectTitleFromRefId()

ilWebDAVRepositoryHelper::getObjectTitleFromRefId ( int  $a_ref_id,
bool  $escape_forbidden_fileextension = false 
)

Just a shortcut and redirect to get a title from a given ref_id.

Parameters
$a_ref_id
Returns
mixed

Definition at line 160 of file class.ilWebDAVRepositoryHelper.php.

References getObjectIdFromRefId(), and getObjectTitleFromObjId().

160  : string
161  {
162  $obj_id = $this->getObjectIdFromRefId($a_ref_id);
163 
164  return $this->getObjectTitleFromObjId($obj_id, $escape_forbidden_fileextension);
165  }
getObjectIdFromRefId(int $a_ref_id)
Just a redirect to the ilObject::_lookupObjectId function.
getObjectTitleFromObjId(int $a_obj_id, bool $escape_forbidden_fileextension=false)
Just a redirect to the ilObject::_lookupTitle function.
+ Here is the call graph for this function:

◆ getObjectTypeFromObjId()

ilWebDAVRepositoryHelper::getObjectTypeFromObjId ( int  $a_obj_id)

Just a redirect to the ilObject::_lookupType function.

Parameters
$a_ref_id
Returns
mixed

Definition at line 147 of file class.ilWebDAVRepositoryHelper.php.

References $type, and ilObject\_lookupType().

147  : string
148  {
149  $type = ilObject::_lookupType($a_obj_id, false);
150  return $type === null ? '' : $type;
151  }
$type
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

◆ getObjectTypeFromRefId()

ilWebDAVRepositoryHelper::getObjectTypeFromRefId ( int  $a_ref_id)

Just a redirect to the ilObject::_lookupType function.

Parameters
$a_ref_id
Returns
mixed

Definition at line 173 of file class.ilWebDAVRepositoryHelper.php.

References $type, and ilObject\_lookupType().

173  : string
174  {
175  $type = ilObject::_lookupType($a_ref_id, true);
176  return is_string($type) ? $type : '';
177  }
$type
static _lookupType($a_id, $a_reference=false)
lookup object type
+ Here is the call graph for this function:

◆ getRawObjectTitleFromObjId()

ilWebDAVRepositoryHelper::getRawObjectTitleFromObjId ( int  $a_obj_id)
protected

Wraps the static call to ilObject::_lookupTitle.

This is on one hand necessary to create unit tests. And on the other hand, it guarantees the return of a string, which ilObject::_lookupTitle() doesn't.

Parameters
int$a_obj_id
Returns
string

Definition at line 135 of file class.ilWebDAVRepositoryHelper.php.

References ilObject\_lookupTitle().

Referenced by getFilenameWithSanitizedFileExtension(), and getObjectTitleFromObjId().

135  : string
136  {
137  $title = ilObject::_lookupTitle($a_obj_id);
138  return is_string($title) ? $title : '';
139  }
static _lookupTitle($a_id)
lookup object title
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ objectWithRefIdExists()

ilWebDAVRepositoryHelper::objectWithRefIdExists ( int  $a_ref_id)

Just a redirect to the ilObject::_exists.

Parameters
$a_ref_id
Returns
bool

Definition at line 75 of file class.ilWebDAVRepositoryHelper.php.

References ilObject\_exists().

75  : int
76  {
77  return ilObject::_exists($a_ref_id, true);
78  }
static _exists($a_id, $a_reference=false, $a_type=null)
checks if an object exists in object_data
+ Here is the call graph for this function:

Field Documentation

◆ $access

ilWebDAVRepositoryHelper::$access
protected

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

Referenced by __construct().

◆ $tree

ilWebDAVRepositoryHelper::$tree
protected

Definition at line 18 of file class.ilWebDAVRepositoryHelper.php.

Referenced by __construct().


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