ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilObjMediaObjectAccess Class Reference

Class ilObjMediaObjectAccess. More...

+ Inheritance diagram for ilObjMediaObjectAccess:
+ Collaboration diagram for ilObjMediaObjectAccess:

Public Member Functions

 __construct ()
 Constructor. More...
 
 canBeDelivered (ilWACPath $ilWACPath)
 

Protected Member Functions

 checkAccessMob ($obj_id)
 
 checkAccessObject ($obj_id, $obj_type='')
 Check access rights for an object by its object id. More...
 
 checkAccessTestQuestion ($obj_id, $usage_id=0)
 Check access rights for a test question This checks also tests with random selection of questions. More...
 
 checkAccessGlossaryTerm ($obj_id, $page_id)
 Check access rights for glossary terms This checks also learning modules linking the term. More...
 
 checkAccessPortfolioPage ($obj_id, $page_id)
 Check access rights for portfolio pages. More...
 
 checkAccessBlogPage ($obj_id)
 Check access rights for blog pages. More...
 
 checkAccessLearningObjectivePage ($obj_id, $page_id)
 

Protected Attributes

 $obj_data_cache
 
 $user
 
 $access
 

Detailed Description

Class ilObjMediaObjectAccess.

Author
Fabian Schmid fs@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
Version
1.0.0

Definition at line 11 of file class.ilObjMediaObjectAccess.php.

Constructor & Destructor Documentation

◆ __construct()

ilObjMediaObjectAccess::__construct ( )

Constructor.

Definition at line 32 of file class.ilObjMediaObjectAccess.php.

References $DIC, and user().

33  {
34  global $DIC;
35 
36  $this->obj_data_cache = $DIC["ilObjDataCache"];
37  $this->user = $DIC->user();
38  $this->access = $DIC->access();
39  }
user()
Definition: user.php:4
$DIC
Definition: xapitoken.php:46
+ Here is the call graph for this function:

Member Function Documentation

◆ canBeDelivered()

ilObjMediaObjectAccess::canBeDelivered ( ilWACPath  $ilWACPath)
Parameters
ilWACPath$ilWACPath
Returns
bool

Implements ilWACCheckingClass.

Definition at line 47 of file class.ilObjMediaObjectAccess.php.

References checkAccessMob(), and ilWACPath\getPath().

48  {
49  preg_match("/.\\/data\\/.*\\/mm_([0-9]*)\\/.*/ui", $ilWACPath->getPath(), $matches);
50  $obj_id = $matches[1];
51 
52  return $this->checkAccessMob($obj_id);
53  }
+ Here is the call graph for this function:

◆ checkAccessBlogPage()

ilObjMediaObjectAccess::checkAccessBlogPage (   $obj_id)
protected

Check access rights for blog pages.

Parameters
intobject id (glossary)
intpage id (definition)
Returns
boolean access given (true/false)

Definition at line 370 of file class.ilObjMediaObjectAccess.php.

References $ilUser, $user, and checkAccessObject().

Referenced by checkAccessMob().

371  {
373  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceTree.php";
374  $tree = new ilWorkspaceTree(0);
375  $node_id = $tree->lookupNodeId($obj_id);
376  if (!$node_id) {
377  return $this->checkAccessObject($obj_id);
378  } else {
379  include_once "Services/PersonalWorkspace/classes/class.ilWorkspaceAccessHandler.php";
380 
381  $access_handler = new ilWorkspaceAccessHandler($tree);
382  if ($access_handler->checkAccessOfUser($tree, $ilUser->getId(), "read", "view", $node_id, "blog")) {
383  return true;
384  }
385  }
386 
387  return false;
388  }
Access handler for personal workspace.
checkAccessObject($obj_id, $obj_type='')
Check access rights for an object by its object id.
Tree handler for personal workspace.
$ilUser
Definition: imgupload.php:18
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkAccessGlossaryTerm()

ilObjMediaObjectAccess::checkAccessGlossaryTerm (   $obj_id,
  $page_id 
)
protected

Check access rights for glossary terms This checks also learning modules linking the term.

Parameters
intobject id (glossary)
intpage id (definition)
Returns
boolean access given (true/false)

Definition at line 298 of file class.ilObjMediaObjectAccess.php.

References ilInternalLink\_getSourcesOfTarget(), ilLMObject\_lookupContObjID(), ilGlossaryDefinition\_lookupTermId(), and checkAccessObject().

Referenced by checkAccessMob().

299  {
300  // give access if glossary is readable
301  if ($this->checkAccessObject($obj_id)) {
302  return true;
303  }
304 
305  $term_id = ilGlossaryDefinition::_lookupTermId($page_id);
306 
307  include_once('./Services/Link/classes/class.ilInternalLink.php');
308  $sources = ilInternalLink::_getSourcesOfTarget('git', $term_id, 0);
309 
310  if ($sources) {
311  foreach ($sources as $src) {
312  switch ($src['type']) {
313  // Give access if term is linked by a learning module with read access.
314  // The term including media is shown by the learning module presentation!
315  case 'lm:pg':
316  include_once("./Modules/LearningModule/classes/class.ilLMObject.php");
317  $src_obj_id = ilLMObject::_lookupContObjID($src['id']);
318  if ($this->checkAccessObject($src_obj_id, 'lm')) {
319  return true;
320  }
321  break;
322 
323  // Don't yet give access if the term is linked by another glossary
324  // The link will lead to the origin glossary which is already checked
325  /*
326  case 'gdf:pg':
327  $src_term_id = ilGlossaryDefinition::_lookupTermId($src['id']);
328  $src_obj_id = ilGlossaryTerm::_lookGlossaryID($src_term_id);
329  if ($this->checkAccessObject($src_obj_id, 'glo'))
330  {
331  return true;
332  }
333  break;
334  */
335  }
336  }
337  }
338  }
static _lookupContObjID($a_id)
get learning module / digibook id for lm object
checkAccessObject($obj_id, $obj_type='')
Check access rights for an object by its object id.
static _lookupTermId($a_def_id)
Looks up term id for a definition id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkAccessLearningObjectivePage()

ilObjMediaObjectAccess::checkAccessLearningObjectivePage (   $obj_id,
  $page_id 
)
protected
Parameters
$obj_id
$page_id
Returns
bool

Definition at line 397 of file class.ilObjMediaObjectAccess.php.

References ilCourseObjective\_lookupContainerIdByObjectiveId(), and checkAccessObject().

Referenced by checkAccessMob().

398  {
399  include_once "Modules/Course/classes/class.ilCourseObjective.php";
401 
402  return $this->checkAccessObject($crs_obj_id, 'crs');
403  }
static _lookupContainerIdByObjectiveId($a_objective_id)
Get container of object.
checkAccessObject($obj_id, $obj_type='')
Check access rights for an object by its object id.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkAccessMob()

ilObjMediaObjectAccess::checkAccessMob (   $obj_id)
protected
Parameters
$obj_id
Returns
bool

Definition at line 61 of file class.ilObjMediaObjectAccess.php.

References $ilUser, $obj_data_cache, $user, ilObjMediaCastAccess\_lookupPublicFiles(), ilNewsItem\_lookupVisibility(), checkAccessBlogPage(), checkAccessGlossaryTerm(), checkAccessLearningObjectivePage(), checkAccessObject(), checkAccessPortfolioPage(), checkAccessTestQuestion(), ilObjMediaObject\getParentObjectIdForUsage(), ilImprint\isActive(), ilMediaPoolPage\lookupUsages(), ilObjMediaObject\lookupUsages(), ilForumPostDraft\newInstanceByDraftId(), NEWS_PUBLIC, and user().

Referenced by canBeDelivered().

62  {
63  foreach (ilObjMediaObject::lookupUsages($obj_id) as $usage) {
65 
66  // for content snippets we must get their usages and check them
67  switch ($usage["type"]) {
68  case "auth:pg":
69  // Mobs on the Loginpage should always be delivered
70  return true;
71  case "mep:pg":
72  include_once("./Modules/MediaPool/classes/class.ilMediaPoolPage.php");
73  $usages2 = ilMediaPoolPage::lookupUsages($usage["id"]);
74  foreach ($usages2 as $usage2) {
75  $oid2 = ilObjMediaObject::getParentObjectIdForUsage($usage2, true);
76  if ($this->checkAccessMobUsage($usage2, $oid2)) {
77  return true;
78  }
79  }
80  break;
81 
82  case "clip":
83  if ($usage["id"] == $this->user->getId()) {
84  return true;
85  }
86  break;
87 
88  default:
89  if ($this->checkAccessMobUsage($usage, $oid)) {
90  return true;
91  }
92  break;
93  }
94  }
95 
96  return false;
97  }
user()
Definition: user.php:4
static lookupUsages($a_id, $a_include_history=true)
Lookup usages of media object.
static lookupUsages($a_id, $a_incl_hist=true)
Lookup usages of media object.
static getParentObjectIdForUsage($a_usage, $a_include_all_access_obj_ids=false)
Get's the repository object ID of a parent object, if possible.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ checkAccessObject()

ilObjMediaObjectAccess::checkAccessObject (   $obj_id,
  $obj_type = '' 
)
protected

Check access rights for an object by its object id.

Parameters
intobject id
Returns
boolean access given (true/false)

Definition at line 231 of file class.ilObjMediaObjectAccess.php.

References $access, $ilUser, $user, ilObject\_getAllReferences(), and ilObject\_lookupType().

Referenced by checkAccessBlogPage(), checkAccessGlossaryTerm(), checkAccessLearningObjectivePage(), checkAccessMob(), and checkAccessTestQuestion().

232  {
233  $ilAccess = $this->access;
235  $user_id = $ilUser->getId();
236 
237  if (!$obj_type) {
238  $obj_type = ilObject::_lookupType($obj_id);
239  }
240  $ref_ids = ilObject::_getAllReferences($obj_id);
241 
242  foreach ($ref_ids as $ref_id) {
243  // foreach ($this->check_users as $user_id) {
244  if ($ilAccess->checkAccessOfUser($user_id, "read", "view", $ref_id, $obj_type, $obj_id)) {
245  return true;
246  }
247  // }
248  }
249 
250  return false;
251  }
static _getAllReferences($a_id)
get all reference ids of object
$ilUser
Definition: imgupload.php:18
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:

◆ checkAccessPortfolioPage()

ilObjMediaObjectAccess::checkAccessPortfolioPage (   $obj_id,
  $page_id 
)
protected

Check access rights for portfolio pages.

Parameters
intobject id (glossary)
intpage id (definition)
Returns
boolean access given (true/false)

Definition at line 349 of file class.ilObjMediaObjectAccess.php.

References $ilUser, and $user.

Referenced by checkAccessMob().

350  {
352  include_once "Modules/Portfolio/classes/class.ilPortfolioAccessHandler.php";
353  $access_handler = new ilPortfolioAccessHandler();
354  if ($access_handler->checkAccessOfUser($ilUser->getId(), "read", "view", $obj_id, "prtf")) {
355  return true;
356  }
357 
358  return false;
359  }
$ilUser
Definition: imgupload.php:18
Access handler for portfolio.
+ Here is the caller graph for this function:

◆ checkAccessTestQuestion()

ilObjMediaObjectAccess::checkAccessTestQuestion (   $obj_id,
  $usage_id = 0 
)
protected

Check access rights for a test question This checks also tests with random selection of questions.

Parameters
intobject id (question pool or test)
intusage id (not yet used)
Returns
boolean access given (true/false)

Definition at line 263 of file class.ilObjMediaObjectAccess.php.

References $access, ilObjTestAccess\_getRandomTestsForQuestionPool(), ilObject\_lookupType(), and checkAccessObject().

Referenced by checkAccessMob().

264  {
265  $ilAccess = $this->access;
266 
267  // give access if direct usage is readable
268  if ($this->checkAccessObject($obj_id)) {
269  return true;
270  }
271 
272  $obj_type = ilObject::_lookupType($obj_id);
273  if ($obj_type == 'qpl') {
274  // give access if question pool is used by readable test
275  // for random selection of questions
276  include_once('./Modules/Test/classes/class.ilObjTestAccess.php');
278  foreach ($tests as $test_id) {
279  if ($this->checkAccessObject($test_id, 'tst')) {
280  return true;
281  }
282  }
283  }
284 
285  return false;
286  }
checkAccessObject($obj_id, $obj_type='')
Check access rights for an object by its object id.
static _getRandomTestsForQuestionPool($qpl_id)
Get all tests using a question pool for random selection.
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:

Field Documentation

◆ $access

ilObjMediaObjectAccess::$access
protected

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

Referenced by checkAccessObject(), and checkAccessTestQuestion().

◆ $obj_data_cache

ilObjMediaObjectAccess::$obj_data_cache
protected

Definition at line 16 of file class.ilObjMediaObjectAccess.php.

Referenced by checkAccessMob().

◆ $user

ilObjMediaObjectAccess::$user
protected

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