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