ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 53 of file class.ilWebDAVRepositoryHelper.php.

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

◆ 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 65 of file class.ilWebDAVRepositoryHelper.php.

65  : bool
66  {
67  return $this->access->checkAccess('create', '', $a_ref_id, $a_type);
68  }
$a_type
Definition: workflow.php:92

◆ 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  include_once("./Services/Repository/classes/class.ilRepUtil.php");
41  $repository_util = new ilRepUtil($this);
42  $parent = $this->tree->getParentId($a_ref_id);
43  $repository_util->deleteObjects($parent, array($a_ref_id));
44  }
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 186 of file class.ilWebDAVRepositoryHelper.php.

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

◆ 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 116 of file class.ilWebDAVRepositoryHelper.php.

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

Referenced by getObjectTitleFromObjId().

116  : string
117  {
118  $unescaped_title = $this->getRawObjectTitleFromObjId($a_obj_id);
119 
120  try {
121  $escaped_title = ilFileUtils::getValidFilename($unescaped_title);
122  } catch (ilFileUtilsException $e) {
123  $escaped_title = "";
124  }
125 
126  return is_string($escaped_title) ? $escaped_title : '';
127  }
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 87 of file class.ilWebDAVRepositoryHelper.php.

References ilObject\_lookupObjectId().

Referenced by getObjectTitleFromRefId().

87  : int
88  {
89  return ilObject::_lookupObjectId($a_ref_id);
90  }
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 98 of file class.ilWebDAVRepositoryHelper.php.

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

Referenced by getObjectTitleFromRefId().

98  : string
99  {
100  if ($escape_forbidden_fileextension && ilObject::_lookupType($a_obj_id) == 'file') {
101  $title = $this->getFilenameWithSanitizedFileExtension($a_obj_id);
102  } else {
103  $title = $this->getRawObjectTitleFromObjId($a_obj_id);
104  }
105 
106  return is_string($title)? $title : '';
107  }
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 161 of file class.ilWebDAVRepositoryHelper.php.

References getObjectIdFromRefId(), and getObjectTitleFromObjId().

161  : string
162  {
163  $obj_id = $this->getObjectIdFromRefId($a_ref_id);
164 
165  return $this->getObjectTitleFromObjId($obj_id, $escape_forbidden_fileextension);
166  }
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 148 of file class.ilWebDAVRepositoryHelper.php.

References $type, and ilObject\_lookupType().

148  : string
149  {
150  $type = ilObject::_lookupType($a_obj_id, false);
151  return $type === null ? '' : $type;
152  }
$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 174 of file class.ilWebDAVRepositoryHelper.php.

References $type, and ilObject\_lookupType().

174  : string
175  {
176  $type = ilObject::_lookupType($a_ref_id, true);
177  return is_string($type) ? $type : '';
178  }
$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 136 of file class.ilWebDAVRepositoryHelper.php.

References $title, and ilObject\_lookupTitle().

Referenced by getFilenameWithSanitizedFileExtension(), and getObjectTitleFromObjId().

136  : string
137  {
138  $title = ilObject::_lookupTitle($a_obj_id);
139  return is_string($title) ? $title : '';
140  }
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 76 of file class.ilWebDAVRepositoryHelper.php.

References ilObject\_exists().

76  : int
77  {
78  return ilObject::_exists($a_ref_id, true);
79  }
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: