-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathclass.usrdefUserGUI.php
More file actions
145 lines (131 loc) · 4.51 KB
/
class.usrdefUserGUI.php
File metadata and controls
145 lines (131 loc) · 4.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
require_once __DIR__ . "/../../vendor/autoload.php";
use srag\Plugins\UserDefaults\UserSetting\UserSetting;
use srag\Plugins\UserDefaults\Utils\UserDefaultsTrait;
/**
* @ilCtrl_IsCalledBy usrdefUserGUI : ilUserDefaultsConfigGUI
* @ilCtrl_Calls usrdefUserGUI : ilpropertyformgui
*/
class usrdefUserGUI
{
use UserDefaultsTrait;
const PLUGIN_CLASS_NAME = ilUserDefaultsPlugin::class;
const CMD_INDEX = 'index';
const CMD_APPLY_FILTER = 'applyFilter';
const CMD_RESET_FILTER = 'resetFilter';
const CMD_SELECT_USER = 'selectUser';
const CMD_CONFIRM = 'confirmSelectUser';
const IDENTIFIER = 'usr_id';
const SESSION_ID = 'multi_assign_user_id';
private ilCtrl $ctrl;
private ilUserDefaultsPlugin $pl;
private ilGlobalTemplateInterface $tpl;
private \ILIAS\DI\UIServices $ui;
/**
* usrdefUserGUI constructor
*/
public function __construct()
{
global $DIC;
//Check Access
if(!ilUserDefaultsPlugin::grantAccess()) {
echo "no Search Permission";
exit;
};
$this->ctrl = $DIC->ctrl();
$this->ui = $DIC->ui();
$this->tpl = $DIC->ui()->mainTemplate();
$this->pl = ilUserDefaultsPlugin::getInstance();
ilSession::set(self::SESSION_ID, NULL);
}
/**
* @throws ilCtrlException
*/
public function executeCommand(): void
{
$next = $this->ctrl->getNextClass();
$cmd = $this->ctrl->getCmd(self::CMD_INDEX);
switch ($next) {
case strtolower(ilPropertyFormGUI::class):
$usrdefUserTableGUI = new usrdefUserTableGUI($this, self::CMD_INDEX);
switch ($_GET['exp_cont']) {
case 'il_expl2_jstree_cont_rep_exp_sel_repo':
//$usrdefUserTableGUI->getCrsSelectorGUI()->handleExplorerCommand();
break;
case 'il_expl2_jstree_cont_rep_exp_sel_orgu':
//todo
//$usrdefUserTableGUI->getOrguSelectorGUI()->handleExplorerCommand();
break;
}
break;
default:
switch ($cmd) {
case self::CMD_INDEX:
case self::CMD_APPLY_FILTER:
case self::CMD_RESET_FILTER:
case self::CMD_SELECT_USER:
// ACCESS CHECK
$this->{$cmd}();
}
break;
}
}
protected function index(): void
{
$usrdefUserTableGUI = new usrdefUserTableGUI($this, self::CMD_INDEX);
$this->ui->mainTemplate()->setContent($usrdefUserTableGUI->getHTML());
}
/**
* @throws ilCtrlException
*/
protected function applyFilter(): void
{
$usrdefUserTableGUI = new usrdefUserTableGUI($this, self::CMD_INDEX);
$usrdefUserTableGUI->resetOffset();
$usrdefUserTableGUI->writeFilterToSession();
$this->ctrl->redirect($this, self::CMD_INDEX);
}
/**
* @throws ilCtrlException
*/
protected function resetFilter(): void
{
$usrdefUserTableGUI = new usrdefUserTableGUI($this, self::CMD_INDEX);
$usrdefUserTableGUI->resetFilter();
$usrdefUserTableGUI->resetOffset();
$this->ctrl->redirect($this, self::CMD_INDEX);
}
protected function confirmSelectUser()
{
// Optinal
}
/**
* @throws ilCtrlException
* @throws \srag\DIC\UserDefaults\Exception\DICException
*/
protected function selectUser(): void
{
$usr_ids = $_POST['id'];
$user_objects = array();
if ((is_array($usr_ids) && count($usr_ids) === 0) || !is_array($usr_ids)) {
global $DIC;
$tpl = $DIC["tpl"];
$tpl->setOnScreenMessage('failure', $this->pl->txt('msg_no_users_selected'), true);
$this->ctrl->redirect($this, self::CMD_INDEX);
}
foreach ($usr_ids as $usr_id) {
$user_objects[] = new ilObjUser($usr_id);
}
/**
* @var UserSetting $ilUserSetting
*/
foreach (UserSetting::where(array(
'status' => UserSetting::STATUS_ACTIVE,
'on_manual' => true,
))->get() as $ilUserSetting) {
$ilUserSetting->doMultipleAssignements($user_objects);
}
$this->tpl->setOnScreenMessage('success', $this->pl->txt('userdef_users_assigned', "", [count($usr_ids)]), true);
$this->ctrl->redirect($this, self::CMD_INDEX);
}
}