ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilObjUserAccess.php
Go to the documentation of this file.
1 <?php
2 
26 {
27  public static function _getCommands(): array
28  {
29  throw new ilException("_getCommands must not be called on user object.");
30  }
31 
32  public function _checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id = null): bool
33  {
34  throw new ilException("_checkAccess must not be called on user object.");
35  }
36 
37  public static function _checkGoto(string $target): bool
38  {
39  global $DIC;
40  $main_tpl = $DIC->ui()->mainTemplate();
41  $settings = isset($GLOBALS['DIC']) ? $GLOBALS['DIC']->settings() : $GLOBALS['DIC']['ilSetting'];
42 
43  if ('usr_registration' == $target) {
44  $regSeetings = new ilRegistrationSettings();
45  if ($regSeetings->getRegistrationType() == ilRegistrationSettings::IL_REG_DISABLED) {
46  $GLOBALS['DIC']->language()->loadLanguageModule('registration');
47  $main_tpl->setOnScreenMessage('failure', sprintf($GLOBALS['DIC']->language()->txt('registration_disabled_no_access'), $settings->get('admin_email')), true);
48  return false;
49  }
50  } elseif ('usr_nameassist' == $target) {
51  if (!$settings->get('password_assistance')) {
52  $GLOBALS['DIC']->language()->loadLanguageModule('pwassist');
53  $main_tpl->setOnScreenMessage('failure', sprintf($GLOBALS['DIC']->language()->txt('unassist_disabled_no_access'), $settings->get('admin_email')), true);
54  return false;
55  }
56  } elseif ('usr_pwassist' == $target) {
57  if (!$settings->get('password_assistance')) {
58  $GLOBALS['DIC']->language()->loadLanguageModule('pwassist');
59  $main_tpl->setOnScreenMessage('failure', sprintf($GLOBALS['DIC']->language()->txt('pwassist_disabled_no_access'), $settings->get('admin_email')), true);
60  return false;
61  }
62  }
63 
64  return true;
65  }
66 
67  public function canBeDelivered(ilWACPath $ilWACPath): bool
68  {
69  global $DIC;
70 
71  $ilUser = $DIC['ilUser'];
72  $ilSetting = $DIC['ilSetting'];
73 
74  preg_match("/usr_(\\d*).*/ui", $ilWACPath->getFileName(), $matches);
75  $usr_id = $matches[1];
76 
77  // check if own image is viewed
78  if ($usr_id == $ilUser->getId()) {
79  return true;
80  }
81 
82  // check if image is in the public profile
83  $public_upload = ilObjUser::_lookupPref($usr_id, 'public_upload');
84  if ($public_upload != 'y') {
85  return false;
86  }
87 
88  // check the publication status of the profile
89  $public_profile = ilObjUser::_lookupPref($usr_id, 'public_profile');
90 
91  if ($public_profile == 'g' and $ilSetting->get('enable_global_profiles') and $ilSetting->get('pub_section')) {
92  // globally public
93  return true;
94  } elseif (($public_profile == 'y' or $public_profile == 'g') and $ilUser->getId() != ANONYMOUS_USER_ID && $ilUser->getId() != 0) {
95  // public for logged in users
96  return true;
97  } else {
98  // not public
99  return false;
100  }
101  }
102 }
array $settings
Setting values (LTI parameters, custom parameters and local parameters).
Definition: System.php:200
const ANONYMOUS_USER_ID
Definition: constants.php:27
_checkAccess(string $cmd, string $permission, int $ref_id, int $obj_id, ?int $user_id=null)
canBeDelivered(ilWACPath $ilWACPath)
static _lookupPref(int $a_usr_id, string $a_keyword)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
global $DIC
Definition: feed.php:28
static _checkGoto(string $target)
$ref_id
Definition: ltiauth.php:67
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Class ilObjAuthSettingsGUI.
global $ilSetting
Definition: privfeed.php:17
$ilUser
Definition: imgupload.php:34