ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
class.ilMStShowUserCoursesGUI.php
Go to the documentation of this file.
1 <?php
2 
5 
17 {
18  const CMD_INDEX = 'index';
19  const CMD_RESET_FILTER = 'resetFilter';
20  const CMD_APPLY_FILTER = 'applyFilter';
21  const CMD_GET_ACTIONS = "getActions";
25  protected $usr_id;
29  protected $table;
33  protected $access;
34 
35 
39  public function __construct()
40  {
41  global $DIC;
42 
43  $this->access = ilMyStaffAccess::getInstance();
44 
45  $this->usr_id = $DIC->http()->request()->getQueryParams()['usr_id'];
46  $DIC->ctrl()->setParameter($this, 'usr_id', $this->usr_id);
47  }
48 
49 
53  protected function checkAccessOrFail()
54  {
55  global $DIC;
56 
57  if (!$this->usr_id) {
58  ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true);
59  $DIC->ctrl()->redirectByClass(ilDashboardGUI::class, "");
60  }
61 
62  if ($this->access->hasCurrentUserAccessToUser($this->usr_id)
63  && $this->access->hasCurrentUserAccessToCourseMemberships()
64  ) {
65  return;
66  } else {
67  ilUtil::sendFailure($DIC->language()->txt("permission_denied"), true);
68  $DIC->ctrl()->redirectByClass(ilDashboardGUI::class, "");
69  }
70  }
71 
72 
76  public function executeCommand()
77  {
78  global $DIC;
79 
80  $this->checkAccessOrFail();
81 
82  $cmd = $DIC->ctrl()->getCmd();
83  $next_class = $DIC->ctrl()->getNextClass();
84 
85  switch ($next_class) {
86  case strtolower(ilFormPropertyDispatchGUI::class):
87  $DIC->ctrl()->setReturn($this, self::CMD_INDEX);
88  $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_INDEX);
89  $this->table->executeCommand();
90  break;
91  default:
92  switch ($cmd) {
93  case self::CMD_RESET_FILTER:
94  case self::CMD_APPLY_FILTER:
95  case self::CMD_INDEX:
96  case self::CMD_GET_ACTIONS:
97  $this->$cmd();
98  break;
99  default:
100  $this->index();
101  break;
102  }
103  }
104  }
105 
106 
110  protected function index()
111  {
112  $this->listUsers();
113  }
114 
115 
119  protected function listUsers()
120  {
121  global $DIC;
122 
123  $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_INDEX);
124  $this->table->setTitle(sprintf($DIC->language()->txt('mst_courses_of'), ilObjCourse::_lookupTitle($this->usr_id)));
125 
126  $DIC->ui()->mainTemplate()->setContent($this->table->getHTML());
127  }
128 
132  protected function applyFilter()
133  {
134  $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_APPLY_FILTER);
135  $this->table->writeFilterToSession();
136  $this->table->resetOffset();
137  $this->index();
138  }
139 
140 
144  protected function resetFilter()
145  {
146  $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_RESET_FILTER);
147  $this->table->resetOffset();
148  $this->table->resetFilter();
149  $this->index();
150  }
151 
152 
156  public function getId()
157  {
158  $this->table = new ilMStShowUserCoursesTableGUI($this, self::CMD_INDEX);
159 
160  return $this->table->getId();
161  }
162 
163 
167  public function cancel()
168  {
169  global $DIC;
170 
171  $DIC->ctrl()->redirect($this);
172  }
173 }
static _lookupTitle($a_id)
lookup object title
global $DIC
Definition: goto.php:24
static sendFailure($a_info="", $a_keep=false)
Send Failure Message to Screen.